Documentation
¶
Overview ¶
Package tscrypto holds small hash and encoding helpers: a one-byte domain-separated SHA-256, the constant-time comparisons, and the UUIDv7 time reader convert id uses. It verifies nothing: this CLI's verifier, which takes its prefix bytes from SPEC.md section 4, is internal/verifier and internal/registry.
Index ¶
- func BytesToHex(b []byte) string
- func DecodeCompactMerkleProof(base64urlProof string) ([]string, error)
- func DecodePublicKey(b64 string) (ed25519.PublicKey, error)
- func DomainHash(prefix byte, data []byte) []byte
- func ExtractUUIDv7Timestamp(id string) (time.Time, error)
- func HexEqual(a, b string) bool
- func SecureEqual(a, b string) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BytesToHex ¶
BytesToHex encodes bytes to lowercase hex string.
func DecodeCompactMerkleProof ¶
DecodeCompactMerkleProof decodes a compact base64url-encoded Merkle proof into the standard ["l:hex", "r:hex", ...] format.
Binary format:
- Byte 0: depth (number of proof steps, 0-64)
- Next ceil(depth/8) bytes: direction bitfield (little-endian) bit=0 means left sibling ("l:"), bit=1 means right sibling ("r:")
- Remaining: depth * 32 bytes of raw sibling hashes
func DecodePublicKey ¶
DecodePublicKey decodes a base64-encoded Ed25519 public key.
func DomainHash ¶
DomainHash computes SHA256(prefix_byte || data).
func ExtractUUIDv7Timestamp ¶
ExtractUUIDv7Timestamp extracts the millisecond timestamp from a UUIDv7 string.
func HexEqual ¶
HexEqual reports whether two hex strings are equal, ignoring ASCII case in the range 'A'-'F'.
The comparison is constant-time in the CONTENTS of the operands: every byte is folded and accumulated, and only the length short-circuits (a length difference is not secret).
Nothing is hex-decoded, so non-hex and odd-length operands compare on hex TEXT rather than decoded bytes. In verify a proof's hex is held to lowercase by SHAPE's pattern classes (SPEC.md section 2.4); this fold does not.
func SecureEqual ¶ added in v0.13.0
SecureEqual reports whether two strings are byte-for-byte equal, in constant time for equal-length inputs. It is exact, with no case folding: a hash is lowercase hex (SPEC.md section 2.4 (Pattern classes)), so a mis-cased value never compares equal to a derived one.
Types ¶
This section is empty.