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

Referencing noir_elgamal can execute test cases, but cannot run them #3

Open
Huang-Xinzhong opened this issue Dec 26, 2023 · 0 comments

Comments

@Huang-Xinzhong
Copy link

Huang-Xinzhong commented Dec 26, 2023

Running nargo prove yields an error message
other error

What is the reason for this?

This is the executed code:

use dep::std;
use dep::std::ec::tecurve::affine::Point as Gaffine;
use dep::std::ec::tecurve::affine::Curve as AffineCurve;
use dep::noir_elgamal;


fn main() {
 let message: u40 = 943594123598;
  let private_key: Field = 0x04c330a81537c0d29cc09e8b2b9c43fc5fb5a9d244ab741fc88dff3d40dbd75c; // chosen randomly between 0 and bjj_l-1
  let randomness: Field = 0x010fe5884a7852054a21e21e549520352f563f03d3f79e66a2d75fbd2a21d5cf; // chosen randomly between 0 and bjj_l-1, and never reused

  let public_key: Gaffine = noir_elgamal::priv_to_pub_key(private_key);
  let ciphertext: (Gaffine,Gaffine) = noir_elgamal::exp_elgamal_encrypt(public_key, message, randomness);
  let decryption = noir_elgamal::exp_elgamal_decrypt(private_key, ciphertext); // in embedded form (before the baby-step giant-step application)

  let bjj_affine: AffineCurve = noir_elgamal::get_affine_curve();
  let base_pt: Gaffine = noir_elgamal::get_base_point();
  let plain_embedded: Gaffine = bjj_affine.mul(message as Field,base_pt);

  assert(plain_embedded.x == decryption.x);
  assert(plain_embedded.y == decryption.y);
}

#[test]
fn test_main() {
    main();
}
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