npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@umbra-privacy/rn-quick-x25519

v0.0.2

Published

X25519 scalar multiplication for React Native

Downloads

187

Readme

@umbra-privacy/rn-quick-x25519

X25519 scalar multiplication (RFC 7748) for React Native, implemented in C++ via Nitro Modules. The curve arithmetic is a public-domain port of TweetNaCl's crypto_scalarmult_curve25519.

This module is intentionally minimal: it exposes only the raw scalar-mult primitive. Higher-level constructions (X3DH, key derivation, AEAD) are out of scope.

Install

npm install @umbra-privacy/rn-quick-x25519 react-native-nitro-modules
# or
pnpm add @umbra-privacy/rn-quick-x25519 react-native-nitro-modules

react-native-nitro-modules is a peer dependency. iOS requires pod install. Android picks the module up via autolinking.

Usage

import { x25519, X25519_BYTES } from '@umbra-privacy/rn-quick-x25519'

// Synchronous (number[] in/out)
const shared = x25519.scalarMult(privateKey, peerPublicKey)
// shared.length === 32

// Asynchronous (zero-copy ArrayBuffer in/out, runs off the JS thread)
const sharedBuf = await x25519.scalarMultAsync(privateKeyBuf, peerPublicKeyBuf)
// sharedBuf.byteLength === 32

All inputs and outputs are exactly 32 bytes, little-endian. The scalar is clamped per RFC 7748 inside the native code, so callers may pass any 32 random bytes as a private key.

API

x25519.scalarMult(scalar: number[], point: number[]): number[]

Synchronous scalar multiplication. Both arguments must be 32-element arrays of byte values (0–255); throws Error otherwise. Runs on the calling JS thread.

x25519.scalarMultAsync(scalar: ArrayBuffer, point: ArrayBuffer): Promise<ArrayBuffer>

Same operation, but:

  • inputs/outputs are ArrayBuffer (no per-byte marshaling),
  • the curve operation runs on a background thread, so multiple calls awaited via Promise.all parallelize across cores.

Both arguments must have byteLength === 32; the promise rejects otherwise.

X25519_BYTES

Constant 32 — the size of every scalar, point, and shared secret.

Choosing between the two

| | scalarMult | scalarMultAsync | |---|---|---| | Input type | number[] | ArrayBuffer | | Threading | JS thread | worker thread | | Best for | one-off calls, small surfaces | batches, latency-sensitive UI, concurrent operations |

Prefer the async + ArrayBuffer path when doing more than a handful of operations or when the caller already has bytes in a buffer (e.g. from expo-crypto, react-native-quick-crypto, or a fetch response).

Security notes

  • The implementation uses TweetNaCl's constant-time field arithmetic. No data-dependent branches or memory accesses on secret values.
  • The output of scalarMult is not checked against the all-zero shared secret (RFC 7748 §6.1). If your protocol can receive untrusted public keys and is not naturally contributory, perform that check at the protocol layer.
  • Key material in scratch buffers is not zeroized after use. If that matters in your threat model, file an issue — it's a small change to apply across both code paths.

Project layout

License

MIT. The bundled curve25519 code is public domain (TweetNaCl, Bernstein et al.).