test(p2bk): pin the NUT-28 example proofs and V4 token vector - #786
Merged
Conversation
Pins the P2PK and HTLC example proofs from the NUT-28 test vectors through the wallet derive/sign/verify path, and the example V4 token through decode and byte-stable re-encode (pe and dleq wire format). Adds an HTLC P2BK integration test (hashlock unblinded at slot 0, lock key at slot 1, receive with preimage). The ITest slot check now uses deriveP2BKSecretKeys, which has no legacy slot 0 fallback, in place of hand-rolled ECDH; the derivation itself is anchored by the fixed vectors in the unit tests.
3 tasks
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #786 +/- ##
==========================================
+ Coverage 95.26% 95.32% +0.05%
==========================================
Files 54 54
Lines 5175 5175
Branches 1284 1284
==========================================
+ Hits 4930 4933 +3
Misses 105 105
+ Partials 140 137 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
42 tasks
69 tasks
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.
Summary
Pins the NUT-28 test vectors (cashubtc/nuts#402) in three layers, so a symmetric sender/receiver drift cannot pass by self-consistency:
test/crypto/NUT28.test.ts): the P2PK and HTLC example proofs verbatim, throughmaybeDeriveP2BKPrivateKeys,signP2PKProofand spend verification. The HTLC proof pins the slot order fixed in fix(p2bk): align HTLC key slots with the [data, ...pubkeys, ...refund] order (NUT-28) #763: hashlock at slot 0 unblinded,pubkeyskey at slot 1,refundkey at slot 2, spendable via both pathways.test/utils/core.test.ts): the example V4 token decodes to the exact proofs (includingdleqandp2pk_e) and re-encodes byte-for-byte, pinning thepe/dwire format against cross-wallet drift. The vector's CBOR was verified independently of this library.test/integration.test.ts): newsend and receive p2bk HTLCround trip (mint, HTLC blindKeys send, receive with privkey plus preimage witness). The sharedexpectP2BKLockedToBobhelper replaces the hand-rolled ECDH check and usesderiveP2BKSecretKeysdirectly, which has no legacy slot 0 fallback, so a sender regression to slot 0 blinding fails the assertion even though receive would still work via the fallback.Also drops a DLEQ reblind check that belonged to NUT-12, not P2BK.
Tests
npm run prtaskspasses (195 files). Full integration suite passes against a fresh CDK 0.17.2 mint (46/46).