sync spec & code (#107)
* sync spec & code * move primitives (merkletree) into the backend * comment on the ops spec and link to issue #108 * typo * fix github-ci mdbook-publish pages
This commit is contained in:
parent
77f3f347e0
commit
02ec7c311b
17 changed files with 90 additions and 64 deletions
|
|
@ -2,12 +2,12 @@ use anyhow::Result;
|
|||
use std::any::Any;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use super::primitives::merkletree::MerkleTree;
|
||||
use crate::constants::MAX_DEPTH;
|
||||
use crate::middleware::{
|
||||
containers::Dictionary, hash_str, AnchoredKey, Hash, Params, Pod, PodId, PodSigner, PodType,
|
||||
Statement, Value, KEY_SIGNER, KEY_TYPE,
|
||||
};
|
||||
use crate::primitives::merkletree::MerkleTree;
|
||||
|
||||
pub struct MockSigner {
|
||||
pub pk: String,
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
pub mod basetypes;
|
||||
pub mod mock_main;
|
||||
pub mod mock_signed;
|
||||
pub mod primitives;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use std::collections::HashMap;
|
|||
use std::fmt;
|
||||
use std::iter::IntoIterator;
|
||||
|
||||
use crate::middleware::{Hash, Value, F, NULL};
|
||||
use crate::backends::plonky2::basetypes::{Hash, Value, F, NULL};
|
||||
|
||||
/// Implements the MerkleTree specified at
|
||||
/// https://0xparc.github.io/pod2/merkletree.html
|
||||
|
|
@ -37,6 +37,7 @@ impl MerkleTree {
|
|||
self.root.hash()
|
||||
}
|
||||
|
||||
/// returns the max_depth parameter from the tree
|
||||
pub fn max_depth(&self) -> usize {
|
||||
self.max_depth
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
//! The frontend includes the user-level abstractions and user-friendly types to define and work
|
||||
//! with Pods.
|
||||
|
||||
use anyhow::{anyhow, Error, Result};
|
||||
use anyhow::{anyhow, Result};
|
||||
use itertools::Itertools;
|
||||
use std::collections::HashMap;
|
||||
use std::convert::From;
|
||||
|
|
@ -689,13 +689,12 @@ pub mod tests {
|
|||
let sanction_list = sanction_list.sign(&mut signer)?;
|
||||
println!("{}", sanction_list);
|
||||
|
||||
let kyc = zu_kyc_pod_builder(¶ms, &gov_id, &pay_stub, &sanction_list)?;
|
||||
println!("{}", kyc);
|
||||
let kyc_builder = zu_kyc_pod_builder(¶ms, &gov_id, &pay_stub, &sanction_list)?;
|
||||
println!("{}", kyc_builder);
|
||||
|
||||
let mut prover = MockProver {};
|
||||
let kyc = kyc.prove(&mut prover, ¶ms)?;
|
||||
let kyc = kyc_builder.prove(&mut prover, ¶ms)?;
|
||||
|
||||
// TODO: prove kyc with MockProver and print it
|
||||
println!("{}", kyc);
|
||||
|
||||
Ok(())
|
||||
|
|
@ -735,7 +734,7 @@ pub mod tests {
|
|||
let great_boy = great_boy_pod_full_flow()?;
|
||||
println!("{}", great_boy);
|
||||
|
||||
// TODO: prove kyc with MockProver and print it
|
||||
// TODO: prove great_boy with MockProver and print it
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ pub mod backends;
|
|||
pub mod constants;
|
||||
pub mod frontend;
|
||||
pub mod middleware;
|
||||
pub mod primitives;
|
||||
mod util;
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
|||
|
|
@ -4,7 +4,9 @@ use anyhow::Result;
|
|||
use std::collections::HashMap;
|
||||
|
||||
use crate::constants::MAX_DEPTH;
|
||||
use crate::primitives::merkletree::{MerkleProof, MerkleTree};
|
||||
|
||||
#[cfg(feature = "backend_plonky2")]
|
||||
use crate::backends::plonky2::primitives::merkletree::{Iter as TreeIter, MerkleProof, MerkleTree};
|
||||
|
||||
use super::basetypes::{hash_value, Hash, Value, EMPTY};
|
||||
|
||||
|
|
@ -42,13 +44,13 @@ impl Dictionary {
|
|||
pub fn verify_nonexistence(root: Hash, proof: &MerkleProof, key: &Value) -> Result<()> {
|
||||
MerkleTree::verify_nonexistence(MAX_DEPTH, root, proof, key)
|
||||
}
|
||||
pub fn iter(&self) -> crate::primitives::merkletree::Iter {
|
||||
pub fn iter(&self) -> TreeIter {
|
||||
self.mt.iter()
|
||||
}
|
||||
}
|
||||
impl<'a> IntoIterator for &'a Dictionary {
|
||||
type Item = (&'a Value, &'a Value);
|
||||
type IntoIter = crate::primitives::merkletree::Iter<'a>;
|
||||
type IntoIter = TreeIter<'a>;
|
||||
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
self.mt.iter()
|
||||
|
|
@ -102,7 +104,7 @@ impl Set {
|
|||
pub fn verify_nonexistence(root: Hash, proof: &MerkleProof, value: &Value) -> Result<()> {
|
||||
MerkleTree::verify_nonexistence(MAX_DEPTH, root, proof, value)
|
||||
}
|
||||
pub fn iter(&self) -> crate::primitives::merkletree::Iter {
|
||||
pub fn iter(&self) -> TreeIter {
|
||||
self.mt.iter()
|
||||
}
|
||||
}
|
||||
|
|
@ -147,7 +149,7 @@ impl Array {
|
|||
pub fn verify(root: Hash, proof: &MerkleProof, i: usize, value: &Value) -> Result<()> {
|
||||
MerkleTree::verify(MAX_DEPTH, root, proof, &Value::from(i as i64), value)
|
||||
}
|
||||
pub fn iter(&self) -> crate::primitives::merkletree::Iter {
|
||||
pub fn iter(&self) -> TreeIter {
|
||||
self.mt.iter()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue