Skip to content

Conversation

@Rapha-btc
Copy link

No description provided.

@Rapha-btc
Copy link
Author

maybe not necessary after all

@Rapha-btc Rapha-btc closed this Dec 23, 2025
@Rapha-btc Rapha-btc reopened this Dec 23, 2025
@Rapha-btc Rapha-btc changed the title double hash until sip correction secp256r1-verify double-hash behavior on mainnet vs simnet Dec 23, 2025
@Rapha-btc
Copy link
Author

Rapha-btc commented Dec 23, 2025

Question: secp256r1-verify double-hash behavior on mainnet vs simnet

Description:

Tests pass with single-hash in secp256r1-utils.ts:

const createFinalMessageHash = (prefix, domainHash, messageHash) => {
  return createHash("sha256")
    .update(Buffer.concat([prefix, domainHash, messageHash]))
    .digest();  // single hash
};

However, per [stacks-core PR #6763](stacks-network/stacks-core#6763), mainnet's secp256r1-verify has a double-hash bug (fixed in upcoming Clarity 5).

Question for @obycode @friedger:

Does simnet in current Clarinet already have the fix, or does mainnet require double-hash in the frontend?

// If mainnet needs double-hash:
const createFinalMessageHash = (prefix, domainHash, messageHash) => {
  const singleHash = createHash("sha256")
    .update(Buffer.concat([prefix, domainHash, messageHash]))
    .digest();
  return createHash("sha256").update(singleHash).digest();
};

Need to confirm before deploying passkey auth to production.

@Rapha-btc
Copy link
Author

Yes, exactly.

When Clarity 5 ships with Brice's fix:

What Change needed?
CSW Clarity contracts ❌ No changes
Frontend/TypeScript ✅ Update sign() to not pre-hash

The Clarity auth helpers just build a hash. The secp256r1-verify function is what was buggy (hashing twice). Once fixed, the frontend needs to match by only hashing once.

CSW contracts are future-proof. Only the signing code (frontend/tests) needs updating later.

@Rapha-btc Rapha-btc closed this Dec 23, 2025
@Rapha-btc
Copy link
Author

Yes — Brice's fix changes secp256r1-verify to not hash, so the frontend will stop pre-hashing and that's it.

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