Documentation
¶
Index ¶
- Constants
- Variables
- func EnableCGO() bool
- func GetAllPostQuantumPrecompiles() map[Address]PrecompiledContract
- func GetGasEstimate(addr Address, inputSize int) uint64
- func Info() map[string]interface{}
- func RegisterBLS(registry *Registry)
- func RegisterLamport(registry *Registry)
- func RegisterSHAKE(registry *Registry)
- type Address
- type BLSAggregateVerify
- type BLSFastAggregate
- type BLSHashToPoint
- type BLSPublicKeyAggregate
- type BLSThresholdCombine
- type BLSThresholdVerify
- type BLSVerify
- type CSHAKE128
- type CSHAKE256
- type LamportBatchVerify
- type LamportMerkleRoot
- type LamportMerkleVerify
- type LamportVerifySHA256
- type LamportVerifySHA512
- type PrecompiledContract
- type Registry
- type SHAKE128
- type SHAKE128_256
- type SHAKE128_512
- type SHAKE256
- type SHAKE256_1024
- type SHAKE256_256
- type SHAKE256_512
Constants ¶
const ( // ML-DSA (FIPS 204) range: 0x0110-0x0119 MLDSAStartAddress = "0x0110" MLDSAEndAddress = "0x0119" // ML-KEM (FIPS 203) range: 0x0120-0x0129 MLKEMStartAddress = "0x0120" MLKEMEndAddress = "0x0129" // SLH-DSA (FIPS 205) range: 0x0130-0x0139 SLHDSAStartAddress = "0x0130" SLHDSAEndAddress = "0x0139" // SHAKE (FIPS 202) range: 0x0140-0x0149 SHAKEStartAddress = "0x0140" SHAKEEndAddress = "0x0149" // Lamport signatures range: 0x0150-0x0159 LamportStartAddress = "0x0150" LamportEndAddress = "0x0159" )
Address ranges for different crypto standards
Variables ¶
var ( // BLS12-381 operations BLSVerifyAddress = HexToAddress("0x0000000000000000000000000000000000000160") BLSAggregateVerifyAddress = HexToAddress("0x0000000000000000000000000000000000000161") BLSFastAggregateAddress = HexToAddress("0x0000000000000000000000000000000000000162") // Threshold BLS operations BLSThresholdVerifyAddress = HexToAddress("0x0000000000000000000000000000000000000163") BLSThresholdCombineAddress = HexToAddress("0x0000000000000000000000000000000000000164") // BLS key operations BLSPublicKeyAggregateAddress = HexToAddress("0x0000000000000000000000000000000000000165") BLSHashToPointAddress = HexToAddress("0x0000000000000000000000000000000000000166") )
BLS precompile addresses
var ( LamportVerifySHA256Address = HexToAddress("0x0000000000000000000000000000000000000150") LamportVerifySHA512Address = HexToAddress("0x0000000000000000000000000000000000000151") LamportBatchVerifyAddress = HexToAddress("0x0000000000000000000000000000000000000152") LamportMerkleRootAddress = HexToAddress("0x0000000000000000000000000000000000000153") LamportMerkleVerifyAddress = HexToAddress("0x0000000000000000000000000000000000000154") )
Lamport precompile addresses
var ( // SHAKE128 precompiles SHAKE128Address = HexToAddress("0x0000000000000000000000000000000000000140") SHAKE128_256Address = HexToAddress("0x0000000000000000000000000000000000000141") SHAKE128_512Address = HexToAddress("0x0000000000000000000000000000000000000142") // SHAKE256 precompiles SHAKE256Address = HexToAddress("0x0000000000000000000000000000000000000143") SHAKE256_256Address = HexToAddress("0x0000000000000000000000000000000000000144") SHAKE256_512Address = HexToAddress("0x0000000000000000000000000000000000000145") SHAKE256_1024Address = HexToAddress("0x0000000000000000000000000000000000000146") // cSHAKE precompiles CSHAKE128Address = HexToAddress("0x0000000000000000000000000000000000000147") CSHAKE256Address = HexToAddress("0x0000000000000000000000000000000000000148") )
SHAKE precompile addresses
var PostQuantumRegistry = NewRegistry()
Global registry for all post-quantum precompiles
Functions ¶
func GetAllPostQuantumPrecompiles ¶
func GetAllPostQuantumPrecompiles() map[Address]PrecompiledContract
GetAllPostQuantumPrecompiles returns all post-quantum precompiles This includes SHAKE, Lamport, and the three NIST standards
func GetGasEstimate ¶
GetGasEstimate returns an estimated gas cost for a precompile
func Info ¶
func Info() map[string]interface{}
Info returns information about all registered precompiles
func RegisterLamport ¶
func RegisterLamport(registry *Registry)
RegisterLamport registers all Lamport precompiles
func RegisterSHAKE ¶
func RegisterSHAKE(registry *Registry)
RegisterSHAKE registers all SHAKE precompiles
Types ¶
type Address ¶
type Address [20]byte
Address represents a 20-byte Ethereum address
func GetPrecompileAddresses ¶
func GetPrecompileAddresses() []Address
GetPrecompileAddresses returns all registered addresses
func HexToAddress ¶
HexToAddress returns Address with byte values of s.
type BLSAggregateVerify ¶
type BLSAggregateVerify struct{}
BLSAggregateVerify verifies multiple signatures with different messages
func (*BLSAggregateVerify) RequiredGas ¶
func (b *BLSAggregateVerify) RequiredGas(input []byte) uint64
type BLSFastAggregate ¶
type BLSFastAggregate struct{}
BLSFastAggregate verifies aggregate signature with same message
func (*BLSFastAggregate) RequiredGas ¶
func (b *BLSFastAggregate) RequiredGas(input []byte) uint64
type BLSHashToPoint ¶
type BLSHashToPoint struct{}
BLSHashToPoint hashes message to BLS12-381 G2 point
func (*BLSHashToPoint) RequiredGas ¶
func (b *BLSHashToPoint) RequiredGas(input []byte) uint64
type BLSPublicKeyAggregate ¶
type BLSPublicKeyAggregate struct{}
BLSPublicKeyAggregate aggregates multiple BLS public keys
func (*BLSPublicKeyAggregate) RequiredGas ¶
func (b *BLSPublicKeyAggregate) RequiredGas(input []byte) uint64
type BLSThresholdCombine ¶
type BLSThresholdCombine struct{}
BLSThresholdCombine combines threshold signature shares
func (*BLSThresholdCombine) RequiredGas ¶
func (b *BLSThresholdCombine) RequiredGas(input []byte) uint64
type BLSThresholdVerify ¶
type BLSThresholdVerify struct{}
BLSThresholdVerify verifies threshold signature
func (*BLSThresholdVerify) RequiredGas ¶
func (b *BLSThresholdVerify) RequiredGas(input []byte) uint64
type BLSVerify ¶
type BLSVerify struct{}
BLSVerify implements single BLS signature verification
func (*BLSVerify) RequiredGas ¶
type CSHAKE128 ¶
type CSHAKE128 struct{}
cSHAKE128 with customization string
func (*CSHAKE128) RequiredGas ¶
type LamportBatchVerify ¶
type LamportBatchVerify struct{}
LamportBatchVerify implements batch verification
func (*LamportBatchVerify) RequiredGas ¶
func (l *LamportBatchVerify) RequiredGas(input []byte) uint64
type LamportMerkleRoot ¶
type LamportMerkleRoot struct{}
LamportMerkleRoot computes Merkle root of Lamport public keys
func (*LamportMerkleRoot) RequiredGas ¶
func (l *LamportMerkleRoot) RequiredGas(input []byte) uint64
type LamportMerkleVerify ¶
type LamportMerkleVerify struct{}
LamportMerkleVerify verifies Merkle proof for a Lamport public key
func (*LamportMerkleVerify) RequiredGas ¶
func (l *LamportMerkleVerify) RequiredGas(input []byte) uint64
type LamportVerifySHA256 ¶
type LamportVerifySHA256 struct{}
LamportVerifySHA256 implements SHA256-based Lamport verification
func (*LamportVerifySHA256) RequiredGas ¶
func (l *LamportVerifySHA256) RequiredGas(input []byte) uint64
type LamportVerifySHA512 ¶
type LamportVerifySHA512 struct{}
LamportVerifySHA512 implements SHA512-based Lamport verification
func (*LamportVerifySHA512) RequiredGas ¶
func (l *LamportVerifySHA512) RequiredGas(input []byte) uint64
type PrecompiledContract ¶
type PrecompiledContract interface {
RequiredGas(input []byte) uint64 // Calculate gas cost
Run(input []byte) ([]byte, error) // Execute the precompile
}
PrecompiledContract is the interface for EVM precompiled contracts
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry contains all available precompiled contracts
func (*Registry) Contracts ¶
func (r *Registry) Contracts() map[Address]PrecompiledContract
Contracts returns the map of all contracts
func (*Registry) Get ¶
func (r *Registry) Get(addr Address) (PrecompiledContract, bool)
Get returns a precompiled contract by address
func (*Registry) Register ¶
func (r *Registry) Register(addr Address, contract PrecompiledContract)
Register adds a precompiled contract to the registry
type SHAKE128 ¶
type SHAKE128 struct{}
SHAKE128 implements variable-output SHAKE128
func (*SHAKE128) RequiredGas ¶
type SHAKE128_256 ¶
type SHAKE128_256 struct{}
func (*SHAKE128_256) RequiredGas ¶
func (s *SHAKE128_256) RequiredGas(input []byte) uint64
type SHAKE128_512 ¶
type SHAKE128_512 struct{}
Fixed size implementations
func (*SHAKE128_512) RequiredGas ¶
func (s *SHAKE128_512) RequiredGas(input []byte) uint64
type SHAKE256 ¶
type SHAKE256 struct{}
SHAKE256 implements variable-output SHAKE256
func (*SHAKE256) RequiredGas ¶
type SHAKE256_1024 ¶
type SHAKE256_1024 struct{}
func (*SHAKE256_1024) RequiredGas ¶
func (s *SHAKE256_1024) RequiredGas(input []byte) uint64
type SHAKE256_256 ¶
type SHAKE256_256 struct{}
func (*SHAKE256_256) RequiredGas ¶
func (s *SHAKE256_256) RequiredGas(input []byte) uint64
type SHAKE256_512 ¶
type SHAKE256_512 struct{}
func (*SHAKE256_512) RequiredGas ¶
func (s *SHAKE256_512) RequiredGas(input []byte) uint64