Skip to content

ODATANO/NIGHTPASS

Repository files navigation

NIGHTPASS - Digital Battery Passport on Midnight

alt text

EU Battery Regulation 2023/1542 Digital Battery Passport with three disclosure tiers, backed by zero-knowledge attestations on Midnight.

Tests codecov @odatano/nightgate SAP CAP Midnight Midnight Catena-X

NIGHTPASS implements the EU Battery Passport. One dataset is exposed with a different view per audience (consumer, recycler, authority), and sensitive numbers (for example "recycled cobalt share is at least the legal minimum") can be proven without revealing the value. Only a payload hash and public metadata are anchored on-chain; everything else stays encrypted off-chain, and the disclosure tier is enforced in the API layer.

It consumes @odatano/nightgate as a CAP plugin, which provides the contract, the ZK proof library, and the Nightgate worker for async on-chain submission.

NIGHTPASS passes the official BatteryPass-Ready test environment (GEFEG / Fraunhofer IPK, DIN DKE SPEC 99100): zero-error data validation and all 11 interoperability scenarios of the DPP Life Cycle API, including the access-rights checks, verified 2026-07-17. On top of the standard API, a NIGHTPASS extension (GET /dpp-api/v1/dpps/{id}/verification) lets any caller verify a served passport live against its Midnight anchor.

How it works, in short

  • Disclosure tiers (Annex XIII): consumer sees public metadata, recycler additionally chemistry / capacity / recycled shares, authority everything including supplier identities. Enforced server-side by after READ handlers; an active on-chain disclosure grant elevates a partner's tier per passport.
  • Field-bound ZK predicates: claims like carbon footprint <= threshold are proven on-chain without revealing the value, bound to a Merkle root over the passport's fields anchored at attest time, so the proven value provably comes from this passport.
  • One contract, attestation-vault (shipped by the plugin): attest, passport binding, disclosure ACL, content-root anchoring, field-bound predicates.
  • Two submit paths to the same contract: server (NIGHTGATE worker wallet, async jobs) or wallet (the user's own Lace via DApp-Connector). Offline-first: without a session or contract, actions land as local log rows and everything still works.
  • Catena-X: the cockpit exports the CX-0143 battery-passport aspect JSON and a Predicate Attestation Credential (PAC), carrying the proven predicates with valueDisclosed: false. That predicate capability is what Tractus-X currently lacks.

Live example (Midnight preview)

One passport, end to end: BAT-FRESH-20260717125619, created through the standard producer flow (all 65 guide attributes seeded automatically and included in the anchored payload hash), zero-error validated by the official BatteryPass-Ready test environment, then server-signed, anchored and predicate-proven on Midnight preview on 2026-07-17. verifyOnChain confirms the anchor live against the indexer. The proof transactions prove each claim against the passport's anchored content root; the value enters only as a private witness, and the ledger accepts the transaction only if the in-circuit asserts hold, so an included tx IS the verified proof.

Step Transaction
attest (payload hash into the vault) 6071a396...248673b8
bindPassport (passport id -> payload hash) 374c61d9...e0df2cb4
anchorContentRoot (Merkle root over provable fields) f7f10047...6512a0aa
prove: carbon footprint <= 4000 kg CO2e (value hidden) 771e6b7f...171581e2
prove: recycled cobalt share >= 16 % (value hidden) f632a4fc...9bdda074
prove: usable capacity >= 70 kWh (value hidden) 33cffbeb...41dfa669

Vault contract: f7c755235cc9408bc6664f7cae88b445798726ccdf9a6a560e7c873c807aabe1. (Each proof run also re-anchors the content root before proving, an idempotent write of the same root value; those bookkeeping transactions are omitted here. The Midnight preview testnet was reset on 2026-07-16; this example lives on the current network.)

Documentation

Doc Contents
docs/producer-flow.md Step-by-step lifecycle: which steps produce transactions and why, how to read them in the explorer, live Preview transactions, glossary
docs/producer-walkthrough.md Producer cockpit with screenshots, tab by tab
docs/architecture.md Layers, data flow, security model, field-bound proof construction, plugin build & deploy

Quick start

Requires Node.js >= 22

npm install            # postinstall generates @cds-models and builds the connector lib
cp .env.example .env   # set ENCRYPTION_KEY (.env is gitignored)
npm run deploy         # creates db/passport.db: domain tables + the midnight_* plugin tables
npm start              # cds-tsx serve  ->  http://localhost:4004

Open http://localhost:4004/ for the launchpad.

Apps and services on :4004

Surface Path
Producer cockpit (create, attest, disclose, prove; in-app Lace wallet flow) /producer/webapp/index.html
Consumer passport viewer (3 tiers) /passport/webapp/
Passport Explorer (public, block-explorer style, live verification) /explorer/
MockSapService (goods-receipt feed) /api/v1/mock-sap
ProducerService /api/v1/producer
PassportService /api/v1/passport
NightgateService (+ indexer / analytics / admin) /api/v1/nightgate

Scripts

Command What it does
npm start Serve via cds-tsx serve
npm run deploy Deploy the merged model to db/passport.db
npm run build:connector-lib Build the connector into app/connector/lib (self-contained ESM, WASM inlined)
npm run producer:smoke Producer cockpit offline-path smoke test
npm run pac:demo Build a PAC and verify it (tractusx/pac/)

About

EU Battery Passport (Reg. 2023/1542) consumer app: SAP CAP service with three disclosure tiers, backed by Midnight ZK attestations via @odatano/nightgate

Topics

Resources

Stars

6 stars

Watchers

0 watching

Forks

Contributors