-
Notifications
You must be signed in to change notification settings - Fork 14
Redeem测试
传入数据需满足:v = v_old - v_s v_s < v_old
v_old/value_old:转换前零知识余额对应的明文余额
v_s/value_s:需要被转换的明文余额
v/value:转换后零知识余额对应的明文余额
理想测试:
uint64_t value = uint64_t(13);
uint64_t value_old = uint64_t(20);
uint64_t value_s = uint64_t(7);
结果:Verifying redeem proof successfully!
v > v_old - v_s
uint64_t value = uint64_t(14);
uint64_t value_old = uint64_t(20);
uint64_t value_s = uint64_t(7);
结果:generate redeem proof fail!
v < v_old - v_s
uint64_t value = uint64_t(12);
uint64_t value_old = uint64_t(20);
uint64_t value_s = uint64_t(7);
结果:generate redeem proof fail!
v_s = 0
uint64_t value = uint64_t(12);
uint64_t value_old = uint64_t(12);
uint64_t value_s = uint64_t(0);
结果:Verifying redeem 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);
结果:generate redeem proof fail!
v_s = v_old
uint64_t value = uint64_t(0);
uint64_t value_old = uint64_t(12);
uint64_t value_s = uint64_t(12);
结果:generate redeem proof fail!
v_s > v_old
uint64_t value = uint64_t(-1);
uint64_t value_old = uint64_t(12);
uint64_t value_s = uint64_t(13);
结果:generate redeem proof fail!
验证proof时的测试参数及测试结果
(1)sn_old,value_s,cmtA_old,cmtA为生成proof时的正确参数:
uint256 sn_old = uint256S("123456");
uint256 cmtA_old = note_old.cm();
uint256 cmtA = note.cm();
uint64_t value_s = uint64_t(7);
验证proof通过,结果: Verifying send proof successfully!!!
(2)value_s,cmtA_old,cmtA为生成proof时的正确参数,sn_old为错误参数:
uint256 wrong_sn_old = uint256S("666");
uint256 cmtA_old = note_old.cm();
uint256 cmtA = note.cm();
uint64_t value_s = uint64_t(7);
验证proof不通过,结果: Verifying redeem proof unsuccessfully!!!
(3)sn_old,cmtA_old,cmtA为生成proof时的正确参数,value_s为错误参数:
uint256 sn_old = uint256S("123456");
uint256 cmtA_old = note_old.cm();
uint256 cmtA = note.cm();
uint64_t wrong_value_s = uint64_t(8);
验证proof不通过,结果: Verifying redeem proof unsuccessfully!!!
(4)sn_old,value_s,cmtA为生成proof时的正确参数,cmtA_old为错误参数:
uint256 sn_old = uint256S("123456");
uint256 wrong_cmtA_old = note.cm();
uint256 cmtA = note.cm();
uint64_t value_s = uint64_t(7);
验证proof不通过,结果: Verifying redeem proof unsuccessfully!!!
(5)sn_old,value_s,cmtA_old为生成proof时的正确参数,cmtA为错误参数:
uint256 sn_old = uint256S("123456");
uint256 cmtA_old = note_old.cm();
uint256 wrong_cmtA = note_old.cm();
uint64_t value_s = uint64_t(7);
验证proof不通过,结果: Verifying redeem proof unsuccessfully!!!