aboutsummaryrefslogtreecommitdiff
path: root/pkg/state/state_manager.go
blob: ce9fc0a9a79d6727f90d9354afe04993b35ba0af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package state

import (
	"context"

	"git.sigsum.org/sigsum-go/pkg/merkle"
	"git.sigsum.org/sigsum-go/pkg/types"
)

// StateManager coordinates access to a log's tree heads and (co)signatures.
type StateManager interface {
	// ToCosignTreeHead returns the log's to-cosign tree head
	ToCosignTreeHead(context.Context) (*types.SignedTreeHead, error)

	// CosignedTreeHead returns the log's cosigned tree head
	CosignedTreeHead(context.Context) (*types.CosignedTreeHead, error)

	// AddCosignature verifies that a cosignature is valid for the to-cosign
	// tree head before adding it
	AddCosignature(context.Context, *types.PublicKey, *types.Signature) error

	// Run peridically rotates the log's to-cosign and cosigned tree heads
	Run(context.Context)
}

// event is a verified cosignature request
type event struct {
	keyHash     *merkle.Hash
	cosignature *types.Signature
}