Documentation
¶
Overview ¶
Package address implements Freizone's self-certifying account addressing scheme: a bech32m-derived identifier computed from the SHA-256 hash of an account's root Ed25519 public key.
Index ¶
- Constants
- func DecodeBech32m(s string) (hrp string, data []int, err error)
- func DeriveID(rootPubKey ed25519.PublicKey) (string, error)
- func DeriveIDVersion(version int, rootPubKey ed25519.PublicKey) (string, error)
- func EncodeBech32m(hrp string, data []int) (string, error)
- func FormatForDisplay(id string) string
- func Normalize(id string) (string, error)
- func StripSeparators(id string) string
- func ValidCharset(s string) bool
- func Verify(id string, rootPubKey ed25519.PublicKey) (bool, error)
- func VerifyVersion(version int, id string, rootPubKey ed25519.PublicKey) (bool, error)
- func VersionOf(id string) (int, error)
Constants ¶
const CurrentVersion = 0
CurrentVersion is the version marker of an account address: SHA-256 root-key hash, bech32m checksum.
const ( // PrefixLength is the number of leading characters of an id that a // server enforces unique among its own accounts (see docs/PROTOCOL.md's // id-prefix uniqueness note): the version marker plus 4 real characters // of entropy. Matches FormatForDisplay's first group size exactly. PrefixLength = 5 )
const VersionGroup = 1
VersionGroup is the version marker of a group id (SRV-01). A group id is derived exactly like an account id -- same hash, same truncation, same checksum, same normalization -- over the group's root key instead of an account's, and is told apart from an account id by this marker alone. That costs no new encoding logic and makes the two impossible to confuse.
Variables ¶
This section is empty.
Functions ¶
func DecodeBech32m ¶
DecodeBech32m decodes a bech32m string, verifies its checksum, and returns the human-readable part and the data values (with the checksum stripped).
func DeriveID ¶
DeriveID computes the self-certifying account address for a root public key: bech32m(SHA-256(rootPubKey) truncated to 70 bits, prefixed with a 5-bit version marker), with no human-readable prefix or separator -- a plain 21-character string (15 payload + 6 checksum).
func DeriveIDVersion ¶ added in v0.12.0
DeriveIDVersion is DeriveID with an explicit version marker, so the same derivation can mint both account ids (CurrentVersion) and group ids (VersionGroup).
func EncodeBech32m ¶
EncodeBech32m encodes hrp and a sequence of 5-bit values (0-31, without a checksum) into a full bech32m string "hrp1<data><checksum>".
func FormatForDisplay ¶
FormatForDisplay inserts hyphens every 5 characters for readability. It is purely cosmetic: the canonical form used in storage, URLs, and comparisons has no separators. 5 (not 4) is deliberate: the first char is always the version marker (see CurrentVersion), so a 5-char first group carries 4 real characters of entropy -- and happens to split the 15-char payload into exactly 3 even groups, leaving only the 6-char checksum tail uneven.
func Normalize ¶
Normalize strips cosmetic separators/whitespace, lowercases, and validates an address's length, character set, and checksum -- without needing the corresponding public key. It returns the canonical 21-character form.
func StripSeparators ¶
StripSeparators removes cosmetic dashes/whitespace and lowercases id, without validating its length or checksum. Shared by Normalize (which additionally enforces the full 21-character form) and any caller that also needs to recognize the shorter, unchecksummed PrefixLength form.
func ValidCharset ¶
ValidCharset reports whether every character in s belongs to the bech32m charset -- useful for validating a short id-prefix, which (unlike a full id) carries no checksum of its own to catch typos.
func Verify ¶
Verify reports whether id is the correct, self-certifying account address for rootPubKey.
func VerifyVersion ¶ added in v0.12.0
VerifyVersion is Verify for an explicit version marker -- VersionGroup to check a group id against its group root key.
Types ¶
This section is empty.