# @harmoniclabs/crypto

> collection of cryptographic functions that support every js runtime for ES5+

Latest version **0.3.1** (published 2026-08-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install @harmoniclabs/crypto
pnpm add @harmoniclabs/crypto
yarn add @harmoniclabs/crypto
bun add @harmoniclabs/crypto
```

## Health

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

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

Warnings: low downloads; no esm support; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.3.1 |
| Published | 2026-08-05 |
| First published | 2023-04-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 807.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Harmonic Laboratories |
| Maintainers | harmonicpool |

## Links

- npm: https://www.npmjs.com/package/@harmoniclabs/crypto
- Repository: https://github.com/HarmonicLabs/crypto
- Homepage: https://github.com/HarmonicLabs/crypto#readme
- Issues: https://github.com/HarmonicLabs/crypto/issues
- npm.io page: https://npm.io/package/@harmoniclabs/crypto

## Dependencies (2)

- [@harmoniclabs/bitstream](https://npm.io/package/@harmoniclabs/bitstream.md) ^1.0.0
- [@harmoniclabs/uint8array-utils](https://npm.io/package/@harmoniclabs/uint8array-utils.md) ^1.0.3

## Recent versions

- 0.3.1 (latest) — 2026-08-05
- 0.3.0 — 2025-04-26
- 0.3.0-dev0 — 2025-02-16
- 0.2.5 — 2025-01-07
- 0.2.4 — 2024-03-15
- 0.2.3 — 2024-03-09
- 0.2.2 — 2024-03-08
- 0.2.1 — 2024-03-08
- 0.2.0 — 2024-03-08
- 0.1.0 — 2023-04-30

## README

# @harmoniclabs/crypto

collection of cryptographic functions that support every js runtime for ES5+

## Disclaimer

The purpose of the library is to guarantee support for any javascript runtime with ES5+.

**THIS IMPLEMENTATION SHOULD NOT BE ASSUMED TO BE SAFE**

If you are in a node js environment you should use the [node crypto native module](https://nodejs.org/api/crypto.html); without doubt more preformant and secure.

## vrf batch verification benchmarks

> NOTE: for batches with 38 elements or more the pippenger multiscalar multiplication should be used
> 
> however it seems that there is something wrong wiht the implementation;
> since pippenger returns false where instead straus returns true (as it should be);
>
> for now then all batches sizes do use the straus algorithm, which is not optimal
>
> as you can see from the benchmarks, after size 32, the time/proof flattens
> (or get even worse in the case of bun) 

```
node --version
v22.13.1
```

```
size:    2; time:     36.216ms; time/proof:   18.108ms result: true
size:    4; time:     59.885ms; time/proof:   14.971ms result: true
size:    8; time:    105.061ms; time/proof:   13.133ms result: true
size:   16; time:    217.173ms; time/proof:   13.573ms result: true
size:   32; time:    397.940ms; time/proof:   12.436ms result: true
size:   64; time:    753.830ms; time/proof:   11.779ms result: true
size:  128; time:   1514.647ms; time/proof:   11.833ms result: true
size:  256; time:   3118.631ms; time/proof:   12.182ms result: true
size:  512; time:   6004.233ms; time/proof:   11.727ms result: true
size: 1024; time:  11948.110ms; time/proof:   11.668ms result: true
```

> NOTE: bun performs better in basically all cryptography functions except for this specific batch vrf.

```
bun --version
1.1.13
```

```
size:    2; time:     68.439ms; time/proof:   34.219ms result: true
size:    4; time:    130.650ms; time/proof:   32.662ms result: true
size:    8; time:    254.191ms; time/proof:   31.774ms result: true
size:   16; time:    505.512ms; time/proof:   31.594ms result: true
size:   32; time:   1001.648ms; time/proof:   31.301ms result: true
size:   64; time:   1975.420ms; time/proof:   30.866ms result: true
size:  128; time:   4077.155ms; time/proof:   31.853ms result: true
size:  256; time:   9204.953ms; time/proof:   35.957ms result: true
size:  512; time:  18359.952ms; time/proof:   35.859ms result: true
size: 1024; time:  35875.629ms; time/proof:   35.035ms result: true
```

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