fix(core): canonicalize P2PK keys with legacy aliases#308
Draft
Egge21M wants to merge 4 commits into
Draft
Conversation
🦋 Changeset detectedLatest commit: 70082b0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 8 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #308 +/- ##
==========================================
+ Coverage 88.27% 88.28% +0.01%
==========================================
Files 131 131
Lines 18208 18234 +26
==========================================
+ Hits 16073 16098 +25
- Misses 2135 2136 +1
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:
|
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.
Replaces #121 with the original two commits rebased onto current
master. Their author metadata remains attributed tolescuer97.Problem
Older coco versions serialized every P2PK key as
02 + x-only key. That remains valid for BIP340 verification, but odd-Y keys do not match the canonical compressed SEC1 identity emitted by CDK and required by the deterministic derivation vectors.Changing the serialized identity without an alias layer would strand existing persisted keys and proofs after an upgrade or seed-based keyring restore.
Summary
02or03SEC1 prefix, matching CDK and the deterministic vectors@cashu/coco-coreExisting legacy rows remain unchanged. The upgraded keyring accepts either encoding and returns the persisted keypair with its stored identity.
References:
Verification
bun run --filter='@cashu/coco-adapter-tests' buildbun run --filter='@cashu/coco-core' typecheckbun run --filter='@cashu/coco-core' test:unit(1,011 passed)bun run --filter='@cashu/coco-core' test -- test/unit/KeyRingService.test.ts(46 passed)bun run docs:buildbunx prettier --check packages/core/services/KeyRingService.ts packages/core/api/KeyRingApi.ts packages/core/test/unit/KeyRingService.test.ts packages/docs/pages/keyring.md .changeset/canonical-p2pk-keys.md