-
Notifications
You must be signed in to change notification settings - Fork 14
Deposit测试
传入数据需满足:v = v_old + v_s
v_old/value_old:转换前零知识余额对应的明文余额
v_s/value_s:需要被转换的明文余额
v/value:转换后零知识余额对应的明文余额
理想测试
uint64_t value = uint64_t(264);
uint64_t value_old = uint64_t(255);
uint64_t value_s = uint64_t(9);
结果:Verifying deposit proof successfully!!!
v > v_old + v_s
uint64_t value = uint64_t(264);
uint64_t value_old = uint64_t(250);
uint64_t value_s = uint64_t(9);
结果:generate deposit proof fail!!!
v < v_old + v_s
uint64_t value = uint64_t(261);
uint64_t value_old = uint64_t(255);
uint64_t value_s = uint64_t(9);
结果:generate deposit proof fail!!!
v_old=0
uint64_t value = uint64_t(264);
uint64_t value_old = uint64_t(0);
uint64_t value_s = uint64_t(264);
结果:Verifying deposit proof successfully!!!
v_s=0
uint64_t value = uint64_t(264);
uint64_t value_old = uint64_t(264);
uint64_t value_s = uint64_t(0);
结果:generate deposit proof fail!!!
v_s = 0 v_old = 0 v=0
uint64_t value = uint64_t(0);
uint64_t value_old = uint64_t(0);
uint64_t value_s = uint64_t(0);
结果:generate deposit proof fail!!!
验证生成proof
auto proof = generate_proof<default_r1cs_ppzksnark_pp>(keypair.pk,
note_s,
note_old,
note,
cmtS,
cmtB_old,
cmtB,
rt,
path
);
理想测试
uint256 cmtS = note_s.cm();
uint256 cmtB_old = note_old.cm();
uint256 cmtB = note.cm();
uint256 rt = wit.root();
auto path = wit.path();
结果:Verifying deposit proof successfully!!!
现改变cmtS为wrong_cmtS,
uint256 wrong_cmtS = note_old.cm();
uint256 cmtB_old = note_old.cm();
uint256 cmtB = note.cm();
uint256 rt = wit.root();
auto path = wit.path();
结果:generate deposit proof fail!!!
现改变cmtB_old为wrong_cmtB_old,
uint256 cmtS = note_s.cm();
uint256 wrong_cmtB_old = note.cm();
uint256 cmtB = note.cm();
uint256 rt = wit.root();
auto path = wit.path();
结果:generate deposit proof fail!!!
现改变cmtB为wrong_cmtB,
uint256 cmtS = note_s.cm();
uint256 cmtB_old = note_old.cm();
uint256 wrong_cmtB = note_old.cm();
uint256 rt = wit.root();
auto path = wit.path();
结果:generate deposit proof fail!!!
现改变rt为wrong_rt,
uint256 cmtS = note_s.cm();
uint256 cmtB_old = note_old.cm();
uint256 cmtB = note.cm();
uint256 wrong_rt = wrong_wit.root();
auto path = wit.path();
结果:generate deposit proof fail!!!
现改变path为wrong_path,
uint256 cmtS = note_s.cm();
uint256 cmtB_old = note_old.cm();
uint256 cmtB = note.cm();
uint256 rt = wit.root();
auto wrong_path = wrong_wit.path();
结果:generate deposit proof fail!!!
现改变rt为wrong_rt,path为wrong_path,
uint256 cmtS = note_s.cm();
uint256 cmtB_old = note_old.cm();
uint256 cmtB = note.cm();
uint256 wrong_rt = wrong_wit.root();
auto wrong_path = wrong_wit.path();
结果:generate deposit proof fail!!!
正常产生proof时,验证proof
bool result = verify_proof(keypair.vk,
*proof,
rt,
pk_recv,
cmtB_old,
sn_old,
cmtB
);
理想测试
uint160 pk_recv = uint160S("123");
uint256 sn_old = uint256S("123456");
uint256 rt = wit.root();
uint256 cmtB_old = note_old.cm();
uint256 cmtB = note.cm();
结果:Verifying deposit proof successfully!!!
现改变pk_recv为wrong_pk_recv,
uint160 wrong_pk_recv = uint160S("333");
uint256 sn_old = uint256S("123456");
uint256 rt = wit.root();
uint256 cmtB_old = note_old.cm();
uint256 cmtB = note.cm();
结果:Verifying deposit proof unsuccessfully!!!
现改变sn_old为wrong_sn_old,
uint160 pk_recv = uint160S("123");
uint256 wrong_sn_old = uint256S("666");
uint256 rt = wit.root();
uint256 cmtB_old = note_old.cm();
uint256 cmtB = note.cm();
结果:Verifying deposit proof unsuccessfully!!!