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

Missing ops #8

Open
NikZak opened this issue Jan 18, 2024 · 2 comments
Open

Missing ops #8

NikZak opened this issue Jan 18, 2024 · 2 comments

Comments

@NikZak
Copy link
Contributor

NikZak commented Jan 18, 2024

My circuit requires:
Fr_element2str
Fr_neg
Fr_div
Fr_band
Fr_shr

I am happy to help implementing those if you could provide a bit of guidance. Thank you!

@NikZak
Copy link
Contributor Author

NikZak commented Jan 20, 2024

and Fr_pow

@biscuitdey
Copy link

biscuitdey commented Mar 25, 2024

@NikZak

A.
To extend the eval functions, we can do the following using ruint library:

  1. Fr_neg --> Neg => (M - a) assuming M is the field's order. This has been used to calculate Sub
  2. Fr_div --> Div => a.mul_mod (b.inv_mod(M), M) use inv_mod from ruint::algorithms as this uses Extended Euclidean Algorithm to calculate the inverse.
  3. Fr_pow --> Pow => a.pow_mod(b, M)

B.
To extend the eval_fr functions, we can do the following:
The Prime Field Fr = Fp256<MontBackend<FrConfig, 4>> elements are implemented using the ark_ff library, which provides functions for calculating negative, division, etc. Adding the following code to the graph.rs file, under the impl Operation -> eval_fr might work :

Neg => a.neg_in_place(),
FromString => Fr::from_str("testString"),
Div => a / b

Source:

  1. Ark prime fields library : ark_ff
  2. Ark BN254 curve example (similar to ark_bn254 curve used) : curve
  3. Arkworks-rs guide
  4. Arkworks-rs github

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

2 participants