mirror of
https://github.com/arnaucube/circom-compat.git
synced 2026-01-09 07:21:33 +01:00
Bump to latest Ethers (#26)
* chore: bump ethers
* fix: adjust ethers breaking changes
1. Use the abigen'd ::deploy methods
2. Use Anvil instead of Ganache
* silence warning
* fix: replace abi with full verifier artifact
* ci: use anvil instead of the node stack
* chore: remove ethers-solc
* fix: return error instead of raise
17c0834abf
this api got deprecated and would panic instead of generating an error that can behandled
* lints
* minimfy json
This commit is contained in:
committed by
GitHub
parent
8f6fcaf40b
commit
06eb0759e0
@@ -56,7 +56,7 @@ fn groth16_proof_wrong_input() {
|
||||
let mut rng = thread_rng();
|
||||
let _params = generate_random_parameters::<Bn254, _, _>(circom, &mut rng).unwrap();
|
||||
|
||||
builder.build().unwrap_err();
|
||||
let _ = builder.build().unwrap_err();
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -6,11 +6,11 @@ use ark_bn254::Bn254;
|
||||
use ark_groth16::{create_random_proof as prove, generate_random_parameters};
|
||||
|
||||
use ethers::{
|
||||
contract::{abigen, ContractError, ContractFactory},
|
||||
contract::ContractError,
|
||||
prelude::abigen,
|
||||
providers::{Http, Middleware, Provider},
|
||||
utils::{compile_and_launch_ganache, Ganache, Solc},
|
||||
utils::Anvil,
|
||||
};
|
||||
|
||||
use std::{convert::TryFrom, sync::Arc};
|
||||
|
||||
#[tokio::test]
|
||||
@@ -35,33 +35,22 @@ async fn solidity_verifier() -> Result<()> {
|
||||
let proof = prove(circom, ¶ms, &mut rng)?;
|
||||
|
||||
// launch the network & compile the verifier
|
||||
let (compiled, ganache) =
|
||||
compile_and_launch_ganache(Solc::new("./tests/verifier.sol"), Ganache::new()).await?;
|
||||
let acc = ganache.addresses()[0];
|
||||
let provider = Provider::<Http>::try_from(ganache.endpoint())?;
|
||||
let anvil = Anvil::new().spawn();
|
||||
let acc = anvil.addresses()[0];
|
||||
let provider = Provider::<Http>::try_from(anvil.endpoint())?;
|
||||
let provider = provider.with_sender(acc);
|
||||
let provider = Arc::new(provider);
|
||||
|
||||
// deploy the verifier
|
||||
let contract = {
|
||||
let contract = compiled
|
||||
.get("TestVerifier")
|
||||
.expect("could not find contract");
|
||||
|
||||
let factory = ContractFactory::new(
|
||||
contract.abi.clone(),
|
||||
contract.bytecode.clone(),
|
||||
provider.clone(),
|
||||
);
|
||||
let contract = factory.deploy(())?.send().await?;
|
||||
let addr = contract.address();
|
||||
Groth16Verifier::new(addr, provider)
|
||||
};
|
||||
let contract = Groth16Verifier::deploy(provider.clone(), ())?
|
||||
.send()
|
||||
.await?;
|
||||
|
||||
// check the proof
|
||||
let verified = contract
|
||||
.check_proof(proof, params.vk, inputs.as_slice())
|
||||
.await?;
|
||||
|
||||
assert!(verified);
|
||||
|
||||
Ok(())
|
||||
@@ -70,8 +59,8 @@ async fn solidity_verifier() -> Result<()> {
|
||||
// We need to implement the conversion from the Ark-Circom's internal Ethereum types to
|
||||
// the ones expected by the abigen'd types. Could we maybe provide a convenience
|
||||
// macro for these, given that there's room for implementation error?
|
||||
abigen!(Groth16Verifier, "./tests/verifier_abi.json");
|
||||
use groth16verifier_mod::{G1Point, G2Point, Proof, VerifyingKey};
|
||||
abigen!(Groth16Verifier, "./tests/verifier_artifact.json");
|
||||
use groth_16_verifier::{G1Point, G2Point, Proof, VerifyingKey};
|
||||
impl From<ethereum::G1> for G1Point {
|
||||
fn from(src: ethereum::G1) -> Self {
|
||||
Self { x: src.x, y: src.y }
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"uint256[]","name":"input","type":"uint256[]"},{"components":[{"components":[{"internalType":"uint256","name":"X","type":"uint256"},{"internalType":"uint256","name":"Y","type":"uint256"}],"internalType":"struct Pairing.G1Point","name":"A","type":"tuple"},{"components":[{"internalType":"uint256[2]","name":"X","type":"uint256[2]"},{"internalType":"uint256[2]","name":"Y","type":"uint256[2]"}],"internalType":"struct Pairing.G2Point","name":"B","type":"tuple"},{"components":[{"internalType":"uint256","name":"X","type":"uint256"},{"internalType":"uint256","name":"Y","type":"uint256"}],"internalType":"struct Pairing.G1Point","name":"C","type":"tuple"}],"internalType":"struct Verifier.Proof","name":"proof","type":"tuple"},{"components":[{"components":[{"internalType":"uint256","name":"X","type":"uint256"},{"internalType":"uint256","name":"Y","type":"uint256"}],"internalType":"struct Pairing.G1Point","name":"alfa1","type":"tuple"},{"components":[{"internalType":"uint256[2]","name":"X","type":"uint256[2]"},{"internalType":"uint256[2]","name":"Y","type":"uint256[2]"}],"internalType":"struct Pairing.G2Point","name":"beta2","type":"tuple"},{"components":[{"internalType":"uint256[2]","name":"X","type":"uint256[2]"},{"internalType":"uint256[2]","name":"Y","type":"uint256[2]"}],"internalType":"struct Pairing.G2Point","name":"gamma2","type":"tuple"},{"components":[{"internalType":"uint256[2]","name":"X","type":"uint256[2]"},{"internalType":"uint256[2]","name":"Y","type":"uint256[2]"}],"internalType":"struct Pairing.G2Point","name":"delta2","type":"tuple"},{"components":[{"internalType":"uint256","name":"X","type":"uint256"},{"internalType":"uint256","name":"Y","type":"uint256"}],"internalType":"struct Pairing.G1Point[]","name":"IC","type":"tuple[]"}],"internalType":"struct Verifier.VerifyingKey","name":"vk","type":"tuple"}],"name":"verify","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]
|
||||
1
tests/verifier_artifact.json
Normal file
1
tests/verifier_artifact.json
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user