Implement Containers (Dictionary,Set,Array) on top of MerkleTree. And restructure the code. (#55)
* Implement Containers (Dictionary,Set,Array) on top of MerkleTree. And restructure the code.
- Reorganize the code grouping backends, middleware, frontend, (crypto) primitives.
- Add types Dictionary,Set,Array at the middleware layer, so that
it can be used both by the backend and frontend. The Dictionary, Set,
Array use the merkletree differently as specified at
f2575d1524/book/src/values.md (dictionary-array-set)
- The containers introduce the trait Container, which has the
method 'cm()'. At the current version this uses a merkletree
under the hood, and the method 'cm' returns the merkle root.
- Ideally neither frontend nor backend use the MerkleTree type, and they
use the wrappers {Dictionary,Set,Array}. Note that the current commit
the MerkleTree is used at the mock-backend to check internal values, but
not at the struct types.
- updated the spec's merkletree section updating the defined interface
- add github ci to run the tests
---------
Co-authored-by: Ahmad Afuni <root@ahmadafuni.com>
Co-authored-by: Eduard S. <eduardsanou@posteo.net>
This commit is contained in:
parent
f2575d1524
commit
bb865a4fea
14 changed files with 330 additions and 94 deletions
|
|
@ -1,5 +1,7 @@
|
|||
use crate::frontend::{MainPodBuilder, MerkleTree, SignedPod, SignedPodBuilder, Value};
|
||||
use crate::middleware::{Params, PodType, KEY_SIGNER, KEY_TYPE};
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::frontend::{MainPodBuilder, SignedPod, SignedPodBuilder, Value};
|
||||
use crate::middleware::{containers::Dictionary, Params, PodType, KEY_SIGNER, KEY_TYPE};
|
||||
use crate::op;
|
||||
|
||||
// ZuKYC
|
||||
|
|
@ -22,7 +24,7 @@ pub fn zu_kyc_pod_builder(
|
|||
gov_id: &SignedPod,
|
||||
pay_stub: &SignedPod,
|
||||
) -> MainPodBuilder {
|
||||
let sanction_list = Value::MerkleTree(MerkleTree { root: 1 });
|
||||
let sanction_list = Value::Dictionary(Dictionary::new(&HashMap::new())); // empty dictionary
|
||||
let now_minus_18y: i64 = 1169909388;
|
||||
let now_minus_1y: i64 = 1706367566;
|
||||
|
||||
|
|
@ -178,7 +180,7 @@ pub fn great_boy_pod_full_flow() -> MainPodBuilder {
|
|||
alice_friend_pods.push(friend.sign(&mut bob_signer).unwrap());
|
||||
alice_friend_pods.push(friend.sign(&mut charlie_signer).unwrap());
|
||||
|
||||
let good_boy_issuers_mt = Value::MerkleTree(MerkleTree { root: 33 });
|
||||
let good_boy_issuers_dict = Value::Dictionary(Dictionary::new(&HashMap::new())); // empty
|
||||
great_boy_pod_builder(
|
||||
¶ms,
|
||||
[
|
||||
|
|
@ -188,7 +190,7 @@ pub fn great_boy_pod_full_flow() -> MainPodBuilder {
|
|||
&charlie_good_boys[1],
|
||||
],
|
||||
[&alice_friend_pods[0], &alice_friend_pods[1]],
|
||||
&good_boy_issuers_mt,
|
||||
&good_boy_issuers_dict,
|
||||
alice,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue