Skip to content

feat(contracts,core)!: hash the holder commitment in one SHA-256 block - #318

Draft
nicolasLuduena wants to merge 6 commits into
feat/310-sign-nullifierfrom
feat/311-holder-one-block
Draft

nicolasLuduena wants to merge 6 commits into
feat/310-sign-nullifierfrom
feat/311-holder-one-block

Conversation

@nicolasLuduena

Copy link
Copy Markdown
Member

Closes #311
Part of #309

PR 3 of 6, stacked on #317.

Summary

The holder commitment fits one SHA-256 block. It used to hash a 32-byte padded tag and the secret, 64 bytes over two blocks. It now hashes a 22-byte tag and the secret, 54 bytes in one block, which saves 1,854 rows in verifyAttestation.

 holderCommitment(secret)
-  persistentHash<Vector<2, Bytes<32>>>([pad(32, "thoth:holder-commitment:v1"), secret])   // 64 bytes, 2 blocks
+  persistentHash<HolderPreimage>({ tag: "thoth:holder-commit:v1" (22 bytes), secret })    // 54 bytes, 1 block

 holderCommitmentOf(secret)            // @txpipe/thoth-core/claim-context
-  persistentHash(Vector<2, Bytes<32>>, [padded tag, secret])
+  sha256(tag ‖ secret)

The vault pseudonym (deriveHolder, hashToCurve over thoth:holder:v1) does not change, so one secret still gives unrelated values in the two roles. The vault, the claim id, byte slots and the signature check are untouched.

Evidence

  • Before: the new holder-parity.test.ts property ("a plain SHA-256 of the tag then the secret, in one block") failed against the old circuit.
    After: it passes for 202 secrets (all zeros, all 0xff, 200 seeded random ones), and so does the core-vs-circuit parity over the same secrets. The existing rejects a caller who does not know the signed holder secret test still throws Holder mismatch. npm test passes (821 passed, 4 skipped), and so do npm run types and npm run check.

npm run bench (Ryzen 7 5700G, proof server 9.0.0, 3 warm runs). Every circuit of both mocks proved, every proof verified against its verifier key, and the server refused the wrong-key control.

Mock Circuit k Rows before Rows after Warm proof before (s) Warm proof after (s)
mock_attestation verifyAttestation 15 23,107 21,253 2.54 2.50
mock_attestation openAndRead 14 8,610 8,610 1.16 1.15
mock_attestation openAndReadPresence 14 8,580 8,580 1.15 1.17
mock_attestation openAndRequireMetric0 14 8,570 8,570 1.16 1.15
mock_attestation openAndBindHost 14 14,633 14,633 1.22 1.22
mock_attestation_bytes verifyAttestation 15 26,930 25,076 2.58 2.55
mock_attestation_bytes openAndReadBytes 15 19,188 19,188 2.25 2.22

k does not change yet; #312 to #314 bring verifyAttestation to k = 14. The contracts README table is regenerated from this run.

No verification skill in this repo.

Merge Danger

Door: two-way

Pre-launch, nothing is deployed. Reverting restores the old tag.

Blast Radius: holders

Every holder commitment changes value. A claim built with an older @txpipe/thoth-core fails Holder mismatch against a contract from this release. Changesets for core and contracts say so.

The commitment is SHA-256 of the 22-byte tag thoth:holder-commit:v1, then the secret: 54 bytes, one block instead of two. A test pins it to a plain SHA-256 and checks the core mirror against the circuit over seeded random secrets.
@coderabbitai

coderabbitai Bot commented Nov 27, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

…nt docs

Seed the pseudonym separation test from THOTH_SEED so a failure replays.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant