# supercop

> cross-compiled javascript implementation of ed25519 based on supercop-ref10

Latest version **3.0.3** (published 2026-03-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install supercop
pnpm add supercop
yarn add supercop
bun add supercop
```

## Health

**Score 65/100 (B)** — status: stable.

Positive: has types; esm support; no vulnerabilities; has provenance; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 3.0.3 |
| Published | 2026-03-14 |
| First published | 2019-06-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 198.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 1 |
| Author | Yersa Nordman |
| Maintainers | finwo |
| Keywords | ed25519, supercop, ref10, elliptic, curve, webassembly |

## Links

- npm: https://www.npmjs.com/package/supercop
- Repository: https://github.com/finwo/supercop
- Issues: https://github.com/finwo/supercop/issues
- Funding: https://github.com/sponsors/finwo
- npm.io page: https://npm.io/package/supercop

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 3.0.3 (latest) — 2026-03-14
- 3.0.2 — 2024-05-23
- 3.0.1 — 2023-06-09
- 3.0.0 — 2023-05-30
- 2.2.6 — 2023-04-03
- 2.2.5 — 2021-08-25
- 2.2.4 — 2021-08-22
- 2.2.3 — 2021-08-18
- 2.2.2 — 2021-06-18
- 2.2.1 — 2021-02-17
- 2.2.0 — 2021-02-17
- 2.1.3 — 2020-08-10
- 2.1.2 — 2020-08-10
- 2.1.1 — 2020-08-10
- 2.1.0 — 2020-08-09
- … 26 more at https://npm.io/package/supercop/versions

## README

# supercop

ed25519 curve operations using [orlp/ed25519](https://github.com/orlp/ed25519) patched and compiled into WebAssembly.

## TL;DR;

For when you don't want to dig through the whole API reference

```typescript
import { createSeed, KeyPair } from 'supercop';

// Create keypairs, usable for keyExchange, signing and verifying
const alice   = await KeyPair.create(createSeed());
const bob     = await KeyPair.create(createSeed());
const charlie = await KeyPair.from(JSON.parse(fs.readFileSync('path-to-file.json')));

// Save bob's key, will become charlie's key in the next run
fs.writeFileSync('path-to-file.json', JSON.stringify(bob));

// Public-only keypairs are possible, usable only for:
// - Verifying a signature
// - Remote side of key exchange
const alicePub = KeyPair.from({ publicKey: alice.publicKey });
const bobPub   = KeyPair.from({ publicKey: bob.publicKey   });

const message = "Hello World!";

// Alice signing the message with her key
const signature = await alice.sign(message);

// Bob verifying the message came from alice
const isValid = await alicePub.verify(signature, message);
console.log({ isValid }); // outputs true

// Generate shared keys on both ends
const aliceShared = await alice.keyExchange(bobPub);
const bobShared   = await bob.keyExchange(alicePub);

// Proof both keys are the same
console.log(Buffer.compare(aliceShared, bobShared) == 0); // outputs true
```

## About

This package provides ed25519/ref10 operations from orlp's implementation into JavaScript/TypeScript in an unopiniated way.

The patching applied is so we can compile it with without relying on emscriptem, but instead go purely for [clang](https://clang.llvm.org/).


## API reference / exports

### type PublicKey: Buffer

Represents a public key in a keypair, simply a 32-byte buffer

### type SecretKey: Buffer

Represents a secret key in a keypair, simply a 64-byte buffer

### type Seed: Buffer

Represents a seed to build a keypair from, simply a 32-byte buffer

### type Signature: Buffer

Represents a signature you can use to verify a message, simply a 64-byte buffer

### function isSeed(data: unknown): data is Seed

Returns whether or not a piece of data can be used as a seed

### function isPublicKey(data: unknown): data is PublicKey

Returns whether or not a piece of data can be used as a public key

### function isSignature(data: unknown): data is Signature

Returns whether or not a piece of data can be used as a signature

### function isSecretKey(data: unknown): data is SecretKey

Returns whether or not a piece of data can be used as a secret key

### function createSeed(): Buffer

Uses `Math.random` to generate a new key. Only use this as a last resort, as `crypto.randomBytes(32)` provides better randomization.

### function createKeyPair(seed: number[] | Seed): Promise&lt;KeyPair&gt;

Build a new KeyPair instance from the given seed.

### function keyPairFrom({ publicKey: number[] | PublicKey, secretKey?: number[] | SecretKey }): KeyPair

Constructs a new KeyPair instance from the key(s) provided you can use to operate with.

### function sign(message: string | Buffer, publicKey: number[] | PublicKey, secretKey: number[] | SecretKey): Promise&lt;Signature&gt;

Sign a message with the given keys, so it can be verified later

### function verify(signature: number[] | Signature, message: string | Buffer, publicKey: number[] | PublicKey): Promise&lt;boolean&gt;

Verify a message/signature combination using the given public key

### function keyExchange(theirPublicKey: number[] | PublicKey | undefined, ourSecretKey: number[] | SecretKey): Promise&lt;Buffer&gt;

Generate a shared secret between 2 key pairs to use as seed for a symmetric encryption algorithm

### class KeyPair

```typescript
class KeyPair {

    // Calls the sign function with the keys stored in the entity
    sign(message: string | Buffer): Promise<Buffer>;

    // Calls the verify function with the keys stored in the entity
    verify(signature: number[] | Signature, message: string | Buffer): Promise<boolean>;

    // Performs key exchange algorithm between the local key and the given key
    // Assumes the local key is 'our' key
    keyExchange(theirPublicKey?: number[] | PublicKey): Promise<Buffer>;

    // Converts the key into something storable to be reconstructed in a later run
    toJSON(): {
        publicKey: number[] | undefined;
        secretKey: number[] | undefined;
    };

    // Generate a (new) keypair from the given seed
    static create(seed: number[] | Seed): Promise<KeyPair>;

    // Reconstruct a keypair from the given data, compatible with the toJSON output format
    static from(data: {
        publicKey: number[] | PublicKey;
        secretKey?: number[] | SecretKey;
    }): KeyPair;
}
```

---
_Source: https://npm.io/package/supercop · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
