ZuKYC example: get the sanctions list from a SignedPod (#98)
* Get the sanctions list from a SignedPod * Formatting
This commit is contained in:
parent
a2bcb501e8
commit
bcfad307e7
3 changed files with 36 additions and 8 deletions
|
|
@ -485,7 +485,8 @@ pub mod tests {
|
|||
fn test_mock_main_zu_kyc() -> Result<()> {
|
||||
let params = middleware::Params::default();
|
||||
|
||||
let (gov_id_builder, pay_stub_builder) = zu_kyc_sign_pod_builders(¶ms);
|
||||
let (gov_id_builder, pay_stub_builder, sanction_list_builder) =
|
||||
zu_kyc_sign_pod_builders(¶ms);
|
||||
let mut signer = MockSigner {
|
||||
pk: "ZooGov".into(),
|
||||
};
|
||||
|
|
@ -494,7 +495,12 @@ pub mod tests {
|
|||
pk: "ZooDeel".into(),
|
||||
};
|
||||
let pay_stub_pod = pay_stub_builder.sign(&mut signer)?;
|
||||
let kyc_builder = zu_kyc_pod_builder(¶ms, &gov_id_pod, &pay_stub_pod)?;
|
||||
let mut signer = MockSigner {
|
||||
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 mut prover = MockProver {};
|
||||
let kyc_pod = kyc_builder.prove(&mut prover)?;
|
||||
|
|
|
|||
|
|
@ -3,12 +3,16 @@ use std::collections::HashMap;
|
|||
|
||||
use crate::backends::plonky2::mock_signed::MockSigner;
|
||||
use crate::frontend::{MainPodBuilder, SignedPod, SignedPodBuilder, Value};
|
||||
use crate::middleware::containers::Set;
|
||||
use crate::middleware::hash_str;
|
||||
use crate::middleware::{containers::Dictionary, Params, PodType, KEY_SIGNER, KEY_TYPE};
|
||||
use crate::op;
|
||||
|
||||
// ZuKYC
|
||||
|
||||
pub fn zu_kyc_sign_pod_builders(params: &Params) -> (SignedPodBuilder, SignedPodBuilder) {
|
||||
pub fn zu_kyc_sign_pod_builders(
|
||||
params: &Params,
|
||||
) -> (SignedPodBuilder, SignedPodBuilder, SignedPodBuilder) {
|
||||
let mut gov_id = SignedPodBuilder::new(params);
|
||||
gov_id.insert("idNumber", "4242424242");
|
||||
gov_id.insert("dateOfBirth", 1169909384);
|
||||
|
|
@ -18,22 +22,34 @@ pub fn zu_kyc_sign_pod_builders(params: &Params) -> (SignedPodBuilder, SignedPod
|
|||
pay_stub.insert("socialSecurityNumber", "G2121210");
|
||||
pay_stub.insert("startDate", 1706367566);
|
||||
|
||||
(gov_id, pay_stub)
|
||||
let mut sanction_list = SignedPodBuilder::new(params);
|
||||
let sanctions_values = ["A343434340"].map(|s| crate::middleware::Value::from(hash_str(s)));
|
||||
sanction_list.insert(
|
||||
"sanctionList",
|
||||
Value::Set(Set::new(&sanctions_values.to_vec()).unwrap()),
|
||||
);
|
||||
|
||||
(gov_id, pay_stub, sanction_list)
|
||||
}
|
||||
|
||||
pub fn zu_kyc_pod_builder(
|
||||
params: &Params,
|
||||
gov_id: &SignedPod,
|
||||
pay_stub: &SignedPod,
|
||||
sanction_list: &SignedPod,
|
||||
) -> Result<MainPodBuilder> {
|
||||
let sanction_list = Value::Dictionary(Dictionary::new(&HashMap::new())?); // empty dictionary
|
||||
let now_minus_18y: i64 = 1169909388;
|
||||
let now_minus_1y: i64 = 1706367566;
|
||||
|
||||
let mut kyc = MainPodBuilder::new(params);
|
||||
kyc.add_signed_pod(&gov_id);
|
||||
kyc.add_signed_pod(&pay_stub);
|
||||
kyc.pub_op(op!(not_contains, &sanction_list, (gov_id, "idNumber")));
|
||||
kyc.add_signed_pod(&sanction_list);
|
||||
kyc.pub_op(op!(
|
||||
not_contains,
|
||||
(sanction_list, "sanctionList"),
|
||||
(gov_id, "idNumber")
|
||||
));
|
||||
kyc.pub_op(op!(lt, (gov_id, "dateOfBirth"), now_minus_18y));
|
||||
kyc.pub_op(op!(
|
||||
eq,
|
||||
|
|
|
|||
|
|
@ -529,7 +529,7 @@ pub mod tests {
|
|||
#[test]
|
||||
fn test_front_zu_kyc() -> Result<()> {
|
||||
let params = Params::default();
|
||||
let (gov_id, pay_stub) = zu_kyc_sign_pod_builders(¶ms);
|
||||
let (gov_id, pay_stub, sanction_list) = zu_kyc_sign_pod_builders(¶ms);
|
||||
|
||||
println!("{}", gov_id);
|
||||
println!("{}", pay_stub);
|
||||
|
|
@ -546,7 +546,13 @@ pub mod tests {
|
|||
let pay_stub = pay_stub.sign(&mut signer).unwrap();
|
||||
println!("{}", pay_stub);
|
||||
|
||||
let kyc = zu_kyc_pod_builder(¶ms, &gov_id, &pay_stub)?;
|
||||
let mut signer = MockSigner {
|
||||
pk: "ZooOFAC".into(),
|
||||
};
|
||||
let sanction_list = sanction_list.sign(&mut signer).unwrap();
|
||||
println!("{}", sanction_list);
|
||||
|
||||
let kyc = zu_kyc_pod_builder(¶ms, &gov_id, &pay_stub, &sanction_list)?;
|
||||
println!("{}", kyc);
|
||||
|
||||
let mut prover = MockProver {};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue