Skip to content

Redeem测试

yangchongbin edited this page Nov 21, 2018 · 5 revisions

传入数据需满足: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!!!

1. 方案设计

VNT零知识设计方案

方案设计图

2. 方案实现

实现细节思考

2.1 libsnark模块实现

2.2 ethereum模块实现

2.3 cgo模块实现

3. 方案测试

部分问题

整体测试出的问题

3.1 libsnark模块测试

3.2 整体测试

4. 修改汇总

4.1 libsnark模块修改汇总

4.2 ethereum模块修改汇总

4.3 cgo模块修改汇总

5. 开发技巧

修改并编译web3.js文件

libsnark遇到的大“坑”

FZQA

CGO

MPT trie

transaction 部分修改

简易以太坊测试

Clone this wiki locally