tscrypto

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToHex

func BytesToHex(b []byte) string

BytesToHex encodes bytes to lowercase hex string.

func DecodeCompactMerkleProof

func DecodeCompactMerkleProof(base64urlProof string) ([]string, error)

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

func DecodePublicKey(b64 string) (ed25519.PublicKey, error)

DecodePublicKey decodes a base64-encoded Ed25519 public key.

func DomainHash

func DomainHash(prefix byte, data []byte) []byte

DomainHash computes SHA256(prefix_byte || data).

func ExtractUUIDv7Timestamp

func ExtractUUIDv7Timestamp(id string) (time.Time, error)

ExtractUUIDv7Timestamp extracts the millisecond timestamp from a UUIDv7 string.

func HexEqual

func HexEqual(a, b string) bool

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

func SecureEqual(a, b string) bool

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.

Jump to

Keyboard shortcuts

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