Documentation
¶
Overview ¶
Package poseidon implements Poseidon-over-Pallas-Fq, byte-identical to the neptune 13.0.0 reference used by the konareef pod-step ZK circuit (paygate-zk crates/konareef-circuit). It is the Go verifier-side counterpart of scripts/poseidon_pallas.py and the in-circuit gadgets in gadgets/memory_poseidon.rs / troot_poseidon.rs.
All parameters (modulus, domain tags, MDS matrices, round constants) are loaded from the pinned artifact konareef-pod-step-v1-poseidon-params-v1.json, whose SHA-256 is gated against ParamArtifactSHA256 so the Go, Rust, and Python implementations cannot silently diverge.
Field arithmetic uses math/big rather than a Montgomery implementation: a verifier hashes only a handful of nodes per proof, so constant-time/perf concerns do not apply, and mod-p big.Int mirrors the Python oracle exactly, removing the principal silent-divergence risk (parameter/field mismatch).
Index ¶
- Constants
- type Params
- func (pr *Params) EmptyRoots() [][32]byte
- func (pr *Params) InternalHash(l, r [32]byte) ([32]byte, error)
- func (pr *Params) LeafHash(vh [32]byte) ([32]byte, error)
- func (pr *Params) RecordToField(record []byte) ([32]byte, error)
- func (pr *Params) TRoot(records [][]byte) ([32]byte, error)
- func (pr *Params) ValueHash(payload []byte) ([32]byte, error)
Constants ¶
const MaxRecordBytes = 330
MaxRecordBytes is the pinned per-record cap (PRD 1 §5.4 / troot_poseidon.rs MAX_RECORD_BYTES). Records beyond this could not have been proven in-circuit.
const MaxTLogRecords = 16
MaxTLogRecords is the pinned tool-log record cap (PRD 1 §7 v1 / troot_poseidon.rs MAX_TLOG_RECORDS). Logs beyond this could not have been proven in-circuit.
const ParamArtifactSHA256 = "4aeda63ce430b5f0486bb31c0264923acc493e3d0ab45a92e19efe8ffe4bbf9f"
ParamArtifactSHA256 is the pinned digest of the parameter artifact. It mirrors the Rust circuit's param_drift_gate.rs constant. A drift here means the Go hash outputs would diverge from the circuit/verifier contract.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Params ¶
type Params struct {
// contains filtered or unexported fields
}
Params is a loaded, drift-checked set of the three Poseidon instances over the Pallas Fq field.
func Default ¶
func Default() *Params
Default returns the Params loaded from the embedded pinned artifact. It panics if the embedded artifact fails its SHA-256 drift gate or cannot be parsed — both are build-time invariants, not recoverable runtime conditions.
func (*Params) EmptyRoots ¶
EmptyRoots returns the 21 empty-subtree roots E0..E20, where E0 = LeafHash(0) and E_k = InternalHash(E_{k-1}, E_{k-1}).
func (*Params) InternalHash ¶
InternalHash is the arity-2 node hash over preimage [l, r]. Both inputs must be canonical 32-byte little-endian field elements.
func (*Params) RecordToField ¶
RecordToField folds one tool-log record's canonical bytes into a single field element (§5.4). Rejects records over MaxRecordBytes (fail-closed: the circuit could not have proven them).