示例#1
0
def decrypt(dk: DecryptionKey,
            ciphertext: Ciphertext,
            dtype: tf.DType = tf.int32):
    c = ciphertext.raw

    gxd = tf_big.pow(c, dk.d1, dk.nn)
    xd = (gxd - 1) // dk.n
    x = (xd * dk.d2) % dk.n

    if dtype == tf.variant:
        return x

    return tf_big.convert_from_tensor(x, dtype=dtype)
示例#2
0
 def export(self, dtype: tf.DType = tf.string):
     return tf_big.convert_from_tensor(self.raw, dtype=dtype)
示例#3
0
 def export(self, dtype: tf.DType = tf.string):
     return (
         tf_big.convert_from_tensor(self.p, dtype=dtype),
         tf_big.convert_from_tensor(self.q, dtype=dtype),
     )