mirror of
https://github.com/luxfi/coreth.git
synced 2026-10-30 17:00:51 +00:00
luxfi/precompile/pqcrypto (the bundled "unified PQ" package) was removed. Its live role is ML-KEM at 0x012201, now the standalone luxfi/precompile/mlkem — which wraps luxfi/crypto/mlkem. Same ContractAddress, same 6-arg StatefulPrecompiledContract Run, so the adapter is untouched. registry.go already blank-imports mlkem (line 32); the pqcrypto line was pure dead weight. Resolves the pqcrypto build break against [email protected].3. (coreth carries further, unrelated legacy dep-skew — warp.UnsignedMessage, geth v1.16.99 in its own go.mod — that is a separate modernization, not this change.) Co-authored-by: Hanzo Dev <[email protected]>
55 lines
1.9 KiB
Go
55 lines
1.9 KiB
Go
// Copyright (C) 2025, Lux Industries, Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package params
|
|
|
|
import (
|
|
"github.com/luxfi/coreth/precompile/contract"
|
|
"github.com/luxfi/geth/common"
|
|
"github.com/luxfi/precompile/mldsa"
|
|
"github.com/luxfi/precompile/mlkem"
|
|
"github.com/luxfi/precompile/slhdsa"
|
|
|
|
pqcontract "github.com/luxfi/precompile/contract"
|
|
)
|
|
|
|
// pqPrecompileAdapter wraps a precompiles.StatefulPrecompiledContract to implement
|
|
// coreth's contract.StatefulPrecompiledContract interface.
|
|
type pqPrecompileAdapter struct {
|
|
inner pqcontract.StatefulPrecompiledContract
|
|
}
|
|
|
|
// Run implements contract.StatefulPrecompiledContract.
|
|
// The PQ crypto precompiles don't use AccessibleState, so we can safely pass nil.
|
|
func (p *pqPrecompileAdapter) Run(
|
|
_ contract.AccessibleState,
|
|
caller common.Address,
|
|
addr common.Address,
|
|
input []byte,
|
|
suppliedGas uint64,
|
|
readOnly bool,
|
|
) (ret []byte, remainingGas uint64, err error) {
|
|
return p.inner.Run(nil, caller, addr, input, suppliedGas, readOnly)
|
|
}
|
|
|
|
// PQCryptoPrecompiles returns the post-quantum cryptography precompiles.
|
|
// These provide ML-DSA, SLH-DSA, and ML-KEM signature verification and key encapsulation.
|
|
var PQCryptoPrecompiles = map[common.Address]contract.StatefulPrecompiledContract{
|
|
// ML-DSA (FIPS 204) - Lattice-based signatures
|
|
mldsa.ContractMLDSAVerifyAddress: &pqPrecompileAdapter{inner: mldsa.MLDSAVerifyPrecompile},
|
|
|
|
// SLH-DSA (FIPS 205) - Hash-based signatures
|
|
slhdsa.ContractSLHDSAVerifyAddress: &pqPrecompileAdapter{inner: slhdsa.SLHDSAVerifyPrecompile},
|
|
|
|
// ML-KEM (FIPS 203) - Key encapsulation (crypto in luxfi/crypto/mlkem)
|
|
mlkem.ContractAddress: &pqPrecompileAdapter{inner: mlkem.MLKEMPrecompile},
|
|
}
|
|
|
|
func init() {
|
|
// PQ crypto precompiles are part of the canonical Lux built-in set under
|
|
// activate-all-implicitly.
|
|
for addr, precompile := range PQCryptoPrecompiles {
|
|
PrecompiledContractsLux[addr] = precompile
|
|
}
|
|
}
|