Documentation
¶
Index ¶
- Constants
- Variables
- func AggregatePublicKeys(vdrs []*Validator) (*bls.PublicKey, error)
- func AggregateRingtailPublicKeys(publicKeys [][]byte) ([]byte, error)
- func SumWeight(vdrs []*Validator) (uint64, error)
- func VerifyRingtailSignature(publicKey []byte, message []byte, signature []byte) bool
- func VerifyWeight(sigWeight uint64, totalWeight uint64, quorumNum uint64, quorumDen uint64) error
- type BitSetSignature
- type CachedValidatorState
- type CanonicalValidatorSet
- func FlattenValidatorSet(vdrSet map[ids.NodeID]*ValidatorData) (CanonicalValidatorSet, error)
- func GetCanonicalValidatorSetFromChainID(ctx context.Context, pChainState validators.State, pChainHeight uint64, ...) (CanonicalValidatorSet, error)
- func GetCanonicalValidatorSetFromSubsubnetID(ctx context.Context, pChainState ValidatorState, pChainHeight uint64, ...) (CanonicalValidatorSet, error)
- type EncryptedWarpPayload
- type HybridBLSRTSignature
- type Message
- type RingtailSignature
- type Signature
- type SignatureType
- type Signer
- type TeleportAttestPayload
- type TeleportMessage
- type TeleportTransferPayload
- type TeleportType
- type UnsignedMessage
- type Validator
- type ValidatorData
- type ValidatorState
Constants ¶
const ( // RingtailQ is the NTT-friendly prime modulus RingtailQ = 0x1000000004A01 // 48-bit prime // RingtailM is the matrix dimension M RingtailM = 8 // RingtailN is the matrix dimension N RingtailN = 7 // RingtailKappa is the hash output bound RingtailKappa = 23 // RingtailDbar is the signature dimension RingtailDbar = 48 // RingtailKeySize is the symmetric key size in bytes (256 bits) RingtailKeySize = 32 )
Ringtail signature constants (from github.com/luxfi/ringtail/sign/config.go)
const ( // MLKEM768CiphertextLen is ML-KEM-768 ciphertext length (NIST Level 3) - DEFAULT MLKEM768CiphertextLen = 1088 // MLKEM768PublicKeyLen is ML-KEM-768 public key length MLKEM768PublicKeyLen = 1184 MLKEM768SharedSecretLen = 32 // MLKEM1024CiphertextLen is ML-KEM-1024 ciphertext length (NIST Level 5) MLKEM1024CiphertextLen = 1568 // AESGCMNonceLen is the nonce length for AES-256-GCM AESGCMNonceLen = 12 // AESGCMTagLen is the authentication tag length AESGCMTagLen = 16 )
ML-KEM security levels per FIPS 203
const CodecVersion = 0
const RingtailSignatureLen = 3309
RingtailSignatureLen is a placeholder for legacy compatibility. Actual Ringtail signature size depends on threshold parameters. Ringtail uses LWE-based signatures, not ML-DSA. See: https://eprint.iacr.org/2024/1113
Deprecated: Use RingtailSignature type which handles variable-length signatures.
const TeleportVersion uint8 = 1
TeleportVersion is the current version of the Teleport protocol
Variables ¶
var ( ErrInvalidBitSet = errors.New("bitset is invalid") ErrInsufficientWeight = errors.New("signature weight is insufficient") ErrInvalidSignature = errors.New("signature is invalid") ErrParseSignature = errors.New("failed to parse signature") ErrInvalidRTSignature = errors.New("ringtail signature is invalid") ErrMissingRTPublicKey = errors.New("missing ringtail public key for validator") ErrHybridVerifyFailed = errors.New("hybrid signature verification failed") ErrDecryptionFailed = errors.New("ML-KEM decryption failed") ErrInvalidCiphertext = errors.New("invalid ciphertext") )
var ( ErrWrongSourceChainID = errors.New("wrong SourceChainID") ErrWrongNetworkID = errors.New("wrong networkID") )
var ( ErrInvalidTeleportVersion = errors.New("invalid teleport version") ErrInvalidTeleportType = errors.New("invalid teleport type") ErrMissingPayload = errors.New("teleport message missing payload") ErrDecryptRequired = errors.New("payload is encrypted but no decryption key provided") )
var ( ErrUnknownValidator = errors.New("unknown validator") ErrWeightOverflow = errors.New("weight overflowed") )
var AnycastID = ids.ID{
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
}
AnycastID is a special DestinationChainID that is used to indicate that the message is intended to be able to be received by any chain.
var Codec codec.Manager
Functions ¶
func AggregatePublicKeys ¶
AggregatePublicKeys returns the public key of the provided validators.
Invariant: All of the public keys in [vdrs] are valid.
func AggregateRingtailPublicKeys ¶ added in v1.16.56
AggregateRingtailPublicKeys aggregates multiple Ringtail public keys into a single combined public key for threshold verification. This uses the threshold package's SchemeRingtail when available, falling back to XOR-based aggregation as a placeholder.
func VerifyRingtailSignature ¶ added in v1.16.56
VerifyRingtailSignature verifies a Ringtail lattice-based signature. This uses the threshold package's SchemeRingtail verifier when available.
Types ¶
type BitSetSignature ¶
type BitSetSignature struct {
// Signers is a big-endian byte slice encoding which validators signed this
// message.
Signers []byte `serialize:"true"`
Signature [bls.SignatureLen]byte `serialize:"true"`
}
func (*BitSetSignature) NumSigners ¶
func (s *BitSetSignature) NumSigners() (int, error)
func (*BitSetSignature) String ¶
func (s *BitSetSignature) String() string
func (*BitSetSignature) Verify ¶
func (s *BitSetSignature) Verify( msg *UnsignedMessage, networkID uint32, validators CanonicalValidatorSet, quorumNum uint64, quorumDen uint64, ) error
type CachedValidatorState ¶ added in v1.16.56
type CachedValidatorState struct {
// contains filtered or unexported fields
}
CachedValidatorState wraps ValidatorState with an LRU cache
func NewCachedValidatorState ¶ added in v1.16.56
func NewCachedValidatorState( state ValidatorState, upgradeConfig *upgrade.Config, networkID uint32, registerer metric.Registerer, ) (*CachedValidatorState, error)
NewCachedValidatorState creates a new cached validator state with Granite upgrade awareness
func (*CachedValidatorState) GetValidatorSet ¶ added in v1.16.56
func (c *CachedValidatorState) GetValidatorSet( ctx context.Context, height uint64, subnetID ids.ID, ) (map[ids.NodeID]*ValidatorData, error)
GetValidatorSet implements ValidatorState with caching for post-Granite queries
type CanonicalValidatorSet ¶
type CanonicalValidatorSet struct {
// Validators slice in canonical ordering of the validators that has public key
Validators []*Validator
// The total weight of all the validators, including the ones that doesn't have a public key
TotalWeight uint64
}
func FlattenValidatorSet ¶
func FlattenValidatorSet(vdrSet map[ids.NodeID]*ValidatorData) (CanonicalValidatorSet, error)
FlattenValidatorSet converts the provided [vdrSet] into a canonical ordering. Also returns the total weight of the validator set.
func GetCanonicalValidatorSetFromChainID ¶
func GetCanonicalValidatorSetFromChainID(ctx context.Context, pChainState validators.State, pChainHeight uint64, sourceChainID ids.ID, ) (CanonicalValidatorSet, error)
GetCanonicalValidatorSetFromChainID returns the canonical validator set given a validators.State, pChain height and a sourceChainID.
func GetCanonicalValidatorSetFromSubsubnetID ¶ added in v1.16.56
func GetCanonicalValidatorSetFromSubsubnetID( ctx context.Context, pChainState ValidatorState, pChainHeight uint64, subsubnetID ids.ID, ) (CanonicalValidatorSet, error)
GetCanonicalValidatorSetFromSubsubnetID returns the CanonicalValidatorSet of [subsubnetID] at [pChcainHeight]. The returned CanonicalValidatorSet includes the validator set in a canonical ordering and the total weight.
type EncryptedWarpPayload ¶ added in v1.16.56
type EncryptedWarpPayload struct {
// EncapsulatedKey is the ML-KEM ciphertext containing the encapsulated shared secret
// Size: 1088 bytes for ML-KEM-768
EncapsulatedKey []byte `serialize:"true"`
// Nonce is the AES-GCM nonce (12 bytes)
Nonce []byte `serialize:"true"`
// Ciphertext is the AES-256-GCM encrypted payload
// Includes 16-byte authentication tag at the end
Ciphertext []byte `serialize:"true"`
// RecipientKeyID identifies which ML-KEM public key was used
// This allows recipients to know which private key to use for decryption
RecipientKeyID []byte `serialize:"true"`
}
EncryptedWarpPayload provides quantum-safe encryption for confidential cross-chain messages using ML-KEM (FIPS 203) key encapsulation.
Use cases: - Private bridge transfers (hidden amounts/recipients) - Sealed-bid cross-chain auctions - Confidential governance votes - MEV protection (encrypt intent until committed)
Encryption: ML-KEM-768 (NIST Level 3) + AES-256-GCM Security: 192-bit post-quantum for key exchange, 256-bit symmetric
func EncryptWarpPayload ¶ added in v1.16.56
func EncryptWarpPayload(plaintext []byte, recipientPubKey []byte, recipientKeyID []byte) (*EncryptedWarpPayload, error)
Encrypt creates an encrypted Warp payload using ML-KEM + AES-256-GCM
Parameters:
- plaintext: The message to encrypt
- recipientPubKey: The recipient's ML-KEM-768 public key
- recipientKeyID: Identifier for the recipient's key (e.g., hash of pubkey)
Returns:
- EncryptedWarpPayload containing the encrypted message
- error if encryption fails
func (*EncryptedWarpPayload) Decrypt ¶ added in v1.16.56
func (e *EncryptedWarpPayload) Decrypt(recipientPrivKey []byte) ([]byte, error)
Decrypt decrypts an encrypted Warp payload using the recipient's ML-KEM private key
Parameters:
- recipientPrivKey: The recipient's ML-KEM-768 private key
Returns:
- The decrypted plaintext
- error if decryption fails (wrong key, tampered ciphertext, etc.)
func (*EncryptedWarpPayload) Size ¶ added in v1.16.56
func (e *EncryptedWarpPayload) Size() int
Size returns the total size of the encrypted payload in bytes
func (*EncryptedWarpPayload) String ¶ added in v1.16.56
func (e *EncryptedWarpPayload) String() string
type HybridBLSRTSignature ¶ added in v1.16.56
type HybridBLSRTSignature struct {
// Signers is a big-endian byte slice encoding which validators signed
Signers []byte `serialize:"true"`
// BLSSignature is the aggregated BLS signature (96 bytes)
BLSSignature [bls.SignatureLen]byte `serialize:"true"`
// RingtailSignature is the aggregated Ringtail lattice signature
// Uses threshold signing to produce a single combined signature
RingtailSignature []byte `serialize:"true"`
// RingtailPublicKeys contains the Ringtail public keys for each signer
// in the same order as indicated by the Signers bitset
// This is needed because validators may have different RT keys than BLS keys
RingtailPublicKeys [][]byte `serialize:"true"`
}
HybridBLSRTSignature implements a quantum-safe hybrid signature combining: - BLS aggregate signatures (classical security, compact) - Ringtail lattice signatures (post-quantum security, larger)
Both signatures MUST verify for the message to be considered valid. This provides security against both classical and quantum attackers.
Migration path: 1. Pre-quantum: BLS-only (BitSetSignature) 2. Transition: HybridBLSRTSignature (both required) 3. Post-quantum: Ringtail-only (future)
func (*HybridBLSRTSignature) NumSigners ¶ added in v1.16.56
func (s *HybridBLSRTSignature) NumSigners() (int, error)
NumSigners returns the number of validators that participated in signing
func (*HybridBLSRTSignature) String ¶ added in v1.16.56
func (s *HybridBLSRTSignature) String() string
func (*HybridBLSRTSignature) Verify ¶ added in v1.16.56
func (s *HybridBLSRTSignature) Verify( msg *UnsignedMessage, networkID uint32, validators CanonicalValidatorSet, quorumNum uint64, quorumDen uint64, ) error
Verify validates both BLS and Ringtail signatures Both MUST be valid for the hybrid signature to be accepted
type Message ¶
type Message struct {
UnsignedMessage `serialize:"true"`
Signature Signature `serialize:"true"`
// contains filtered or unexported fields
}
Message defines the standard format for a Warp message.
func NewMessage ¶
func NewMessage( unsignedMsg *UnsignedMessage, signature Signature, ) (*Message, error)
NewMessage creates a new *Message and initializes it.
func ParseMessage ¶
ParseMessage converts a slice of bytes into an initialized *Message.
func (*Message) Bytes ¶
Bytes returns the binary representation of this message. It assumes that the message is initialized from either New, Parse, or an explicit call to Initialize.
func (*Message) Initialize ¶
Initialize recalculates the result of Bytes(). It does not call Initialize() on the UnsignedMessage.
type RingtailSignature ¶ added in v1.16.56
type RingtailSignature struct {
// Signers is a big-endian byte slice encoding which validators signed
Signers []byte `serialize:"true"`
// Signature is the Ringtail threshold signature
// Contains: c (challenge polynomial), z (response vector), Delta (hint vector)
// Size depends on threshold parameters (M, N, Dbar, Kappa)
Signature []byte `serialize:"true"`
}
RingtailSignature is the Warp 1.5 quantum-safe signature type. This is the recommended signature type for all new Warp messages. It uses Ringtail (LWE-based) threshold signatures for post-quantum security.
Ringtail properties: - Native threshold support (no need for separate TSS layer) - Two-round signing protocol - Post-quantum secure (based on LWE hardness) - Paper: https://eprint.iacr.org/2024/1113
Replaces: BitSetSignature (BLS), HybridBLSRTSignature Security: Post-quantum secure (LWE-based) Size: Variable based on threshold parameters
func (*RingtailSignature) NumSigners ¶ added in v1.16.56
func (s *RingtailSignature) NumSigners() (int, error)
NumSigners returns the number of validators that participated in signing
func (*RingtailSignature) String ¶ added in v1.16.56
func (s *RingtailSignature) String() string
func (*RingtailSignature) Verify ¶ added in v1.16.56
func (s *RingtailSignature) Verify( msg *UnsignedMessage, networkID uint32, validators CanonicalValidatorSet, quorumNum uint64, quorumDen uint64, ) error
Verify validates the Ringtail (ML-DSA) threshold signature
type Signature ¶
type Signature interface {
fmt.Stringer
// NumSigners is the number of [bls.PublicKeys] that participated in the
// [Signature]. This is exposed because users of these signatures typically
// impose a verification fee that is a function of the number of
// signers.
NumSigners() (int, error)
// Verify that this signature was signed by at least [quorumNum]/[quorumDen]
// of the validators of [msg.SourceChainID] at [pChainHeight].
//
// Invariant: [msg] is correctly initialized.
Verify(
msg *UnsignedMessage,
networkID uint32,
validators CanonicalValidatorSet,
quorumNum uint64,
quorumDen uint64,
) error
}
type SignatureType ¶ added in v1.16.56
type SignatureType uint8
SignatureType indicates which signature algorithm to use
const ( // SigTypeBLS uses classical BLS signatures (Warp 1.0 compatibility) SigTypeBLS SignatureType = iota // SigTypeRingtail uses quantum-safe Ringtail signatures (recommended) SigTypeRingtail // SigTypeHybrid uses BLS+Ringtail hybrid (deprecated) SigTypeHybrid )
func RecommendedSignatureType ¶ added in v1.16.56
func RecommendedSignatureType() SignatureType
RecommendedSignatureType returns the recommended signature type for Warp 1.5 This is Ringtail (quantum-safe) by default
func (SignatureType) IsQuantumSafe ¶ added in v1.16.56
func (s SignatureType) IsQuantumSafe() bool
IsQuantumSafe returns whether the signature type provides post-quantum security
func (SignatureType) String ¶ added in v1.16.56
func (s SignatureType) String() string
String returns the name of the signature type
type Signer ¶
type Signer interface {
// Returns this node's BLS signature over an unsigned message. If the caller
// does not have the authority to sign the message, an error will be
// returned.
//
// Assumes the unsigned message is correctly initialized.
Sign(msg *UnsignedMessage) ([]byte, error)
}
type TeleportAttestPayload ¶ added in v1.16.56
type TeleportAttestPayload struct {
// AttestationType identifies what is being attested
AttestationType uint8 `serialize:"true"`
// Timestamp of the attestation
Timestamp uint64 `serialize:"true"`
// Data is the attestation payload (e.g., price feed, compute result)
Data []byte `serialize:"true"`
// AttesterID identifies who created the attestation
AttesterID ids.NodeID `serialize:"true"`
}
TeleportAttestPayload represents an attestation (oracle data)
type TeleportMessage ¶ added in v1.16.56
type TeleportMessage struct {
// Version is the Teleport protocol version
Version uint8 `serialize:"true"`
// MessageType indicates the type of cross-chain operation
MessageType TeleportType `serialize:"true"`
// SourceChainID identifies the source blockchain
SourceChainID ids.ID `serialize:"true"`
// DestChainID identifies the destination blockchain
DestChainID ids.ID `serialize:"true"`
// Nonce prevents replay attacks
Nonce uint64 `serialize:"true"`
// Payload contains the application-specific message data
// For TeleportPrivate, this should be an EncryptedWarpPayload
Payload []byte `serialize:"true"`
// Encrypted indicates whether the payload is encrypted
Encrypted bool `serialize:"true"`
}
TeleportMessage wraps a Warp message for cross-chain bridging operations. This is the high-level abstraction for Teleport cross-chain messaging.
Warp 1.5 supports three signature types: - BitSetSignature: Classical BLS (legacy) - RingtailSignature: Quantum-safe (recommended) - HybridBLSRTSignature: BLS+RT hybrid (deprecated)
func NewPrivateTeleportMessage ¶ added in v1.16.56
func NewPrivateTeleportMessage( sourceChainID ids.ID, destChainID ids.ID, nonce uint64, payload []byte, recipientPubKey []byte, recipientKeyID []byte, ) (*TeleportMessage, error)
NewPrivateTeleportMessage creates an encrypted Teleport message
func NewTeleportMessage ¶ added in v1.16.56
func NewTeleportMessage( messageType TeleportType, sourceChainID ids.ID, destChainID ids.ID, nonce uint64, payload []byte, ) *TeleportMessage
NewTeleportMessage creates a new Teleport message for cross-chain communication
func (*TeleportMessage) DecryptPayload ¶ added in v1.16.56
func (t *TeleportMessage) DecryptPayload(recipientPrivKey []byte) ([]byte, error)
DecryptPayload decrypts an encrypted TeleportMessage payload
func (*TeleportMessage) String ¶ added in v1.16.56
func (t *TeleportMessage) String() string
String returns a human-readable representation of the TeleportMessage
func (*TeleportMessage) ToWarpMessage ¶ added in v1.16.56
func (t *TeleportMessage) ToWarpMessage(networkID uint32) (*UnsignedMessage, error)
ToWarpMessage converts a TeleportMessage to an UnsignedMessage for signing
func (*TeleportMessage) Validate ¶ added in v1.16.56
func (t *TeleportMessage) Validate() error
Validate checks if the TeleportMessage is well-formed
type TeleportTransferPayload ¶ added in v1.16.56
type TeleportTransferPayload struct {
// AssetID is the asset being transferred
AssetID ids.ID `serialize:"true"`
// Amount is the quantity being transferred
Amount uint64 `serialize:"true"`
// Sender is the source address (chain-specific encoding)
Sender []byte `serialize:"true"`
// Recipient is the destination address (chain-specific encoding)
Recipient []byte `serialize:"true"`
// Fee paid for the bridge operation
Fee uint64 `serialize:"true"`
// Memo is optional metadata
Memo []byte `serialize:"true"`
}
TeleportTransferPayload represents a cross-chain asset transfer
func NewTransferPayload ¶ added in v1.16.56
func NewTransferPayload( assetID ids.ID, amount uint64, sender []byte, recipient []byte, fee uint64, memo []byte, ) *TeleportTransferPayload
NewTransferPayload creates a new transfer payload for cross-chain asset transfers
func ParseTransferPayload ¶ added in v1.16.56
func ParseTransferPayload(data []byte) (*TeleportTransferPayload, error)
ParseTransferPayload deserializes a transfer payload
func (*TeleportTransferPayload) Bytes ¶ added in v1.16.56
func (p *TeleportTransferPayload) Bytes() ([]byte, error)
Bytes serializes the transfer payload
type TeleportType ¶ added in v1.16.56
type TeleportType uint8
TeleportType represents the type of cross-chain operation
const ( // TeleportTransfer is a standard asset transfer between chains TeleportTransfer TeleportType = iota // TeleportSwap is an atomic swap between chains TeleportSwap // TeleportLock locks assets on the source chain TeleportLock // TeleportUnlock unlocks assets on the destination chain TeleportUnlock // TeleportAttest is an attestation message (oracle data, price feeds) TeleportAttest // TeleportGovernance is a cross-chain governance message TeleportGovernance // TeleportPrivate is an encrypted private transfer TeleportPrivate )
type UnsignedMessage ¶
type UnsignedMessage struct {
NetworkID uint32 `serialize:"true"`
SourceChainID ids.ID `serialize:"true"`
Payload []byte `serialize:"true"`
// contains filtered or unexported fields
}
UnsignedMessage defines the standard format for an unsigned Warp message.
func NewUnsignedMessage ¶
func NewUnsignedMessage( networkID uint32, sourceChainID ids.ID, payload []byte, ) (*UnsignedMessage, error)
NewUnsignedMessage creates a new *UnsignedMessage and initializes it.
func ParseUnsignedMessage ¶
func ParseUnsignedMessage(b []byte) (*UnsignedMessage, error)
ParseUnsignedMessage converts a slice of bytes into an initialized *UnsignedMessage.
func (*UnsignedMessage) Bytes ¶
func (m *UnsignedMessage) Bytes() []byte
Bytes returns the binary representation of this message. It assumes that the message is initialized from either New, Parse, or an explicit call to Initialize.
func (*UnsignedMessage) ID ¶
func (m *UnsignedMessage) ID() ids.ID
ID returns an identifier for this message. It assumes that the message is initialized from either New, Parse, or an explicit call to Initialize.
func (*UnsignedMessage) Initialize ¶
func (m *UnsignedMessage) Initialize() error
Initialize recalculates the result of Bytes().
func (*UnsignedMessage) String ¶
func (m *UnsignedMessage) String() string
type Validator ¶
type Validator struct {
PublicKey *bls.PublicKey
PublicKeyBytes []byte
RingtailPubKey []byte // Post-quantum Ringtail public key
Weight uint64
NodeIDs []ids.NodeID
}
func FilterValidators ¶
FilterValidators returns the validators in [vdrs] whose bit is set to 1 in [indices].
Returns an error if [indices] references an unknown validator.