NightForge NightForge ← back to homepage

Credential Gate — fail to prove to pass

midnight-credential-gate is a reusable Compact module that lets any DApp gate a circuit on a verifiable credential. The flow below runs end-to-end on Midnight preview: a swap call fails because the caller has no KYC credential, a prove_kyc circuit issues one, and the same swap call then passes. Two on-chain transactions, one Compact assertion, one deployed contract. All three steps are verifiable on the preview indexer.

Checking contract liveness…
Fail Compact assert
swap() reverts
Caller has no credential. The Compact module aborts the circuit at require_credential(subject, claim) before any state change.
Reverted assertion
Credential required
Layer
Compact 0.22 · deterministic, no tx submitted
View Compact source
Prove prove_kyc circuit
Issue credential on chain
The issuer signs and the prove_kyc circuit posts a credential commitment for the subject. Block landed below.
Tx hash
a7de8021…6664ecd1
Block
#467,663
Verify on indexer
Pass swap circuit
swap() lands
Same caller, same arguments, same contract address. The credential is now present, the gate clears, the swap circuit completes.
Tx hash
7b8d8c2d…0bafefc5
Block
#467,673
Verify on indexer

Reproduce locally

Three commands. ~30s on a warm cache.
# clone, install, run the full fail to prove to pass loop git clone https://github.com/cryptoleo79/YAMORI.git cd YAMORI/contracts/credential-gate/deploy npm install && npm run demo:clean
Contract address 7ee02faf5e88911e2f4b12edfb95bb4612282b3ad26536ff9d5ce290fa7a3703copied
Deploy block #454,958
Deploy tx cf00cff58be5300a0d6ea6e42b46a98528de28e3d976e5141bde82f4a21d2c4ecopied
Network Midnight preview
Library midnight-credential-gate · repo

Every value above is either verifiable on the Midnight preview indexer or quoted verbatim from the source repo. The status pill polls /api/credential-gate/liveness every 30 seconds.