Skip to content

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

Open
paolodamico wants to merge 2 commits into
arkworks-rs:masterfrom
paolodamico:master
Open

feat!: use ruint & alloy for ethereum compat#80
paolodamico wants to merge 2 commits into
arkworks-rs:masterfrom
paolodamico:master

Conversation

@paolodamico

@paolodamico paolodamico commented Nov 19, 2024

Copy link
Copy Markdown
  • 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.

Comment thread src/ethereum.rs
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
Copy Markdown
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

Dzejkop commented Dec 3, 2024

Copy link
Copy Markdown
Contributor

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

@Pratyush

Copy link
Copy Markdown
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.

Comment thread tests/solidity.rs
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
Copy Markdown
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 thread tests/solidity.rs
Comment on lines +79 to +81
A: src.a.into(),
B: src.b.into(),
C: src.c.into(),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same here?

Comment thread tests/solidity.rs
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
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ditto.

Comment thread tests/solidity.rs
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
Copy Markdown
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