compactcert

package
v0.0.0-...-15eb78e Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2022 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HashType = crypto.Sumhash
	HashSize = crypto.SumhashDigestSize
)

HashType/ hashSize relate to the type of hash this package uses.

View Source
const (
	// MaxReveals is a bound on allocation and on numReveals to limit log computation
	MaxReveals = 1024
)

Variables

View Source
var ErrIndexOutOfBound = errors.New("index is out of bound")

ErrIndexOutOfBound returned when an index is out of the array's bound

Functions

This section is empty.

Types

type Builder

type Builder struct {
	Params
	// contains filtered or unexported fields
}

Builder keeps track of signatures on a message and eventually produces a compact certificate for that message.

func MkBuilder

func MkBuilder(param Params, part []basics.Participant, parttree *merklearray.Tree) (*Builder, error)

MkBuilder constructs an empty builder (with no signatures). The message to be signed, as well as other security parameters, are specified in param. The participants that will sign the message are in part and parttree.

func (*Builder) Add

func (b *Builder) Add(pos uint64, sig merklesignature.Signature, verifySig bool) error

Add a signature to the set of signatures available for building a certificate. verifySig should be set to true in production; setting it to false is useful for benchmarking to avoid the cost of signature checks.

func (*Builder) Build

func (b *Builder) Build() (*Cert, error)

Build returns a compact certificate, if the builder has accumulated enough signatures to construct it.

func (*Builder) Present

func (b *Builder) Present(pos uint64) bool

Present checks if the builder already contains a signature at a particular offset.

func (*Builder) Ready

func (b *Builder) Ready() bool

Ready returns whether the certificate is ready to be built.

func (*Builder) SignedWeight

func (b *Builder) SignedWeight() uint64

SignedWeight returns the total weight of signatures added so far.

type Cert

type Cert struct {
	SigCommit    crypto.GenericDigest `codec:"c"`
	SignedWeight uint64               `codec:"w"`
	SigProofs    merklearray.Proof    `codec:"S"`
	PartProofs   merklearray.Proof    `codec:"P"`

	// Reveals is a sparse map from the position being revealed
	// to the corresponding elements from the sigs and participants
	// arrays.
	Reveals map[uint64]Reveal `codec:"r,allocbound=MaxReveals"`
	// contains filtered or unexported fields
}

Cert represents a compact certificate.

func (*Cert) CanMarshalMsg

func (_ *Cert) CanMarshalMsg(z interface{}) bool

func (*Cert) CanUnmarshalMsg

func (_ *Cert) CanUnmarshalMsg(z interface{}) bool

func (*Cert) MarshalMsg

func (z *Cert) MarshalMsg(b []byte) (o []byte)

MarshalMsg implements msgp.Marshaler

func (*Cert) MsgIsZero

func (z *Cert) MsgIsZero() bool

MsgIsZero returns whether this is a zero value

func (*Cert) Msgsize

func (z *Cert) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Cert) UnmarshalMsg

func (z *Cert) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type CompactOneTimeSignature

type CompactOneTimeSignature struct {
	merklesignature.Signature
	// contains filtered or unexported fields
}

CompactOneTimeSignature is crypto.OneTimeSignature with omitempty

func (*CompactOneTimeSignature) CanMarshalMsg

func (_ *CompactOneTimeSignature) CanMarshalMsg(z interface{}) bool

func (*CompactOneTimeSignature) CanUnmarshalMsg

func (_ *CompactOneTimeSignature) CanUnmarshalMsg(z interface{}) bool

func (*CompactOneTimeSignature) MarshalMsg

func (z *CompactOneTimeSignature) MarshalMsg(b []byte) (o []byte)

MarshalMsg implements msgp.Marshaler

func (*CompactOneTimeSignature) MsgIsZero

func (z *CompactOneTimeSignature) MsgIsZero() bool

MsgIsZero returns whether this is a zero value

func (*CompactOneTimeSignature) Msgsize

func (z *CompactOneTimeSignature) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*CompactOneTimeSignature) UnmarshalMsg

func (z *CompactOneTimeSignature) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type Params

type Params struct {
	Msg          crypto.Hashable // Message to be cerified
	ProvenWeight uint64          // Weight threshold proven by the certificate
	SigRound     basics.Round    // The round for which the ephemeral key is committed to
	SecKQ        uint64          // Security parameter (k+q) from analysis document

	EnableBatchVerification bool // whether ED25519 batch verification is enabled
}

Params defines common parameters for the verifier and builder.

type Reveal

type Reveal struct {
	SigSlot sigslotCommit      `codec:"s"`
	Part    basics.Participant `codec:"p"`
	// contains filtered or unexported fields
}

Reveal is a single array position revealed as part of a compact certificate. It reveals an element of the signature array and the corresponding element of the participants array.

func (*Reveal) CanMarshalMsg

func (_ *Reveal) CanMarshalMsg(z interface{}) bool

func (*Reveal) CanUnmarshalMsg

func (_ *Reveal) CanUnmarshalMsg(z interface{}) bool

func (*Reveal) MarshalMsg

func (z *Reveal) MarshalMsg(b []byte) (o []byte)

MarshalMsg implements msgp.Marshaler

func (*Reveal) MsgIsZero

func (z *Reveal) MsgIsZero() bool

MsgIsZero returns whether this is a zero value

func (*Reveal) Msgsize

func (z *Reveal) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Reveal) UnmarshalMsg

func (z *Reveal) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type SortUint64

type SortUint64 = basics.SortUint64

SortUint64 implements sorting by uint64 keys for canonical encoding of maps in msgpack format.

type Verifier

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

Verifier is used to verify a compact certificate.

func MkVerifier

func MkVerifier(p Params, partcom crypto.GenericDigest) *Verifier

MkVerifier constructs a verifier to check the compact certificate on the message specified in p, with partcom specifying the Merkle root of the participants that must sign the message.

func (*Verifier) Verify

func (v *Verifier) Verify(c *Cert) error

Verify checks if c is a valid compact certificate for the message and participants that were used to construct the Verifier.

Jump to

Keyboard shortcuts

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