compactcert

package
v0.0.0-...-76c1feb Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2021 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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 []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 crypto.OneTimeSignature, 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.Digest   `codec:"c"`
	SignedWeight uint64          `codec:"w"`
	SigProofs    []crypto.Digest `codec:"S,allocbound=maxProofDigests"`
	PartProofs   []crypto.Digest `codec:"P,allocbound=maxProofDigests"`

	// 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 {
	crypto.OneTimeSignature
	// 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    // Ephemeral signature round to expect
	SecKQ        uint64          // Security parameter (k+q) from analysis document
}

Params defines common parameters for the verifier and builder.

type Participant

type Participant struct {

	// PK is AccountData.VoteID.
	PK crypto.OneTimeSignatureVerifier `codec:"p"`

	// Weight is AccountData.MicroAlgos.
	Weight uint64 `codec:"w"`

	// KeyDilution is AccountData.KeyDilution() with the protocol for sigRound
	// as expected by the Builder.
	KeyDilution uint64 `codec:"d"`
	// contains filtered or unexported fields
}

A Participant corresponds to an account whose AccountData.Status is Online, and for which the expected sigRound satisfies AccountData.VoteFirstValid <= sigRound <= AccountData.VoteLastValid.

In the Algorand ledger, it is possible for multiple accounts to have the same PK. Thus, the PK is not necessarily unique among Participants. However, each account will produce a unique Participant struct, to avoid potential DoS attacks where one account claims to have the same VoteID PK as another account.

func (*Participant) CanMarshalMsg

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

func (*Participant) CanUnmarshalMsg

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

func (*Participant) MarshalMsg

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

MarshalMsg implements msgp.Marshaler

func (*Participant) MsgIsZero

func (z *Participant) MsgIsZero() bool

MsgIsZero returns whether this is a zero value

func (*Participant) Msgsize

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

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

func (Participant) ToBeHashed

func (p Participant) ToBeHashed() (protocol.HashID, []byte)

ToBeHashed implements the crypto.Hashable interface.

func (*Participant) UnmarshalMsg

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

UnmarshalMsg implements msgp.Unmarshaler

type Reveal

type Reveal struct {
	SigSlot sigslotCommit `codec:"s"`
	Part    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.Digest) *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