feat: add Ed25519 and Secp256k1 cryptography strategies#20
Closed
feat: add Ed25519 and Secp256k1 cryptography strategies#20
Conversation
Add Swift implementations of Ed25519 and Secp256k1 cryptographic strategies matching the TypeScript implementations in open-signer: Ed25519Strategy: - getPrivateKeyFromSeed(seed: Data) -> Data - getPublicKey(privateKey: Data) -> Data - sign(privateKey: Data, message: Data) -> Data - formatPublicKey(publicKey: Data, encoding: KeyEncoding) -> Ed25519PublicKey - formatSignature(signature: Data, encoding: KeyEncoding) -> Ed25519Signature Secp256k1Strategy: - getPrivateKeyFromSeed(seed: Data) async -> Data - getPublicKey(privateKey: Data) -> Data - sign(privateKey: Data, digest: Data) -> Data - formatPublicKey(publicKey: Data) -> Secp256k1PublicKey - formatSignature(signature: Data) -> Secp256k1Signature Includes comprehensive unit tests for both implementations with real cryptographic signature verification. Co-Authored-By: austin@paella.dev <austin@paella.dev>
Contributor
Original prompt from austin@paella.dev |
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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
Adds Swift implementations of Ed25519 and Secp256k1 cryptographic strategies, porting the functionality from the open-signer TypeScript implementation. This enables native iOS signing without relying on the WebView/iframe approach.
Ed25519Strategy (for Solana):
getPrivateKeyFromSeed(seed:)- Extract 32-byte private key from seedgetPublicKey(privateKey:)- Derive public key (handles 32 or 64-byte keys)sign(privateKey:message:)- Sign arbitrary messagesformatPublicKey/formatSignature- Encode as base58 or hexSecp256k1Strategy (for Ethereum):
getPrivateKeyFromSeed(seed:)- Derive key using SHA-256 with derivation pathgetPublicKey(privateKey:)- Get uncompressed 65-byte public keysign(privateKey:digest:)- Sign 32-byte digest with recovery byte (r+s+v format)formatPublicKey/formatSignature- Encode as hex with 0x prefixReview & Testing Checklist for Human
0x1b/0x1c(27/28) matching Ethereum conventions. Confirm this matches what open-signer expects.Curve25519.Signingis used. Confirm signatures are valid Ed25519 signatures that Solana will accept.Recommended test plan:
Notes
secp256k1-derivation-pathin ASCII, matching the TypeScript implementationswift-secp256k1package dependency for low-level secp256k1 operationsLink to Devin run: https://app.devin.ai/sessions/a80b8782ddae48d681d02ea7065d3b4a
Requested by: austin@paella.dev (@afeight)