Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incorrect ciphertext output #34

Open
alexcostars opened this issue Sep 14, 2024 · 0 comments
Open

incorrect ciphertext output #34

alexcostars opened this issue Sep 14, 2024 · 0 comments

Comments

@alexcostars
Copy link

Hi,
I'm trying to use this project to generate ZKP for Paillier, but the result is not correct. For example:

let p_novo = BigInt::from_str_radix("23194683100664294251", 10).unwrap();
let q_novo = BigInt::from_str_radix("11084480205242485763", 10).unwrap();

let key_pair = Keypair::from((&p_novo, &q_novo));
let (ek, _dk) = key_pair.keys();

println!("ek: {:?}, dk: {:?}", ek, _dk);

let secret_r = BigInt::from_str_radix("464682464", 10).unwrap();
let secret_x = BigInt::from_str_radix("150", 10).unwrap();

let ciphertext = Paillier::encrypt_with_chosen_randomness(
    &ek,
    RawPlaintext::from(&secret_x),
    &Randomness::from(&secret_r),
);

The output of this execution is ciphertext.0 = 1841450431121342017079889925321805034960817609110249141263892292849164403537, but when I double-checked with other Paillier libraries and tools (like Paillier-BigInt or Web Paillier tool) the correct output should be 13672180411290983406955843804043697528775972482458284502917460944323517355794.

Why is the output different between this library and other libraries?

Correct values, according to other libraries:

{
  'λ': 128550502848092886185216712673701734250,
  'μ': 99415112783958120837453228651924117883,
  'p': 23194683100664294251,
  'q': 11084480205242485763,
  'ek': {
    'n': 257101005696185772404712588653310248513,
    'n2': 66100927129990148988580376256581599042222861977533021384053044100117818711169,
    'g': 42236085824128668347721885950881174027286600093280187481692825207432221167302
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant