feat: add Ed25519 and Secp256k1 cryptography strategies #20
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: [email protected] (@afeight)