Petri Nets as ZK Containers. Visual editor + ZK prover + Solidity generation + .btw DSL.
make run # Serves on :8088
make build # Build binary only
make test # Run testsbitwrap-io also builds under pure-Bzlmod Bazel, mirroring go-pflow and beats-bitwrap-io. go.mod/go.sum stay the source of truth (Gazelle's go_deps reads them), so make build / go test ./... keep working — Bazel is opt-in. Driven by bazelisk (pinned in .bazelversion).
bazel build //... # build everything (runs nogo; builds prover.wasm hermetically)
bazel test //... # all tests — Go targets + 6 pure-JS parity tests
bazel run //:gazelle # regenerate BUILD.bazel after adding/moving .go files
bazel mod tidy # sync go_deps use_repo after editing go.modSecond cross-project consumer on the Bazel graph (go-pflow ROADMAP Phase 1 — confirms the pattern generalizes). Pins mirror go-pflow exactly (rules_go 0.55.1, gazelle 0.44.0, Go SDK 1.24.10, Bazel 7.6.1) since both share the Go 1.24 line — maximizing shared-cache hits once Phase 2 lands. Decisions specific to bitwrap:
- go-pflow is an ordinary registry dep (go.mod pins
v0.9.0, no localreplace), sogo_depsfetches it like any module — no cross-repo wiring (simpler than beats, which uses a local replace). puregotag (.bazelrc) — gnark-crypto asm doesn't resolve in the sandbox; Bazel uses pure-Go field arithmetic.go build/Makefile keep the asm fast path.- Hermetic wasm.
public/embed.goembedsprover.wasm, a 23 MB gitignored artifact normally produced bymake wasm. Under Bazel it's built in the graph://cmd/prover-wasmcarriesgoos=js, goarch=wasm(# keep) so it always cross-builds, and//public:gen_prover_wasmcopies it toprover.wasmfor the embed (# gazelle:exclude prover.wasmkeeps Gazelle off the on-disk copy). Sobazel build //...is self-contained — more hermetic thango build, which needs a priormake wasm. The smallwasm_exec.jsruntime shim is committed (tied to the Go 1.24 line; refreshed bymake wasm). - JS in the graph.
//public:*nodejs_testtargets run the 6 pure-JS parity/smoke checks (coercion, parity, pedersen, seal-cid, sk-creator-store, witness-v3) under a hermetic Node toolchain, via the sharedtools/nodejs_test.bzlrule. The 6 WASM-dependent diagnostics (v3_wasm_*,wasm_load_*,wasm_roundtrip,prover_wasm_circuits_smoke) need a prover.wasm + Go runtime harness and are not yet wired — a known gap. - After editing
go.mod→bazel mod tidy; after adding/moving.gofiles →bazel run //:gazelle.
-port 8088 HTTP port (default 8088)
-data ./data Data directory for CID storage
-no-prover Disable ZK prover (faster startup)
-no-solgen Disable Solidity generation endpoints
-key-dir ./keys Persist circuit keys for fast restarts
-compile path/to/file.btw Compile .btw file to JSON schema on stdout
cmd/bitwrap/main.go— single binary entry pointdsl/— .btw DSL lexer, parser, AST, buildererc/— ERC token standard templates (020, 0721, 01155, 04626, 05725)prover/— ZK circuits (Groth16 via gnark, re-exports from go-pflow)solidity/— Solidity contract generation from metamodel schemasinternal/server/— HTTP handlersinternal/petri/— Petri net model types + execution engineinternal/metamodel/— Schema types (states, actions, arcs, events, constraints)internal/metamodel/guard/— Guard expression parser + evaluatorarc/— Arc-level execution (MiMC Merkle state trees, firing, safe math)internal/seal/— CID computation (JSON-LD canonicalization)internal/store/— Filesystem storageinternal/svg/— SVG generation from Petri net modelspublic/— frontend JS/CSS/HTML (go:embed via public/embed.go)
GET /— landing pageGET /editor— visual Petri net editorGET /remix— Remix IDE pluginPOST /api/save— save JSON-LD, returns{"cid": "..."}GET /o/{cid}— get stored model by CIDGET /img/{cid}.svg— render model as SVGPOST /api/svg— generate SVG from posted JSON-LDGET /api/templates— list ERC templatesGET /api/templates/{id}— get full template modelPOST /api/solgen— generate Solidity from template IDPOST /api/testgen— generate Foundry tests from template IDPOST /api/genesisgen— generate Foundry genesis script from template IDPOST /api/compile— compile .btw DSL source to schema JSONGET /api/circuits— list available ZK circuitsPOST /api/prove— submit witness for ZK proof generationGET /api/vk/{circuit}— download verifying key (binary)GET /api/vk/{circuit}/solidity— download Solidity verifier contract
github.com/pflow-xyz/go-pflow— core prover infrastructuregithub.com/consensys/gnark— ZK proof system (Groth16)github.com/ipfs/go-cid— content addressinggithub.com/piprate/json-gold— JSON-LD canonicalization (URDNA2015)github.com/holiman/uint256— safe 256-bit arithmetic
| URL | Port | Purpose |
|---|---|---|
| bitwrap.io | 8088 | Landing page |
| app.bitwrap.io | 8088 | Editor (redirects to /editor) |
| api.bitwrap.io | 8088 | API endpoints |
| solver.bitwrap.io | 8088 | Remix IDE plugin (redirects to /remix) |
| prover.bitwrap.io | 8088 | ZK prover |
ssh pflow.dev "cd ~/Workspace/bitwrap-io && git pull && make build && ~/services restart bitwrap"