Closed hargathor closed 5 years ago
gate_constant()
takes an array of plaintext bits (see the doc entry) and creates "encrypted" bits out of it (note that the created LWEs are trivial, so it works as a parameter in other gates, but is not secure).
The problem here is that clearly not enough input checking is performed, so the ciphertext you pass gets treated as a single boolean True
(because it is an object and not None
), and then result
gets filled with an encrypted True
as the first value and whatever garbage is located beyond the first element of the source array on GPU.
Do you need "re-encryption" functionality (that is, creating a different ciphertext encrypting the same plaintext), or were you just trying out the interface?
Ok thanks for the explanation.
Actually I need to do a operation between a encrypted value (resulting of a previous operation) against a numerical constant : enc(b)+ 1
That is exactly the intended usage of the constant gate, you pass the representation of 1
to it as a plaintext array, and then use it in other gates just like any other encrypted value.
Ok thanks it does work properly when doing as you said. Creating the object with numpy.int_([1], dtype=numpy.uint32)
for example
Commit e4fcaaa5b5f013ad9fcccdbb9ecfbc1237765492 and commit 229d291f3d9bcd522a0b0348c0b2bcbac071932f should help avoid further confusion like this. Closing now.
I'm trying to compute a operation with a constant. I tried to use the constant gate but it seems that it process my numpy array backwards. I'm passing a 32 bits constant with 31
False
and the last bit atTrue
and the results after going through the gate and deciphering it i get the first bit atTrue
and 31 last bits atFalse
Here is the code i used to test it
Expected
[False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False True]
Actual[ True False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False]