types

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2022 License: BSD-2-Clause Imports: 9 Imported by: 12

Documentation

Index

Constants

View Source
const (
	HashSize      = sha256.Size
	SignatureSize = ed25519.SignatureSize
	PublicKeySize = ed25519.PublicKeySize

	LeafNodePrefix     = byte(0x00)
	InteriorNodePrefix = byte(0x01)
)
View Source
const (
	EndpointAddLeaf             = Endpoint("add-leaf")
	EndpointAddCosignature      = Endpoint("add-cosignature")
	EndpointGetTreeHeadLatest   = Endpoint("get-tree-head-latest")
	EndpointGetTreeHeadToSign   = Endpoint("get-tree-head-to-sign")
	EndpointGetTreeHeadCosigned = Endpoint("get-tree-head-cosigned")
	EndpointGetInclusionProof   = Endpoint("get-inclusion-proof")
	EndpointGetConsistencyProof = Endpoint("get-consistency-proof")
	EndpointGetLeaves           = Endpoint("get-leaves")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ConsistencyProof

type ConsistencyProof struct {
	NewSize uint64
	OldSize uint64
	Path    []Hash `ascii:"consistency_path"`
}

func (*ConsistencyProof) FromASCII

func (p *ConsistencyProof) FromASCII(r io.Reader, oldSize, newSize uint64) error

func (*ConsistencyProof) ToASCII

func (p *ConsistencyProof) ToASCII(w io.Writer) error

func (*ConsistencyProof) Verify

func (p *ConsistencyProof) Verify(newRoot, oldRoot *Hash) bool

type CosignedTreeHead

type CosignedTreeHead struct {
	SignedTreeHead
	Cosignature []Signature `ascii:"cosignature"`
	KeyHash     []Hash      `ascii:"key_hash"`
}

func (*CosignedTreeHead) FromASCII

func (cth *CosignedTreeHead) FromASCII(r io.Reader) error

func (*CosignedTreeHead) ToASCII

func (cth *CosignedTreeHead) ToASCII(w io.Writer) error

type Endpoint

type Endpoint string

func (Endpoint) Path

func (e Endpoint) Path(components ...string) string

Path joins a number of components to form a full endpoint path. For example, EndpointAddLeaf.Path("example.com", "sigsum/v0") -> example.com/sigsum/v0/add-leaf.

type Hash

type Hash [HashSize]byte

func HashFn

func HashFn(buf []byte) *Hash

func LeafHash

func LeafHash(buf []byte) *Hash

type InclusionProof

type InclusionProof struct {
	TreeSize  uint64
	LeafIndex uint64 `ascii:"leaf_index"`
	Path      []Hash `ascii:"inclusion_path"`
}

func (*InclusionProof) FromASCII

func (p *InclusionProof) FromASCII(r io.Reader, treeSize uint64) error

func (*InclusionProof) ToASCII

func (p *InclusionProof) ToASCII(w io.Writer) error

func (*InclusionProof) Verify

func (p *InclusionProof) Verify(treeSize uint64) bool

type Leaf

type Leaf struct {
	Statement
	Signature Signature `ascii:"signature"`
	KeyHash   Hash      `ascii:"key_hash"`
}

func (*Leaf) FromASCII

func (l *Leaf) FromASCII(r io.Reader) error

func (*Leaf) FromBinary

func (l *Leaf) FromBinary(b []byte) error

func (*Leaf) ToASCII

func (l *Leaf) ToASCII(w io.Writer) error

func (*Leaf) ToBinary

func (l *Leaf) ToBinary() []byte

type Leaves

type Leaves []Leaf

func (*Leaves) FromASCII

func (l *Leaves) FromASCII(r io.Reader) error

type PublicKey

type PublicKey [PublicKeySize]byte

type Signature

type Signature [SignatureSize]byte

type SignedTreeHead

type SignedTreeHead struct {
	TreeHead
	Signature Signature `ascii:"signature"`
}

func (*SignedTreeHead) FromASCII

func (sth *SignedTreeHead) FromASCII(r io.Reader) error

func (*SignedTreeHead) ToASCII

func (sth *SignedTreeHead) ToASCII(w io.Writer) error

func (*SignedTreeHead) Verify

func (sth *SignedTreeHead) Verify(key *PublicKey, kh *Hash) bool

type Statement

type Statement struct {
	ShardHint uint64 `ascii:"shard_hint"`
	Checksum  Hash   `ascii:"checksum"`
}

func (*Statement) Sign

func (s *Statement) Sign(signer crypto.Signer) (*Signature, error)

func (*Statement) ToBinary

func (s *Statement) ToBinary() []byte

func (*Statement) Verify

func (s *Statement) Verify(key *PublicKey, sig *Signature) bool

type TreeHead

type TreeHead struct {
	Timestamp uint64 `ascii:"timestamp"`
	TreeSize  uint64 `ascii:"tree_size"`
	RootHash  Hash   `ascii:"root_hash"`
}

func (*TreeHead) Sign

func (th *TreeHead) Sign(s crypto.Signer, kh *Hash) (*SignedTreeHead, error)

func (*TreeHead) ToBinary

func (th *TreeHead) ToBinary(keyHash *Hash) []byte

Jump to

Keyboard shortcuts

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