ptype

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package ptype holds the frozen registry of proof type codes and the registry names that travel on the wire.

A bundle's `type` is a registry NAME (`block`, `beacon`, `item`, `entropy_nist`, `entropy_stellar`, `entropy_bitcoin`). The signed payload (Appendix E.16) carries the frozen integer CODE for that name, so the two halves of the registry are both permanent: a name is never renamed and never reused, a code is never renumbered and never reassigned.

Category ranges (blocks of 10):

10-19  subject: block family  (10 = block, 11 = beacon)
20-29  subject: item
30-39  subject: entropy sources
40-49  commitment chains (reserved; never on the wire)
50+    reserved for future categories

Beacon (11) shares the block structural shape (no `subject`, no `inclusion_proof`, same `block` + `commitments`) but is a distinct code for domain separation: because the code is part of the signed payload, a `block` and a `beacon` bundle for the same block produce different signatures.

The commitment chains `stellar` (40) and `bitcoin` (41) are named on the wire by `commitments[].chain` only; their codes are documented history and are reserved so nothing else ever claims them.

Index

Constants

View Source
const (
	NameBlock          = "block"
	NameBeacon         = "beacon"
	NameItem           = "item"
	NameEntropyNIST    = "entropy_nist"
	NameEntropyStellar = "entropy_stellar"
	NameEntropyBitcoin = "entropy_bitcoin"
)

Registry names of the six subject types, in code order.

View Source
const (
	ChainStellar = "stellar"
	ChainBitcoin = "bitcoin"
)

Chain names carried in `commitments[].chain`.

Variables

SubjectNames lists every registered subject type name, in code order. It is the vocabulary a `type` field must draw from (Appendix E.6, E.24).

Functions

func Humanize

func Humanize(c Code) string

Humanize returns a display-friendly label for a code.

func IsBlockLikeSubject

func IsBlockLikeSubject(c Code) bool

IsBlockLikeSubject reports whether c is a block-family subject type, a plain block (10) or a beacon (11). The two share one wire shape: no `subject`, no `inclusion_proof`, `subject_hash == block_hash`.

func IsChainName added in v0.13.0

func IsChainName(name string) bool

IsChainName reports whether name is one of the two registered commitment chain names.

func IsEntropySubject

func IsEntropySubject(c Code) bool

IsEntropySubject reports whether c is one of the entropy subject types.

func IsSubjectName added in v0.13.0

func IsSubjectName(name string) bool

IsSubjectName reports whether name is one of the six registered subject type names.

func IsValidSubject

func IsValidSubject(c Code) bool

IsValidSubject reports whether c is a registered subject type code.

func Name

func Name(c Code) string

Name returns the registry name for a code. Returns "unknown" for an unregistered code.

Types

type Code

type Code uint16

Code is the frozen integer code for a registry name. Subject codes are emitted as uint16 big-endian in the signed payload.

const (
	Block          Code = 10
	Beacon         Code = 11
	Item           Code = 20
	EntropyNIST    Code = 30
	EntropyStellar Code = 31
	EntropyBitcoin Code = 32
)

Registered subject type codes.

const (
	CommitmentStellar Code = 40
	CommitmentBitcoin Code = 41
)

Reserved commitment chain codes. They are never written to the wire and never appear in a preimage; `commitments[].chain` names the chain instead.

func FromName added in v0.13.0

func FromName(name string) (Code, bool)

FromName resolves a registry name to its frozen code. ok is false for any string that is not one of the six subject names; a verifier MUST reject such a `type` at E.6 rather than guess a code (Appendix E.16, E.24).

Jump to

Keyboard shortcuts

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