-
Notifications
You must be signed in to change notification settings - Fork 14
Deposit测试
wzysdu edited this page Dec 3, 2018
·
5 revisions
传入数据需满足:v = v_old + v_s && v_s < b
v_old/value_old:转换前零知识余额对应的明文余额
v_s/value_s:需要被转换的明文余额
v/value:转换后零知识余额对应的明文余额
b/balance:转换前账户的明文余额
理想测试
uint64_t value = uint64_t(264);
uint64_t value_old = uint64_t(255);
uint64_t value_s = uint64_t(9);
uint64_t balance = uint64_t(30);
结果: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);
uint64_t balance = uint64_t(30);
结果: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);
uint64_t balance = uint64_t(30);
结果: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);
uint64_t balance = uint64_t(30);
结果:Verifying mint proof successfully!
v_s=0
uint64_t value = uint64_t(13);
uint64_t value_old = uint64_t(13);
uint64_t value_s = uint64_t(0);
uint64_t balance = uint64_t(30);
结果:Verifying mint proof successfully!
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);
uint64_t balance = uint64_t(30);
结果:Verifying mint proof successfully!
v_s > b
uint64_t value = uint64_t(13);
uint64_t value_old = uint64_t(6);
uint64_t value_s = uint64_t(7);
uint64_t balance = uint64_t(1);
结果:generate mint proof fail!!!
v_s = b
uint64_t value = uint64_t(13);
uint64_t value_old = uint64_t(6);
uint64_t value_s = uint64_t(7);
uint64_t balance = uint64_t(7);
结果:generate mint proof fail!!!
对于负数情况,因为补码问题有时也会是对的
uint64_t value = uint64_t(8);
uint64_t value_old = uint64_t(-18446744073709551610);
uint64_t value_s = uint64_t(2);
uint64_t balance = uint64_t(-18446744073709551610);
结果:Verifying mint proof successfully!
因为-18446744073709551610补码为6 且2<6,2+6=8
但是,由于value_s 和 balance为所有人都知道的参数变量,所以该问题可以避免。