You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: EIPS/eip-8051.md
+62-67Lines changed: 62 additions & 67 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,26 +10,21 @@ category: Core
10
10
created: 2025-10-15
11
11
---
12
12
13
-
14
-
# ML-DSA EIP
15
-
16
13
## Abstract
17
14
18
15
This proposal adds precompiled contracts that perform signature verifications using the NIST module-lattice signature scheme. Two instantiations are supported:
19
16
20
-
21
-
22
17
***ML-DSA** — NIST-compliant version using SHAKE256 (FIPS-204),
23
18
***ML-DSA-ETH** — EVM-optimized version for cheaper on-chain verification:
* Stores public-key polynomial `t1` in the NTT domain to skip one NTT during verification (convertible to regular encoding offline)
26
21
27
22
Two precompile contracts are specified:
28
-
-`VERIFY_MLDSA` — verifies a ML-DSA signature compliant to FIPS-204.
29
-
-`VERIFY_MLDSA_ETH` — verifies a ML-DSA-ETH signature replacing SHAKE256 with a more efficient hash function, deviating from FIPS-204.
30
23
31
-
## Motivation
24
+
*`VERIFY_MLDSA` — verifies a ML-DSA signature compliant to FIPS-204.
25
+
*`VERIFY_MLDSA_ETH` — verifies a ML-DSA-ETH signature replacing SHAKE256 with a more efficient hash function, deviating from FIPS-204.
32
26
27
+
## Motivation
33
28
34
29
Quantum computers pose a long-term risk to classical cryptographic algorithms. In particular, signature algorithms based on the hardness of the Elliptic Curve Discrete Logarithm Problem (ECDLP) such as secp256k1, are widely used in Ethereum and threaten by quantum algorithms. This exposes potentially on-chain assets and critical infrastructure to quantum adversaries.
35
30
@@ -60,22 +55,24 @@ The following specification provides two precompiled contract:
60
55
While ML-DSA can be instantiated for three security levels: NIST level II, III and IV, this EIP only covers NIST level II, corresponding to 128 bits of security.
61
56
62
57
For the two variants of ML-DSA of this EIP, the following parameters are fixed:
63
-
- Polynomial degree: `n = 256`,
64
-
- Field modulus: `q = 8380417`,
65
-
- Matrix dimensions: `k=4`, `l=4`,
66
-
- Bounds of rejection: `γ_1 = 2¹⁷`, `γ_2 = (q-1)/88`,
These parameters strictly follows NIST. More precisely, `q`, `n`, `k`, `l` and `η` are chosen in order to ensure a hard MLWE related problem, and the remaining parameters are chosen for the hardness of MSIS as well as for the efficiency of the scheme.
70
66
71
67
In terms of storage, ML-DSA public key can be derived by the verifier, making the overall public key of 1312 bytes. However, this increases the verifier cost, making the on-chain verification too expensive from a practical point of view. In this EIP, the verification algorithm takes the public key in raw format, meaning that the storage for the public key is:
72
-
- The full matrix `A_hat` of 16 384 bytes,
73
-
-`tr` is stored in order to save one hash, with 32 bytes,
74
-
-`t1` is stored in the NTT domain in order to save one NTT, with 4096 bytes.
68
+
69
+
* The full matrix `A_hat` of 16 384 bytes,
70
+
*`tr` is stored in order to save one hash, with 32 bytes,
71
+
*`t1` is stored in the NTT domain in order to save one NTT, with 4096 bytes.
75
72
76
73
The overall storage for the **public key** is **20512 bytes**. The signature follows the same format as specified in FIPS-204: 32 bytes for `c_tilde`, 2304 bytes for the coefficients of `z`, and 84 bytes for `h`. In total, a **signature** requires **2420 bytes**.
77
74
78
-
### Sub-algorithms of ML-DSA
75
+
### Sub-algorithms of ML-DSA
79
76
80
77
#### Number Theoretic Transform
81
78
@@ -85,8 +82,9 @@ Polynomial arithmetic is computed efficiency using Number Theoretic Transform (N
85
82
86
83
The verification algorithm requires an eXtendable Output Function (XOF) made from a hash function.
87
84
This EIP provides two instantiations of a XOF:
88
-
- SHAKE256 is the XOF provided in NIST submission, a sponge construction derived from SHA256. Extracting bytes using SHAKE256 calls the `Keccak_f` permutation as described in Section 3.7 of FIPS-204. While this construction is standardized, it is expensive when computed in the Ethereum Virtual Machine because `Keccak_f` has no EVM opcode.
89
-
- Keccak-PRNG is a XOF that is build from a counter-mode PRNG based on Keccak256. Generating new chunks of bytes requires an incrementing counter, as described in NIST SP800-90A revision 1. This XOF has the same interface as SHAKE256, but requires a `flip()` function that initiate a counter to `0`. Then, the `squeeze` function outputs as many bytes as needed using a counter mode as specified in SP800-90A revision 1. A precompile of `Keccak256` is available in the Ethereum Virtual Machine, making this XOF very efficient in the EVM.
85
+
86
+
* SHAKE256 is the XOF provided in NIST submission, a sponge construction derived from SHA256. Extracting bytes using SHAKE256 calls the `Keccak_f` permutation as described in Section 3.7 of FIPS-204. While this construction is standardized, it is expensive when computed in the Ethereum Virtual Machine because `Keccak_f` has no EVM opcode.
87
+
* Keccak-PRNG is a XOF that is build from a counter-mode PRNG based on Keccak256. Generating new chunks of bytes requires an incrementing counter, as described in NIST SP800-90A revision 1. This XOF has the same interface as SHAKE256, but requires a `flip()` function that initiate a counter to `0`. Then, the `squeeze` function outputs as many bytes as needed using a counter mode as specified in SP800-90A revision 1. A precompile of `Keccak256` is available in the Ethereum Virtual Machine, making this XOF very efficient in the EVM.
The verification of ML-DSA-ETH signatures follows the same algorithm with another hash function, with two differences:
126
-
-`t1` from the public key is stored in the NTT domain in order to save one NTT. The multiplication by `2^d` is also precomputed. Note that this change can be seen as a change of representation.
127
-
- A variant of `sample_in_ball` is defined using KeccakPRNG. The only difference from Algorithm 29 of FIPS-204 is that it requires a `flip()` between lines 3 and 4 so that it initializes the counter to `0` before starting squeezing. Note that this can be implemented in `absorb()` and `squeeze()` so that the same interface can be used as in SHAKE256.
128
123
124
+
*`t1` from the public key is stored in the NTT domain in order to save one NTT. The multiplication by `2^d` is also precomputed. Note that this change can be seen as a change of representation.
125
+
* A variant of `sample_in_ball` is defined using KeccakPRNG. The only difference from Algorithm 29 of FIPS-204 is that it requires a `flip()` between lines 3 and 4 so that it initializes the counter to `0` before starting squeezing. Note that this can be implemented in `absorb()` and `squeeze()` so that the same interface can be used as in SHAKE256.
- The hint `h` needs to be properly encoded. The malformation of the hint is specified in Algorithm 21 of FIPS-204.
150
-
- The element `z` must have a norm satisfying `||z||_∞ < γ_1 - β`. The norm `||.||_∞` is defined page 6 of FIPS-204.
151
-
- The final hash output must be equal to the signature bytes `c_tilde`.
146
+
* The hint `h` needs to be properly encoded. The malformation of the hint is specified in Algorithm 21 of FIPS-204.
147
+
* The element `z` must have a norm satisfying `||z||_∞ < γ_1 - β`. The norm `||.||_∞` is defined page 6 of FIPS-204.
148
+
* The final hash output must be equal to the signature bytes `c_tilde`.
152
149
153
150
### Precompiled contract specification
154
151
155
-
### ML-DSA precompiled contract
152
+
### ML-DSA precompiled contract
156
153
157
154
The precompiled contract VERIFY_MLDSA is proposed with the following input and outputs, which are big-endian values:
158
155
159
-
-**Input data**
160
-
- 32 bytes for the message
161
-
- 2420 bytes for ML-DSA signature
162
-
- 20512 bytes for the ML-DSA expanded public key
163
-
-**Output data**:
164
-
- If the algorithm process succeeds, it returns 1 in 32 bytes format.
165
-
- If the algorithm process fails, it returns 0 in 32 bytes format.
156
+
***Input data**
157
+
* 32 bytes for the message
158
+
* 2420 bytes for ML-DSA signature
159
+
* 20512 bytes for the ML-DSA expanded public key
160
+
***Output data**:
161
+
* If the algorithm process succeeds, it returns 1 in 32 bytes format.
162
+
* If the algorithm process fails, it returns 0 in 32 bytes format.
166
163
167
164
#### Error Cases
168
165
169
-
- Insufficient gas has been provided.
170
-
- Invalid input length (not compliant to described input)
171
-
- Invalid field element encoding (≥ q)
172
-
- Invalid norm bound
173
-
- Invalid hint check
174
-
- Signature verification failure
175
-
166
+
* Insufficient gas has been provided.
167
+
* Invalid input length (not compliant to described input)
168
+
* Invalid field element encoding (≥ q)
169
+
* Invalid norm bound
170
+
* Invalid hint check
171
+
* Signature verification failure
176
172
177
-
### ML-DSA-ETH precompiled contract
173
+
### ML-DSA-ETH precompiled contract
178
174
179
175
The precompiled contract VERIFY_MLDSA_ETH is proposed with the following input and outputs, which are big-endian values:
180
176
181
-
-**Input data**
182
-
- 32 bytes for the message
183
-
- 2420 bytes for ML-DSA-ETH signature
184
-
- 20512 bytes for the ML-DSA-ETH expanded public key
185
-
-**Output data**:
186
-
- If the algorithm process succeeds, it returns 1 in 32 bytes format.
187
-
- If the algorithm process fails, it returns 0 in 32 bytes format.
177
+
***Input data**
178
+
* 32 bytes for the message
179
+
* 2420 bytes for ML-DSA-ETH signature
180
+
* 20512 bytes for the ML-DSA-ETH expanded public key
181
+
***Output data**:
182
+
* If the algorithm process succeeds, it returns 1 in 32 bytes format.
183
+
* If the algorithm process fails, it returns 0 in 32 bytes format.
188
184
189
185
#### Error Cases
190
186
191
-
- Insufficient gas has been provided.
192
-
- Invalid input length (not compliant to described input)
193
-
- Invalid field element encoding (≥ q)
194
-
- Invalid norm bound
195
-
- Invalid hint check
196
-
- Signature verification failure
187
+
* Insufficient gas has been provided.
188
+
* Invalid input length (not compliant to described input)
189
+
* Invalid field element encoding (≥ q)
190
+
* Invalid norm bound
191
+
* Invalid hint check
192
+
* Signature verification failure
197
193
198
194
### Precompiled contract gas usage
199
195
200
196
The cost of the **VERIFY_MLDSA** and **VERIFY_MLDSA_ETH** functions is dominated by the call to the NTTs, and the required hash calls for sampling in the ball (and for μ and the final check).
201
197
It represents in average 5 calls to the hash function. Taking linearly the cost of keccak256, and avoiding the context switching it represents 4500 gas.
202
198
203
-
204
199
## Rationale
205
200
206
201
The ML-DSA scheme was selected as a NIST-standardized post-quantum cryptographic algorithm due to its strong security guarantees and efficiency.
@@ -211,11 +206,9 @@ ML-DSA (based on CRYSTALS-Dilithium) offers a strong balance between security, e
211
206
212
207
Given the increasing urgency of transitioning to quantum-resistant cryptographic primitives or even having them ready in the event that research into quantum computers speeds up.
213
208
214
-
215
209
## Backwards Compatibility
216
210
217
-
In compliance with EIP-7932, the necessary parameters and structure for its integration are provided. `ALG_TYPE = 0xD1` uniquely identifies ML-DSA transactions, set MAX_SIZE = 2420 bytes to accommodate the fixed-length signature_info container, and recommend a `GAS_PENALTY` of approximately `3000` gas subject to benchmarking. The verification function follows the EIP-7932 model, parsing the signature_info, recovering the corresponding Dilithium public key, verifying the signature against the transaction payload hash, and deriving the signer’s Ethereum address as the last 20 bytes of keccak256(pubkey). This definition ensures that ML-DSA can be cleanly adopted within the `AlgorithmicTransaction` container specified by EIP-7932.
218
-
211
+
In compliance with EIP-7932, the necessary parameters and structure for its integration are provided. `ALG_TYPE = 0xD1` uniquely identifies ML-DSA transactions, set MAX_SIZE = 2420 bytes to accommodate the fixed-length signature_info container, and recommend a `GAS_PENALTY` of approximately `3000` gas subject to benchmarking. The verification function follows the EIP-7932 model, parsing the signature_info, recovering the corresponding Dilithium public key, verifying the signature against the transaction payload hash, and deriving the signer's Ethereum address as the last 20 bytes of keccak256(pubkey). This definition ensures that ML-DSA can be cleanly adopted within the `AlgorithmicTransaction` container specified by EIP-7932.
A set of test vectors for verifying implementations is located in a separate file (to be provided for each opcode). For the NIST compliant version, KATs are reproduced.
260
255
261
-
262
256
## Reference Implementation
263
257
264
258
An implementation is provided in `assets` of this EIP. For the NIST-compliant version, KAT vectors of the NIST submission are valid.
@@ -268,4 +262,5 @@ An implementation is provided in `assets` of this EIP. For the NIST-compliant ve
268
262
The derivation path to obtain the private key from the seed is (tbd).
269
263
270
264
## Copyright
265
+
271
266
Copyright and related rights waived via [CC0](../LICENSE.md).
0 commit comments