types

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 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          = 4
	NumFieldConsistencyProof        = 3
	NumFieldInclusionProof          = 3
	NumFieldLeavesRequest           = 2
	NumFieldInclusionProofRequest   = 2
	NumFieldConsistencyProofRequest = 2
	NumFieldLeafRequest             = 5
	NumFieldCosignatureRequest      = 2

	// New leaf keys
	ShardHint       = "shard_hint"
	Checksum        = "checksum"
	Signature       = "signature"
	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"

	// Witness signature-identity keys
	KeyHash     = "key_hash"
	Cosignature = "cosignature"
)
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
	// TreeHeadSize is the number of bytes in a Trunnel-encoded tree head
	TreeHeadSize = 8 + 8 + HashSize + 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")
	EndpointGetInclusionProof   = Endpoint("get-inclusion-proof")
	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
}

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
}

func (*ConsistencyProofRequest) UnmarshalASCII

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

type CosignatureRequest

type CosignatureRequest struct {
	SigIdent
}

func (*CosignatureRequest) UnmarshalASCII

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

type CosignedTreeHead

type CosignedTreeHead struct {
	SignedTreeHead
	SigIdent []*SigIdent
}

func (*CosignedTreeHead) MarshalASCII

func (cth *CosignedTreeHead) MarshalASCII(w io.Writer) 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
}

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
}

func (*InclusionProofRequest) UnmarshalASCII

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

type Leaf

type Leaf struct {
	Message
	SigIdent
}

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

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
}

func (*LeafRequest) UnmarshalASCII

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

type LeavesRequest

type LeavesRequest struct {
	StartSize uint64
	EndSize   uint64
}

func (*LeavesRequest) UnmarshalASCII

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

type Message

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

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
}

func (*SigIdent) MarshalASCII

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

type SignedTreeHead

type SignedTreeHead struct {
	TreeHead
	Signature *[SignatureSize]byte
}

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
	KeyHash   *[HashSize]byte
}

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