messages

package
v0.0.0-...-5abc84a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 7, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidMessage = errors.New("invalid message")

Functions

func CheckFROSTMarshaler

func CheckFROSTMarshaler(input, output FROSTMarshaler) error

CheckFROSTMarshaler provides some basic tests to make sure the interface is properly implemented. Should be used for tests of message types.

Types

type FROSTMarshaler

type FROSTMarshaler interface {
	encoding.BinaryMarshaler
	encoding.BinaryUnmarshaler
	// BytesAppend is the same as BinaryMarshall but allows the caller to perform the allocation
	BytesAppend(existing []byte) (data []byte, err error)
	// Size should return the number of bytes used to store the type.
	Size() int

	// Equal is used mostly for testing and returns true if other represents the same value as the receiver.
	Equal(other interface{}) bool
}
type Header struct {
	// Type is the message type
	Type MessageType

	// From returns the party.ID of the party who sent this message.
	// Cannot be 0
	From party.ID

	// To is the party.ID of the party the message is addressed to.
	// If the message is intended for broadcast, the ID returned is 0 (invalid),
	// therefore, you should call IsBroadcast() first.
	To party.ID
}

func (*Header) BytesAppend

func (h *Header) BytesAppend(existing []byte) (data []byte, err error)

func (*Header) Equal

func (h *Header) Equal(other interface{}) bool

func (*Header) IsBroadcast

func (h *Header) IsBroadcast() bool

IsBroadcast returns true if the message is intended to be broadcast

func (*Header) MarshalBinary

func (h *Header) MarshalBinary() (data []byte, err error)

func (*Header) Size

func (h *Header) Size() int

func (*Header) UnmarshalBinary

func (h *Header) UnmarshalBinary(data []byte) error

type KeyGen1

type KeyGen1 struct {
	Proof       *zk.Schnorr
	Commitments *polynomial.Exponent
}

func (*KeyGen1) BytesAppend

func (m *KeyGen1) BytesAppend(existing []byte) ([]byte, error)

func (*KeyGen1) Equal

func (m *KeyGen1) Equal(other interface{}) bool

func (*KeyGen1) MarshalBinary

func (m *KeyGen1) MarshalBinary() (data []byte, err error)

MarshalBinary implements the encoding.BinaryMarshaler interface.

func (*KeyGen1) Size

func (m *KeyGen1) Size() int

func (*KeyGen1) UnmarshalBinary

func (m *KeyGen1) UnmarshalBinary(data []byte) error

UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.

type KeyGen2

type KeyGen2 struct {
	// Share is a Shamir additive share for the destination party
	Share ristretto.Scalar
}

func (*KeyGen2) BytesAppend

func (m *KeyGen2) BytesAppend(existing []byte) ([]byte, error)

func (*KeyGen2) Equal

func (m *KeyGen2) Equal(other interface{}) bool

func (*KeyGen2) MarshalBinary

func (m *KeyGen2) MarshalBinary() ([]byte, error)

MarshalBinary implements the encoding.BinaryMarshaler interface.

func (*KeyGen2) Size

func (m *KeyGen2) Size() int

func (*KeyGen2) UnmarshalBinary

func (m *KeyGen2) UnmarshalBinary(data []byte) error

UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.

type Message

type Message struct {
	Header
	KeyGen1 *KeyGen1
	KeyGen2 *KeyGen2
	Sign1   *Sign1
	Sign2   *Sign2
}

func NewKeyGen1

func NewKeyGen1(from party.ID, proof *zk.Schnorr, commitments *polynomial.Exponent) *Message

func NewKeyGen2

func NewKeyGen2(from, to party.ID, share *ristretto.Scalar) *Message

func NewSign1

func NewSign1(from party.ID, commitmentD, commitmentE *ristretto.Element) *Message

func NewSign2

func NewSign2(from party.ID, signatureShare *ristretto.Scalar) *Message

func (*Message) BytesAppend

func (m *Message) BytesAppend(existing []byte) (data []byte, err error)

func (*Message) Equal

func (m *Message) Equal(other interface{}) bool

func (*Message) MarshalBinary

func (m *Message) MarshalBinary() ([]byte, error)

MarshalBinary implements the encoding.BinaryMarshaler interface.

func (*Message) Size

func (m *Message) Size() int

func (*Message) UnmarshalBinary

func (m *Message) UnmarshalBinary(data []byte) error

UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.

type MessageType

type MessageType uint8
const (
	MessageTypeNone MessageType = iota
	MessageTypeKeyGen1
	MessageTypeKeyGen2
	MessageTypeSign1
	MessageTypeSign2
)

MessageType s must be increasing.

type Sign1

type Sign1 struct {
	// Di = [di] B
	// Ei = [ei] B
	Di, Ei ristretto.Element
}

func (*Sign1) BytesAppend

func (m *Sign1) BytesAppend(existing []byte) ([]byte, error)

func (*Sign1) Equal

func (m *Sign1) Equal(other interface{}) bool

func (*Sign1) MarshalBinary

func (m *Sign1) MarshalBinary() ([]byte, error)

MarshalBinary implements the encoding.BinaryMarshaler interface.

func (*Sign1) Size

func (m *Sign1) Size() int

func (*Sign1) UnmarshalBinary

func (m *Sign1) UnmarshalBinary(data []byte) error

UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.

type Sign2

type Sign2 struct {
	// Zi is a ristretto.Scalar.
	// It represents the sender's share of the 's' part of the final signature
	Zi ristretto.Scalar
}

func (*Sign2) BytesAppend

func (m *Sign2) BytesAppend(existing []byte) ([]byte, error)

func (*Sign2) Equal

func (m *Sign2) Equal(other interface{}) bool

func (*Sign2) MarshalBinary

func (m *Sign2) MarshalBinary() ([]byte, error)

MarshalBinary implements the encoding.BinaryMarshaler interface.

func (*Sign2) Size

func (m *Sign2) Size() int

func (*Sign2) UnmarshalBinary

func (m *Sign2) UnmarshalBinary(data []byte) error

UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL