mirror of
https://github.com/luxfi/precompile.git
synced 2026-07-27 03:33:45 +00:00
feat(addresses): canonicalize PQ precompiles to LP-4200 unified block
Per LP-4200 unified PQCrypto block: - ML-KEM 0x012201 (was 0x0200...0007) - ML-DSA 0x012202 (was 0x0200...0006) - SLH-DSA 0x012203 (was 0x0600...0001) - Corona 0x012204 (was 0x0200...000B) Adds LP-12xxx range (0x012000-0x012FFF) to modules/registerer whitelist so the new block validates as in-range. LLM.md updated to mark legacy 0x0600 / 0x0800 ranges as superseded by the unified block. Solidity callers updated in luxfi/standard (#59). Spec docs reconciled in lp-3500/lp-3520 (#61).
This commit is contained in:
@@ -179,6 +179,14 @@ Example hook implementations:
|
||||
## Complete Precompile Registry (v0.3.0)
|
||||
|
||||
### Address Ranges
|
||||
|
||||
> **Canonical (LP-4200)**: the unified PQCrypto precompile block at
|
||||
> `0x012201..0x012204` is authoritative — ML-KEM `0x012201`, ML-DSA
|
||||
> `0x012202`, SLH-DSA `0x012203`, Corona `0x012204`. The `0x0600`
|
||||
> (Post-Quantum) and `0x0800` (Threshold) ranges below are the legacy
|
||||
> per-VM mapping; new code MUST target the unified block. See
|
||||
> `~/work/lux/evm/LLM.md` for the canonical per-feature address table.
|
||||
|
||||
| Range | Category | Description |
|
||||
|-------|----------|-------------|
|
||||
| 0x0001-0x00FF | Standard EVM | ECRECOVER, SHA256, BN254, BLS12-381 |
|
||||
@@ -187,9 +195,9 @@ Example hook implementations:
|
||||
| 0x0300-0x03FF | AI/ML | Mining, NVTrust, ModelRegistry |
|
||||
| 0x0400-0x04FF | DEX | Uniswap v4-style AMM, Lending, Perps |
|
||||
| 0x0500-0x05FF | Graph/Query | GraphQL, Subscriptions, Cache |
|
||||
| 0x0600-0x06FF | Post-Quantum | ML-DSA, ML-KEM, SLH-DSA, Quasar |
|
||||
| 0x0600-0x06FF | Post-Quantum (legacy) | superseded by LP-4200 0x012201..0x012204 |
|
||||
| 0x0700-0x07FF | Privacy | FHE, ECIES, Ring, HPKE |
|
||||
| 0x0800-0x08FF | Threshold | FROST, CGGMP21, Corona |
|
||||
| 0x0800-0x08FF | Threshold (legacy) | superseded by LP-4200 unified block |
|
||||
| 0x0900-0x09FF | ZK Proofs | KZG, Groth16, PLONK |
|
||||
| 0x0A00-0x0AFF | Curves | P-256 (secp256r1) |
|
||||
|
||||
|
||||
+4
-2
@@ -20,8 +20,10 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
// ContractCoronaThresholdAddress is the address of the Corona threshold signature precompile (Threshold range 0x0800)
|
||||
ContractCoronaThresholdAddress = common.HexToAddress("0x020000000000000000000000000000000000000B")
|
||||
// ContractCoronaThresholdAddress is the address of the Corona threshold signature precompile.
|
||||
// LP-4200 unified PQCrypto block (post-quantum threshold slot): 0x012204.
|
||||
// Was 0x020000...000B which collides with FHE precompile space (0x0200...0080+).
|
||||
ContractCoronaThresholdAddress = common.HexToAddress("0x0000000000000000000000000000000000012204")
|
||||
|
||||
// Singleton instance
|
||||
CoronaThresholdPrecompile = &coronaThresholdPrecompile{}
|
||||
|
||||
@@ -191,7 +191,7 @@ func TestCoronaThresholdVerify_GasCost(t *testing.T) {
|
||||
// TestCoronaThresholdPrecompile_Address tests precompile address
|
||||
func TestCoronaThresholdPrecompile_Address(t *testing.T) {
|
||||
precompile := &coronaThresholdPrecompile{}
|
||||
expectedAddress := common.HexToAddress("0x020000000000000000000000000000000000000B")
|
||||
expectedAddress := common.HexToAddress("0x0000000000000000000000000000000000012204")
|
||||
require.Equal(t, expectedAddress, precompile.Address())
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -17,7 +17,9 @@ import (
|
||||
|
||||
var (
|
||||
// ContractMLDSAVerifyAddress is the address of the ML-DSA verify precompile
|
||||
ContractMLDSAVerifyAddress = common.HexToAddress("0x0200000000000000000000000000000000000006")
|
||||
// (LP-3500/LP-4200 unified PQCrypto block: 0x012202).
|
||||
// 0x0200... is FHE-precompile space; PQ verify lives in 0x012200-0x0122FF.
|
||||
ContractMLDSAVerifyAddress = common.HexToAddress("0x0000000000000000000000000000000000012202")
|
||||
|
||||
// Singleton instance
|
||||
MLDSAVerifyPrecompile = &mldsaVerifyPrecompile{}
|
||||
|
||||
@@ -403,7 +403,7 @@ func TestMLDSAVerify_GasCost(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMLDSAPrecompile_Address(t *testing.T) {
|
||||
expectedAddr := common.HexToAddress("0x0200000000000000000000000000000000000006")
|
||||
expectedAddr := common.HexToAddress("0x0000000000000000000000000000000000012202")
|
||||
require.Equal(t, expectedAddr, ContractMLDSAVerifyAddress)
|
||||
require.Equal(t, expectedAddr, MLDSAVerifyPrecompile.Address())
|
||||
}
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
// See the file LICENSE for licensing terms.
|
||||
|
||||
// Package mlkem implements the ML-KEM (FIPS 203) key encapsulation precompile.
|
||||
// Address: 0x0200000000000000000000000000000000000007
|
||||
// Address: 0x0000000000000000000000000000000000012201 (LP-4200 unified PQCrypto block)
|
||||
//
|
||||
// Operations:
|
||||
// - 0x01: Encapsulate -- generate shared secret + ciphertext from public key
|
||||
@@ -69,7 +69,7 @@ func deriveSeed(caller common.Address, raw [SeedSize]byte) [SeedSize]byte {
|
||||
|
||||
var (
|
||||
// ContractAddress is the address of the ML-KEM precompile
|
||||
ContractAddress = common.HexToAddress("0x0200000000000000000000000000000000000007")
|
||||
ContractAddress = common.HexToAddress("0x0000000000000000000000000000000000012201")
|
||||
|
||||
// Singleton instance
|
||||
MLKEMPrecompile = &mlkemPrecompile{}
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
func TestMLKEMPrecompileAddress(t *testing.T) {
|
||||
expected := common.HexToAddress("0x0200000000000000000000000000000000000007")
|
||||
expected := common.HexToAddress("0x0000000000000000000000000000000000012201")
|
||||
if MLKEMPrecompile.Address() != expected {
|
||||
t.Errorf("expected address %s, got %s", expected.Hex(), MLKEMPrecompile.Address().Hex())
|
||||
}
|
||||
|
||||
@@ -145,6 +145,13 @@ var (
|
||||
Start: common.HexToAddress("0x0000000000000000000000000000000000009000"),
|
||||
End: common.HexToAddress("0x0000000000000000000000000000000000009fff"),
|
||||
},
|
||||
// LP-12xxx: Unified PQCrypto block (0x0..12000 - 0x0..12fff)
|
||||
// LP-3500/LP-3501/LP-4200: ML-KEM=0x12201, ML-DSA=0x12202,
|
||||
// SLH-DSA=0x12203, Corona-Threshold=0x12204.
|
||||
{
|
||||
Start: common.HexToAddress("0x0000000000000000000000000000000000012000"),
|
||||
End: common.HexToAddress("0x0000000000000000000000000000000000012fff"),
|
||||
},
|
||||
// =====================================================================
|
||||
// LOW-BYTE RANGES (EIP-collision-free addresses)
|
||||
// =====================================================================
|
||||
|
||||
+3
-2
@@ -15,8 +15,9 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
// ContractSLHDSAVerifyAddress is the address of the SLH-DSA verify precompile (Post-Quantum range 0x0600)
|
||||
ContractSLHDSAVerifyAddress = common.HexToAddress("0x0600000000000000000000000000000000000001")
|
||||
// ContractSLHDSAVerifyAddress is the address of the SLH-DSA verify precompile.
|
||||
// LP-3501/LP-4200 unified PQCrypto block: 0x012203.
|
||||
ContractSLHDSAVerifyAddress = common.HexToAddress("0x0000000000000000000000000000000000012203")
|
||||
|
||||
// Singleton instance
|
||||
SLHDSAVerifyPrecompile = &slhdsaVerifyPrecompile{}
|
||||
|
||||
Reference in New Issue
Block a user