ZenGo-X / rust-paillier

A pure-Rust implementation of the Paillier encryption scheme
Other
36 stars 38 forks source link

BigInt type problem (curv and rust-paillier) #21

Open marvellous987 opened 2 years ago

marvellous987 commented 2 years ago

Hi, I encountered a type conversion issue among type BigInt:

  1. Using Paillier::encrypt in rust-paillier, we need to first convert the BigInt variable to RawPlaintext. However, there is an error:

    error[E0277]: the trait bound `RawPlaintext<'_>: From<&curv::BigInt>` is not satisfied
    --> ...
    |
    63  |         RawPlaintext::from(&x1)
    |         ^^^^^^^^^^^^^^^^^^ the trait `From<&curv::BigInt>` is not implemented for `RawPlaintext<'_>`
  2. Using Paillier::decrypt in rust-paillier:

    let gamma1 = Paillier::decrypt(
        &dk,
        RawCiphertext::from(C_gamma.clone())
    ).0
    .clone()
    .into_owned();

    and gamma1 is a paillier::Bigint rather than a curv::BigInt.

I think it is the same origin of problem, would anyone can give me any suggestion?

Thank you!

omershlo commented 2 years ago

Hi ,

  1. try to use x1.clone() instead of &x1
  2. I don’t see any error. Where do you get stuck ?
marvellous987 commented 2 years ago

I think I have got the problem... It was caused by different version of curv used in different libraries.