Documentation
¶
Overview ¶
Package testlog is an in-memory transparency log and a fake of the Compliance API surface axt-verify reads, for hermetic tests. Tree hashes and proofs come from golang.org/x/mod/sumdb/tlog — an implementation independent of the transparency-dev/merkle code the verifier checks them with.
Index ¶
- Constants
- type Log
- func (l *Log) Append(entries ...[]byte) uint64
- func (l *Log) Checkpoint(size uint64) []byte
- func (l *Log) CheckpointFor(origin string, size uint64, root []byte) []byte
- func (l *Log) ConsistencyProof(from, to uint64) [][]byte
- func (l *Log) Entry(i uint64) []byte
- func (l *Log) InclusionProof(index, size uint64) [][]byte
- func (l *Log) RootAt(size uint64) []byte
- func (l *Log) SignedNote(text string) []byte
- func (l *Log) Size() uint64
- type LogKey
- type Server
Constants ¶
const APIKey = "sk-ant-test-compliance-key"
APIKey is the key the fake accepts.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Log ¶
Log is an append-only in-memory Merkle log.
func (*Log) Checkpoint ¶
Checkpoint returns the checkpoint for the first size leaves, signed by the log key.
func (*Log) CheckpointFor ¶
CheckpointFor signs an arbitrary (origin, size, root) — for forging.
func (*Log) ConsistencyProof ¶
func (*Log) InclusionProof ¶
func (*Log) SignedNote ¶
SignedNote signs arbitrary note text with the log key.
type LogKey ¶
type LogKey struct {
VKey string
// contains filtered or unexported fields
}
LogKey is an ECDSA P-256 note signer shaped like the production log key: key name = origin, key hash = SHA-256(SPKI DER)[:4], verifier string "<origin>+<hash>+base64(0x02 || SPKI DER)".
type Server ¶
type Server struct {
Log *Log
OrgUUID string
HTTP *httptest.Server
// Published is the tree size the served checkpoint commits to; proofs
// are computed against it. Publish() advances it to the log's size.
Published uint64
// Fault hooks. Zero values serve honestly.
CheckpointOverride []byte // served verbatim by /checkpoint
InclusionAgainst map[uint64]uint64 // leaf index → tree size its proof (and embedded checkpoint) use
InclusionLeafSwap map[uint64]uint64 // leaf index → index whose proof is served instead
InclusionIndexLie map[uint64]uint64 // leaf index → the leaf_index the answer reports
ConsistencyGarbage bool // /consistency serves a wrong proof
FailNext map[string][]int // endpoint name → statuses to return before serving honestly
FeedStuckCursor bool // /activities always reports more, with a cursor that never moves
ProofsAhead bool // proof endpoints answer at the log's real size while /checkpoint lags at Published
FeedStuckWithNew bool // /activities holds last_id constant while serving one new event per page
Events []json.RawMessage // the activity feed, any order
Requests map[string]int // endpoint name → count
// contains filtered or unexported fields
}
Server fakes the Compliance API endpoints axt-verify reads, over one Log.