Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/heavy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ on:
branches: [ main ]
paths:
- 'zeroj-integration-tests/src/test/java/org/zeroj/examples/notes/**'
- 'zeroj-integration-tests/src/test/java/org/zeroj/it/sha2/**'
- 'zeroj-integration-tests/build.gradle'
- 'zeroj-circuit-lib/src/main/java/org/zeroj/circuit/lib/zk/**'
- 'zeroj-circuit-lib/src/main/java/org/zeroj/circuit/lib/jubjub/**'
- 'zeroj-circuit-lib/src/main/java/org/zeroj/circuit/lib/hash/**'
- '.github/workflows/heavy.yml'

permissions:
Expand Down
33 changes: 33 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,36 @@ https://github.com/dylibso/chicory
Used only by the assurance/ WASM differential providers, which are outside the
default build and are never published.

--------------------------------------------------------------------------
Bouncy Castle — Cryptography Provider (bcprov-jdk18on)
--------------------------------------------------------------------------
Copyright (c) 2000-2023 The Legion of the Bouncy Castle Inc. (https://www.bouncycastle.org)
Licensed under the Bouncy Castle License (MIT-style)
https://www.bouncycastle.org/licence.html

Permission is hereby granted, free of charge, to any person obtaining a copy of this software
and associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

--------------------------------------------------------------------------
picocli — Command-Line Interface Framework
--------------------------------------------------------------------------
Copyright (c) 2017-2024 Remko Popma
Licensed under the Apache License, Version 2.0
https://picocli.info/

--------------------------------------------------------------------------
Cardano Client Lib
--------------------------------------------------------------------------
Expand Down Expand Up @@ -92,6 +122,9 @@ Shipped in a published artifact:

Test data only (in no published artifact):

zeroj-bls12381/src/test/resources/rfc9380/
RFC 9380 "Hashing to Elliptic Curves" test vectors (IETF Trust;
Revised BSD License)
zeroj-bbs/src/test/resources/cfrg-bbs/
BBS draft-10 fixtures from decentralized-identity/bbs-signature
(Apache License 2.0; the values are also in the IETF draft)
Expand Down
41 changes: 20 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

[![snapshot](https://img.shields.io/maven-metadata/v?metadataUrl=https%3A%2F%2Frepo.bloxbean.org%2Fmaven%2Fsnapshots%2Forg%2Fzeroj%2Fzeroj-crypto%2Fmaven-metadata.xml&strategy=latestProperty&label=snapshot)](#development-snapshots)

> ## **Preview Status**
> **ZeroJ** is currently in preview and under active development. Core functionality is available and usable for experimentation and testnet development, but some components and edge cases are still being implemented and hardened.
> ## **Research & Pre-Release Status**
> **ZeroJ** is experimental research software under active development. Components are labeled **Beta** (feature-complete and correctness-tested, testnet/evaluation only) or **Experimental** (opt-in, evolving) in the Support Matrix below.
>
> ZeroJ has **not been externally audited**. APIs, serialization formats, and on-chain verifier scripts may change between releases. **Production use is not yet recommended.**
> ZeroJ has **not been externally audited**. APIs, serialization formats, and on-chain verifier scripts may change between releases. **Not for value-bearing or production/mainnet use.**

Java-first zero-knowledge proof toolkit for Cardano.

Expand All @@ -25,20 +25,20 @@ ZeroJ lets Java developers **define ZK circuits**, **generate proofs**, **verify

## Support Matrix

**Beta** means feature-complete and correctness-tested (3,500+ tests; the full
Groth16 flow is verified end-to-end on-chain against Yaci DevKit), but **not
externally audited and not for value-bearing/mainnet use**. **Experimental**
components are opt-in and may change or have known limitations. Statuses and
remaining production gates are tracked in
**Beta** means feature-complete and correctness-tested (including end-to-end
Groth16 verification on-chain against Yaci DevKit), but **not externally audited
and not for value-bearing/mainnet use** (tests are not a security or maturity
proof). **Experimental** components are opt-in and may change or have known
limitations. Statuses and remaining production gates are tracked in
[ADR-0026](docs/adr/0026-production-readiness-review-and-remediation-plan.md).

| Area | Components | Status |
|------|-----------|--------|
| Core proof model, codecs, verifier SPI/orchestrator | `zeroj-api`, `zeroj-codec`, `zeroj-backend-spi` | **Beta** |
| Circuit definition (DSL, symbolic annotations, gadgets) | `zeroj-circuit-dsl`, `zeroj-circuit-annotation-*`, `zeroj-circuit-lib` ([per-gadget table](zeroj-circuit-lib/README.md)) | **Beta** |
| Groth16 BLS12-381 — pure Java prove + verify | `zeroj-crypto`, `zeroj-verifier-groth16` | **Beta** (production trusted setup requires an external snarkjs MPC ceremony; in-repo setup is dev-only and flag-gated) |
| Groth16 BLS12-381 — on-chain (Julc / Plutus V3) | `zeroj-onchain-julc` | **Beta — testnet only**, not value-bearing; bind `ScriptContext` in real validators (see `Groth16BLS12381TxOutRefBindingVerifier`) |
| PlonK BLS12-381 — pure Java prove + verify, `.ptau` SRS import | `zeroj-crypto`, `zeroj-verifier-plonk` | **Experimental** — universal `.ptau` SRS import (`PtauImporterBLS381`) + pure-Java prove/verify; snarkjs PlonK `.zkey` import is unsupported ([ADR-0066](docs/adr/0066-plonk-bls12381-ptau-and-zkey-import.md)) |
| Groth16 BLS12-381 — pure Java prove + verify | `zeroj-crypto`, `zeroj-verifier-groth16` | **Beta** — proving is offline/isolated only (witness scalars are not heap-zeroized or constant-time in the JVM); production trusted setup requires an external snarkjs MPC ceremony (in-repo setup is dev-only and flag-gated) |
| Groth16 BLS12-381 — on-chain (Julc / Plutus V3) | `zeroj-onchain-julc` | **Beta — testnet only**, not value-bearing; bind `ScriptContext` in real validators (see `Groth16AuthenticatedStateTransitionValidator` and `Groth16BLS12381TxOutRefBindingVerifier`) |
| PlonK BLS12-381 — pure Java prove + verify, `.ptau` SRS import | `zeroj-crypto`, `zeroj-verifier-plonk` | **Experimental** — universal `.ptau` SRS import (`PtauImporterBLS381`) + pure-Java prove/verify; proving is offline/isolated only (witness scalars are not heap-zeroized or constant-time in the JVM); snarkjs PlonK `.zkey` import is unsupported ([ADR-0066](docs/adr/0066-plonk-bls12381-ptau-and-zkey-import.md)) |
| PlonK BLS12-381 — on-chain (Julc / Plutus V3) | `zeroj-onchain-julc` | **Experimental** — full KZG check implemented; labeled testnet trials only |
| BBS (CFRG draft-10) — verification | `zeroj-bbs` | **Beta** (spec is an IRTF draft, not yet an RFC) |
| BBS — issuance / proof generation | `zeroj-bbs` | **Beta with caveat** — offline/isolated only: no provider (pure Java or blst) has an evidenced side-channel contract ([ADR-0062](docs/adr/0062-bls12381-independent-review-and-remediation.md)) |
Expand All @@ -58,7 +58,7 @@ remaining production gates are tracked in
- **Multi-backend compilation** — one Java circuit can compile to R1CS for Groth16 or to PlonK

### Generate Proofs
- **Pure Java prover** (recommended) — Groth16 + PlonK for BLS12-381. Zero native dependencies. GraalVM compatible. Allocation-lean flat arithmetic, an `mmap`-able proving key, and a streaming trusted setup keep large circuits (millions of constraints) within commodity memory, no JNI (ADR-0029/0033/0034/0035).
- **Pure Java prover** (recommended) — Groth16 + PlonK for BLS12-381. Zero native dependencies (offline/isolated host model; witness scalars are not heap-zeroized or constant-time in the JVM). Allocation-lean flat arithmetic, an `mmap`-able proving key, and a streaming trusted setup keep large circuits (millions of constraints) within commodity memory, no JNI (ADR-0029/0033/0034/0035). (GraalVM `native-image` CI currently builds and verifies the `zeroj-ceremony` CLI; native-image proving is not yet CI-verified.)
- **blst-accelerated prover backend** — optional, opt-in FFM-bound native MSM (`blst_p1s/p2s_mult_pippenger`); a faster Groth16 proving backend, bit-identical proofs. The MSM's `libblst` is built from source (no third-party wrapper) ([ADR-0029](docs/adr/0029-blst-accelerated-groth16-prover.md)).
- **snarkjs CLI** — external CLI for circom-based circuits
- **snarkjs key & SRS import** — import Groth16 `.zkey` files and streaming BLS12-381 `.ptau` SRS files, prove with the pure Java prover
Expand All @@ -80,10 +80,6 @@ Reusable on-chain verifiers only verify the cryptographic proof statement. A
real application validator must also bind replay protection, nullifiers,
authorization, and any `ScriptContext` policy required by the business flow.

### Anchor on Cardano L1
- 4 anchor patterns: proof hash, state root + proof hash, full verification ref, nullifier commitment
- CCL integration — fluent helpers for attaching proof metadata to transactions

## Quick Start — Zero Dependencies

Define a circuit, prove it, and verify — all in pure Java.
Expand Down Expand Up @@ -204,7 +200,8 @@ The **pure Java prover and verifier require no optional dependencies**.
## Building

```bash
# Build the full repository, including opt-in WASM/native modules
# Build the default product surface (opt-in assurance WASM and benchmark modules require
# -PincludeAssurance or -PincludeBenchmarks)
./gradlew build

# Build the core privacy path only
Expand Down Expand Up @@ -251,6 +248,7 @@ The **pure Java prover and verifier require no optional dependencies**.

| Module | Description |
|--------|-------------|
| [`zeroj-bom-core`](zeroj-bom-core/) | Published BOM (Bill of Materials) for the default core product surface |
| [`zeroj-api`](zeroj-api/) | Core proof model, envelopes, verification result types |
| [`zeroj-codec`](zeroj-codec/) | Proof serialization — snarkjs JSON, CBOR, canonical hashing |
| [`zeroj-backend-spi`](zeroj-backend-spi/) | Service Provider Interface for verification backends, plus verifier orchestration and backend routing |
Expand All @@ -261,7 +259,9 @@ The **pure Java prover and verifier require no optional dependencies**.
| [`zeroj-crypto-blst`](zeroj-crypto-blst/) | **Opt-in blst prover backend** — thin bridge wiring `zeroj-blst`'s native MSM into the `zeroj-crypto` prover SPI (keeps `zeroj-crypto` pure-Java by default; pure Java matches blst at large sizes since ADR-0033/0034) |
| [`zeroj-tools`](zeroj-tools/) | Reusable operator tools and the `zeroj-ceremony` CLI — snarkjs-compatible Groth16 phase-2 contributor (`ZkeyContributor`), hash-to-G2 challenge derivation; embeddable in coordinator services and wallets |
| [`zeroj-circuit-dsl`](zeroj-circuit-dsl/) | Java Circuit DSL — define circuits with CircuitSpec, compile to R1CS/PlonK |
| [`zeroj-circuit-lib`](zeroj-circuit-lib/) | Circuit standard library — Poseidon, Merkle, Comparators, Binary, Mux, AliasCheck; in-circuit Blake2b / SHA-256 / SHA-512 / HMAC-SHA512 and Ed25519 / BIP32 / CIP-1852 key derivation; symbolic adapters; [per-gadget status](zeroj-circuit-lib/README.md#gadget-status) |
| [`zeroj-circuit-annotation-api`](zeroj-circuit-annotation-api/) | Symbolic circuit annotations (`@ZKCircuit`, `@Prove`, `@Public`, `@Secret`) and typed symbolic values (`ZkField`, `ZkBool`, `ZkUInt`, `ZkArray`, `ZkBits`, `ZkBytes`) |
| [`zeroj-circuit-annotation-processor`](zeroj-circuit-annotation-processor/) | Compile-time annotation processor generating typed `*Circuit` builders, schemas, and `Inputs` facades |
| [`zeroj-circuit-lib`](zeroj-circuit-lib/) | Circuit standard library — Poseidon, Merkle, Comparators, Binary, Mux, RangeCheck; in-circuit Blake2b / SHA-256 / SHA-512 / HMAC-SHA512 and Ed25519 / BIP32 / CIP-1852 key derivation; symbolic adapters; [per-gadget status](zeroj-circuit-lib/README.md#gadget-status) |
| [`zeroj-onchain-julc`](zeroj-onchain-julc/) | Reusable Plutus V3 on-chain verifiers and libraries via Julc; Groth16 is the primary supported path, PlonK BLS12-381 validators/libraries are experimental opt-in |

#### Explicit Opt-In Product Modules
Expand All @@ -283,7 +283,6 @@ documented independently; it does not mean untested.
|--------|-------------|
| [`zeroj-test-vectors`](zeroj-test-vectors/) | Shared test fixtures — pre-generated proofs and VKs |
| [`zeroj-integration-tests`](zeroj-integration-tests/) | Cross-module security and end-to-end regressions (Groth16/PlonK E2E, tampering, invalid witness, snarkjs interop, Julc/Yaci on-chain) |
| [`zeroj-bom-core`](zeroj-bom-core/) | The single stable BOM for the default product surface |

#### Opt-In Assurance and Benchmark Projects

Expand All @@ -306,7 +305,7 @@ BloxBean Maven repository (`https://repo.bloxbean.org/maven/releases`), with the

```gradle
dependencies {
implementation platform('org.zeroj:zeroj-bom-core:0.1.0')
implementation platform('org.zeroj:zeroj-bom-core:0.1.0-pre13')

// Circuit definition + standard library
implementation 'org.zeroj:zeroj-circuit-dsl'
Expand All @@ -320,7 +319,7 @@ dependencies {
implementation 'org.zeroj:zeroj-verifier-groth16'

// Opt-in product artifacts are outside the stable BOM — give them a version
implementation 'org.zeroj:zeroj-verifier-plonk:0.1.0'
implementation 'org.zeroj:zeroj-verifier-plonk:0.1.0-pre13'

// On-chain verification (Cardano Plutus V3)
implementation 'org.zeroj:zeroj-onchain-julc'
Expand Down
11 changes: 6 additions & 5 deletions docs/adr/0031-groth16-mpc-trusted-setup-ceremony.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ Java developers calling APIs — each role gets one command:
| command | who | what | milestone |
|---|---|---|---|
| `export-r1cs --circuit <FQCN of @ZKCircuit> --out c.r1cs` | coordinator | compile the ZeroJ circuit → iden3 `.r1cs` (used by **both** options) | M4 |
| `contribute in.zkey out.zkey` | contributor | Option B phase-2 contribution (entropy prompt + hash printout) | M5 |
| `verify c.r1cs pot.ptau final.zkey` | anyone | convenience wrapper; **independent check remains `snarkjs zkey verify`** | M5 |
| `beacon in.zkey out.zkey --hash <pub randomness>` | coordinator | final beacon contribution | M5 |
| `contribute --in in.zkey --out out.zkey` | contributor | Option B phase-2 contribution (entropy prompt + hash printout) | M5 |
| `verify c.r1cs pot.ptau final.zkey` | anyone | *not implemented in `zeroj-ceremony`* — use **`snarkjs zkey verify`** directly so verification remains completely independent | N/A |
| `beacon` | coordinator | *not implemented in `zeroj-ceremony`* — use **`snarkjs zkey beacon`** for the final beacon contribution | N/A |
| `finalize final.zkey --pk-store <dir>` | coordinator | import + persist via `Groth16PkStore`, export the VK for the validator | M2/M4 |

Same module family later hosts the planned end-user proving CLI (seed phrase → ownership proof) —
Expand Down Expand Up @@ -100,7 +100,8 @@ Phase-2 contribution (BGM17): contributor samples random `d`, then
- every **H** and **L** query point ← `d⁻¹·point` (the delta-divided sections),
- appends a proof-of-knowledge of `d` (the s-pair construction) + running transcript hash,
in exactly the snarkjs `.zkey` contributions-section layout, so `snarkjs zkey verify` accepts the
chain. CLI shape: `zeroj-ceremony contribute in.zkey out.zkey` (+ `verify`, `beacon`).
chain. CLI shape: `zeroj-ceremony contribute --in in.zkey --out out.zkey` (transcript verification
and final beacon remain in `snarkjs zkey verify` / `snarkjs zkey beacon`).

**Honest cost estimate:** a contribution rescales ~77M G1 points (H+L) by one scalar — independent
variable-base muls, embarrassingly parallel. Expected ~1 h-class per contribution at 19M on a
Expand Down Expand Up @@ -156,7 +157,7 @@ that stays with the circuit's ceremony (minimum viable: coordinator contribution
| M2 | `.zkey` import at 19M + `Groth16PkStore` integration | ownership-circuit-scale zkey imports within memory budget; persisted; warm prove works |
| M3 | Phase-1 source decision (spike) | own-ptau vs Filecoin-conversion measured; one selected + documented |
| M4 | **Option A runbook** | scripted, documented snarkjs ceremony (coordinator + contributor guides, transcript publication, beacon procedure); dry-run on a small circuit |
| M5 | **Option B contributor** | `zeroj-ceremony contribute/verify` producing snarkjs-verifiable contributions; cross-verified against snarkjs on the same transcript; timing measured at 19M |
| M5 | **Option B contributor** | `zeroj-ceremony contribute` producing snarkjs-verifiable contributions; independently verified with `snarkjs zkey verify` on the same transcript; timing measured at 19M |
| M6 | Dry-run ceremony on the ownership circuit | ≥3 contributors (mixed A/B tooling on the same transcript), beacon, published transcript, `snarkjs zkey verify` green, imported key proves + verifies on-chain (testnet) |

## Results (2026-07-08) — M1–M6 delivered
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ therefore already consistent with the ADR-0025 profile. Only the native setup di
- **Untrusted shape at setup time:** the relation (`constraints`, `numWires`, `numPublic`) is
caller-supplied. As in issue #46, the setup must not weaken or silently reshape a relation;
it must reject one it cannot produce a profile-conforming key for.
- **Untrusted at import time:** a `.zkey` file. `ZkeyPkStoreImporter` currently accepts an
infinity `IC` entry (`isOnCurve() || isInfinity()`); after this ADR it rejects it, matching
the verifier profile at the import boundary.
- **Untrusted at import/load time:** a `.zkey` file or cached/stored key bundle.
`ZkeyPkStoreImporter`, `Groth16SetupCache`, and `Groth16PkStore.load` all enforce the
verifier profile and reject any infinity `IC` entry at the import/load boundary.
- **Secret:** `tau, alpha, beta, gamma, delta` in the dev setup (dev/test only, behind the
ADR-0025 insecure-setup opt-in) and the prover blinders `r, s`. The new checks read only
relation shape and the derived `IC` scalars; they do not introduce secret-dependent control
Expand Down
4 changes: 3 additions & 1 deletion docs/adr/0050-julc-pre17-org-julclang-and-typed-bls.md
Original file line number Diff line number Diff line change
Expand Up @@ -358,11 +358,13 @@ ZeroJ upgrades `julcVersion` from `0.1.0-pre18` to `0.1.0-pre22` alongside [ADR-
|---|---:|---|
| `Groth16BLS12381Verifier` | 1,117 | `59f37dc68c0dd3a9f1aeeef7dbbdc3b57ab7acf0e75ddb28d1385db6` |
| `Groth16BLS12381TxOutRefBindingVerifier` | 1,325 | `5c2f90090a78275d2b5eb26195bfeeebf9633daec452e01deef01b13` |
| `Groth16AuthenticatedStateTransitionValidator` | 2,817 | `46c77c445f4d16b156797d05aee6964f9c93d7446dd4f12d26824d4d` |
| `Groth16AuthenticatedStateTransitionValidator` | 2,845 | `5192732cf2c70ce2f03859f1e9f728d986f6a0e1c18e1a1ab86f8eb2` |
| `PlonkBLS12381Verifier` | 4,262 | `7e36f398c0d0c1d3f141563c4766118cb6ea1496dfaab269fc30b2de` |
| `PlonkBLS12381MultiInputVerifier` | 4,668 | `4172c86d5e8e8e69dfd91f92776176b567c4c2200108dc98273d4a1e` |
| `PlonkBLS12381MultiInputParamVerifier` | 4,707 | `7e78ad1bbf6ef553a4401fab1025250f14e3f5271816bcc8a732f38f` |

Note: `Groth16AuthenticatedStateTransitionValidator` was originally `2,817` bytes (`46c77c445f4d16b156797d05aee6964f9c93d7446dd4f12d26824d4d`) under the initial `0.1.0-pre22` migration and was updated in place to `2,845` bytes (`5192732cf2c70ce2f03859f1e9f728d986f6a0e1c18e1a1ab86f8eb2`) when the `continuingOutput.referenceScript().isEmpty()` guard was added.

Downstream validators embedding `BbsProofVerify`, `PedersenG1Lib`, `Groth16BLS12381Lib`, or `PlonkBLS12381Lib` (including `zeroj-integration-tests` example validators and `zeroj-usecases` validators) also receive regenerated UPLC bytes and new script hashes.

## Open questions
Expand Down
Loading
Loading