Documentation
¶
Overview ¶
Package entviz renders high-entropy values as comparable SVG fingerprints (entviz, spec v10). It is a Go port of the certified reference implementation; see https://github.com/dhh1128/entviz for the spec.
The deterministic shared core lives here: alphabets, tokenization + 24-bit quant extension, the SHA-512 fingerprint, ftok median/quartile selection, the Oklab color rules + weighted-RGB edge selection, and grid selection. The format-specific parsers live in entropy.go and the SVG renderer in pipeline.go.
Index ¶
- Constants
- Variables
- func ClosestPaletteColor(target string, palette []string) string
- func ComputeFingerprint(core string) [64]byte
- func NucleusColors(quant uint32) (string, string)
- func OklabLightness(r, g, b uint8) float64
- func Render(entropyText string, targetAR, fontSizePt float64, note *string) (string, error)
- func SecondDigest(core string) [64]byte
- func WeightedRGBDistance(c1, c2 string) float64
- type Alphabet
- type Eip55Error
- type Grid
- type Parsed
- type RenderError
- type Token
- type VisualStyle
Constants ¶
const LibVersion = "0.11.0"
LibVersion is this Go module's own version stamp. It is per-impl and is not compared by the conformance checker (only data-entviz-version is).
const SpecVersion = "v11"
SpecVersion is the entviz spec level this library implements.
Variables ¶
var ( HEX = Alphabet{ Name: "hex", Chars: "0123456789ABCDEF", BitsPerChar: 4, } BASE64URL = Alphabet{ Name: "base64url", Chars: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", BitsPerChar: 6, } BASE58 = Alphabet{ Name: "base58", Chars: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz", BitsPerChar: 6, } BASE64 = Alphabet{ Name: "base64", Chars: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", BitsPerChar: 6, } BASE32 = Alphabet{ Name: "base32", Chars: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", BitsPerChar: 5, } BECH32 = Alphabet{ Name: "bech32", Chars: "qpzry9x8gf2tvdw0s3jn54khce6mua7l", BitsPerChar: 5, } CROCKFORD32 = Alphabet{ Name: "crockford32", Chars: "0123456789ABCDEFGHJKMNPQRSTVWXYZ", BitsPerChar: 5, } BASE36 = Alphabet{ Name: "base36", Chars: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", BitsPerChar: 6, } DECIMAL = Alphabet{ Name: "decimal", Chars: "0123456789", BitsPerChar: 4, } )
Canonical alphabet constants used across the core and parsers.
var MiddleDomainTag = []byte("entviz/fingerprint-middle/v6\x00")
MiddleDomainTag is the frozen domain-separation constant for the second digest. The trailing NUL is included; the v6 here is the *construction* version (frozen), NOT the spec version — see the spec's large-input section.
var PossibleEdgeColors = [5]string{"#ffffff", "#e7be00", "#ff3f2f", "#2f3fbf", "#000000"}
PossibleEdgeColors is the fixed palette; indices 0-3 are background candidates, black (index 4) is always an edge color.
Functions ¶
func ClosestPaletteColor ¶
ClosestPaletteColor returns the palette entry with minimum weighted distance.
func ComputeFingerprint ¶
ComputeFingerprint returns the SHA-512 digest of the core text bytes.
func NucleusColors ¶
NucleusColors returns (bgHex, fgHex). Red is the low byte of the quant.
func OklabLightness ¶
OklabLightness returns the Oklab L of an sRGB color.
func SecondDigest ¶
SecondDigest returns SHA-512(MiddleDomainTag ‖ core). Computed for every input: it drives the two color-bar markers (and the middle cells on large inputs).
func WeightedRGBDistance ¶
WeightedRGBDistance is the spec's cheap CIELAB ΔE stand-in for edge selection.
Types ¶
type Eip55Error ¶
type Eip55Error struct {
Position int
}
Eip55Error is a hard rejection: an EIP-55 mixed-case checksum mismatch. The Position is the 0-based index (within the 40-hex body) of the first digit whose case disagrees with the canonical case.
func (*Eip55Error) Error ¶
func (e *Eip55Error) Error() string
type Grid ¶
Grid is the chosen layout.
func ChooseGrid ¶
ChooseGrid selects the layout whose aspect ratio is closest to (but not below) the target, with at least 2 columns and 2 rows.
type Parsed ¶
type Parsed struct {
TypeName string
Alphabet Alphabet
Prefix *string
Core string
Suffix *string
PrefixSemantic bool
}
Parsed is a recognized entropy classification.
type RenderError ¶
type RenderError struct {
Kind string // "note" | "input-too-long" | "font-size" | "aspect-ratio" | "no-tokens" | "eip55"
Message string
Position int // for eip55
}
RenderError represents a render rejection. Kind discriminates the reason.
func (*RenderError) Error ¶
func (e *RenderError) Error() string
type Token ¶
Token is one rendered chunk of entropy (or one ftok of a fingerprint).
func MedianToken ¶
MedianToken returns the lower-middle token of the ASCII text-sorted list.
func QuartileTokens ¶
QuartileTokens returns the first token of each of the four mirror-sorted quartiles; a slot is absent (ok=false) when it would fall in padding.
func Tokenize ¶
Tokenize splits text into 24-bit tokens under the given alphabet, extending short trailing chunks to a full 24-bit quant by the bit-repeat rule.
func TokenizeEntropy ¶
TokenizeEntropy tokenizes entropy with v6+ large-input handling. It returns (tokens, truncated).
func TokenizeFingerprint ¶
TokenizeFingerprint serializes the 64-byte digest to base64url and splits it into the 22 ftoks the spec guarantees.
type VisualStyle ¶
VisualStyle is the entviz background plus the 4-entry edge palette.
func SelectVisualStyle ¶
func SelectVisualStyle(medianFtok Token) VisualStyle
SelectVisualStyle picks the background from the median ftok's low 2 bits and forms the edge palette from the remaining four colors.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
entviz-conformance
command
Command entviz-conformance is the conformance CLI: read one vector's JSON on stdin, write the entviz SVG to stdout (exit 0), or exit non-zero to reject (the contract in the entviz repo's compliance/README.md).
|
Command entviz-conformance is the conformance CLI: read one vector's JSON on stdin, write the entviz SVG to stdout (exit 0), or exit non-zero to reject (the contract in the entviz repo's compliance/README.md). |