当前位置:网站首页>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]
参考资料
边栏推荐
- 【云驻共创】DWS告警服务DMS详细介绍和集群连接方式简介
- 再见!IE浏览器,这条路由Edge替IE继续走下去
- An error is reported when uninstalling Oracle
- 一文读懂 12种卷积方法(含1x1卷积、转置卷积和深度可分离卷积等)
- [200 opencv routines] 213 Draw circle
- Cisco * VRF (virtual route forwarding table)
- 谁知道在中信建投证券开户是不是安全的
- [Unity][ECS]学习笔记(三)
- bad zipfile offset (local header sig)
- bye! IE browser, this route edge continues to go on for IE
猜你喜欢

Thread lifecycle

Starting from full power to accelerate brand renewal, Chang'an electric and electrification products sound the "assembly number"
![[unity][ecs] learning notes (II)](/img/72/d3e46a820796a48b458cd2d0a18f8f.png)
[unity][ecs] learning notes (II)
Ribbon核心源码解析

Sqlcmd database connection error

Looking at jBPM from jbm3 to jbm5 and activiti

Unity AssetBundle资源打包与资源加载

PMP Exam key summary VI - chart arrangement

增强 Jupyter Notebook 的功能,这里有四个妙招

丢弃 Tkinter!简单配置快速生成超酷炫 GUI!
随机推荐
Resolution: overview of decentralized hosting solution
An error is reported when uninstalling Oracle
[NLP] this year's college entrance examination English AI score is 134. The research of Fudan Wuda alumni is interesting
What is the best way to learn machine learning
Flip CEP skip policy aftermatchskipstrategy Skippastlastevent() matched no longer matches the Bikeng Guide
Sword finger offer | linked list transpose
Dear leaders, ask me if MySQL does not support early_ Offset mode? Unsupported star
Chapter 5 trees and binary trees
Instant messaging and BS architecture simulation of TCP practical cases
[Unity][ECS]学习笔记(二)
Is it safe to open an account with the QR code of CICC securities? Tell me what you know
The R language uses the avplots function in the car package to create added variable plots. In image interaction, manually identify (add) strong influence points that have a great impact on each predi
2D code generator for openharmony application development
云服务器MYSQL查询速度慢
Google open source dependency injection framework Guice Guide
The introduction of flink-sql-mysql-cdc-2.2.1 has solved many dependency conflicts?
R语言使用car包中的avPlots函数创建变量添加图(Added-variable plots)、在图像交互中,在变量添加图中手动标识(添加)对于每一个预测变量影响较大的强影响点
Bridge mode
Naming rules and specifications for identifiers
理想中的接口自动化项目