Skip to content

Conversation

@lcovar
Copy link
Contributor

@lcovar lcovar commented Jan 14, 2026

Implement the initial wasm-solana package to support Solana address generation using Rust compiled to WebAssembly. This is the first phase of replacing JavaScript Solana dependencies (@solana/web3.js, tweetnacl) with secure Rust implementations to mitigate npm supply chain attack risks.

Architecture follows wasm-utxo patterns:

  • Two-layer Rust design: core logic (src/.rs) + thin WASM wrappers (src/wasm/.rs)
  • TypeScript wrappers (js/*.ts) providing idiomatic camelCase APIs
  • Comprehensive test suite with BitGoJS compatibility tests

Components added:

  • Keypair: Ed25519 keypair generation from random or 32/64-byte secret keys
  • Pubkey: Base58 encoding/decoding for Solana addresses
  • Error handling using js_sys::Error for proper JS exceptions

Build tooling:

  • Cargo.toml with wasm-bindgen, solana-client-wasm, ed25519-dalek
  • Makefile matching wasm-utxo's wasm-pack workflow
  • TypeScript configs for ESM and CJS output

Verified compatibility with BitGoJS sdk-coin-sol test vectors to ensure byte-identical address derivation from the same secret keys.

Ticket: BTC-2927

@lcovar lcovar marked this pull request as ready for review January 14, 2026 06:30
@lcovar lcovar requested a review from a team as a code owner January 14, 2026 06:30
@lcovar lcovar marked this pull request as draft January 14, 2026 06:59
Implement wasm-solana package for Solana address generation using official
Solana SDK crates (solana-pubkey, solana-keypair) compiled to WebAssembly.
This is Phase 1 of replacing JavaScript Solana dependencies to mitigate
npm supply chain attack risks.

Architecture follows wasm-utxo patterns:
- Core types wrap official Solana SDK with extension traits (PubkeyExt, KeypairExt)
- Thin WASM bindings (src/wasm/*.rs) expose types to JavaScript
- TypeScript wrappers (js/*.ts) provide idiomatic camelCase APIs

Components:
- Pubkey: base58 encoding/decoding, is_on_curve() for PDA detection
- Keypair: creation from 32-byte seed or 64-byte Solana secret key format

Build tooling:
- Makefile matching wasm-utxo's wasm-pack workflow
- TypeScript configs for ESM and CJS output

Verified compatibility with BitGoJS sdk-coin-sol test vectors.

Ticket: BTC-2927
@lcovar lcovar marked this pull request as ready for review January 14, 2026 08:45
Copy link
Contributor

@OttoAllmendinger OttoAllmendinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

Copy link
Contributor

@OttoAllmendinger OttoAllmendinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually you need to include the package in the github action test matrix

Comment on lines +2 to +5
"name": "@bitgo/wasm-solana",
"description": "WebAssembly wrapper for Solana cryptographic operations",
"version": "0.0.1",
"type": "module",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you have to set this to private: true for now, otherwise we'll break the publish action

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.

3 participants