Closed polyfractal closed 7 years ago
I was able to reduce the test-case a bit. It fails once every 5 tries or so...
extern crate paillier;
use paillier::*;
fn main() {
let (ek, dk) = Paillier::keypair().keys();
let code = integral::Code::new(100, 16);
let eek = ek.with_code(&code);
let secret: Vec<u64> = (0..100).collect();
let cypher = Paillier::encrypt(&eek, &secret);
let ddk = dk.with_code(&code);
let m: Vec<u64> = Paillier::decrypt(&ddk, &cypher);
assert_eq!(m, secret);
}
Making progress here, the bug is presumably in the CRT variant of the decryption code. Switching to standard decryption algo fixed it.
@polyfractal Feel tree to try out the fix-crt branch, as we will only be able to merge and release early next week.
Oh, awesome, thanks! I just assumed it was the mixing of different code types, rather than just a bug in the decryption.
This is a super cool library btw, been fun playing around with it :)
Hi @polyfractal, thanks for reporting the issue! New version now merged and pushed to crates.io.
I'm still reading up on how Paillier actually works, so this may be a silly question. Is it possible for a single set of keys to encrypt both a scalar and a vector at the same time? I attempted to do this, but the output was unstable. The vector was occasionally the correct result, but often just garbage values. Interestingly, the scalar was correct all the time.
The test is pretty simple. The secret is a vector from 0-100. In 10 iterations, 0,1,2,3...is added to each position in the vector. The amount added is also tallied onto a counter.
At the end, the vector should be
[45, 46, 47, ...]
But the output is often crazy :)
This is running with
features = ["inclramp", "defaultramp", "keygen"]