types

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Delim is a key-value separator
	Delim = "="

	// EOL is a line sepator
	EOL = "\n"

	// NumField* is the number of unique keys in an incoming ASCII message
	NumFieldLeaf                    = 4
	NumFieldSignedTreeHead          = 5
	NumFieldConsistencyProof        = 3
	NumFieldInclusionProof          = 3
	NumFieldLeavesRequest           = 2
	NumFieldInclusionProofRequest   = 2
	NumFieldConsistencyProofRequest = 2
	NumFieldLeafRequest             = 5
	NumFieldCosignatureRequest      = 2

	// New leaf keys
	ShardHint            = "shard_hint"
	Checksum             = "checksum"
	SignatureOverMessage = "signature_over_message"
	VerificationKey      = "verification_key"
	DomainHint           = "domain_hint"

	// Inclusion proof keys
	LeafHash      = "leaf_hash"
	LeafIndex     = "leaf_index"
	InclusionPath = "inclusion_path"

	// Consistency proof keys
	NewSize         = "new_size"
	OldSize         = "old_size"
	ConsistencyPath = "consistency_path"

	// Range of leaves keys
	StartSize = "start_size"
	EndSize   = "end_size"

	// Tree head keys
	Timestamp = "timestamp"
	TreeSize  = "tree_size"
	RootHash  = "root_hash"

	// Signature and signer-identity keys
	Signature = "signature"
	KeyHash   = "key_hash"
)
View Source
const (
	// MessageSize is the number of bytes in a Trunnel-encoded leaf message
	MessageSize = 8 + HashSize
	// LeafSize is the number of bytes in a Trunnel-encoded leaf
	LeafSize = MessageSize + SignatureSize + HashSize
)
View Source
const (
	HashSize            = sha256.Size
	SignatureSize       = ed25519.SignatureSize
	VerificationKeySize = ed25519.PublicKeySize

	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")
	EndpointGetProofByHash      = Endpoint("get-proof-by-hash")
	EndpointGetConsistencyProof = Endpoint("get-consistency-proof")
	EndpointGetLeaves           = Endpoint("get-leaves")
)
View Source
const (
	LeafHashPrefix = 0x00
)

Variables

This section is empty.

Functions

func Hash

func Hash(buf []byte) *[HashSize]byte

func HashLeaf

func HashLeaf(buf []byte) *[HashSize]byte

Types

type ConsistencyProof

type ConsistencyProof struct {
	NewSize uint64
	OldSize uint64
	Path    []*[HashSize]byte
}

ConsistencyProof is a consistency proof that proves the log's append-only property.

func (*ConsistencyProof) MarshalASCII

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

func (*ConsistencyProof) UnmarshalASCII

func (p *ConsistencyProof) UnmarshalASCII(r io.Reader) error

func (*ConsistencyProof) Verify

func (p *ConsistencyProof) Verify(oldTH, newTH *TreeHead) error

Verify checks if two tree heads are consistent

type ConsistencyProofRequest

type ConsistencyProofRequest struct {
	NewSize uint64
	OldSize uint64
}

ConsistencyProofRequest is a get-consistency-proof request

func (*ConsistencyProofRequest) UnmarshalASCII

func (req *ConsistencyProofRequest) UnmarshalASCII(r io.Reader) error

type CosignatureRequest

type CosignatureRequest struct {
	SigIdent
}

CosignatureRequest is an add-cosignature request

func (*CosignatureRequest) UnmarshalASCII

func (req *CosignatureRequest) UnmarshalASCII(r io.Reader) error

type Endpoint

type Endpoint string

Endpoint is a named HTTP API endpoint

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", "st/v0") -> example.com/st/v0/add-leaf.

type InclusionProof

type InclusionProof struct {
	TreeSize  uint64
	LeafIndex uint64
	Path      []*[HashSize]byte
}

InclusionProof is an inclusion proof that proves a leaf is included in the log.

func (*InclusionProof) MarshalASCII

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

func (*InclusionProof) UnmarshalASCII

func (p *InclusionProof) UnmarshalASCII(r io.Reader) error

func (*InclusionProof) Verify

func (p *InclusionProof) Verify(leaf *Leaf, th *TreeHead) error

Verify checks if a leaf is included in the log

type InclusionProofRequest

type InclusionProofRequest struct {
	LeafHash *[HashSize]byte
	TreeSize uint64
}

InclusionProofRequest is a get-proof-by-hash request

func (*InclusionProofRequest) UnmarshalASCII

func (req *InclusionProofRequest) UnmarshalASCII(r io.Reader) error

type Leaf

type Leaf struct {
	Message
	SigIdent
}

Leaf is the log's Merkle tree leaf.

func (*Leaf) Marshal

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

Marshal returns a Trunnel-encoded leaf

func (*Leaf) MarshalASCII

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

* * MarshalASCII wrappers for types that the log server outputs *

func (*Leaf) Unmarshal

func (l *Leaf) Unmarshal(buf []byte) error

Unmarshal parses the Trunnel-encoded buffer as a leaf

type LeafList

type LeafList []*Leaf

LeafList is a list of leaves

func (*LeafList) UnmarshalASCII

func (ll *LeafList) UnmarshalASCII(r io.Reader) error

* * Unmarshal ASCII wrappers that the log server and/or log clients receive. *

type LeafRequest

type LeafRequest struct {
	Message
	Signature       *[SignatureSize]byte
	VerificationKey *[VerificationKeySize]byte
	DomainHint      string
}

LeafRequest is an add-leaf request

func (*LeafRequest) UnmarshalASCII

func (req *LeafRequest) UnmarshalASCII(r io.Reader) error

type LeavesRequest

type LeavesRequest struct {
	StartSize uint64
	EndSize   uint64
}

LeavesRequest is a get-leaves request

func (*LeavesRequest) UnmarshalASCII

func (req *LeavesRequest) UnmarshalASCII(r io.Reader) error

type Message

type Message struct {
	ShardHint uint64
	Checksum  *[HashSize]byte
}

Message is composed of a shard hint and a checksum. The submitter selects these values to fit the log's shard interval and the opaque data in question.

func (*Message) Marshal

func (m *Message) Marshal() []byte

Marshal returns a Trunnel-encoded message

type MessageASCII

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

MessageASCI is a wrapper that manages ASCII key-value pairs

func NewMessageASCII

func NewMessageASCII(r io.Reader, numFieldExpected int) (*MessageASCII, error)

NewMessageASCII unpacks an incoming ASCII message

func (*MessageASCII) GetHash

func (msg *MessageASCII) GetHash(key string) (*[HashSize]byte, error)

GetHash unpacks a hash

func (*MessageASCII) GetSignature

func (msg *MessageASCII) GetSignature(key string) (*[SignatureSize]byte, error)

GetSignature unpacks a signature

func (*MessageASCII) GetString

func (msg *MessageASCII) GetString(key string) (string, error)

GetString unpacks a string

func (*MessageASCII) GetStrings

func (msg *MessageASCII) GetStrings(key string) []string

GetStrings returns a list of strings

func (*MessageASCII) GetUint64

func (msg *MessageASCII) GetUint64(key string) (uint64, error)

GetUint64 unpacks an uint64

func (*MessageASCII) GetVerificationKey

func (msg *MessageASCII) GetVerificationKey(key string) (*[VerificationKeySize]byte, error)

GetVerificationKey unpacks a verification key

func (*MessageASCII) NumField

func (msg *MessageASCII) NumField() int

NumField returns the number of unique keys

type SigIdent

type SigIdent struct {
	Signature *[SignatureSize]byte
	KeyHash   *[HashSize]byte
}

SigIdent is composed of a signature-signer pair. The signature is computed over the Trunnel-serialized leaf message. KeyHash identifies the signer.

func (*SigIdent) MarshalASCII

func (si *SigIdent) MarshalASCII(w io.Writer) error

type SignedTreeHead

type SignedTreeHead struct {
	TreeHead
	SigIdent []*SigIdent
}

SignedTreeHead is composed of a tree head and a list of signature-signer pairs. Each signature is computed over the Trunnel-serialized tree head.

func (*SignedTreeHead) MarshalASCII

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

func (*SignedTreeHead) UnmarshalASCII

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

type TreeHead

type TreeHead struct {
	Timestamp uint64
	TreeSize  uint64
	RootHash  *[HashSize]byte
}

TreeHead is the log's tree head.

func (*TreeHead) Marshal

func (th *TreeHead) Marshal() []byte

Marshal returns a Trunnel-encoded tree head

func (*TreeHead) Sign

func (th *TreeHead) Sign(signer crypto.Signer) (*SignedTreeHead, error)

Sign signs the tree head using the log's signature scheme

func (*TreeHead) Verify

func (th *TreeHead) Verify(vk *[VerificationKeySize]byte, sig *[SignatureSize]byte) error

Verify verifies the tree head signature using the log's signature scheme

Jump to

Keyboard shortcuts

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