8000 feat!: use ruint & alloy for ethereum compat by paolodamico · Pull Request #80 · arkworks-rs/circom-compat · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat!: use ruint & alloy for ethereum compat #80

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

paolodamico
Copy link
@paolodamico paolodamico commented Nov 19, 2024
  • Removes dependency on ethers which is now deprecated.
  • Uses ruint's U256 directly, which alloy uses under the hood. This poses a minor breaking change for the Ethereum compatibility module because previously the output was a uint (different crate) coming from ethers-core.
  • Updates tests to use alloy instead of ethers.
  • Very minor updates to the README that seem outdated.

@@ -185,7 +184,7 @@ fn u256_to_point<F: PrimeField>(point: U256) -> F {
fn point_to_u256<F: PrimeField>(point: F) -> U256 {
let point = point.into_bigint();
let point_bytes = point.to_bytes_be();
U256::from(&point_bytes[..])
U256::try_from_be_slice(&point_bytes[..]).expect("always works")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@recmo I believe we could move this to little Endian for consistency with u256_to_point, thoughts?

@paolodamico paolodamico changed the title use ruint & alloy for ethereum compat feat!: use ruint & alloy for ethereum compat Nov 20, 2024
@Dzejkop
Copy link
Contributor
Dzejkop commented Dec 3, 2024

Should probably bump crate version to 0.2.0 to account for the breaking change

@Pratyush
Copy link
Member

Hi, sorry for the delay on getting feedback for this PR. Is there still interest in getting this merged? If so, happy to merge once conflicts are resolved.

impl From<ethereum::G1> for G1Point {
fn from(src: ethereum::G1) -> Self {
Self { x: src.x, y: src.y }
Self { X: src.x, Y: src.y }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be a breaking change, right?

Comment on lines +79 to +81
A: src.a.into(),
B: src.b.into(),
C: src.c.into(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here?

Comment on lines +88 to +92
alfa1: src.alpha1.into(),
beta2: src.beta2.into(),
gamma2: src.gamma2.into(),
delta2: src.delta2.into(),
IC: src.ic.into_iter().map(|i| i.into()).collect(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

Comment on lines -98 to -119
impl<M: Middleware> Groth16Verifier<M> {
async fn check_proof<
I: Into<ethereum::Inputs>,
P: Into<ethereum::Proof>,
VK: Into<ethereum::VerifyingKey>,
>(
&self,
proof: P,
vk: VK,
inputs: I,
) -> Result<bool, ContractError<M>> {
// convert into the expected format by the contract
let proof = proof.into().into();
let vk = vk.into().into();
let inputs = inputs.into().0;

// query the contract
let res = self.verify(inputs, proof, vk).call().await?;

Ok(res)
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm why was this deleted?

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

Successfully merging this pull request may close these issues.

3 participants
0