comparing lattigo and SEAL #363
-
I'm doing a comparison between these two popular libraries, and I've found out that in lattigo you can do // RotateColumns rotates the columns of ct0 by k positions to the left and returns the result in ctOut. As an additional input it requires a RotationKeys struct.
func (eval *evaluator) RotateColumns(ct0 *rlwe.Ciphertext, k int, ctOut *rlwe.Ciphertext) {
eval.Automorphism(ct0, eval.params.GaloisElementForColumnRotationBy(k), ctOut)
} while in SEAL you can do /**
Rotates plaintext matrix rows cyclically. When batching is used with the BFV/BGV scheme, this function rotates
the encrypted plaintext matrix rows cyclically to the left (steps > 0) or to the right (steps < 0). Since the
size of the batched matrix is 2-by-(N/2), where N is the degree of the polynomial modulus, the number of steps
to rotate must have absolute value at most N/2-1. Dynamic memory allocations in the process are allocated from
the memory pool pointed to by the given MemoryPoolHandle.
@param[in] encrypted The ciphertext to rotate
@param[in] steps The number of steps to rotate (positive left, negative right)
@param[in] galois_keys The Galois keys
@param[in] pool The MemoryPoolHandle pointing to a valid memory pool
@throws std::logic_error if scheme is not scheme_type::bfv or scheme_type::bgv
@throws std::logic_error if the encryption parameters do not support batching
@throws std::invalid_argument if encrypted or galois_keys is not valid for
the encryption parameters
@throws std::invalid_argument if galois_keys do not correspond to the top
level parameters in the current context
@throws std::invalid_argument if encrypted is not in the default NTT form
@throws std::invalid_argument if encrypted has size larger than 2
@throws std::invalid_argument if steps has too big absolute value
@throws std::invalid_argument if necessary Galois keys are not present
@throws std::invalid_argument if pool is uninitialized
@throws std::logic_error if keyswitching is not supported by the context
@throws std::logic_error if result ciphertext is transparent
*/
inline void rotate_rows_inplace(
Ciphertext &encrypted, int steps, const GaloisKeys &galois_keys,
MemoryPoolHandle pool = MemoryManager::GetPool()) const
{
auto scheme = context_.key_context_data()->parms().scheme();
if (scheme != scheme_type::bfv && scheme != scheme_type::bgv)
{
throw std::logic_error("unsupported scheme");
}
rotate_internal(encrypted, steps, galois_keys, std::move(pool));
} It seems that both methods are doing the same but for different things (columns in lattigo vs rows in SEAL), do they represent exactly the same thing with a different name? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
See this answer: #361 (comment) I believe that indeed the rows/columns names are interchanged between Lattigo and SEAL. Lattigo refers to the position indexes of elements in the |
Beta Was this translation helpful? Give feedback.
See this answer: #361 (comment)
I believe that indeed the rows/columns names are interchanged between Lattigo and SEAL. Lattigo refers to the position indexes of elements in the
2 x N/2
matrix, indexed as[rows][columns]
. Thus if we rotate the columns, we will rotate the indexes of the second dimension[columns]
, while the indexes of the first dimension[rows]
remain untouched.