Repository navigation
feat(contracts,client)!: the registry checks the N named signatures - #321
Draft
nicolasLuduena wants to merge 14 commits into
Draft
nicolasLuduena wants to merge 14 commits into
nicolasLuduena wants to merge 14 commits into
Conversation
The registry verifies exactly N signatures, each with the standard library's jubjubSchnorrVerify against the key of the registry slot it names, instead of one signature per registry slot. Slots must strictly increase, be in range and hold a key; the key is selected by reading every slot, so the proof does not reveal which attestors signed. The signatures move to their own witness, getSignatures, so the open circuits no longer take them.
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
lolaaimar
reviewed
Dec 1, 2026
| /// ledger operation depends on which slots are named. | ||
| export circuit requireSignatures<#N>(msg: Vector<7, Field>, sigs: Vector<N, SlotSignature>): [] { | ||
| // order[1] is one past the last slot seen; a Uint<17> holds 65,536. | ||
| const order = fold((acc: [Boolean, Uint<17>], s: SlotSignature) => |
Contributor
There was a problem hiding this comment.
For N = 0 the fold returns [true, ...] allowing an unsigned claim to be vaulted.
Proposed fix: assert(N > 0, "Threshold must be positive"); either here or on initRegistry to fail on deploy.
…ures # Conflicts: # packages/client/README.md # packages/contracts/README.md # packages/zk-tls/README.md
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #314
Closes #309
PR 6 of 6 of spec #309, stacked on #320 (
feat/313-whole-byte-slots).Summary
The registry checks only the N signatures the prover names. Before, it checked one signature for each of the M slots. Each signature is still verified with the standard library's
jubjubSchnorrVerify. The slots are private inputs.What the client hands over:
named signaturessuite inregistry.test.ts, the client'sslot-signatures.test.ts, and every other suite moved to the named shape (atSlots,signClaimwithnullfor a slot that does not sign). The two acceptance tests useslotSignaturesOf; the benchmark's captures build the same named entries with the test helperssignClaimandatSlots.registryIndexinvariant and mock descriptions inAGENTS.md,DESIGN.md, the kind author guide, the root, contracts, client and zk-tls READMEs, and both kinds' dApp guides.Evidence
After: exactly N signatures from distinct slots, with no dummy, for 2-of-3:
npm test: 849 passed, 4 skipped (the opt-in live checks), both acceptance tests included.npm run typesandnpm run checkpass, and the pre-push hook ran the whole suite green.Privacy, checked on the compiled circuit, not only the source. I wrote a taint pass over each circuit's zkir. It marks the
getSignaturesprivate inputs (%sigs.*) and follows them through every instruction. In both mocks'verifyAttestation, it finds 6 signature inputs and 64 values that depend on them. None of those values reaches animpact(a ledger operation), apublic_inputor a guard. The open circuits have no signature inputs at all. As a control, I compiled a throwaway copy that writes a slot to a ledger field, and the pass flagged twoimpacts there. The generated contract code readskeysonce, as a whole vector. In the simulator, two submissions of one claim from slots {0,1} and {1,2} produce identicalpublicTranscript,inputandoutput(the last test above).Benchmark (
npm run benchunder the prove lock; Ryzen 7 5700G, 16 threads, proof server 9.0.0, 3 warm proofs). Every circuit of both mocks proved, and the proof server verified each proof. It refused a proof under the wrong verifier key. No open circuit crashed the prover: they still hold thehashToCurvevault pseudonym.Before (#320):
After (this PR; also in the contracts README's "Proving cost"):
verifyAttestationdrops by 1,469 rows on the numeric mock and 1,470 on the bytes mock. The bytes mock now has 2,261 rows of headroom under 16,384, where it had 791. Each open circuit loses the 18 rows its unused signature inputs cost. Proof size is 5,772 B throughout.The spec's row targets, with the final numbers:
verifyAttestation, both mocksk = 17)k = 14)k = 14)openAndRead,openAndReadPresence,openAndRequireMetric0k = 14)k = 13)k = 13)openAndReadBytesk = 15)k = 14)k = 14)No verification skill in this repo.
Not verified: the live zkFetch and Cardano checks (opt-in, need real witnesses or endpoints). I also did not test, at the prover level, a signature whose response is malleated past the Jubjub order. The client and the circuit both use the standard library's verify, and the simulator accepts exactly what
jubjubVerifieraccepts in the acceptance tests.Merge Danger
Door: two-way
Nothing is deployed and the claim's
versionstays1. Reverting restores the per-slot registry.Blast Radius: consumers
Every dApp's witnesses change:
getAttestationWitnessreturns only the claim, and a newgetSignaturesreturns exactly N{ registryIndex, signature }entries in slot order. A contract compiled from this release rejects the old[claim, Vector<M, sig>]witness at the type check. One invalid signature now fails the proof instead of not being counted, sothresholdmust equal the contract's N.