feat: add container update ops (#390)
* Add container update ops * Update src/middleware/operation.rs Co-authored-by: Eduard S. <eduardsanou@posteo.net> * Update src/backends/plonky2/mainpod/mod.rs Co-authored-by: Eduard S. <eduardsanou@posteo.net> * Code review --------- Co-authored-by: Eduard S. <eduardsanou@posteo.net>
This commit is contained in:
parent
656cae77e0
commit
1508dd6126
15 changed files with 1452 additions and 72 deletions
|
|
@ -19,7 +19,10 @@ use crate::{
|
|||
error::{Error, Result},
|
||||
hash_common_data,
|
||||
mock::emptypod::MockEmptyPod,
|
||||
primitives::{ec::schnorr::SecretKey, merkletree::MerkleClaimAndProof},
|
||||
primitives::{
|
||||
ec::schnorr::SecretKey,
|
||||
merkletree::{MerkleClaimAndProof, MerkleTreeStateTransitionProof},
|
||||
},
|
||||
recursion::{
|
||||
hash_verifier_data, prove_rec_circuit, RecursiveCircuit, RecursiveCircuitTarget,
|
||||
},
|
||||
|
|
@ -173,6 +176,33 @@ pub(crate) fn extract_merkle_proofs(
|
|||
Ok(table)
|
||||
}
|
||||
|
||||
/// Extracts Merkle state transition proofs from container update ops.
|
||||
pub(crate) fn extract_merkle_tree_state_transition_proofs(
|
||||
params: &Params,
|
||||
aux_list: &mut [OperationAux],
|
||||
operations: &[middleware::Operation],
|
||||
) -> Result<Vec<MerkleTreeStateTransitionProof>> {
|
||||
let mut table = Vec::new();
|
||||
for (i, op) in operations.iter().enumerate() {
|
||||
let pf = match op {
|
||||
middleware::Operation::ContainerInsertFromEntries(_, _, _, _, pf)
|
||||
| middleware::Operation::ContainerUpdateFromEntries(_, _, _, _, pf)
|
||||
| middleware::Operation::ContainerDeleteFromEntries(_, _, _, pf) => pf.clone(),
|
||||
_ => continue,
|
||||
};
|
||||
aux_list[i] = OperationAux::MerkleTreeStateTransitionProofIndex(table.len());
|
||||
table.push(pf);
|
||||
}
|
||||
if table.len() > params.max_merkle_tree_state_transition_proofs_containers {
|
||||
return Err(Error::custom(format!(
|
||||
"The number of required Merkle proofs ({}) exceeds the maximum number ({}).",
|
||||
table.len(),
|
||||
params.max_merkle_tree_state_transition_proofs_containers
|
||||
)));
|
||||
}
|
||||
Ok(table)
|
||||
}
|
||||
|
||||
pub(crate) fn extract_public_key_of(
|
||||
params: &Params,
|
||||
aux_list: &mut [OperationAux],
|
||||
|
|
@ -471,6 +501,9 @@ impl PodProver for Prover {
|
|||
let public_key_of_sks =
|
||||
extract_public_key_of(params, &mut aux_list, inputs.operations, inputs.statements)?;
|
||||
|
||||
let merkle_tree_state_transition_proofs =
|
||||
extract_merkle_tree_state_transition_proofs(params, &mut aux_list, inputs.operations)?;
|
||||
|
||||
let (statements, public_statements) = layout_statements(params, false, &inputs)?;
|
||||
let operations = process_private_statements_operations(
|
||||
params,
|
||||
|
|
@ -513,6 +546,7 @@ impl PodProver for Prover {
|
|||
operations,
|
||||
merkle_proofs,
|
||||
public_key_of_sks,
|
||||
merkle_tree_state_transition_proofs,
|
||||
custom_predicate_batches,
|
||||
custom_predicate_verifications,
|
||||
};
|
||||
|
|
@ -912,14 +946,15 @@ pub mod tests {
|
|||
max_signed_pod_values: 2,
|
||||
max_public_statements: 2,
|
||||
num_public_statements_id: 4,
|
||||
max_statement_args: 3,
|
||||
max_operation_args: 3,
|
||||
max_statement_args: 4,
|
||||
max_operation_args: 4,
|
||||
max_custom_predicate_batches: 2,
|
||||
max_custom_predicate_verifications: 2,
|
||||
max_custom_predicate_arity: 2,
|
||||
max_custom_predicate_wildcards: 3,
|
||||
max_custom_batch_size: 2,
|
||||
max_merkle_proofs_containers: 2,
|
||||
max_merkle_tree_state_transition_proofs_containers: 2,
|
||||
max_public_key_of: 2,
|
||||
max_depth_mt_containers: 4,
|
||||
max_depth_mt_vds: 6,
|
||||
|
|
@ -979,13 +1014,14 @@ pub mod tests {
|
|||
max_input_recursive_pods: 0,
|
||||
max_statements: 9,
|
||||
max_public_statements: 4,
|
||||
max_statement_args: 3,
|
||||
max_operation_args: 3,
|
||||
max_statement_args: 4,
|
||||
max_operation_args: 4,
|
||||
max_custom_predicate_arity: 3,
|
||||
max_custom_batch_size: 3,
|
||||
max_custom_predicate_wildcards: 4,
|
||||
max_custom_predicate_verifications: 2,
|
||||
max_merkle_proofs_containers: 0,
|
||||
max_merkle_tree_state_transition_proofs_containers: 0,
|
||||
..Default::default()
|
||||
};
|
||||
println!("{:#?}", params);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue