MIT License

项目介绍

dajiaji/hpke-js 是一个托管在 GitHub 上的开源项目,主要使用 TypeScript 编写,采用 MIT License 许可证,目前获得 123 个 Star、16 次 Fork。

仓库全名
dajiaji/hpke-js
开源许可证
MIT License
Star 数
123
Fork 数
16
未关闭 Issue
7

README 摘要

hpke-js A modular TypeScript Hybrid Public Key Encryption (HPKE) library and HPKE-based protocol suite ( OHTTP , COSE-HPKE , JOSE-HPKE ) built on top of Web Cryptography API . Works on web browsers, Node.js, Deno and various other JavaScript runtimes. Documentation: jsr.io | pages (only for the latest ver.) For Node.js, you can install @hpke/core and other extensions via npm, yarn, pnpm or jsr: Following extensions…

完整内容见 GitHub 原始 README 或本页 。

常见问题

hpke-js 用什么语言开发?

主要使用 TypeScript 编写,采用 MIT License 许可证,目前有 123 个 Star。

hpke-js 可以免费商用吗?

仓库采用 MIT License 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 hpke-js 的源码?

可以直接克隆仓库:git clone https://github.com/dajiaji/hpke-js.git,默认分支为 main;安装与运行步骤见仓库 README。

hpke-js 最近还在维护吗?

仓库最近一次更新为 6月9日,当前有 7 个未关闭 Issue;Star 数为 123,可作为社区活跃度的参考。

关于

A Hybrid Public Key Encryption (HPKE) module built on top of Web Cryptography API.

描述取自 GitHub 官方 API,中文内容由 GitRead 中文社区 编辑团队整理。

简要分析

热度分
156
价值分
78
活跃状态
活跃

语言占比

HTML
JavaScript
TypeScript

README

hpke-js

A modular TypeScript Hybrid Public Key Encryption (HPKE) library and HPKE-based protocol suite (OHTTP, COSE-HPKE, JOSE-HPKE) built on top of Web Cryptography API. Works on web browsers, Node.js, Deno and various other JavaScript runtimes.

For Node.js, you can install @hpke/core and other extensions via npm, yarn, pnpm or jsr:

# Using npm:
npm install @hpke/core
yarn add @hpke/core
pnpm install @hpke/core
# Using jsr:
npx jsr add @hpke/core
yarn add jsr:@hpke/core
pnpm add jsr:@hpke/core

Following extensions can be installed in the same manner:

  • @hpke/chacha20poly1305
  • @hpke/dhkem-x25519
  • @hpke/dhkem-x448
  • @hpke/dhkem-secp256k1
  • @hpke/hybridkem-x-wing
  • @hpke/ml-kem
  • @hpke/hybridkem-x25519-kyber768 - deprecated

Then, you can use it as follows:

import {
  Aes128Gcm,
  CipherSuite,
  DhkemP256HkdfSha256,
  HkdfSha256,
} from "@hpke/core";

async function doHpke() {
  const suite = new CipherSuite({
    kem: new DhkemP256HkdfSha256(),
    kdf: new HkdfSha256(),
    aead: new Aes128Gcm(),
  });

  // A recipient generates a key pair.
  const rkp = await suite.kem.generateKeyPair();

  // A sender encrypts a message with the recipient public key.
  const sender = await suite.createSenderContext({
    recipientPublicKey: rkp.publicKey,
  });
  const ct = await sender.seal(new TextEncoder().encode("Hello world!"));

  // The recipient decrypts it.
  const recipient = await suite.createRecipientContext({
    recipientKey: rkp.privateKey,
    enc: sender.enc,
  });
  const pt = await recipient.open(ct);

  // Hello world!
  console.log(new TextDecoder().decode(pt));
}

try {
  doHpke();
} catch (e) {
  console.log("failed:", e.message);
}

Index

Packages

HPKE Library

name registry description
@hpke/core npm
JSR
The HPKE core module implemented using only Web Cryptography API. It does not support the X448-based KEM and the ChaCha20/Poly1305 AEAD, but it has no external module dependencies. It’s small in size and tree-shaking friendly.
README / samples
@hpke/chacha20poly1305 npm
JSR
The HPKE module extension for ChaCha20Poly1305 AEAD.
README / samples
@hpke/dhkem-x25519 npm
JSR
The HPKE module extension for DHKEM(X25519, HKDF-SHA256).
README / samples
@hpke/dhkem-x448 npm
JSR
The HPKE module extension for DHKEM(X448, HKDF-SHA512).
README / samples
hpke-js npm The HPKE module supporting all of the ciphersuites defined in RFC9180, which consists of the above @hpke/{core, dhkem-x25519, dhkem-x448, chacha20poly1305} internally.
README / samples
@hpke/hpke-js JSR The JSR version of the above hpke-js.
README / samples
@hpke/ml-kem npm
JSR
EXPERIMENTAL AND NOT STANDARDIZED
The HPKE module extension for ML-KEM.
README / samples
@hpke/hybridkem-x-wing npm
JSR
EXPERIMENTAL AND NOT STANDARDIZED
The HPKE module extension for X-Wing: general-purpose hybrid post-quantum KEM.
README / samples
@hpke/hybridkem-x25519-kyber768 (deprelated) npm
JSR
EXPERIMENTAL AND NOT STANDARDIZED
The HPKE module extension for the hybrid post-quantum KEM currently named X25519Kyber768Draft00.
README / samples
@hpke/dhkem-secp256k1 npm
JSR
EXPERIMENTAL AND NOT STANDARDIZED
The HPKE module extension for DHKEM(secp256k1, HKDF-SHA256).
README / samples

HPKE-based Protocol Implementations (Coming Soon)

name registry description
@hpke/ohttp - Oblivious HTTP (RFC 9458) client and server implementation using HPKE.
README
@hpke/cose npm
JSR
COSE-HPKE (draft-ietf-cose-hpke-27) implementation built on top of @hpke/core.
README / samples
@hpke/jose npm
JSR
JOSE-HPKE (draft-ietf-jose-hpke-encrypt-22) encryption implementation built on top of @hpke/core.
README / samples

Supported Features

HPKE Modes

Base PSK Auth AuthPSK
✅ ✅ ✅ ✅

Key Encapsulation Machanisms (KEMs)

KEMs Browser Node.js Deno Cloudflare
Workers
bun
DHKEM (P-256, HKDF-SHA256) ✅
hpke-js
@hpke/core
✅
hpke-js
@hpke/core
✅
hpke-js
@hpke/core
✅
hpke-js
@hpke/core
✅
hpke-js
@hpke/core
DHKEM (P-384, HKDF-SHA384) ✅
hpke-js
@hpke/core
✅
hpke-js
@hpke/core
✅
hpke-js
@hpke/core
✅
hpke-js
@hpke/core
✅
hpke-js
@hpke/core
DHKEM (P-521, HKDF-SHA512) ✅
hpke-js
@hpke/core
✅
hpke-js
@hpke/core
✅
hpke-js
@hpke/core
✅
hpke-js
@hpke/core
✅
hpke-js
@hpke/core
DHKEM (X25519, HKDF-SHA256) ✅
hpke-js
@hpke/core
@hpke/dhkem-x25519
✅
hpke-js
@hpke/core
@hpke/dhkem-x25519
✅
hpke-js
@hpke/core
@hpke/dhkem-x25519
✅
hpke-js
@hpke/core
@hpke/dhkem-x25519
✅
hpke-js
@hpke/core
@hpke/dhkem-x25519
DHKEM (X448, HKDF-SHA512) ✅
hpke-js
@hpke/dhkem-x448
✅
hpke-js
@hpke/dhkem-x448
✅
hpke-js
@hpke/dhkem-x448
✅
hpke-js
@hpke/dhkem-x448
✅
hpke-js
@hpke/dhkem-x448
ML-KEM-512 ✅
@hpke/ml-kem
✅
@hpke/ml-kem
✅
@hpke/ml-kem
✅
@hpke/ml-kem
✅
@hpke/ml-kem
ML-KEM-768 ✅
@hpke/ml-kem
✅
@hpke/ml-kem
✅
@hpke/ml-kem
✅
@hpke/ml-kem
✅
@hpke/ml-kem
ML-KEM-1024 ✅
@hpke/ml-kem
✅
@hpke/ml-kem
✅
@hpke/ml-kem
✅
@hpke/ml-kem
✅
@hpke/ml-kem
X-Wing ✅
@hpke/hybridkem-x-wing
✅
@hpke/hybridkem-x-wing
✅
@hpke/hybridkem-x-wing
✅
@hpke/hybridkem-x-wing
✅
@hpke/hybridkem-x-wing
Hybrid KEM (X25519, Kyber768) ✅
@hpke/hybridkem-x25519-kyber768
✅
@hpke/hybridkem-x25519-kyber768
✅
@hpke/hybridkem-x25519-kyber768
✅
@hpke/hybridkem-x25519-kyber768
✅
@hpke/hybridkem-x25519-kyber768
DHKEM (secp256k1, HKDF-SHA256) ✅
@hpke/dhkem-secp256k1
✅
@hpke/dhkem-secp256k1
✅
@hpke/dhkem-secp256k1
✅
@hpke/dhkem-secp256k1
✅
@hpke/dhkem-secp256k1

Key Derivation Functions (KDFs)

KDFs Browser Node.js Deno Cloudflare
Workers
bun
HKDF-SHA256 ✅
hpke-js
@hpke/core(*1)
✅
hpke-js
@hpke/core(*1)
✅
hpke-js
@hpke/core(*1)
✅
hpke-js
@hpke/core(*1)
✅
hpke-js
@hpke/core(*1)
HKDF-SHA384 ✅
hpke-js
@hpke/core(*1)
✅
hpke-js
@hpke/core(*1)
✅
hpke-js
@hpke/core(*1)
✅
hpke-js
@hpke/core(*1)
✅
hpke-js
@hpke/core(*1)
HKDF-SHA512 ✅
hpke-js
@hpke/core(*1)
✅
hpke-js
@hpke/core(*1)
✅
hpke-js
@hpke/core(*1)
✅
hpke-js
@hpke/core(*1)
✅
hpke-js
@hpke/core(*1)
  • (*1) The HKDF functions built in @hpke/core can derive keys of the same length as the hash size. If you want to derive keys longer than the hash size, use hpke-js.

Authenticated Encryption with Associated Data (AEAD) Functions

AEADs Browser Node.js Deno Cloudflare
Workers
bun
AES-128-GCM ✅
hpke-js
@hpke/core
✅
hpke-js
@hpke/core
✅
hpke-js
@hpke/core
✅
hpke-js
@hpke/core
✅
hpke-js
@hpke/core
AES-256-GCM ✅
hpke-js
@hpke/core
✅
hpke-js
@hpke/core
✅
hpke-js
@hpke/core
✅
hpke-js
@hpke/core
✅
hpke-js
@hpke/core
ChaCha20
Poly1305
✅
hpke-js
@hpke/chacha
20poly1305
✅
hpke-js
@hpke/chacha
20poly1305
✅
hpke-js
@hpke/chacha
20poly1305
✅
hpke-js
@hpke/chacha
20poly1305
✅
hpke-js
@hpke/chacha
20poly1305
Export Only ✅
hpke-js
@hpke/core
✅
hpke-js
@hpke/core
✅
hpke-js
@hpke/core
✅
hpke-js
@hpke/core
✅
hpke-js
@hpke/core

Supported Environments

  • Web Browser: Web Cryptography API supported browsers
    • Confirmed: Chrome, Firefox, Edge, Safari, Opera, Vivaldi, Brave
  • Node.js: 16.x, 17.x, 18.x, 19.x, 20.x, 21.x, 22.x, 23.x, 24.x, 25.x, 26.x
  • Deno: 2.x
  • Cloudflare Workers
  • bun: 0.x (0.6.0-), 1.x

Warnings and Restrictions

Contributing

We welcome all kind of contributions, filing issues, suggesting new features or sending PRs. Please see our CONTRIBUTING.md for detailed guidelines on:

  • Development setup and prerequisites
  • Available development tasks
  • Code quality requirements
  • Project structure
  • Testing requirements
  • Documentation guidelines

References

评论

暂无评论