@@ -22,7 +22,7 @@ bool shielding()
22
22
23
23
std::string proof;
24
24
zsl_prove_shielding (rho, pk, value, proof);
25
- std::cout << " shielding proof:" << proof << std::endl;;
25
+ // std::cout << "shielding proof:" << proof << std::endl;;
26
26
27
27
std::string send_nf = Note::computeSendNullifier (rho);
28
28
std::cout << " send_nf:" << send_nf << std::endl;
@@ -53,7 +53,7 @@ bool unshielding()
53
53
value = 2378237 ;
54
54
std::string proof_u;
55
55
zsl_prove_unshielding (rho, sk, value, index, uncles, proof_u);
56
- std::cout << " unshielding proof:" << proof_u << std::endl;
56
+ // std::cout << "unshielding proof:" << proof_u << std::endl;
57
57
58
58
bool ret = zsl_verify_unshielding (proof_u, spend_nf, mt.root (), value);
59
59
return ret;
@@ -83,22 +83,10 @@ bool shield_transfer()
83
83
uint64_t index1 = 0 ;
84
84
std::vector<std::string> auth_path1;
85
85
mt.get_witness (input_cm1, index1, auth_path1);
86
- // std::vector<std::string> auth_path1 = mt.getWitness(intput_cm1);
87
- std::cout << " index1:" << index1 << std::endl;
88
- for (int i = 0 ; i < 29 ; i++) {
89
- // auth_path1.push_back("8000000000000000000000000000000000000000000000000000000000000100");
90
- std::cout << auth_path1[i] << std::endl;
91
- }
92
- std::cout << " ===== auth path 2" << std::endl;
86
+
93
87
uint64_t index2 = 0 ;
94
88
std::vector<std::string> auth_path2;
95
89
mt.get_witness (input_cm2, index2, auth_path2);
96
- // std::vector<std::string> auth_path2 = mt.getWitness(intput_cm2);
97
- std::cout << " index2:" << index2 << std::endl;
98
- for (int i = 0 ; i < 29 ; i++) {
99
- // auth_path2.push_back("8000000000000000000000000000000000000000000000000000000000000100");
100
- std::cout << auth_path2[i] << std::endl;
101
- }
102
90
103
91
std::string output_pk;
104
92
std::string output_sk;
@@ -114,25 +102,49 @@ bool shield_transfer()
114
102
get_randomness (output_rho2, 32 );
115
103
116
104
Note output_note1 (output_pk, 150 , output_rho1);
117
- Note output_note2 (pk , 50 , output_rho2);
105
+ Note output_note2 (output_pk1 , 50 , output_rho2);
118
106
119
107
std::string anchor = mt.root ();
120
- // std::string anchor = "8610652739ac0c6bb6b5353649bb822b26543f0ebe88f32a489a56843cd04f03";
121
108
122
- std::cout << " input_note1:" << std::endl;
109
+ /* std::cout << "input_note1:" << std::endl;
123
110
input_note1.debug_string();
124
111
std::cout << "input_note2:" << std::endl;
125
112
input_note2.debug_string();
126
113
std::cout << "output_note1:" << std::endl;
127
114
output_note1.debug_string();
128
115
std::cout << "output_note1:" << std::endl;
129
- output_note2.debug_string ();
116
+ output_note2.debug_string();*/
130
117
131
118
132
119
std::string proof_t ;
133
120
zsl_prove_transfer (proof_t , input_note1.rho , sk, input_note1.value , index1, auth_path1, input_note2.rho , sk1, input_note2.value , index2, auth_path2, output_note1.rho , output_note1.pk , output_note1.value , output_note2.rho , output_note2.pk , output_note2.value );
134
121
135
122
bool ret = zsl_verify_transfer (proof_t , anchor, input_note1.spend_nf (sk), input_note2.spend_nf (sk1), output_note1.send_nf (), output_note2.send_nf (), output_note1.cm (), output_note2.cm ());
123
+ if (ret) {
124
+ std::cout << " spend the new output note test" << std::endl;
125
+ std::string new_input_cm1 = output_note1.cm ();
126
+ mt.add_commitment (new_input_cm1);
127
+ std::string new_input_cm2 = output_note2.cm ();
128
+ mt.add_commitment (new_input_cm2);
129
+
130
+ auth_path1.clear ();
131
+ auth_path2.clear ();
132
+ mt.get_witness (new_input_cm1, index1, auth_path1);
133
+ mt.get_witness (new_input_cm2, index2, auth_path2);
134
+
135
+ get_randomness (output_rho1, 32 );
136
+ get_randomness (output_rho2, 32 );
137
+
138
+ Note new_output_note1 (pk, 190 , output_rho1);
139
+ Note new_output_note2 (output_pk, 10 , output_rho2);
140
+
141
+ std::string anchor = mt.root ();
142
+
143
+ std::string new_proof;
144
+ zsl_prove_transfer (new_proof, output_note1.rho , output_sk, output_note1.value , index1, auth_path1, output_note2.rho , output_sk1, output_note2.value , index2, auth_path2, new_output_note1.rho , new_output_note1.pk , new_output_note1.value , new_output_note2.rho , new_output_note2.pk , new_output_note2.value );
145
+
146
+ bool ret = zsl_verify_transfer (new_proof, anchor, output_note1.spend_nf (output_sk), output_note2.spend_nf (output_sk1), new_output_note1.send_nf (), new_output_note2.send_nf (), new_output_note1.cm (), new_output_note2.cm ());
147
+ }
136
148
return ret;
137
149
}
138
150
0 commit comments