Add verifier-datas tree (set) & in-circuit verification (#274)
* containers: add method to create new {Dict,Set,Array} with custom max_depth
* add vds_tree computation, update tree circuit interface
* add VDTree struct, add DEFAULT_VD_TREE, integrate it with MainPod,EmptyPod,frontend,etc.
* adapt frontend/serialization tests to new containers field (max_depth)
* adapt interfaces to allow using custom vd_tree in frontend & backend constructors
* rename VDTree to VDSet (and derivate namings too)
* containers 'new' always with param 'max_depth', use params.max_depth_mt_containers instead of the global constant MAX_DEPTH
* adapt after rebasing the branch to main latest changes
* apply review suggestions from @ed255
* use emptypod vd_mt_proofs (using vd_set as circuit input), merge the two existing set_targets methods of MainPodVerifyTarget
* document VDSet & vds_root
This commit is contained in:
parent
6258e52e1a
commit
273d803ebd
17 changed files with 486 additions and 259 deletions
|
|
@ -19,7 +19,7 @@ use crate::{
|
|||
},
|
||||
middleware::{
|
||||
self, hash_str, AnchoredKey, DynError, Hash, MainPodInputs, NativePredicate, Params, Pod,
|
||||
PodId, PodProver, PodType, Predicate, RecursivePod, StatementArg, KEY_TYPE, SELF,
|
||||
PodId, PodProver, PodType, Predicate, RecursivePod, StatementArg, VDSet, KEY_TYPE, SELF,
|
||||
},
|
||||
};
|
||||
|
||||
|
|
@ -29,6 +29,7 @@ impl PodProver for MockProver {
|
|||
fn prove(
|
||||
&self,
|
||||
params: &Params,
|
||||
_vd_set: &VDSet,
|
||||
inputs: MainPodInputs,
|
||||
) -> Result<Box<dyn RecursivePod>, Box<DynError>> {
|
||||
Ok(Box::new(MockMainPod::new(params, inputs)?))
|
||||
|
|
@ -176,7 +177,7 @@ impl MockMainPod {
|
|||
Ok(Self {
|
||||
params: params.clone(),
|
||||
id,
|
||||
vds_root: inputs.vds_root,
|
||||
vds_root: inputs.vds_set.root(),
|
||||
// input_signed_pods,
|
||||
// input_main_pods,
|
||||
// input_statements,
|
||||
|
|
@ -356,12 +357,13 @@ pub mod tests {
|
|||
zu_kyc_sign_pod_builders,
|
||||
},
|
||||
frontend,
|
||||
middleware::{self},
|
||||
middleware::{self, DEFAULT_VD_SET},
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn test_mock_main_zu_kyc() -> frontend::Result<()> {
|
||||
let params = middleware::Params::default();
|
||||
let vd_set = &*DEFAULT_VD_SET;
|
||||
let (gov_id_builder, pay_stub_builder, sanction_list_builder) =
|
||||
zu_kyc_sign_pod_builders(¶ms);
|
||||
let mut signer = MockSigner {
|
||||
|
|
@ -376,8 +378,13 @@ pub mod tests {
|
|||
pk: "ZooOFAC".into(),
|
||||
};
|
||||
let sanction_list_pod = sanction_list_builder.sign(&mut signer)?;
|
||||
let kyc_builder =
|
||||
zu_kyc_pod_builder(¶ms, &gov_id_pod, &pay_stub_pod, &sanction_list_pod)?;
|
||||
let kyc_builder = zu_kyc_pod_builder(
|
||||
¶ms,
|
||||
&vd_set,
|
||||
&gov_id_pod,
|
||||
&pay_stub_pod,
|
||||
&sanction_list_pod,
|
||||
)?;
|
||||
|
||||
let mut prover = MockProver {};
|
||||
let kyc_pod = kyc_builder.prove(&mut prover, ¶ms)?;
|
||||
|
|
|
|||
|
|
@ -27,13 +27,13 @@ impl MockSigner {
|
|||
}
|
||||
|
||||
impl MockSigner {
|
||||
fn _sign(&mut self, _params: &Params, kvs: &HashMap<Key, Value>) -> Result<MockSignedPod> {
|
||||
fn _sign(&mut self, params: &Params, kvs: &HashMap<Key, Value>) -> Result<MockSignedPod> {
|
||||
let mut kvs = kvs.clone();
|
||||
let pubkey = self.public_key();
|
||||
kvs.insert(Key::from(KEY_SIGNER), Value::from(pubkey));
|
||||
kvs.insert(Key::from(KEY_TYPE), Value::from(PodType::MockSigned));
|
||||
|
||||
let dict = Dictionary::new(kvs.clone())?;
|
||||
let dict = Dictionary::new(params.max_depth_mt_containers, kvs.clone())?;
|
||||
let id = PodId(dict.commitment());
|
||||
let signature = format!("{}_signed_by_{}", id, pubkey);
|
||||
Ok(MockSignedPod { id, signature, kvs })
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue