1
0
Fork 0
mirror of synced 2025-09-23 12:18:44 +00:00
This commit is contained in:
schaeff 2022-05-18 13:33:22 +02:00
parent dac05b5a90
commit 6b36e4b23b
5 changed files with 22 additions and 29 deletions

View file

@ -49,14 +49,14 @@ pub fn exec(sub_matches: &ArgMatches) -> Result<(), String> {
// extract curve and scheme parameters from both
let curve = proof
.get("curve")
.ok_or("Field `curve` not found in proof".to_string())?
.ok_or_else(|| "Field `curve` not found in proof".to_string())?
.as_str()
.ok_or("`curve` should be a string".to_string())?;
.ok_or_else(|| "`curve` should be a string".to_string())?;
let scheme = proof
.get("scheme")
.ok_or("Field `scheme` not found in proof".to_string())?
.ok_or_else(|| "Field `scheme` not found in proof".to_string())?
.as_str()
.ok_or("`scheme` should be a string".to_string())?;
.ok_or_else(|| "`scheme` should be a string".to_string())?;
let parameters: (CurveParameter, SchemeParameter) =
(curve.try_into().unwrap(), scheme.try_into().unwrap());

View file

@ -73,24 +73,24 @@ pub fn exec(sub_matches: &ArgMatches) -> Result<(), String> {
// extract curve and scheme parameters from both
let proof_curve = proof
.get("curve")
.ok_or("Field `curve` not found in proof".to_string())?
.ok_or_else(|| "Field `curve` not found in proof".to_string())?
.as_str()
.ok_or("`curve` should be a string".to_string())?;
.ok_or_else(|| "`curve` should be a string".to_string())?;
let proof_scheme = proof
.get("scheme")
.ok_or("Field `scheme` not found in proof".to_string())?
.ok_or_else(|| "Field `scheme` not found in proof".to_string())?
.as_str()
.ok_or("`scheme` should be a string".to_string())?;
.ok_or_else(|| "`scheme` should be a string".to_string())?;
let vk_curve = vk
.get("curve")
.ok_or("Field `curve` not found in verification key".to_string())?
.ok_or_else(|| "Field `curve` not found in verification key".to_string())?
.as_str()
.ok_or("`curve` should be a string".to_string())?;
.ok_or_else(|| "`curve` should be a string".to_string())?;
let vk_scheme = vk
.get("scheme")
.ok_or("Field `scheme` not found in verification key".to_string())?
.ok_or_else(|| "Field `scheme` not found in verification key".to_string())?
.as_str()
.ok_or("`scheme` should be a string".to_string())?;
.ok_or_else(|| "`scheme` should be a string".to_string())?;
if proof_curve != vk_curve {
return Err(format!(

View file

@ -298,8 +298,6 @@ mod integration {
"verify",
"--backend",
backend,
"--proving-scheme",
scheme,
"-j",
proof_path.to_str().unwrap(),
"-v",
@ -387,14 +385,14 @@ mod integration {
// Compile lib
let g2_lib =
Contract::compile_from_src_string(&SOLIDITY_G2_ADDITION_LIB, "BN256G2", true, &[])
Contract::compile_from_src_string(SOLIDITY_G2_ADDITION_LIB, "BN256G2", true, &[])
.unwrap();
// Deploy lib
let create_result = evm
.deploy(g2_lib.encode_create_contract_bytes(&[]).unwrap(), &deployer)
.unwrap();
let lib_addr = create_result.addr.clone();
let lib_addr = create_result.addr;
// Compile contract
let contract = Contract::compile_from_src_string(
@ -412,7 +410,7 @@ mod integration {
&deployer,
)
.unwrap();
let contract_addr = create_result.addr.clone();
let contract_addr = create_result.addr;
// convert to the solidity proof format
let solidity_proof = S::Proof::from(proof.proof);
@ -448,11 +446,11 @@ mod integration {
assert_eq!(&result.out, &to_be_bytes(&U256::from(1)));
// modify the proof
let modified_solidity_proof = S::modify(solidity_proof.clone());
let modified_solidity_proof = S::modify(solidity_proof);
let modified_proof_token = S::to_token(modified_solidity_proof.clone());
let modified_proof_token = S::to_token(modified_solidity_proof);
let inputs = [modified_proof_token, input_token.clone()];
let inputs = [modified_proof_token, input_token];
// Call verify function on contract
let result = evm

View file

@ -236,11 +236,8 @@ mod tests {
.execute(program.clone(), &[Bls12_377Field::from(42)])
.unwrap();
let proof = <Ark as Backend<Bls12_377Field, G16>>::generate_proof(
program.into(),
witness,
keypair.pk,
);
let proof =
<Ark as Backend<Bls12_377Field, G16>>::generate_proof(program, witness, keypair.pk);
let ans = <Ark as Backend<Bls12_377Field, G16>>::verify(keypair.vk, proof);
assert!(ans);

View file

@ -1711,8 +1711,7 @@ mod tests {
)
.annotate(Type::FieldElement, 1u32)
.into(),
)
.into()]
)]
.into(),
)
.annotate(Type::FieldElement, 1u32),
@ -1736,8 +1735,7 @@ mod tests {
)
.annotate(Type::FieldElement, 1u32)
.into(),
)
.into()]
)]
.into(),
)
.annotate(Type::FieldElement, 1u32),