Repository navigation
test: property-based tests for the off-chain/circuit parity checks - #299
Closed
nicolasLuduena wants to merge 2 commits into
Closed
nicolasLuduena wants to merge 2 commits into
nicolasLuduena wants to merge 2 commits into
Conversation
Generate claims, subjects, holder secrets, addresses and canonical values with fast-check, and check encoder and hash parity against the compiled mock circuits, message injectivity, canonical JSON, and the schema to encoder round trip. Remove the hand-picked cases the properties cover.
Change one claim field at a time in most injectivity pairs and change every byte of every 32-byte field, so a field or byte the encoder drops fails the property. Pair policy values with one-step edits and reversed arrays, so lost array order or dropped nulls fail the canonical JSON property. Name the shared generators for what they produce and share the header field table.
nicolasLuduena
marked this pull request as draft
November 25, 2026 05:00
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 #298.
Stacked on #281 (stack: #291 → #292 → #293 → #294 → #285 → #283 → #282 → #281 → this). Test-only: no production code, wire layout or schema changes.
Summary
fast-check generates the inputs for each check, and a failure shrinks to a minimal counterexample. fast-check is a dev dependency of
core,contractsandcardanoonly.claimToMessage(claim)equalsmessage(toContractClaim(claim))contracts/test/parity.test.tsMockAttestation(V=3, W=0) andMockAttestationBytes(V=3, W=1)subjectHashOf,holderCommitmentOfandcardanoAddressHashOfmatch their circuitssubject-parity,holder-parity,cardano/.../address-paritycore/test/claim.test.tscore/test/claim-context.test.tsclaimSchemaaccepts encodes, and each field fits its Compact typecore/test/claim.test.tsGenerated claims follow the
presentmask semantics: an absent slot carries zero, and a measured slot may still hold0.Decisions the issue left open
Bytes<L>, always changes the digest.seedandpathon failure. Pass both tofc.assertto replay a failure.AGENTS.mdnow says so.-0and0share one serialization. That is the documented encoding, so property 4 treats those pairs as the same data. Two policies of one kind could share a hash only if a field's schema accepted both a bigint and a string. I did not file a bug for this.Removed, because a property now covers them: the 11-claim parity list and its
toContractClaimloop, the fixed subject and holder samples, the single-address witness case, the window-swap and flip-every-byte circuit tests, the bytes round-trip and B = 0 parity cases, and the key-order and array-order policy examples.Kept, because they pin a specific vector: the B = 0 vault id, the known-answer subject, holder and
bakedHashdigests, the absent-half and zero-padding cases inbytes.test.ts, and the wire-position pins inattestation.test.tsandclaim.test.ts.Evidence
No verification skill in this repo, so the test runs below are the evidence.
Before: 776 passed, 4 skipped. The hand-picked samples checked one claim list, one address and one byte-flip loop.
After: 776 passed, 4 skipped (the opt-in live checks), at the pushed head
9127a17.npm run typesandnpm run checkpass. The properties run 100 cases each (20 for the byte sweep) and add about 0.3 s in total.Breaking
claimToMessage's field order on purpose fails property 1 (not committed):Mutation runs (each break applied to
packages/core/src, then restored from git):windowStartwritten twice,windowEndlostnulldropped from arraysMerge Danger
Door: two-way
Blast Radius: tests
Only test files, the three dev dependencies and one
AGENTS.mdparagraph change. Seeds are random, so a property can fail on a seed that has never run before. When that happens, the printedseedandpathreplay it.