canonical

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package canonical is the canonical form an evidence digest commits to: RFC 8785 (JSON Canonicalization Scheme) as the Proof-of-Control standard pins it down in schema/canonicalization.md. Keys sorted by UTF-16 code unit, no whitespace, minimal escapes, non-ASCII literal, digests tagged with their algorithm, and no floating point in a claim set: a float is refused, not formatted, because number formatting is where canonical forms go wrong quietly.

Index

Constants

View Source
const Algorithm = "sha-256"

Variables

View Source
var ErrFloat = errors.New("the claim set forbids floating point; see canonicalization.md")

ErrFloat is returned for a non-integer number: the claim set forbids it.

Functions

func Digest

func Digest(v any) (string, error)

Digest is the lowercase hex sha256 of the canonical form of a value.

func Encode

func Encode(v any) ([]byte, error)

Encode returns the canonical bytes of a value. Maps become objects, slices arrays; json.Number and integers are written as integers; float64 is accepted only when it is a whole number within the safe range.

func SHA256

func SHA256(b []byte) string

SHA256 of raw bytes, lowercase hex.

func Tag

func Tag(hex string) string

Tag is the wire form of a digest: algorithm-tagged, so evidence written before a hash migration is still interpretable after one.

func Untag

func Untag(digest string) (string, error)

Untag refuses an untagged, foreign or malformed sha-256 digest rather than guessing.

func UntagAny added in v0.2.0

func UntagAny(digest string) (alg, value string, err error)

UntagAny accepts any digest the schema admits and returns its algorithm and hex. A measurement from a TDX quote is sha-384; the chain and snapshot digests stay sha-256.

Types

This section is empty.

Jump to

Keyboard shortcuts

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