# @bitcoinerlab/secp256k1

> A library for performing elliptic curve operations on the secp256k1 curve. It is designed to integrate into the BitcoinJS & BitcoinerLAB ecosystems and uses the audited noble-curves library. It is compatible with environments that do not support WASM, suc

Latest version **2.0.0** (published 2026-08-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install @bitcoinerlab/secp256k1
pnpm add @bitcoinerlab/secp256k1
yarn add @bitcoinerlab/secp256k1
bun add @bitcoinerlab/secp256k1
```

## Health

**Score 60/100 (C)** — status: active.

Positive: has types; no vulnerabilities; recently updated; high quality score.

Warnings: low downloads; no esm support; large bundle.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2026-08-17 |
| First published | 2023-01-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=20.19.0 |
| Dependencies | 1 |
| Unpacked size | 10 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Jose-Luis Landabaso |
| Maintainers | jl.landabaso |
| Keywords | secp256k1, noble, bitcoinjs, ecpair, bip32, factory, no-WASM, pure-Javascript |

## Links

- npm: https://www.npmjs.com/package/@bitcoinerlab/secp256k1
- Repository: https://github.com/bitcoinerlab/secp256k1
- Homepage: https://bitcoinerlab.com/secp256k1
- Issues: https://github.com/bitcoinerlab/secp256k1/issues
- npm.io page: https://npm.io/package/@bitcoinerlab/secp256k1

## Dependencies (1)

- [@noble/curves](https://npm.io/package/@noble/curves.md) ^2.3.0

## Recent versions

- 2.0.0 (latest) — 2026-08-17
- 1.2.0 — 2024-12-13
- 1.1.1 — 2024-02-09
- 1.1.0 — 2024-02-09
- 1.0.5 — 2023-07-10
- 1.0.4 — 2023-06-28
- 1.0.3 — 2023-06-28
- 1.0.2 — 2023-02-15
- 1.0.1 — 2023-01-10
- 1.0.0 — 2023-01-09

## README

<!--Related:
https://github.com/paulmillr/noble-secp256k1/issues/73
https://github.com/bitcoinjs/ecpair/issues/13
https://github.com/bitcoinjs/ecpair/pull/11
https://github.com/bitcoinjs/tiny-secp256k1/issues/91
https://github.com/bitcoinjs/tiny-secp256k1/issues/84#issuecomment-1210013688
Test this: https://github.com/spsina/bip47
-->

# Secp256k1

@bitcoinerlab/secp256k1 is a Javascript library for performing elliptic curve operations on the secp256k1 curve. It is designed to integrate into the [BitcoinJS](https://github.com/bitcoinjs) and [BitcoinerLAB](https://bitcoinerlab.com) ecosystems and uses the audited [noble-curves library](https://github.com/paulmillr/noble-curves), created by [Paul Miller](https://paulmillr.com/noble/).

 This library is compatible with environments that do not support WebAssembly, such as React Native.

## Features

- Compatible with BitcoinJS [ecpair](https://github.com/bitcoinjs/ecpair) and [bip32](https://github.com/bitcoinjs/bip32) Factory functions.
- Based on audited code [@noble/curves](https://github.com/paulmillr/noble-curves).
- Can be used in environments that do not support WASM, such as React Native.
- Uses the same tests as [tiny-secp256k1](https://github.com/bitcoinjs/tiny-secp256k1).

## Installation

To install the package, use npm:

```
npm install @bitcoinerlab/secp256k1
```

Version 2 requires Node.js 20.19 or newer. The package keeps its CommonJS entry point while using the ESM-only `@noble/curves` version 2 dependency.

## Usage

### API

This implementation follows the tiny-secp256k1 API. Please refer to [tiny-secp256k1](https://github.com/bitcoinjs/tiny-secp256k1#documentation) for documentation on the methods.

- **`xOnlyPointAddTweakCheck`**: This method is not yet implemented. It is not used in `ecpair` or `bip32`.

- **`signSchnorr`**: Starting from version 1.2.0, this function deviates from the exact behavior mapping with [`bitcoinjs/tiny-secp256k1`](https://github.com/bitcoinjs/tiny-secp256k1) and no longer initializes the auxiliary random data parameter (`e`) to a zero-filled array by default. Instead, it requires the caller to explicitly provide randomness if desired. If omitted, the underlying implementation uses cryptographically secure randomness (through `crypto.getRandomValues`). For more details on this change, see the discussion [here](https://github.com/bitcoinerlab/secp256k1/pull/10#discussion_r1876541974) and the conclusions [here](https://github.com/bitcoinerlab/secp256k1/pull/10#issuecomment-2537916286).

### Examples

You can test the examples in this section using the online playground demo available at https://bitcoinerlab.com/modules/secp256k1.

```javascript
import ecc from '@bitcoinerlab/secp256k1';
import { BIP32Factory } from 'bip32';
import { ECPairFactory } from 'ecpair';
const BIP32 = BIP32Factory(ecc);
const ECPair = ECPairFactory(ecc);

const keyPair1 = ECPair.fromWIF(
  'KynD8ZKdViVo5W82oyxvE18BbG6nZPVQ8Td8hYbwU94RmyUALUik'
);
const node = BIP32.fromBase58(
  'xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi'
);
```

### Usage with React Native

`@noble/curves` uses Javascript `BigInt`, which is fully supported in React Native on iOS. However, to use it on Android, you must make sure you use the Hermes Javascript Engine, available from [RN-0.70 release](https://github.com/facebook/hermes/issues/510).

Noble uses `crypto.getRandomValues` for operations such as Schnorr auxiliary randomness and scalar blinding. React Native environments that do not provide it must install a compatible polyfill such as [`react-native-get-random-values`](https://github.com/LinusU/react-native-get-random-values).

## Authors and Contributors

The project was initially developed and is currently maintained by [Jose-Luis Landabaso](https://github.com/landabaso). Contributions and help from other developers are welcome.

Here are some resources to help you get started with contributing:

### Building from source

To download the source code and build the project, follow these steps:

1. Clone the repository:

```
git clone https://github.com/bitcoinerlab/secp256k1.git
```

2. Install the dependencies:

```
npm install
```

3. Build the project:

```
npm run build
```

This will build the project and generate the necessary files in the `dist` directory.

### Testing

Before committing any code, make sure it passes all tests by running:

```
npm run test
```

## Licensing

This project is licensed under the MIT License.

## Acknowledgments

Thanks to Paul Miller for creating and maintaining the noble-curves library, upon which this library is based.

Thanks to the BitcoinJS team for creating and maintaining the BitcoinJS ecosystem, including the ecpair and bip32 libraries, which this library is designed to integrate with.

Thanks to the tiny-secp256k1 team for creating and maintaining the tiny-secp256k1 library, which this library uses for testing.

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