types

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package types implements the threshold collective signature and its verifier.

It wraps a signature implementation in order to extract the correct aggregated public key.

The messages have been implemented in this isolated package so that it does not create cycle imports when importing the serde formats.

Documentation Last Review: 05.10.2020

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewThresholdVerifierFactory

func NewThresholdVerifierFactory(fac crypto.VerifierFactory) crypto.VerifierFactory

NewThresholdVerifierFactory creates a new verifier factory from the underlying verifier factory.

func RegisterSignatureFormat

func RegisterSignatureFormat(c serde.Format, f serde.FormatEngine)

RegisterSignatureFormat saves the format to be used when serializing/deserializing signature messages for the given codec.

Types

type AggKey

type AggKey struct{}

AggKey is the key for the aggregate signature factory.

type Signature

type Signature struct {
	// contains filtered or unexported fields
}

Signature is a threshold signature which includes an aggregated signature and the mask of signers from the associated collective authority.

- implements crypto.Signature

func NewSignature

func NewSignature(agg crypto.Signature, mask []byte) *Signature

NewSignature returns a new threshold signature.

func (*Signature) Equal

func (s *Signature) Equal(o crypto.Signature) bool

Equal implements crypto.Signature.

func (*Signature) GetAggregate

func (s *Signature) GetAggregate() crypto.Signature

GetAggregate returns the aggregate of the signature which corresponds to the addition of the public keys enabled in the mask.

func (*Signature) GetIndices

func (s *Signature) GetIndices() []int

GetIndices returns the list of indices that have participated in the collective signature.

func (*Signature) GetMask

func (s *Signature) GetMask() []byte

GetMask returns a bit mask of which public key is enabled.

func (*Signature) HasBit

func (s *Signature) HasBit(index int) bool

HasBit returns true when the bit at the given index is set to 1.

func (*Signature) MarshalBinary

func (s *Signature) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler.

func (*Signature) Merge

func (s *Signature) Merge(signer crypto.AggregateSigner, index int, sig crypto.Signature) error

Merge adds the signature.

func (*Signature) Serialize

func (s *Signature) Serialize(ctx serde.Context) ([]byte, error)

Serialize implements serde.Message. It serializes the signature into JSON format.

func (*Signature) String

func (s *Signature) String() string

String implements fmt.Stringer. It returns a string representation of the signature.

type SignatureFactory

type SignatureFactory struct {
	// contains filtered or unexported fields
}

SignatureFactory is the factory to deserialize collective signature.

- implements crypto.SignatureFactory - implements serde.Factory

func NewSignatureFactory

func NewSignatureFactory(f crypto.SignatureFactory) SignatureFactory

NewSignatureFactory returns a new signature factory.

func (SignatureFactory) Deserialize

func (f SignatureFactory) Deserialize(ctx serde.Context, data []byte) (serde.Message, error)

Deserialize implements serde.Factory. It populates the signature from the data if appropriate, otherwise it returns an error.

func (SignatureFactory) SignatureOf

func (f SignatureFactory) SignatureOf(ctx serde.Context, data []byte) (crypto.Signature, error)

SignatureOf implements crypto.SignatureFactory. It populates the signature from the data if appropriate, otherwise it returns an error.

type Verifier

type Verifier struct {
	// contains filtered or unexported fields
}

Verifier is a threshold verifier which can verify threshold signatures by aggregating public keys according to the mask.

- implements crypto.Verifier

func (Verifier) Verify

func (v Verifier) Verify(msg []byte, s crypto.Signature) error

Verify implements crypto.Verifier. It returns nil if the signature matches the aggregate public key for the mask associated to the signature.

Jump to

Keyboard shortcuts

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