Documentation
¶
Overview ¶
Package secp256k1 provides instruction builders for the Solana secp256k1 precompile program, which verifies Ethereum-style ECDSA signatures. It is a native precompile: it reads instruction data only and takes no account inputs.
Index ¶
- Variables
- func NewInstruction(data []byte) solana.Instruction
- func NewRawInstruction(data []byte) solana.Instruction
- func NewSignatureVerifyInstruction(signatures []Secp256k1SignatureOffsets) (solana.Instruction, error)
- func NewVerifyEthSignature(ethAddress [20]byte, signature [64]byte, recoveryID uint8, message []byte) (solana.Instruction, error)
- type Secp256k1SignatureOffsets
Constants ¶
This section is empty.
Variables ¶
var ProgramID = solana.MustPublicKey("KeccakSecp256k11111111111111111111111111111")
ProgramID is the canonical address of the Solana secp256k1 precompile: KeccakSecp256k11111111111111111111111111111.
Functions ¶
func NewInstruction ¶
func NewInstruction(data []byte) solana.Instruction
NewInstruction is an alias for NewRawInstruction.
func NewRawInstruction ¶
func NewRawInstruction(data []byte) solana.Instruction
NewRawInstruction wraps pre-encoded secp256k1 precompile data as a solana.Instruction.
func NewSignatureVerifyInstruction ¶
func NewSignatureVerifyInstruction(signatures []Secp256k1SignatureOffsets) (solana.Instruction, error)
NewSignatureVerifyInstruction builds a secp256k1 precompile instruction from a slice of Secp256k1SignatureOffsets descriptors. Layout: [1 byte count] [11 bytes per entry, LE encoded]. len(signatures) must not exceed 255 (the on-chain count field is u8).
func NewVerifyEthSignature ¶
func NewVerifyEthSignature(ethAddress [20]byte, signature [64]byte, recoveryID uint8, message []byte) (solana.Instruction, error)
NewVerifyEthSignature builds a self-contained Secp256k1 verification instruction. All data (signature, Ethereum address, message) is packed inline in the instruction data field; no other instructions are needed.
ethAddress — 20-byte Ethereum address (keccak256(uncompressed pubkey)[12:]) signature — 64-byte compact ECDSA signature (r ‖ s, no recovery bit) recoveryID — 0 or 1 message — bytes that were signed; must be ≤ 65535 bytes
The instruction has no accounts; the precompile reads everything from the instruction data.
Types ¶
type Secp256k1SignatureOffsets ¶
type Secp256k1SignatureOffsets struct {
SignatureOffset uint16 // byte offset to the 64-byte secp256k1 signature
SignatureInstructionIndex uint8 // which transaction instruction holds the signature
EthAddressOffset uint16 // byte offset to the 20-byte Ethereum address
EthAddressInstructionIndex uint8 // which transaction instruction holds the eth address
MessageDataOffset uint16 // byte offset to the signed message data
MessageDataSize uint16 // length of the message data in bytes
MessageInstructionIndex uint8 // which transaction instruction holds the message
}
Secp256k1SignatureOffsets describes the byte offsets within a secp256k1 precompile instruction where the signature components can be found. On-wire layout is 11 bytes, all fields little-endian.