Skip to content
This repository was archived by the owner on Apr 9, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e4df8d5
bring back serde
kevaundray May 16, 2023
100db6c
recursion in live with acvm 0.12.0 changes and struct varaints for bl…
vezenovm May 17, 2023
d26b253
proof_as_fields and vk_as_fields in ProofSystemCompiler trait
vezenovm May 17, 2023
4934dd3
verify_proof with acvm after 0.12.0 with struct variants for black bo…
vezenovm May 17, 2023
8a8b212
add is_recursive flag to prove and verify with keys
vezenovm May 18, 2023
cfbd0ec
remove unnecessary fields from VerifyProof
vezenovm May 19, 2023
7fb1694
merge conflicts with master
vezenovm May 22, 2023
d4c884e
Merge branch 'master' into mv/verify-proof-2
kevaundray May 22, 2023
d445670
rename VerifyProof to RecursiveAggregation, make input agg an option,…
vezenovm May 23, 2023
81f9231
add some comments for is_recursive
vezenovm May 23, 2023
d58ea54
cargo fmt
vezenovm May 23, 2023
352c28b
remove recursive aggregation simulation
vezenovm May 26, 2023
a90514d
switched BlackBoxFunc to RecursiveAggregation
vezenovm May 26, 2023
e3a2e18
merge conflicts with keccak var opcode
vezenovm May 26, 2023
ab635dd
one more comment on BlackBoxFunc::RecursiveAggregation
vezenovm May 26, 2023
9d5b32f
cargo fmt
vezenovm May 26, 2023
ae14a4b
Merge branch 'master' into mv/verify-proof-2
vezenovm May 26, 2023
d5a2cf8
add func to fetch values from WitnessMap
vezenovm May 26, 2023
803d852
Merge branch 'master' into mv/verify-proof-2
vezenovm May 30, 2023
1df20f5
Merge branch 'mv/verify-proof-2' into mv/get-witness-values
vezenovm May 30, 2023
64a6db4
remove unnecessary method for fetching WitnessMap values
vezenovm May 30, 2023
bb0b1d4
Merge branch 'master' into mv/verify-proof-2
vezenovm Jun 1, 2023
b8198aa
don't incldue input aggregation object in inputs vec
vezenovm Jun 2, 2023
b4592d9
add comment why do not return an input_aggregation_object in the inpu…
vezenovm Jun 2, 2023
fa4b004
Merge branch 'master' into mv/verify-proof-2
vezenovm Jun 2, 2023
db9a5c2
Merge branch 'master' into mv/verify-proof-2
vezenovm Jun 5, 2023
71e5017
Merge branch 'master' into mv/verify-proof-2
vezenovm Jun 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions acir/src/circuit/black_box_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub enum BlackBoxFunc {
EcdsaSecp256k1,
FixedBaseScalarMul,
Keccak256,
VerifyProof,
}

impl std::fmt::Display for BlackBoxFunc {
Expand All @@ -44,6 +45,7 @@ impl BlackBoxFunc {
BlackBoxFunc::XOR => "xor",
BlackBoxFunc::RANGE => "range",
BlackBoxFunc::Keccak256 => "keccak256",
BlackBoxFunc::VerifyProof => "verify_proof",
Comment thread
kevaundray marked this conversation as resolved.
Outdated
}
}
pub fn lookup(op_name: &str) -> Option<BlackBoxFunc> {
Expand All @@ -60,6 +62,7 @@ impl BlackBoxFunc {
"xor" => Some(BlackBoxFunc::XOR),
"range" => Some(BlackBoxFunc::RANGE),
"keccak256" => Some(BlackBoxFunc::Keccak256),
"verify_proof" => Some(BlackBoxFunc::VerifyProof),
_ => None,
}
}
Expand Down
48 changes: 47 additions & 1 deletion acir/src/circuit/opcodes/black_box_function_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ pub enum BlackBoxFuncCall {
inputs: Vec<FunctionInput>,
outputs: Vec<Witness>,
},
VerifyProof {
Comment thread
kevaundray marked this conversation as resolved.
Outdated
key: Vec<FunctionInput>,
Comment thread
vezenovm marked this conversation as resolved.
Outdated
proof: Vec<FunctionInput>,
public_inputs: Vec<FunctionInput>,
Comment thread
vezenovm marked this conversation as resolved.
key_hash: FunctionInput,
Comment thread
kevaundray marked this conversation as resolved.
input_aggregation_object: Vec<FunctionInput>,
// This is the recursive verification output aggregation object.
// The name `outputs` was kept to simplify code reuse with the other BlackBoxFuncCall's
Comment thread
vezenovm marked this conversation as resolved.
Outdated
outputs: Vec<Witness>,
},
}

impl BlackBoxFuncCall {
Expand Down Expand Up @@ -122,6 +132,14 @@ impl BlackBoxFuncCall {
BlackBoxFunc::Keccak256 => {
BlackBoxFuncCall::Keccak256 { inputs: vec![], outputs: vec![] }
}
BlackBoxFunc::VerifyProof => BlackBoxFuncCall::VerifyProof {
key: vec![],
proof: vec![],
public_inputs: vec![],
key_hash: FunctionInput::dummy(),
input_aggregation_object: vec![],
outputs: vec![],
},
}
}

Expand All @@ -139,6 +157,7 @@ impl BlackBoxFuncCall {
BlackBoxFuncCall::EcdsaSecp256k1 { .. } => BlackBoxFunc::EcdsaSecp256k1,
BlackBoxFuncCall::FixedBaseScalarMul { .. } => BlackBoxFunc::FixedBaseScalarMul,
BlackBoxFuncCall::Keccak256 { .. } => BlackBoxFunc::Keccak256,
BlackBoxFuncCall::VerifyProof { .. } => BlackBoxFunc::VerifyProof,
}
}

Expand Down Expand Up @@ -192,6 +211,32 @@ impl BlackBoxFuncCall {
inputs.extend(hashed_message.iter().copied());
inputs
}
BlackBoxFuncCall::VerifyProof {
key,
proof,
public_inputs,
key_hash,
input_aggregation_object,
..
} => {
let mut inputs = Vec::with_capacity(
key.len()
+ proof.len()
+ public_inputs.len()
+ 1
+ input_aggregation_object.len(),
);
inputs.extend(key.iter().copied());
inputs.extend(proof.iter().copied());
inputs.extend(public_inputs.iter().copied());
inputs.push(*key_hash);
// If we do not have an input aggregation object assigned
// do not return it as part of the input vector as to not trigger
if !input_aggregation_object.iter().any(|v| v.witness == Witness(0)) {
Comment thread
kevaundray marked this conversation as resolved.
Outdated
inputs.extend(input_aggregation_object.iter().copied());
}
inputs
}
}
}

Expand All @@ -202,7 +247,8 @@ impl BlackBoxFuncCall {
| BlackBoxFuncCall::Blake2s { outputs, .. }
| BlackBoxFuncCall::FixedBaseScalarMul { outputs, .. }
| BlackBoxFuncCall::Pedersen { outputs, .. }
| BlackBoxFuncCall::Keccak256 { outputs, .. } => outputs.to_vec(),
| BlackBoxFuncCall::Keccak256 { outputs, .. }
| BlackBoxFuncCall::VerifyProof { outputs, .. } => outputs.to_vec(),
BlackBoxFuncCall::AND { output, .. }
| BlackBoxFuncCall::XOR { output, .. }
| BlackBoxFuncCall::HashToField128Security { output, .. }
Expand Down
23 changes: 23 additions & 0 deletions acvm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,15 @@ pub trait PartialWitnessGenerator {
input: &FunctionInput,
outputs: &[Witness],
) -> Result<OpcodeResolution, OpcodeResolutionError>;
fn verify_proof(
Comment thread
kevaundray marked this conversation as resolved.
Outdated
&self,
initial_witness: &mut WitnessMap,
key: &[FunctionInput],
proof: &[FunctionInput],
public_inputs: &[FunctionInput],
input_aggregation_object: &[FunctionInput],
outputs: &[Witness],
) -> Result<OpcodeResolution, OpcodeResolutionError>;
}

pub trait SmartContract {
Expand Down Expand Up @@ -150,6 +159,7 @@ pub trait ProofSystemCompiler {
circuit: &Circuit,
witness_values: WitnessMap,
proving_key: &[u8],
is_recursive: bool,
Comment thread
kevaundray marked this conversation as resolved.
) -> Result<Vec<u8>, Self::Error>;

/// Verifies a Proof, given the circuit description, the circuit's public inputs, and the verification key
Expand All @@ -160,5 +170,18 @@ pub trait ProofSystemCompiler {
public_inputs: WitnessMap,
circuit: &Circuit,
verification_key: &[u8],
is_recursive: bool,
) -> Result<bool, Self::Error>;

fn proof_as_fields(
Comment thread
kevaundray marked this conversation as resolved.
&self,
proof: &[u8],
public_inputs: WitnessMap,
) -> Result<Vec<FieldElement>, Self::Error>;

fn vk_as_fields(
&self,
common_reference_string: &[u8],
verification_key: &[u8],
) -> Result<(Vec<FieldElement>, FieldElement), Self::Error>;
}
12 changes: 12 additions & 0 deletions acvm/src/pwg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,18 @@ mod test {
) -> Result<OpcodeResolution, OpcodeResolutionError> {
panic!("Path not trodden by this test")
}

fn verify_proof(
&self,
_initial_witness: &mut WitnessMap,
_key: &[FunctionInput],
_proof: &[FunctionInput],
_public_inputs: &[FunctionInput],
_input_aggregation_object: &[FunctionInput],
_outputs: &[Witness],
) -> Result<OpcodeResolution, OpcodeResolutionError> {
panic!("Path not trodden by this test")
}
}

#[test]
Expand Down
15 changes: 15 additions & 0 deletions acvm/src/pwg/blackbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,20 @@ pub(crate) fn solve(
BlackBoxFuncCall::Keccak256 { inputs, outputs } => {
keccak256(initial_witness, inputs, outputs)
}
BlackBoxFuncCall::VerifyProof {
key,
proof,
public_inputs,
input_aggregation_object,
outputs,
..
} => backend.verify_proof(
initial_witness,
key,
proof,
public_inputs,
input_aggregation_object,
outputs,
),
}
}