Documentation
¶
Index ¶
- Constants
- Variables
- func AddUint64(a, b uint64) (uint64, error)
- func AggregateSignatures(signatures []*bls.Signature) (*bls.Signature, error)
- func ChainIDToHash(chainID []byte) common.Hash
- func CheckMulDoesNotOverflow(a, b uint64) error
- func ComputeHash256(data []byte) []byte
- func ParsePublicKey(publicKeyBytes []byte) (*bls.PublicKey, error)
- func SerializePublicKey(publicKey *bls.PublicKey) []byte
- func Sign(msg []byte, sk *bls.SecretKey) (*bls.Signature, error)
- func ValidateValidatorSet(validators []*Validator) error
- func ValidatorSetToMap(validators []*Validator) map[string]*Validator
- func VerifyMessage(msg *Message, networkID uint32, validatorState ValidatorState, ...) error
- func VerifyWeight(signedWeight uint64, totalWeight uint64, quorumNum uint64, quorumDen uint64) error
- type BitSetSignature
- type Bits
- func (b *Bits) Add(i int)
- func (b Bits) BitLen() int
- func (b *Bits) Clear()
- func (b Bits) Contains(i int) bool
- func (b Bits) Difference(other Bits) Bits
- func (b Bits) Equal(other Bits) bool
- func (b Bits) HighestSetBit() int
- func (b Bits) Intersection(other Bits) Bits
- func (b Bits) Len() int
- func (b Bits) String() string
- func (b Bits) Union(other Bits) Bits
- type CanonicalValidatorSet
- type CodecImpl
- type Error
- type FakeSender
- func (FakeSender) SendAppError(context.Context, ids.NodeID, uint32, int32, string) error
- func (FakeSender) SendAppGossip(context.Context, set.Set[ids.NodeID], []byte) error
- func (FakeSender) SendAppRequest(context.Context, set.Set[ids.NodeID], uint32, []byte) error
- func (FakeSender) SendAppResponse(context.Context, ids.NodeID, uint32, []byte) error
- func (FakeSender) SendError(context.Context, ids.NodeID, uint32, int32, string) error
- func (FakeSender) SendGossip(context.Context, SendConfig, []byte) error
- func (FakeSender) SendRequest(context.Context, set.Set[ids.NodeID], uint32, []byte) error
- func (FakeSender) SendResponse(context.Context, ids.NodeID, uint32, []byte) error
- type Handler
- type Message
- type SendConfig
- type Sender
- type Signature
- type Signer
- type UnsignedMessage
- type Validator
- type ValidatorState
Constants ¶
const ( // CodecVersion is the current codec version CodecVersion = 0 // MaxMessageSize is the maximum size of a warp message MaxMessageSize = 256 * KiB )
const ( // KiB is 1024 bytes KiB = 1024 // SignatureLen is the length of a BLS signature SignatureLen = 96 // PublicKeyLen is the length of a BLS public key PublicKeyLen = 48 )
Constants
Variables ¶
var ( // ErrInvalidSignature is returned when a signature is invalid ErrInvalidSignature = errors.New("invalid signature") // ErrInvalidMessage is returned when a message is invalid ErrInvalidMessage = errors.New("invalid message") // ErrUnknownValidator is returned when a validator is not known ErrUnknownValidator = errors.New("unknown validator") // ErrInsufficientWeight is returned when signatures don't meet the threshold ErrInsufficientWeight = errors.New("insufficient weight") )
var ( ErrWrongSourceChainID = errors.New("wrong SourceChainID") ErrWrongNetworkID = errors.New("wrong networkID") )
var Codec = &CodecImpl{}
Codec is the default codec instance
Functions ¶
func AggregateSignatures ¶
AggregateSignatures aggregates multiple signatures into one
func ChainIDToHash ¶
ChainIDToHash converts a chain ID to a common.Hash
func CheckMulDoesNotOverflow ¶
CheckMulDoesNotOverflow checks if a * b would overflow uint64
func ParsePublicKey ¶
ParsePublicKey parses a BLS public key from bytes
func SerializePublicKey ¶
SerializePublicKey serializes a BLS public key to bytes
func ValidateValidatorSet ¶
ValidateValidatorSet performs validation on a validator set
func ValidatorSetToMap ¶
ValidatorSetToMap converts a validator slice to a map keyed by node ID
func VerifyMessage ¶
func VerifyMessage( msg *Message, networkID uint32, validatorState ValidatorState, quorumNum uint64, quorumDen uint64, ) error
VerifyMessage verifies a message against a validator set
Types ¶
type BitSetSignature ¶
type BitSetSignature struct {
Signers Bits `serialize:"true"`
Signature [bls.SignatureLen]byte `serialize:"true"`
}
BitSetSignature is a signature that uses a bit set to indicate which validators signed
func NewBitSetSignature ¶
func NewBitSetSignature(signers Bits, signature [bls.SignatureLen]byte) *BitSetSignature
NewBitSetSignature creates a new bit set signature
func (*BitSetSignature) Bytes ¶ added in v0.1.2
func (s *BitSetSignature) Bytes() []byte
Bytes returns the bytes representation of the signature
func (*BitSetSignature) Equal ¶
func (s *BitSetSignature) Equal(other Signature) bool
Equal returns true if two signatures are equal
func (*BitSetSignature) GetSignedWeight ¶
func (s *BitSetSignature) GetSignedWeight(validators []*Validator) (uint64, error)
GetSignedWeight returns the total weight of validators that signed
type Bits ¶
type Bits []byte
Bits represents a bit set
func (Bits) Difference ¶
Difference returns the difference of two bit sets (elements in b but not in other)
func (Bits) HighestSetBit ¶ added in v1.4.2
HighestSetBit returns the highest bit index that is set + 1 Returns 0 if no bits are set
func (Bits) Intersection ¶
Intersection returns the intersection of two bit sets
type CanonicalValidatorSet ¶
type CanonicalValidatorSet struct {
// contains filtered or unexported fields
}
CanonicalValidatorSet represents the canonical ordering of validators
func NewCanonicalValidatorSet ¶
func NewCanonicalValidatorSet(validators []*Validator) (*CanonicalValidatorSet, error)
NewCanonicalValidatorSet creates a new canonical validator set
func (*CanonicalValidatorSet) GetValidator ¶
func (c *CanonicalValidatorSet) GetValidator(index int) (*Validator, error)
GetValidator returns the validator at the given index
func (*CanonicalValidatorSet) Len ¶
func (c *CanonicalValidatorSet) Len() int
Len returns the number of validators
func (*CanonicalValidatorSet) TotalWeight ¶
func (c *CanonicalValidatorSet) TotalWeight() uint64
TotalWeight returns the total weight of all validators
func (*CanonicalValidatorSet) Validators ¶
func (c *CanonicalValidatorSet) Validators() []*Validator
Validators returns the validators in canonical order
type CodecImpl ¶
type CodecImpl struct{}
CodecImpl is used for serializing/deserializing warp messages
func (*CodecImpl) RegisterType ¶
RegisterType is a no-op for RLP codec
type FakeSender ¶ added in v1.4.2
type FakeSender struct{}
FakeSender is a test implementation of Sender that does nothing.
func (FakeSender) SendAppError ¶ added in v1.4.2
func (FakeSender) SendAppGossip ¶ added in v1.4.2
func (FakeSender) SendAppRequest ¶ added in v1.4.2
Backward compatibility methods
func (FakeSender) SendAppResponse ¶ added in v1.4.2
func (FakeSender) SendGossip ¶ added in v1.4.2
func (FakeSender) SendGossip(context.Context, SendConfig, []byte) error
func (FakeSender) SendRequest ¶ added in v1.4.2
func (FakeSender) SendResponse ¶ added in v1.4.2
type Handler ¶ added in v1.4.2
type Handler interface {
Request(ctx context.Context, nodeID ids.NodeID, requestID uint32, deadline time.Time, msg []byte) error
Response(ctx context.Context, nodeID ids.NodeID, requestID uint32, msg []byte) error
Gossip(ctx context.Context, nodeID ids.NodeID, msg []byte) error
RequestFailed(ctx context.Context, nodeID ids.NodeID, requestID uint32, err *Error) error
// App* methods are aliases for backward compatibility
AppRequest(ctx context.Context, nodeID ids.NodeID, requestID uint32, deadline time.Time, msg []byte) error
AppResponse(ctx context.Context, nodeID ids.NodeID, requestID uint32, msg []byte) error
AppGossip(ctx context.Context, nodeID ids.NodeID, msg []byte) error
AppRequestFailed(ctx context.Context, nodeID ids.NodeID, requestID uint32, err *Error) error
}
Handler handles warp messages
type Message ¶
type Message struct {
UnsignedMessage *UnsignedMessage `serialize:"true"`
Signature Signature `serialize:"true"`
}
Message is a signed warp message
func NewMessage ¶
func NewMessage( unsigned *UnsignedMessage, signature Signature, ) (*Message, error)
NewMessage creates a new signed message
func ParseMessage ¶
ParseMessage parses a message from bytes
func SignMessage ¶
func SignMessage( msg *UnsignedMessage, signers []*bls.SecretKey, validators []*Validator, ) (*Message, error)
SignMessage signs a warp message with a set of signers
func (*Message) SourceChainID ¶
SourceChainID returns the source chain ID as a common.Hash
type SendConfig ¶ added in v1.4.2
SendConfig configures message sending.
type Sender ¶ added in v1.4.2
type Sender interface {
// SendRequest sends a warp request to the given nodes.
SendRequest(ctx context.Context, nodeIDs set.Set[ids.NodeID], requestID uint32, requestBytes []byte) error
// SendResponse sends a warp response to a request.
SendResponse(ctx context.Context, nodeID ids.NodeID, requestID uint32, responseBytes []byte) error
// SendError sends a warp error response
SendError(ctx context.Context, nodeID ids.NodeID, requestID uint32, errorCode int32, errorMessage string) error
// SendGossip sends a warp gossip message.
SendGossip(ctx context.Context, config SendConfig, gossipBytes []byte) error
// SendAppRequest is an alias for SendRequest (for backward compatibility)
SendAppRequest(ctx context.Context, nodeIDs set.Set[ids.NodeID], requestID uint32, requestBytes []byte) error
// SendAppResponse is an alias for SendResponse (for backward compatibility)
SendAppResponse(ctx context.Context, nodeID ids.NodeID, requestID uint32, responseBytes []byte) error
// SendAppError is an alias for SendError (for backward compatibility)
SendAppError(ctx context.Context, nodeID ids.NodeID, requestID uint32, errorCode int32, errorMessage string) error
// SendAppGossip is an alias for SendGossip but takes nodeIDs directly
SendAppGossip(ctx context.Context, nodeIDs set.Set[ids.NodeID], gossipBytes []byte) error
}
Sender sends warp messages
type Signature ¶
type Signature interface {
// Verify verifies the signature against the message and validator set
Verify(msg []byte, validators []*Validator) error
// GetSignedWeight returns the total weight of validators that signed
GetSignedWeight(validators []*Validator) (uint64, error)
// Equal returns true if two signatures are equal
Equal(other Signature) bool
// Bytes returns the bytes representation of the signature
Bytes() []byte
}
Signature is an interface for warp message signatures
type Signer ¶ added in v1.4.2
type Signer interface {
// Sign signs an unsigned warp message and returns the signature bytes
Sign(msg *UnsignedMessage) ([]byte, error)
}
Signer signs warp messages
type UnsignedMessage ¶
type UnsignedMessage struct {
NetworkID uint32 `serialize:"true"`
SourceChainID []byte `serialize:"true"`
Payload []byte `serialize:"true"`
}
UnsignedMessage is an unsigned warp message
func NewUnsignedMessage ¶
func NewUnsignedMessage( networkID uint32, sourceChainID []byte, payload []byte, ) (*UnsignedMessage, error)
NewUnsignedMessage creates a new unsigned message
func ParseUnsignedMessage ¶
func ParseUnsignedMessage(b []byte) (*UnsignedMessage, error)
ParseUnsignedMessage parses an unsigned message from bytes
func (*UnsignedMessage) Bytes ¶
func (u *UnsignedMessage) Bytes() []byte
Bytes returns the byte representation of the unsigned message
func (*UnsignedMessage) ID ¶
func (u *UnsignedMessage) ID() []byte
ID returns the hash of the unsigned message
func (*UnsignedMessage) Verify ¶
func (u *UnsignedMessage) Verify() error
Verify verifies the unsigned message
type Validator ¶
type Validator struct {
PublicKey *bls.PublicKey
PublicKeyBytes []byte
Weight uint64
NodeID []byte
}
Validator represents a validator in the network
func GetCanonicalValidatorSet ¶
func GetCanonicalValidatorSet( validatorState ValidatorState, chainID []byte, ) ([]*Validator, uint64, error)
GetCanonicalValidatorSet retrieves and canonicalizes the validator set
type ValidatorState ¶
type ValidatorState interface {
// GetValidatorSet returns the validator set for a given chain ID at a given height
GetValidatorSet(chainID []byte, height uint64) (map[string]*Validator, error)
// GetCurrentHeight returns the current height
GetCurrentHeight() (uint64, error)
}
ValidatorState is an interface for retrieving validator sets
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
plugin
Package warp provides cross-chain messaging functionality for the Lux CLI
|
Package warp provides cross-chain messaging functionality for the Lux CLI |
|
warpcli
command
|
|
|
crypto
|
|
|
fhe
Package fhe provides Fully Homomorphic Encryption interfaces for private messaging.
|
Package fhe provides Fully Homomorphic Encryption interfaces for private messaging. |
|
ringtail
Package ringtail implements random ringtail validation for post-quantum safety.
|
Package ringtail implements random ringtail validation for post-quantum safety. |
|
signature
Package signature provides modular signature verification for Warp messages.
|
Package signature provides modular signature verification for Warp messages. |
|
messages
|
|
|
relayer
|
|
|
signature-aggregator
|
|
|
Package types defines the core interfaces for the Warp message format.
|
Package types defines the core interfaces for the Warp message format. |