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.PrivateKey) (*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) 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 Message
- type Signature
- 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 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) 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 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.PrivateKey, 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 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 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
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. |