Skip to content

Commit

Permalink
Merge pull request #48 from dajiaji/update-bench
Browse files Browse the repository at this point in the history
Update bench from Kyber to MlKem.
  • Loading branch information
dajiaji authored Sep 15, 2024
2 parents a2bb44a + 17264ca commit bd6973c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 20 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<div align="center">
<a href="https://jsr.io/@dajiaji/mlkem"><img src="https://jsr.io/badges/@dajiaji/mlkem" alt="JSR"/></a>
<a href="https://www.npmjs.com/package/mlkem"><img src="https://img.shields.io/npm/v/mlkem?color=%23EE3214" alt="NPM"/></a>
<img src="https://github.com/dajiaji/crystals-kyber-js/actions/workflows/ci_browsers.yml/badge.svg" alt="Browser CI" />
<img src="https://github.com/dajiaji/crystals-kyber-js/actions/workflows/ci_node.yml/badge.svg" alt="Node.js CI" />
<img src="https://github.com/dajiaji/crystals-kyber-js/actions/workflows/ci_deno.yml/badge.svg" alt="Deno CI" />
Expand Down Expand Up @@ -44,8 +45,8 @@ This repository has the following packages:

| package | registry | description |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| crystals-kyber-js | [![npm](https://img.shields.io/npm/v/crystals-kyber-js?color=%234C48FF)](https://www.npmjs.com/package/crystals-kyber-js) | `v1.x` implements CRYSTALS-KYBER, and `v2.x-` implements ML-KEM (FIPS 203). `crystals-kyber-js` may become deprecated in the near future. Instead, we recommend switching to the following `mlkem` or `@dajiaji/mlkem`. |
| mlkem | [![npm](https://img.shields.io/npm/v/mlkem?color=%234C48FF)](https://www.npmjs.com/package/mlkem) | Implements only ML-KEM (FIPS 203). It is an alias for the above `crystals-kyber-js` starting from `v2` onwards. We recommend using this package going forward. |
| crystals-kyber-js | [![npm](https://img.shields.io/npm/v/crystals-kyber-js?color=%23EE3214)](https://www.npmjs.com/package/crystals-kyber-js) | `v1.x` implements CRYSTALS-KYBER, and `v2.x-` implements ML-KEM (FIPS 203). `crystals-kyber-js` may become deprecated in the near future. Instead, we recommend switching to the following `mlkem` or `@dajiaji/mlkem`. |
| mlkem | [![npm](https://img.shields.io/npm/v/mlkem?color=%23EE3214)](https://www.npmjs.com/package/mlkem) | Implements only ML-KEM (FIPS 203). It is an alias for the above `crystals-kyber-js` starting from `v2` onwards. We recommend using this package going forward. |
| @dajiaji/mlkem | [![JSR](https://jsr.io/badges/@dajiaji/mlkem)](https://jsr.io/@dajiaji/mlkem) | Implements only ML-KEM (FIPS 203). It is an ML-KEM package for [jsr.io](https://jsr.io/). The above `mlkem` is an npm package of `@dajiaji/mlkem`, which has been converted using [@deno/dnt](https://github.com/denoland/dnt). |

For Node.js, you can install `mlkem` or `crystals-kyber-js` via npm, yarn or
Expand Down
12 changes: 6 additions & 6 deletions bench/kyber1024.bench.ts → bench/mlKem1024.bench.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as kyber from "npm:crystals-kyber";
import { Kyber1024 } from "../mod.ts";
import { MlKem1024 } from "../mod.ts";

Deno.bench("deriveKeyPair", async (b) => {
const ctx = new Kyber1024();
const ctx = new MlKem1024();
const seed = new Uint8Array(64);
globalThis.crypto.getRandomValues(seed);
b.start();
Expand All @@ -11,7 +11,7 @@ Deno.bench("deriveKeyPair", async (b) => {
});

Deno.bench("generateKeyPair", async (b) => {
const ctx = new Kyber1024();
const ctx = new MlKem1024();
b.start();
const [_pk, _sk] = await ctx.generateKeyPair();
b.end();
Expand All @@ -22,7 +22,7 @@ Deno.bench("crystals-kyber:KeyGen1024", () => {
});

Deno.bench("encap", async (b) => {
const ctx = new Kyber1024();
const ctx = new MlKem1024();
const [pk, _sk] = await ctx.generateKeyPair();
b.start();
const [_ct, _ss] = await ctx.encap(pk);
Expand All @@ -37,7 +37,7 @@ Deno.bench("crystals-kyber:Encrypt1024", (b) => {
});

Deno.bench("decap", async (b) => {
const ctx = new Kyber1024();
const ctx = new MlKem1024();
const [pk, sk] = await ctx.generateKeyPair();
const [ct, _ss1] = await ctx.encap(pk);
b.start();
Expand All @@ -54,7 +54,7 @@ Deno.bench("crystals-kyber:Decrypt1024", (b) => {
});

Deno.bench("all - generateKeyPair/encap/decap", async (b) => {
const ctx = new Kyber1024();
const ctx = new MlKem1024();
b.start();
const [pk, sk] = await ctx.generateKeyPair();
const [ct, _ss1] = await ctx.encap(pk);
Expand Down
12 changes: 6 additions & 6 deletions bench/kyber512.bench.ts → bench/mlKem512.bench.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as kyber from "npm:crystals-kyber";
import { Kyber512 } from "../mod.ts";
import { MlKem512 } from "../mod.ts";

Deno.bench("deriveKeyPair", async (b) => {
const ctx = new Kyber512();
const ctx = new MlKem512();
const seed = new Uint8Array(64);
globalThis.crypto.getRandomValues(seed);
b.start();
Expand All @@ -11,7 +11,7 @@ Deno.bench("deriveKeyPair", async (b) => {
});

Deno.bench("generateKeyPair", async (b) => {
const ctx = new Kyber512();
const ctx = new MlKem512();
b.start();
const [_pk, _sk] = await ctx.generateKeyPair();
b.end();
Expand All @@ -22,7 +22,7 @@ Deno.bench("crystals-kyber:KeyGen512", () => {
});

Deno.bench("encap", async (b) => {
const ctx = new Kyber512();
const ctx = new MlKem512();
const [pk, _sk] = await ctx.generateKeyPair();
b.start();
const [_ct, _ss] = await ctx.encap(pk);
Expand All @@ -37,7 +37,7 @@ Deno.bench("crystals-kyber:Encrypt512", (b) => {
});

Deno.bench("decap", async (b) => {
const ctx = new Kyber512();
const ctx = new MlKem512();
const [pk, sk] = await ctx.generateKeyPair();
const [ct, _ss1] = await ctx.encap(pk);
b.start();
Expand All @@ -54,7 +54,7 @@ Deno.bench("crystals-kyber:Decrypt512", (b) => {
});

Deno.bench("all - generateKeyPair/encap/decap", async (b) => {
const ctx = new Kyber512();
const ctx = new MlKem512();
b.start();
const [pk, sk] = await ctx.generateKeyPair();
const [ct, _ss1] = await ctx.encap(pk);
Expand Down
12 changes: 6 additions & 6 deletions bench/kyber768.bench.ts → bench/mlKem768.bench.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as kyber from "npm:crystals-kyber";
import { Kyber768 } from "../mod.ts";
import { MlKem768 } from "../mod.ts";

Deno.bench("deriveKeyPair", async (b) => {
const ctx = new Kyber768();
const ctx = new MlKem768();
const seed = new Uint8Array(64);
globalThis.crypto.getRandomValues(seed);
b.start();
Expand All @@ -11,7 +11,7 @@ Deno.bench("deriveKeyPair", async (b) => {
});

Deno.bench("generateKeyPair", async (b) => {
const ctx = new Kyber768();
const ctx = new MlKem768();
b.start();
const [_pk, _sk] = await ctx.generateKeyPair();
b.end();
Expand All @@ -22,7 +22,7 @@ Deno.bench("crystals-kyber:KeyGen768", () => {
});

Deno.bench("encap", async (b) => {
const ctx = new Kyber768();
const ctx = new MlKem768();
const [pk, _sk] = await ctx.generateKeyPair();
b.start();
const [_ct, _ss] = await ctx.encap(pk);
Expand All @@ -37,7 +37,7 @@ Deno.bench("crystals-kyber:Encrypt768", (b) => {
});

Deno.bench("decap", async (b) => {
const ctx = new Kyber768();
const ctx = new MlKem768();
const [pk, sk] = await ctx.generateKeyPair();
const [ct, _ss1] = await ctx.encap(pk);
b.start();
Expand All @@ -54,7 +54,7 @@ Deno.bench("crystals-kyber:Decrypt768", (b) => {
});

Deno.bench("all - generateKeyPair/encap/decap", async (b) => {
const ctx = new Kyber768();
const ctx = new MlKem768();
b.start();
const [pk, sk] = await ctx.generateKeyPair();
const [ct, _ss1] = await ctx.encap(pk);
Expand Down

0 comments on commit bd6973c

Please sign in to comment.