Reference implementation, Rust
Source: pcoc at commit aaa8946. Assumes: you have read the SPEC reading guide. Next: make a hike with it (Integrate a producer) or check one (Verifier and policy).
- What it is and isn't. It is one of three independent reference implementations ("refs": Rust, Go, Java). Each is tested against spec/conformance/v2.0. It is a guide and optional. If it disagrees with the SPEC, the SPEC wins and the ref has a bug. Rust is the only one that writes the vectors (
PCOC_REGEN_V2=1); Go and Java compare against those bytes. (source: reference/README.md, reference/rust/README.md) Disagreements. Only values fixed by a hash count as evidence. Report a text-vs-vector conflict as a defect and don't pick a side. (source: CONTRIBUTING.md) - Pins. Tip tag
ref-rust-v2.0.5. Bari (bari-v0.6.8), the Gate (gate-v0.4.1), and the desktop app (desktop-v0.1.3) pinref-rust-v2.0.5; the index still pinspcoc-bariatbari-v0.6.7(and reaches hike through that). Android 3.5.47 (primal-pcoc tagandroid-v3.5.47) vendorsref-rust-v2.0.5. reference/SPEC_PIN namesspec-v2.0.3plus a vector hash. Check it withpython3 reference/tools/check_spec_pin.pyfrom the repo root. Toolchain is Rust 1.99.0 (rust-toolchain.toml); the hike crate's rust-version is 1.83. (source: reference/rust/README.md, reference/SPEC_PIN, reference/tools/check_spec_pin.py) Bari and the index: Bari is 0.6.8 (services/bari/Cargo.toml, tagbari-v0.6.8). The index still pinspcoc-bariatbari-v0.6.7(services/index/Cargo.toml) (the Cargo.toml pin; a build from tagbari-v0.6.7reports crate 0.6.6 because that tag points at the commit before the version bump). - Crates.
hikeis the shared library (fill, leg, bind, object, path body, Hashcash; src/ has produce.rs, verify.rs, section14.rs, terrain.rs …).hike-netholds network and test-plane policy kept out of measurement (chainrpc.rs, policy.rs).nip06holds DEMO keys only.satoshi-hike-produceandsatoshi-hike-verifyare the CLIs. (source: reference/README.md) - Build and test.
cargo test --locked --releasein reference/rust runs the conformance pack; leave PCOC_REGEN_V2 unset. To regenerate:PCOC_REGEN_V2=1 cargo test --manifest-path reference/rust/hike/Cargo.toml --test conformance_v2 -- --exact conformance_v2_pack. (source: reference/rust/README.md, spec/conformance/v2.0/README.md) - Verify. This comes first because checking the vectors needs no network, so it is the easiest first result. The rest of the docs go produce, then verify.
satoshi-hike-verify --input OBJECT --index-url URL. The default--profile testnever dials index.groundinglab.io and reads PCOC_TEST_INDEX_URL.--profile live --index-url https://index.groundinglab.iouses the hosted index, which is opt-in. To run your own index, usepcoc-index rebuild --source esplora|rpc(public API or a pruned node). Output is the §14 record only, with no policy. (source: reference/rust/README.md, reference/rust/hike/src/args.rs, services/index/README.md) - Produce.
satoshi-hike-producetakes--pubkey-hex,--output,--gossip-peer,--bari-url, and optional--report,--profile test|live|slow-lan,--clock-source gossipand--gossip-network mainnet|regtest; or a demo seed phrase in place of--pubkey-hex(flag in the reference README). The test profile fills them from PCOC_TEST_BARI_URL / PCOC_TEST_GOSSIP_PEER. The live default Bari is https://bari.groundinglab.io (consts DEFAULT_BARI_URL), which is opt-in. To run your own: startbarifrom services/bari and pass--bari-urlwith its address (setup in Integrate a producer, beat 3). The demo seed phrase is a lab derivation, not a production seed. (source: reference/rust/satoshi-hike-produce/src/main.rs, reference/rust/hike/src/args.rs, reference/rust/hike/src/consts.rs, services/bari/README.md) On the live profile, anyhttpsBari or index origin (no path) is accepted; a host other than groundinglab's prints a warning and proceeds. Live produce does not need its own gossip peer: with no--gossip-peerand no PCOC_LIVE_GOSSIP_PEER it falls back to Bitcoin's public DNS seeds (mainnet). A named peer wins, and the command line wins over the variable.--tip-urland--clock-source httpare usage errors. (source: reference/rust/satoshi-hike-produce/src/main.rs, reference/rust/hike/src/args.rs) - Embedding (calling the library from your own program). The Gate, groundinglab's admission service (Admission gate), calls
hike::verify_with_bind_threads(services/admission-gate/src/verifier.rslinked_measure). Android callshike::produce_with_settlement_sizedand verifies withhike::Sizes::production()through JNI; primal-pcoc 3.5.47 vendorshikeatref-rust-v2.0.5(android-v3.5.47). The CLI reads PCOC_BIND_THREADS: default 6,1runs serially, and the record doesn't change. (source: reference/README.md, reference/rust/hike/src/verify.rs) API stability: nothing in the repo declares a stable public API forhikeyet (hike/src/lib.rs states none). Pin a tag. (source: reference/rust/hike/src/lib.rs)
Checked against pcoc aaa8946. Raw markdown.