@harmoniclabs/crypto

中文文档
0.3.1发布于 2026/08/05MITTypeScriptCommonJS近 30 天下载 10.2万

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

原始使用文档

@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; 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

版本与发布记录

@harmoniclabs/crypto 共发布 10 个版本,首次发布于 2023/04/30;过去 12 个月发布了 1 个版本。

版本发布日期距今
0.3.1latest2026/08/053 个月前
0.3.02025/04/261.6 年前
0.3.0-dev02025/02/171.7 年前
0.2.52025/01/071.9 年前
0.2.42024/03/152 年前
0.2.32024/03/092 年前

关于 @harmoniclabs/crypto 的常见问题

@harmoniclabs/crypto 是什么?

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

如何安装 @harmoniclabs/crypto?

在项目目录运行 npm install @harmoniclabs/crypto,或使用 pnpm add / yarn add / bun add。

@harmoniclabs/crypto 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@harmoniclabs/crypto 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@harmoniclabs/crypto 可以商用吗?

@harmoniclabs/crypto 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@harmoniclabs/crypto 的下载量有多少?

根据 npm 官方下载统计,@harmoniclabs/crypto 在 2026/10/17 – 2026/11/15 这 30 天内被下载 101,716 次,日均约 3,391 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@harmoniclabs/crypto 还在维护吗?

最新版本 0.3.1 发布于 2026/08/05(3 个月前);至今共发布 10 个版本,其中过去 12 个月发布了 1 个;首次发布于 2023/04/30。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。