warp
Package warp
import "github.com/luxfi/node/vms/platformvm/warp"Functions
AggregateCoronaPublicKeys
func AggregateCoronaPublicKeys(publicKeys [][]byte) ([]byte, error)AggregateCoronaPublicKeys aggregates multiple Corona public keys into a single combined public key for threshold verification. This uses the threshold package's SchemeCorona.
AggregatePublicKeys
func AggregatePublicKeys(vdrs []*Validator) (*bls.PublicKey, error)AggregatePublicKeys returns the public key of the provided validators.
Invariant: All of the public keys in [vdrs] are valid.
BatchVerifyAggregateSignatures
func BatchVerifyAggregateSignatures(aggPubKeys []*bls.PublicKey, aggSigs []*bls.Signature, messages [][]byte) ([]bool, error)BatchVerifyAggregateSignatures verifies multiple aggregate signatures in parallel. Each signature is an aggregated BLS signature over the same message by different key sets.
BatchVerifyBLSSignatures
func BatchVerifyBLSSignatures(publicKeys []*bls.PublicKey, messages [][]byte, signatures []*bls.Signature) ([]bool, error)BatchVerifyBLSSignatures verifies multiple BLS signatures using GPU acceleration when available. Falls back to sequential CPU verification if GPU is unavailable.
Parameters:
- publicKeys: Slice of BLS public keys (48 bytes each, compressed G1 points)
- messages: Slice of messages to verify
- signatures: Slice of BLS signatures (96 bytes each, G2 points)
Returns:
- results: Slice of booleans indicating validity of each signature
- error: Error if batch verification setup fails
SumWeight
func SumWeight(vdrs []*Validator) (uint64, error)SumWeight returns the total weight of the provided validators.
VerifyBLSAggregateWithGPU
func VerifyBLSAggregateWithGPU(aggPubKey *bls.PublicKey, aggSig *bls.Signature, message []byte) boolVerifyBLSAggregateWithGPU verifies an aggregate BLS signature with GPU acceleration. This is used by BitSetSignature.Verify() for high-throughput scenarios.
VerifyCoronaSignature
func VerifyCoronaSignature(publicKey []byte, message []byte, signature []byte) boolVerifyCoronaSignature verifies a Corona lattice-based signature. This uses the threshold package's SchemeCorona verifier.
VerifyWeight
func VerifyWeight(
sigWeight uint64,
totalWeight uint64,
quorumNum uint64,
quorumDen uint64,
) errorVerifyWeight returns [nil] if [sigWeight] is at least [quorumNum]/[quorumDen] of [totalWeight]. If [sigWeight >= totalWeight * quorumNum / quorumDen] then return [nil]
Types
BitSetSignature
func (s *BitSetSignature) NumSigners() (int, error)func (s *BitSetSignature) String() stringfunc (s *BitSetSignature) Verify(
msg *UnsignedMessage,
networkID uint32,
validators CanonicalValidatorSet,
quorumNum uint64,
quorumDen uint64,
) errorCachedValidatorState
CachedValidatorState wraps ValidatorState with an LRU cache
func NewCachedValidatorState(
state ValidatorState,
upgradeConfig *upgrade.Config,
networkID uint32,
registerer metric.Registerer,
) (*CachedValidatorState, error)func (c *CachedValidatorState) GetValidatorSet(
ctx context.Context,
height uint64,
chainID ids.ID,
) (map[ids.NodeID]*ValidatorData, error)CanonicalValidatorSet
func FlattenValidatorSet(vdrSet map[ids.NodeID]*ValidatorData) (CanonicalValidatorSet, error)func GetCanonicalValidatorSetFromChainID(ctx context.Context,
pChainState validators.State,
pChainHeight uint64,
sourceChainID ids.ID,
) (CanonicalValidatorSet, error)func GetCanonicalValidatorSetFromSubchainID(
ctx context.Context,
pChainState ValidatorState,
pChainHeight uint64,
subchainID ids.ID,
) (CanonicalValidatorSet, error)CoronaSignature
CoronaSignature is the Warp 1.5 quantum-safe signature type. This is the recommended signature type for all new Warp messages. It uses Corona (LWE-based) threshold signatures for post-quantum security.
Corona 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), HybridBLSCoronaSignature Security: Post-quantum secure (LWE-based) Size: Variable based on threshold parameters
func (s *CoronaSignature) NumSigners() (int, error)func (s *CoronaSignature) String() stringfunc (s *CoronaSignature) Verify(
msg *UnsignedMessage,
networkID uint32,
validators CanonicalValidatorSet,
quorumNum uint64,
quorumDen uint64,
) errorEncryptedWarpPayload
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(plaintext []byte, recipientPubKey []byte, recipientKeyID []byte) (*EncryptedWarpPayload, error)func (e *EncryptedWarpPayload) Decrypt(recipientPrivKey []byte) ([]byte, error)func (e *EncryptedWarpPayload) Size() intfunc (e *EncryptedWarpPayload) String() stringHybridBLSCoronaSignature
HybridBLSCoronaSignature implements a quantum-safe hybrid signature combining:
- BLS aggregate signatures (classical security, compact)
- Corona 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:
- Pre-quantum: BLS-only (BitSetSignature)
- Transition: HybridBLSCoronaSignature (both required)
- Post-quantum: Corona-only (future)
Wire format: this type is the 4th type registered in the warp codec (codec.go), which assigns it codec typeID 0x03. The typeID, field order, and field encodings are part of the on-chain wire format and MUST NOT change. The Go-side type name is metadata only and was renamed from HybridBLSRTSignature in the threshold sweep; wire bytes are byte-equal pre/post rename.
func (s *HybridBLSCoronaSignature) NumSigners() (int, error)func (s *HybridBLSCoronaSignature) String() stringfunc (s *HybridBLSCoronaSignature) Verify(
msg *UnsignedMessage,
networkID uint32,
validators CanonicalValidatorSet,
quorumNum uint64,
quorumDen uint64,
) errorMessage
Message defines the standard format for a Warp message.
Wire (native ZAP): one object holding the self-delimiting unsigned-message buffer and the wkind-tagged signature buffer as two opaque byte fields — unsigned bytes @0, signature bytes @8 = 16-byte object header. Message is the container shape, so it needs no kind of its own; the signature it carries is dispatched by ITS wkind at offset 0.
func NewMessage(
unsignedMsg *UnsignedMessage,
signature Signature,
) (*Message, error)func ParseMessage(b []byte) (*Message, error)func (m *Message) Bytes() []bytefunc (m *Message) Initialize() errorfunc (m *Message) String() stringSignature
SignatureType
SignatureType indicates which signature algorithm to use
func RecommendedSignatureType() SignatureTypefunc (s SignatureType) IsQuantumSafe() boolfunc (s SignatureType) String() stringSigner
func NewSigner(sk bls.Signer, networkID uint32, chainID ids.ID) SignerTeleportAttestPayload
TeleportAttestPayload represents an attestation (oracle data)
func ParseAttestPayload(data []byte) (*TeleportAttestPayload, error)func (p *TeleportAttestPayload) Bytes() ([]byte, error)TeleportMessage
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)
- CoronaSignature: Quantum-safe (recommended)
- HybridBLSCoronaSignature: BLS+Corona hybrid (deprecated)
func NewPrivateTeleportMessage(
sourceChainID ids.ID,
destChainID ids.ID,
nonce uint64,
payload []byte,
recipientPubKey []byte,
recipientKeyID []byte,
) (*TeleportMessage, error)func NewTeleportMessage(
messageType TeleportType,
sourceChainID ids.ID,
destChainID ids.ID,
nonce uint64,
payload []byte,
) *TeleportMessagefunc ParseTeleportMessage(data []byte) (*TeleportMessage, error)func (t *TeleportMessage) DecryptPayload(recipientPrivKey []byte) ([]byte, error)func (t *TeleportMessage) String() stringfunc (t *TeleportMessage) ToWarpMessage(networkID uint32) (*UnsignedMessage, error)func (t *TeleportMessage) Validate() errorTeleportTransferPayload
TeleportTransferPayload represents a cross-chain asset transfer
func NewTransferPayload(
assetID ids.ID,
amount uint64,
sender []byte,
recipient []byte,
fee uint64,
memo []byte,
) *TeleportTransferPayloadfunc ParseTransferPayload(data []byte) (*TeleportTransferPayload, error)func (p *TeleportTransferPayload) Bytes() ([]byte, error)TeleportType
TeleportType represents the type of cross-chain operation
UnsignedMessage
UnsignedMessage defines the standard format for an unsigned Warp message.
Wire (native ZAP, no kind byte — always parsed in context): NetworkID u32 @0, SourceChainID 32B @4, Payload bytes @36 = 44-byte object header.
func NewUnsignedMessage(
networkID uint32,
sourceChainID ids.ID,
payload []byte,
) (*UnsignedMessage, error)func ParseUnsignedMessage(b []byte) (*UnsignedMessage, error)func (m *UnsignedMessage) Bytes() []bytefunc (m *UnsignedMessage) ID() ids.IDfunc (m *UnsignedMessage) Initialize() errorfunc (m *UnsignedMessage) String() stringValidator
func FilterValidators(
indices set.Bits,
vdrs []*Validator,
) ([]*Validator, error)func (v *Validator) Compare(o *Validator) intValidatorData
ValidatorData contains the data for a single validator
ValidatorState
ValidatorState defines the functions that must be implemented to get the canonical validator set for warp message validation.