Просмотр исходного кода

[zk/lead] cop with changed incrementalmerkletree api

mohab 4 лет назад
Родитель
Сommit
8d5b757ab4
2 измененных файлов с 11 добавлено и 8 удалено
  1. 9 6
      example/lead.rs
  2. 2 2
      src/zk/circuit/lead_contract.rs

+ 9 - 6
example/lead.rs

@@ -27,9 +27,9 @@ use darkfi::{
     zk::circuit::lead_contract::LeadContract,
     zk::circuit::lead_contract::LeadContract,
 };
 };
 
 
-//use pasta_curves::{arithmetic::CurveAffine, group::Curve};
-//use halo2_proofs::arithmetic::CurveAffine;
+use pasta_curves::{arithmetic::CurveAffine, group::Curve};
 use pasta_curves::group::{ff::PrimeField, GroupEncoding};
 use pasta_curves::group::{ff::PrimeField, GroupEncoding};
+//use halo2_proofs::arithmetic::CurveAffine;
 
 
 #[derive(Debug, Default, Clone, Copy)]
 #[derive(Debug, Default, Clone, Copy)]
 pub struct Coin {
 pub struct Coin {
@@ -67,8 +67,9 @@ fn main() {
         sks.push(sk.clone());
         sks.push(sk.clone());
         let node = MerkleNode(pallas::Base::from(sk));
         let node = MerkleNode(pallas::Base::from(sk));
         tree.append(&node.clone());
         tree.append(&node.clone());
-        tree.witness();
-        let (leaf_pos, path) = tree.authentication_path(&node).unwrap();
+        let leaf_position = tree.witness();
+        //let (leaf_pos, path) = tree.authentication_path(leaf_position.unwrap()).unwrap();
+        let  path = tree.authentication_path(leaf_position.unwrap()).unwrap();
         root_sks.push(tree.root().clone());
         root_sks.push(tree.root().clone());
         path_sks.push(path.as_slice().try_into().unwrap());
         path_sks.push(path.as_slice().try_into().unwrap());
     }
     }
@@ -123,8 +124,10 @@ fn main() {
         */
         */
         let c_cm_node = MerkleNode(pallas::Base::from(1)); // this is temporary, shouldn't pass of course
         let c_cm_node = MerkleNode(pallas::Base::from(1)); // this is temporary, shouldn't pass of course
         tree_cm.append(&c_cm_node.clone());
         tree_cm.append(&c_cm_node.clone());
-        tree_cm.witness();
-        let (leaf_pos, c_cm_path) = tree_cm.authentication_path(&c_cm_node).unwrap();
+        let leaf_position = tree_cm.witness();
+        //let (leaf_pos, c_cm_path) = tree_cm.authentication_path(&c_cm_node).unwrap();
+        //let (leaf_pos, c_cm_path) = tree_cm.authentication_path(leaf_position.unwrap()).unwrap();
+        let c_cm_path = tree_cm.authentication_path(leaf_position.unwrap()).unwrap();
         let c_root_cm = tree_cm.root();
         let c_root_cm = tree_cm.root();
         // lead coin commitment
         // lead coin commitment
         let c_seed2 = pedersen_commitment_scalar(mod_r_p(c_seed), mod_r_p(c_root_sk.inner()));
         let c_seed2 = pedersen_commitment_scalar(mod_r_p(c_seed), mod_r_p(c_root_sk.inner()));

+ 2 - 2
src/zk/circuit/lead_contract.rs

@@ -37,9 +37,9 @@ use crate::zk::{
     greater_than::{GreaterThanChip, GreaterThanConfig, GreaterThanInstruction},
     greater_than::{GreaterThanChip, GreaterThanConfig, GreaterThanInstruction},
 };
 };
 
 
-//use pasta_curves::{arithmetic::CurveAffine, group::Curve};
-//use halo2_proofs::arithmetic::CurveAffine;
+use pasta_curves::{arithmetic::CurveAffine, group::Curve};
 use pasta_curves::group::{ff::PrimeField, GroupEncoding};
 use pasta_curves::group::{ff::PrimeField, GroupEncoding};
+//use halo2_proofs::arithmetic::CurveAffine;
 
 
 const WORD_BITS: u32 = 24;
 const WORD_BITS: u32 = 24;