From 26b786d9857db21fdf110eaf9cb6d1d6e4e68ef9 Mon Sep 17 00:00:00 2001 From: Rasmus Dahlberg Date: Mon, 13 Sep 2021 19:53:17 +0200 Subject: updated (co)signed tree head structures - Added key_hash in tree head, see motivation in api.md - Added separate types for (co)signed tree heads - Refactored tree head HTTP APIs to be current, see api.md --- pkg/types/types.go | 37 ++++++++++--------------------------- 1 file changed, 10 insertions(+), 27 deletions(-) (limited to 'pkg/types/types.go') diff --git a/pkg/types/types.go b/pkg/types/types.go index 96e2b18..bc58c98 100644 --- a/pkg/types/types.go +++ b/pkg/types/types.go @@ -32,78 +32,67 @@ func (e Endpoint) Path(components ...string) string { return strings.Join(append(components, string(e)), "/") } -// Leaf is the log's Merkle tree leaf. type Leaf struct { Message SigIdent } -// 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. type Message struct { ShardHint uint64 Checksum *[HashSize]byte } -// SigIdent is composed of a signature-signer pair. The signature is computed -// over the Trunnel-serialized leaf message. KeyHash identifies the signer. type SigIdent struct { Signature *[SignatureSize]byte KeyHash *[HashSize]byte } -// SignedTreeHead is composed of a tree head and a list of signature-signer -// pairs. Each signature is computed over the Trunnel-serialized tree head. type SignedTreeHead struct { TreeHead + Signature *[SignatureSize]byte +} + +type CosignedTreeHead struct { + SignedTreeHead SigIdent []*SigIdent } -// TreeHead is the log's tree head. type TreeHead struct { Timestamp uint64 TreeSize uint64 RootHash *[HashSize]byte + KeyHash *[HashSize]byte } -// ConsistencyProof is a consistency proof that proves the log's append-only -// property. type ConsistencyProof struct { NewSize uint64 OldSize uint64 Path []*[HashSize]byte } -// InclusionProof is an inclusion proof that proves a leaf is included in the -// log. type InclusionProof struct { TreeSize uint64 LeafIndex uint64 Path []*[HashSize]byte } -// LeafList is a list of leaves type LeafList []*Leaf -// ConsistencyProofRequest is a get-consistency-proof request type ConsistencyProofRequest struct { NewSize uint64 OldSize uint64 } -// InclusionProofRequest is a get-proof-by-hash request type InclusionProofRequest struct { LeafHash *[HashSize]byte TreeSize uint64 } -// LeavesRequest is a get-leaves request type LeavesRequest struct { StartSize uint64 EndSize uint64 } -// LeafRequest is an add-leaf request type LeafRequest struct { Message Signature *[SignatureSize]byte @@ -111,7 +100,6 @@ type LeafRequest struct { DomainHint string } -// CosignatureRequest is an add-cosignature request type CosignatureRequest struct { SigIdent } @@ -123,17 +111,12 @@ func (th *TreeHead) Sign(signer crypto.Signer) (*SignedTreeHead, error) { return nil, fmt.Errorf("Sign: %v", err) } - sigident := SigIdent{ - KeyHash: Hash(signer.Public().(ed25519.PublicKey)[:]), + sth := &SignedTreeHead{ + TreeHead: *th, Signature: &[SignatureSize]byte{}, } - copy(sigident.Signature[:], sig) - return &SignedTreeHead{ - TreeHead: *th, - SigIdent: []*SigIdent{ - &sigident, - }, - }, nil + copy(sth.Signature[:], sig) + return sth, nil } // Verify verifies the tree head signature using the log's signature scheme -- cgit v1.2.3