power_house 0.1.48

power_house provides deterministic sum-check proofs, finite-field arithmetic, transcript logging, and quorum ledger tooling for transparent verification in Rust.
Documentation

rebuild + copy binaries/configs, then restart services on both boot nodes

python3 scripts/netctl.py deploy --hosts boot1 boot2

stream the latest anchors/log output

python3 scripts/netctl.py logs --lines 200 --hosts boot1

Inspect the statements and compare to the pinned digests above

cat mynode.anchor.txt

Reconcile against a published anchor (example with boot1)

julian node reconcile ./logs/mynode boot1.anchor.txt 2

julian node reconcile ./logs/boot1 boot2.anchor.txt 2 julian node reconcile ./logs/boot2 boot1.anchor.txt 2

Interactive proof techniques underpin cutting-edge cryptographic protocols and blockchain consensus. This crate distills those advanced concepts into a standalone laboratory for experimentation, formal verification, and pedagogy. It emulates the essential features of the sum-check protocol, exhibits a rudimentary Byzantine consensus mechanism, and now powers the JULIAN Protocol—a proof-transparent ledger that anchors folding transcripts into verifiable consensus states.

  • Finite Field Arithmetic: A lean yet robust implementation of arithmetic modulo a prime, essential for homomorphic operations and algebraic proofs.

  • Sum-Check Protocol Demo: Illustrates how a prover can succinctly certify a polynomial’s evaluation over a Boolean hypercube, while the verifier checks integrity with negligible soundness error.

  • Deterministic PRNG: A compact linear-congruential generator serving as a deterministic source of challenge derivation, thereby eliminating external entropy dependencies.

  • Generalized Multilinear Sum-Check: The MultilinearPolynomial, Transcript, and GeneralSumClaim types enable non-interactive proofs for arbitrary multilinear polynomials—still without any external crates.

  • Transcript & Chaining Toolkit: Capture Fiat–Shamir challenges, per-round sums, and final evaluations, then chain proofs together or feed them directly into the ALIEN ledger scaffold for deterministic auditing.

  • Streaming Proof Generation: Build massive sum-checks via streaming evaluators (no full hypercube allocation), with per-round timing exported by the benchmarking CLI.

  • Ledger Transcript Logging with Integrity Hashes: Persist proofs as ASCII dossiers tagged with built-in hash digests so transcripts remain self-authenticating without external crates. Ledger anchors are append-only commitments to those transcripts; a ledger state is valid iff every anchor agrees on the statement string and ordered hash list.

  • Quorum Finality for the JULIAN Protocol: reconcile_anchors_with_quorum formalises finality: once ≥ q nodes publish matching anchors, the JULIAN ledger state is final. Divergent anchors are immediately pinpointed by re-running verify_logs.

  • Consensus Primitive: Demonstrates quorum-based agreement logic reflective of Byzantine fault tolerance in distributed systems.

  • ALIEN Ledger Blueprint: A scaffold for integrating proofs, consensus, and randomness into a unified verification ledger, pointing toward PSPACE-level expressive power and quantum-assisted extensions.

The julian binary exposes both local ledger tooling and the optional JROC-NET networking stack.

These commands are always available and require only the standard library:

  • julian node run <node_id> <log_dir> <output> – recomputes transcript hashes from <log_dir>, prepends the JULIAN genesis anchor, and writes a machine-readable anchor file.
  • julian node anchor <log_dir> – prints a formatted ledger anchor derived from the logs.
  • julian node reconcile <log_dir> <peer_anchor> <quorum> – recomputes the local anchor, loads a peer’s anchor file, and checks quorum finality.
  • julian node prove <log_dir> <entry_index> <leaf_index> [output.json] – emits a Merkle proof for a specific transcript digest.
  • julian node verify-proof <anchor_file> <proof_file> – checks a proof against a stored anchor and exits non-zero on failure.

End-to-end anchor example (after running cargo run --example hash_pipeline):

# Prepare node log directories.
mkdir -p ./logs/nodeA ./logs/nodeB
cp /tmp/power_house_anchor_a/* ./logs/nodeA/
cp /tmp/power_house_anchor_b/* ./logs/nodeB/

# Produce anchors and reach quorum.
julian node run nodeA ./logs/nodeA nodeA.anchor
julian node run nodeB ./logs/nodeB nodeB.anchor
julian node reconcile ./logs/nodeA nodeB.anchor 2

The networking subcommands pull in optional dependencies (libp2p, ed25519-dalek, tokio). Build with the feature enabled:

cargo install --path . --features net
# or, for local runs
cargo run --features net --bin julian -- net ...

Supported commands:

  • julian net start --node-id <id> --log-dir <path> --listen <multiaddr> --bootstrap <multiaddr>... --broadcast-interval <ms> --quorum <q> [--key <spec>]
    • --key accepts ed25519://deterministic-seed, or a path to raw/hex/base64 secret key bytes; omitted ⇒ fresh key.
    • --identity loads an encrypted identity file (XOR of the secret key with SHA-512(passphrase)); the CLI prompts for the passphrase.
    • --metrics [:port] exposes Prometheus metrics (defaults to 0.0.0.0:<port> when prefixed with a colon).
    • --policy governance.json loads a governance descriptor (backend: static | static-file | multisig) and enforces the returned membership set.
    • --policy-allowlist allow.json restricts quorum counting to the listed ed25519 keys.
    • --checkpoint-interval N writes signed anchor checkpoints every N broadcasts.
  • julian net anchor --log-dir <path> [--node-id <id>] [--quorum <q>] emits a machine-readable JSON anchor.
  • julian net verify-envelope --file <path> --log-dir <path> [--quorum <q>] validates a signed envelope, decodes the anchor payload, and performs the quorum check against local logs.

Example session with two local nodes and deterministic keys:

# Terminal 1 – nodeA
cargo run --features net --bin julian -- net start \
  --node-id nodeA \
  --log-dir ./logs/nodeA \
  --listen /ip4/127.0.0.1/tcp/7001 \
  --broadcast-interval 5000 \
  --quorum 2 \
  --key ed25519://nodeA-seed

# Terminal 2 – nodeB
cargo run --features net --bin julian -- net start \
  --node-id nodeB \
  --log-dir ./logs/nodeB \
  --listen /ip4/127.0.0.1/tcp/7002 \
  --bootstrap /dns4/boot1.jrocnet.com/tcp/7001/p2p/12D3KooWLASw1JVBdDFNATYDJMbAn69CeWieTBLxAKaN9eLEkh3q \
  --broadcast-interval 5000 \
  --quorum 2 \
  --key ed25519://nodeB-seed

Each node recomputes anchors from its log directory, signs them, broadcasts envelopes over Gossipsub, and logs finality events once the quorum predicate succeeds.

Run scripts/smoke_net.sh to exercise the two-node quorum workflow locally; the script boots nodes on ports 7211/7212, waits for signed anchor broadcasts, confirms finality, and exits non-zero on failure.

{
  "schema": "jrocnet.anchor.v1",
  "network": "JROC-NET",
  "node_id": "nodeA",
  "genesis": "JULIAN::GENESIS",
  "challenge_mode": "mod",
  "fold_digest": "98807230712cd2b09c17df617b1f951787815b29c7037dbe9fcab2af490d196b",
  "crate_version": "0.1.48",
  "entries": [
    {
      "statement": "JULIAN::GENESIS",
      "hashes": ["139f1985df5b36dae23fa509fb53a006ba58e28e6dbb41d6d71cc1e91a82d84a"],
      "merkle_root": "09c0673e5d1a15ea98da1e7188d64e4db53f46982810d631264dbbd001ad995a"
    },
    {
      "statement": "Dense polynomial proof",
      "hashes": ["ded75c45b3b7eedd37041aae79713d7382e000eb4d83fab5f6aca6ca4d276e8c"],
      "merkle_root": "80e7cb9d1721ce47f6f908f9ac01098d9c035f1225fff84083a6e1d0828144f4"
    },
    {
      "statement": "Hash anchor proof",
      "hashes": ["c72413466b2f76f1471f2e7160dadcbf912a4f8bc80ef1f2ffdb54ecb2bb2114"],
      "merkle_root": "637aeed7e8fbb42747c39c82dfe1eb242bda92fead2a24abaf8c5ffc45ff8e82"
    }
  ],
  "quorum": 2,
  "timestamp_ms": 1730246400000
}
{
  "schema": "jrocnet.envelope.v1",
  "public_key": "<base64-ed25519-pk>",
  "node_id": "nodeA",
  "payload": "<base64-raw-json-of-anchor>",
  "signature": "<base64-sign(payload)>"
}

Validation steps: ensure the schema matches, base64-decode the payload, verify the ed25519 signature, parse the embedded anchor JSON, then reconcile with the local ledger.

  1. Topics & networking

    • Gossip topics: jrocnet/anchors/v1, optional jrocnet/ping/v1, jrocnet/peers/v1.
    • Bootstrap multiaddrs: /ip4/<BOOT>/tcp/7001/p2p/<PEER_ID> defined per public node.
  2. Anchor schema – Machine-readable anchors follow jrocnet.anchor.v1 as shown above.

  3. Signed envelopesjrocnet.envelope.v1 ensures tamper-evident broadcasts (ed25519 signatures over the raw anchor JSON).

  4. CLI flagsjulian net start accepts --bootstrap, --key, --broadcast-interval, --quorum, mirroring the launch playbook; julian net anchor/verify-envelope cover audit tooling.

  5. Libp2p behaviour – TCP + Noise + Yamux transports, Gossipsub for anchor gossip, Kademlia for peer discovery, Identify for metadata.

  6. Security hygiene – Message-id cache (SHA256 payload hash), strict validation, per-topic rate limiting, and schema/network checks before reconciliation.

  7. Observability – Console summaries plus the optional --metrics Prometheus endpoint exporting anchors_received_total, anchors_verified_total, invalid_envelopes_total, lrucache_evictions_total, finality_events_total, and gossipsub_rejects_total.

    • Import contrib/grafana/jroc_net_dashboard.json into Grafana for a starter dashboard.
  8. Launch playbook – Run at least two bootstrap nodes, publish their multiaddrs, then let community nodes join via:

    cargo install power_house --features net
    julian net start \
      --node-id <your_name> \
      --log-dir ./logs/<your_name> \
      --listen /ip4/0.0.0.0/tcp/0 \
      --bootstrap /dns4/boot1.jrocnet.com/tcp/7001/p2p/12D3KooWLASw1JVBdDFNATYDJMbAn69CeWieTBLxAKaN9eLEkh3q \
      --bootstrap /dns4/boot2.jrocnet.com/tcp/7002/p2p/12D3KooWRLM7PJrtjRM6NZPX8vmdu4YGJa9D6aPoEnLcE1o6aKCd \
      --broadcast-interval 5000 \
      --quorum 2 \
      --key ed25519://<seed>
    

    Bootstrap multiaddrs (A2 testnet reference):

  • /dns4/boot1.jrocnet.com/tcp/7001/p2p/12D3KooWLASw1JVBdDFNATYDJMbAn69CeWieTBLxAKaN9eLEkh3q
  • /dns4/boot2.jrocnet.com/tcp/7002/p2p/12D3KooWRLM7PJrtjRM6NZPX8vmdu4YGJa9D6aPoEnLcE1o6aKCd

The testnet keeps every transcript, proof, and anchor transparent so auditors can replay history end-to-end.

use power_house::{Field, SumClaim};

let field = Field::new(101);
let claim = SumClaim::prove_demo(&field, 8);
assert!(claim.verify_demo());

Run the executable variant to see the non-interactive sum-check in action:

cargo run --example demo

The program exits with a non-zero status if verification ever fails, making it easy to embed inside scripts or CI checks.

The crt_chain example threads three large primes through a deterministic LCG, combines the outputs with the Chinese Remainder Theorem, and emits transcript digests derived from the Field arithmetic:

cargo run --example crt_chain

It prints a 12-round trace with reproducible totals and hash pairs, highlighting how Power-House components compose into a heavier protocol.

use power_house::{Field, GeneralSumClaim, MultilinearPolynomial};

let field = Field::new(97);
let poly = MultilinearPolynomial::from_evaluations(3, vec![
    0, 1, 4, 5, 7, 8, 11, 23,
]);
let claim = GeneralSumClaim::prove(&poly, &field);
assert!(claim.verify(&poly, &field));

Re-run it interactively with:

cargo run --example general_sumcheck

The example exercises the Fiat–Shamir transcript helper and the generalized sum-check prover/verifier against a three-variable polynomial.

Transcript outputs include deterministic Fiat–Shamir challenges; when logged via the ledger, each record carries a domain-separated BLAKE2b-256 integrity hash for tamper-evident storage.

cargo run --example mega_sumcheck

This walkthrough builds 10-variable polynomials, records per-round timings, and chains multiple proofs together before handing them off to the ALIEN ledger scaffold.

cargo run --example scale_sumcheck

Prints a timing table for increasing numbers of variables, helping you profile how multilinear proofs scale as the hypercube size grows. Set POWER_HOUSE_SCALE_OUT=/path/to/results.csv to emit machine-readable timing data alongside the console output.

cargo run --example verify_logs -- /tmp/power_house_ledger_logs

Replays ledger log files, recomputes their integrity hashes, and prints a pass/fail summary so archived transcripts remain tamper-evident.

cargo run --example hash_pipeline

Streams per-proof hashes into constant-time anchors, folds them with domain-separated BLAKE2b-256, and reconciles the anchors across multiple ledgers while emitting tamper-evident logs. This example is the reference JULIAN Protocol pipeline: nodes replay transcript logs, exchange LedgerAnchor structures, and call reconcile_anchors_with_quorum to reach finality.

The full JULIAN Protocol write-up lives in JULIAN_PROTOCOL.md.

cargo run --bin julian -- node run <node_id> <log_dir> <output_anchor>
cargo run --bin julian -- node anchor <log_dir>
cargo run --bin julian -- node reconcile <log_dir> <peer_anchor> <quorum>

These commands replay transcript logs, derive JULIAN anchors, and check quorum finality using nothing beyond the Rust standard library.