Skip to content

Repository files navigation

curve25519-helpers

Small TypeScript helpers for working with curve25519 / X25519 / base58 in the browser and Node. Thin wrappers around @noble/curves.

Install

npm install @zksend/curve25519-helpers

API surface

  • bs58encode(bytes) / bs58decode(str) — base58 without Buffer
  • edwardsToMontgomeryPub(pub) — point form conversion
  • clampScalar(bytes) — RFC 8032 §5.1.5 clamping
  • ecdhSharedSecret(scalar, peerPub) — DH on ed25519

Why

The Solana ecosystem standard for crypto is @noble/curves. This package adds a few project-specific helpers used across ZKSend repos.

License

MIT

API

Function Returns Notes
bs58encode(bytes) string matches bs58 package
bs58decode(str) Uint8Array throws on invalid char
concatBytes(...) Uint8Array one-shot concat
clampScalar(seed) Uint8Array RFC 8032
ecdhSharedSecret(scalar, peer) Uint8Array Edwards-direct

API

Function Returns Notes
bs58encode(bytes) string matches bs58 package
bs58decode(str) Uint8Array throws on invalid char
concatBytes(...) Uint8Array one-shot concat
clampScalar(seed) Uint8Array RFC 8032
ecdhSharedSecret(scalar, peer) Uint8Array Edwards-direct

Example: browser-safe base58

import { bs58encode, bs58decode } from "@zksend/curve25519-helpers";

const addr = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
const bytes = bs58decode(addr);          // Uint8Array(32)
const back  = bs58encode(bytes);          // === addr

No Buffer. Works in any browser, Bun, Deno, Node 18+.

Example: browser-safe base58

import { bs58encode, bs58decode } from "@zksend/curve25519-helpers";

const addr = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
const bytes = bs58decode(addr);          // Uint8Array(32)
const back  = bs58encode(bytes);          // === addr

No Buffer. Works in any browser, Bun, Deno, Node 18+.

References

References

About

small TypeScript helpers for curve25519 / X25519 / base58 — used by stealth-core

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages