Short answer is that there are no other ways of accessing the ciphertext data in SEAL. The pointer returned by Ciphertext::data
will give you direct access to the ciphertext data and in that sense allows you to do any kind of computation on it, e.g. converting to a human-readable string if for some reason you would want to do that.
Of course to do anything intelligible you need to know the data layout of the ciphertext. In the BFV scheme a ciphertext consists of a pair of polynomials (c0, c1) with large (size coeff_modulus
) coefficients. Since operating on polynomials with such large coefficients is inconvenient, SEAL 2.3.1 instead uses a composite coeff_modulus
and stores both c0 and c1 modulo each of the prime factors specified in the coeff_modulus
(denote these factors q1,q2,...,qk). Each qi fits into a 64-bit word, so all of these 2k polynomials have word-size coefficients.
The ciphertext coefficient data layout is as follows (contiguous in memory):
[ c0 mod q1 ][ c0 mod q2 ]...[ c0 mod qk ][ c1 mod q1 ][ c1 mod q2 ]...[ c1 mod qk ]
where each [ ci mod qj ] looks like
[ c0[0] mod qj ][ c1[0] mod qj ]...[ cn-1[0] mod qj ]
Here I used ci[k] to denote the degree k coefficient of ci. Note that each coefficient is stored in a uint64_t
.
Ciphertext::data
returns a pointer to the constant coefficient of the c0 polynomial with respect to the first modulus in your coeff_modulus
, i.e. to c0[0] mod q1. In addition to this coefficient data, a Ciphertext contains a few other fields that you can read using the member functions.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…