From bd2b8e80781f9b98c4d67f69a793d79cfdc62a56 Mon Sep 17 00:00:00 2001 From: Ajitomi Daisuke Date: Sun, 10 Nov 2024 19:09:15 +0900 Subject: [PATCH] ml-kem: initial commit. --- .github/workflows/ci_browser.yml | 11 +++++++ .github/workflows/ci_node.yml | 8 +++++ .github/workflows/publish.yml | 7 ++++ npm/package-lock.json | 55 ++++++++++++++++++++++++++++++++ 4 files changed, 81 insertions(+) diff --git a/.github/workflows/ci_browser.yml b/.github/workflows/ci_browser.yml index 3d67afb5f..272dd0e30 100644 --- a/.github/workflows/ci_browser.yml +++ b/.github/workflows/ci_browser.yml @@ -45,6 +45,8 @@ jobs: cp -rf ../hybridkem-x25519-kyber768/test/runtimes/browsers/pages/* test/runtimes/browsers/pages/hybridkem-x25519-kyber768 mkdir test/runtimes/browsers/pages/hybridkem-x-wing cp -rf ../hybridkem-x-wing/test/runtimes/browsers/pages/* test/runtimes/browsers/pages/hybridkem-x-wing + mkdir test/runtimes/browsers/pages/ml-kem + cp -rf ../ml-kem/test/runtimes/browsers/pages/* test/runtimes/browsers/pages/ml-kem mkdir test/runtimes/browsers/pages/dhkem-secp256k1 cp -rf ../dhkem-secp256k1/test/runtimes/browsers/pages/* test/runtimes/browsers/pages/dhkem-secp256k1 - name: Build docs for @hpke/common @@ -57,6 +59,7 @@ jobs: deno task minify > ../hpke-js/test/runtimes/browsers/pages/chacha20poly1305/src/hpke-common.js deno task minify > ../hpke-js/test/runtimes/browsers/pages/hybridkem-x25519-kyber768/src/hpke-common.js deno task minify > ../hpke-js/test/runtimes/browsers/pages/hybridkem-x-wing/src/hpke-common.js + deno task minify > ../hpke-js/test/runtimes/browsers/pages/ml-kem/src/hpke-common.js deno task minify > ../hpke-js/test/runtimes/browsers/pages/dhkem-secp256k1/src/hpke-common.js - name: Build docs for @hpke/core working-directory: ./packages/core @@ -68,6 +71,7 @@ jobs: deno task minify > ../hpke-js/test/runtimes/browsers/pages/chacha20poly1305/src/hpke-core.js deno task minify > ../hpke-js/test/runtimes/browsers/pages/hybridkem-x25519-kyber768/src/hpke-core.js deno task minify > ../hpke-js/test/runtimes/browsers/pages/hybridkem-x-wing/src/hpke-core.js + deno task minify > ../hpke-js/test/runtimes/browsers/pages/ml-kem/src/hpke-core.js deno task minify > ../hpke-js/test/runtimes/browsers/pages/dhkem-secp256k1/src/hpke-core.js - name: Build docs for @hpke/chacha20poly1305 working-directory: ./packages/chacha20poly1305 @@ -99,6 +103,11 @@ jobs: run: | npx typedoc --name "@hpke/hybridkem-x-wing" --out ../hpke-js/test/runtimes/browsers/pages/hybridkem-x-wing/docs mod.ts deno task minify > ../hpke-js/test/runtimes/browsers/pages/hybridkem-x-wing/src/hpke-hybridkem-x-wing.js + - name: Build docs for @hpke/ml-kem + working-directory: ./packages/ml-kem + run: | + npx typedoc --name "@hpke/ml-kem" --out ../hpke-js/test/runtimes/browsers/pages/ml-kem/docs mod.ts + deno task minify > ../hpke-js/test/runtimes/browsers/pages/ml-kem/src/hpke-ml-kem.js - name: Build docs for @hpke/hpke-js working-directory: ./packages/hpke-js run: | @@ -128,6 +137,8 @@ jobs: run: npm install && npx playwright install && npx playwright test - working-directory: ./packages/hybridkem-x-wing/test/runtimes/browsers run: npm install && npx playwright install && npx playwright test + - working-directory: ./packages/ml-kem/test/runtimes/browsers + run: npm install && npx playwright install && npx playwright test - working-directory: ./packages/dhkem-secp256k1/test/runtimes/browsers run: npm install && npx playwright install && npx playwright test - working-directory: ./packages/hpke-js/test/runtimes/browsers diff --git a/.github/workflows/ci_node.yml b/.github/workflows/ci_node.yml index 11b5cc18c..5dde15bdd 100644 --- a/.github/workflows/ci_node.yml +++ b/.github/workflows/ci_node.yml @@ -97,3 +97,11 @@ jobs: - name: Publish to npm (dry) for /packages/hpke-js working-directory: ./npm/packages/hpke-js run: npm publish --dry-run + - name: Run dnt & minify for /packages/ml-kem + working-directory: ./packages/ml-kem + run: | + deno task dnt + deno task minify > ../../npm/packages/ml-kem/hpke-ml-kem.min.js + - name: Publish to npm (dry) for /packages/ml-kem + working-directory: ./npm/packages/ml-kem + run: npm publish --dry-run \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 77b9cf4aa..352045be1 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -93,3 +93,10 @@ jobs: run: npm publish --provenance env: NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + - name: Publish @hpke/ml-kem to npm + continue-on-error: true + working-directory: ./npm/packages/ml-kem + run: npm publish --provenance + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + diff --git a/npm/package-lock.json b/npm/package-lock.json index 94f7da76a..facc33210 100644 --- a/npm/package-lock.json +++ b/npm/package-lock.json @@ -15,6 +15,7 @@ "packages/hybridkem-x25519-kyber768", "packages/hybridkem-x-wing", "packages/hpke-js", + "packages/ml-kem", "test/**/*/runtimes/cloudflare", "samples/**/*" ] @@ -732,6 +733,10 @@ "resolved": "packages/hybridkem-x25519-kyber768", "link": true }, + "node_modules/@hpke/ml-kem": { + "resolved": "packages/ml-kem", + "link": true + }, "node_modules/@jest/schemas": { "version": "29.6.3", "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", @@ -2381,6 +2386,10 @@ "resolved": "samples/hpke-js", "link": true }, + "node_modules/samples-node-hpke-ml-kem": { + "resolved": "samples/ml-kem", + "link": true + }, "node_modules/selfsigned": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/selfsigned/-/selfsigned-2.4.1.tgz", @@ -2586,6 +2595,10 @@ "resolved": "test/hpke-js/runtimes/cloudflare", "link": true }, + "node_modules/test-cloudflare-hpke-ml-kem": { + "resolved": "test/ml-kem/runtimes/cloudflare", + "link": true + }, "node_modules/tinybench": { "version": "2.9.0", "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz", @@ -3766,6 +3779,24 @@ "node": ">=16.0.0" } }, + "packages/ml-kem": { + "name": "@hpke/ml-kem", + "version": "0.1.0", + "license": "MIT", + "dependencies": { + "@hpke/common": "^1.7.1", + "mlkem": "^2.3.0" + }, + "devDependencies": { + "@deno/shim-deno": "~0.18.0", + "@hpke/core": "^1.7.1", + "@types/node": "^20.9.0", + "picocolors": "^1.0.0" + }, + "engines": { + "node": ">=16.0.0" + } + }, "samples/chacha20poly1305": { "name": "samples-node-hpke-chacha20poly1305", "version": "1.0.0", @@ -3851,6 +3882,15 @@ "@hpke/hybridkem-x25519-kyber768": "^1.5.0" } }, + "samples/ml-kem": { + "name": "samples-node-hpke-ml-kem", + "version": "1.0.0", + "license": "MIT", + "dependencies": { + "@hpke/core": "^1.7.1", + "@hpke/ml-kem": "^0.1.0" + } + }, "test/chacha20poly1305/runtimes/cloudflare": { "name": "test-cloudflare-hpke-chacha20poly1305", "version": "0.0.0", @@ -3983,6 +4023,21 @@ "vitest": "1.5.0", "wrangler": "^3.60.3" } + }, + "test/ml-kem/runtimes/cloudflare": { + "name": "test-cloudflare-hpke-ml-kem", + "version": "0.0.0", + "dependencies": { + "@hpke/core": "^1.7.1", + "@hpke/ml-kem": "^0.1.0" + }, + "devDependencies": { + "@cloudflare/vitest-pool-workers": "^0.4.5", + "@cloudflare/workers-types": "^4.20240903.0", + "typescript": "^5.5.2", + "vitest": "1.5.0", + "wrangler": "^3.60.3" + } } } }