当前位置:网站首页>appliedzkp zkevm(10)中的Transactions Proof
appliedzkp zkevm(10)中的Transactions Proof
2022-06-28 10:00:00 【mutourend】
1. 引言
transactions proof会:
- 验证每笔交易的签名;
- 验证
transactionsRoot对应的merkle patricia trie中刚好包含了所有的交易(不多不少); - 使得EVM proof可通过transaction table访问transactions data。
2. Transcation encoding
存在不同的交易编码方式。在第一版本的zkEVM将仅支持兼容EIP-155的Legacy transaction。未来将支持Non-Legacy (EIP-2718)transactions。
2.1 Legacy Transaction encoding
Legacy type为:
rlp([nonce, gasPrice, gas, to, value, data, sig_v, r, s])
- 在BIP-155之前,待签名的hashed data为:
(nonce, gasprice, gas, to, value, data)withsig_v = {0,1} + 27 - 在EIP-155之后,待签名的hashed data为:
(nonce, gasprice, gas, to, value, data, chain_id, 0, 0)withsig_v = {0,1} + CHAIN_ID * 2 + 35
其中的{0,1}表示的curve point y y y坐标的极性,该curve point对应为secp256k1签名过程中的公钥。
2.2 Non-Legacy (EIP-2719) Transaction encoding
根据:
Non-Legacy类型为:
0x02 || rlp([chain_id, nonce, max_priority_fee_per_gas, max_fee_per_gas, gas, destination, amount, data, access_list, signature_y_parity, signature_r, signature_s])
待签名的hashed data为:待定。
3. Circuit behaviour
Transactions proof证明电路中对应的public inputs有:
- chain_id
- transactionsRoot
每笔交易由以下参数定义:
- (nonce, gas_price, gas, to, value, data, sig_v, sig_r, sig_s)
其中可用作public inputs的参数有:
- (nonce, gas_price, gas, to, value, data, from)
Transactions proof证明电路的验证逻辑为:
- 1)txSignData: bytes = rlp([nonce, gas_price, gas, to, value, data, chain_id, 0, 0])
- 2)txSignHash: word = keccak(txSignData)
- 3)sig_parity: {0, 1} = sig_v - 35 - chain_id / 2
- 4)ecdsa_recover(txSignHash, sig_parity, sig_r, sig_s) = pubKey 或等价为 verify(txSignHash, sig_r, sig_s, pubKey) = true
- 5)fromAddress = keccak(pubKey)[-20:]
其中:
- 第1)步中对交易参数的rlp编码将采用定制的rlp encoding gadget来实现,以区分(不同于)MPT circuit中使用的rlp encoding。
- 第2)步中的待签名消息keccak hash验证将采用keccak circuit。该tx circuit将实现一个单独的对应keccak 的lookup table(使用RLC将rlp encoded transaction类加紧一个single value内)。
- 第3)步中根据待签名消息和签名恢复公钥将采用ECDSA circuit。该tx circuit将实现一个对应ECDSA的lookup table。
- 第5)步中的公钥keccak hash验证将采用keccak circuit。该tx circuit将实现一个对应keccak的lookup table。
根据以上信息,构建了TxTable:
| 0 TxID | 1 Tag | 2 Index | 3 value |
|---|---|---|---|
| TxContextFieldTag | |||
| $TxID | Nonce | 0 | $value: raw |
| $TxID | Gas | 0 | $value: raw |
| $TxID | GasPrice | 0 | $value: rlc |
| $TxID | GasTipCap | 0 | $value: 0 |
| $TxID | GasFeeCap | 0 | $value: 0 |
| $TxID | CallerAddress | 0 | $value: raw |
| $TxID | CalleeAddress | 0 | $value: raw |
| $TxID | IsCreate | 0 | $value: raw |
| $TxID | Value | 0 | $value: rlc |
| $TxID | CallDataLength | 0 | $value: raw |
| $TxID | CallData | $ByteIndex | $value: raw |
其中:
- Gas = gas
- GasTipCap = 0
- GasFeeCap = 0
- CallerAddress = fromAddress
- CalleeAddress = to
- IsCreate =
1 if to is None else 0 - CallDataLength = len(data)
- CallData[KaTeX parse error: Can't use function '\]' in math mode at position 10: ByteIndex\̲]̲ = data\[ByteIndex]
参考资料
边栏推荐
- [NLP] this year's college entrance examination English AI score is 134. The research of Fudan Wuda alumni is interesting
- 标识符的命名规则和规范
- Key summary IV of PMP examination - planning process group (2)
- 接口自动化框架脚手架-利用反射机制实现接口统一发起端
- 如图 用sql行转列 图一原表,图二希望转换后
- Idea failed to connect to SQL Sever
- Ribbon核心源码解析
- Comprehensive evaluation of outline note taking software workflow: advantages, disadvantages and evaluation
- Ideal interface automation project
- Bron filter Course Research Report
猜你喜欢

Adapter mode

fastposter v2.8.4 发布 电商海报生成器

How to use dataant to monitor Apache apisex

Function sub file writing

Instant messaging and BS architecture simulation of TCP practical cases

PMP Exam key summary VI - chart arrangement

Matplotlib属性及注解

Global exception handlers and unified return results
![[Unity]EBUSY: resource busy or locked](/img/72/d3e46a820796a48b458cd2d0a18f8f.png)
[Unity]EBUSY: resource busy or locked

手把手教你处理 JS 逆向之 SVG 映射
随机推荐
Looking at jBPM from jbm3 to jbm5 and activiti
ECS MySQL query is slow
第六天 脚本与动画系统
What is the difference between MySQL development environment and test environment??
Discard Tkinter! Simple configuration to quickly generate cool GUI!
Read PDF image and identify content
Explain final, finally, and finalize
错过金三银四,找工作4个月,面试15家,终于拿到3个offer,定级P7+
Caffeine cache, the king of cache, has stronger performance than guava
增量快照 必须要求mysql表有主键的吗?
Django database operation and problem solving
卸载oracle报错
On the influence of small program on the digitalization of media industry
纵观jBPM从jBPM3到jBPM5以及Activiti
[unity][ecs] learning notes (III)
2022 Wu Enda machine learning specialization week 2 practice lab: linear expression
Missed the golden three silver four, found a job for 4 months, interviewed 15 companies, and finally got 3 offers, ranking P7+
Thread lifecycle
PMP examination key summary VIII - monitoring process group (2)
[Unity][ECS]学习笔记(一)