canonical

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommitID

func CommitID(c CommitContent) string

CommitID returns the lowercase hex SHA-256 of the canonical commit preimage.

func CommitPreimageBytes

func CommitPreimageBytes(c CommitContent) []byte

CommitPreimageBytes returns the raw bytes that CommitID hashes. Exported so tests can pin the exact byte sequence, not just the hash.

func RequestPreimageBytes

func RequestPreimageBytes(r RequestContent) []byte

RequestPreimageBytes returns the canonical bytes to be signed (or verified).

Types

type CommitContent

type CommitContent struct {
	Message   string
	AuthorID  string
	CreatedAt int64    // Unix ms, set by the client at commit time
	Parents   [][]byte // 32-byte raw hashes in order (first parent, second for merge); NOT sorted
	Files     []CommitFile
}

CommitContent is the input to CommitID and CommitPreimageBytes.

type CommitFile

type CommitFile struct {
	Path       string
	ObjectHash []byte // nil for a deletion
}

CommitFile is one file entry in a commit.

type RequestContent

type RequestContent struct {
	PrincipalID   string
	Method        string // uppercase ASCII: "GET", "POST", …
	RequestTarget string // endpoint path + query string, exactly as sent
	Timestamp     int64  // Unix ms
	BodySHA256    []byte // 32 raw bytes; SHA-256 of empty body if none
}

RequestContent is the input to RequestPreimageBytes. The preimage bytes are passed directly to ed25519.Sign (which hashes internally).

Jump to

Keyboard shortcuts

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