tfhe / spqlios-arithmetic

spqlios arithmetic library for FHE and post-quantum crypto
Apache License 2.0
13 stars 0 forks source link

[Question]: Regarding the scratch bytes required for Base2K normalization #28

Closed Pro7ech closed 2 months ago

Pro7ech commented 3 months ago

The library offers two ways to normalize a Base2K vector:

Both require a buffer to store the carry, but znx_normalize takes an array of int64, expected to be of size N, while vec_znx_normalize_base2k requires an array of byte, which expected to be of size N*sizeof(int64_t), so the same size.

Everything seems to indicate that the type of these buffers could be uniformized. Is there a reason for the difference between the argument types between those two functions?

Additionally, vec_znx_normalize_base2k_tmp_bytes_ref takes two arguments, which if I understand are supposed to be the number of limbs of the input and output vectors, but these have no effect on its output since it always returns N*size_of(int64_t).

action-items

ngama75 commented 3 months ago

good catch, yes agreed, we should remove the vector sizes from vec_znx_normalize_base2k_tmp_bytes, it can take only the module as argument.

IMO, normalization is also almost never time-critical, so we could even maybe expose a variant without tmp, that do non-sequential memory accesses.