diff --git a/.github/workflows/cross.yml b/.github/workflows/cross.yml index 6d97df9..48ab046 100644 --- a/.github/workflows/cross.yml +++ b/.github/workflows/cross.yml @@ -9,7 +9,6 @@ jobs: strategy: matrix: target: [ - aarch64-linux-android, aarch64-unknown-linux-gnu, aarch64-unknown-linux-musl, arm-unknown-linux-gnueabi, diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..3b1ffaa --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,26 @@ +name: Version Release + +on: + push: + branches: + - master + tags: + - 'v[0-9]+.[0-9]+.*' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + # Trims latest release notes from CHANGELOG,md + - name: Generate Release Notes + run: sed '1p;1,/^##/!d;/##/d' CHANGELOG.md > ${{ github.ref_name }}.md + + - name: Publish Release + uses: softprops/action-gh-release@v1 + with: + body_path: ${{ github.ref_name }}.md + env: + GITHUB_REPOSITORY: Argyle-Software/kyber \ No newline at end of file diff --git a/.gitignore b/.gitignore index 6716d50..cf9b54e 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,3 @@ www/node_modules/ www/dist/ www/.bin/ pkg/package.json.bak -release_checklist diff --git a/CHANGELOG.txt b/CHANGELOG.md similarity index 57% rename from CHANGELOG.txt rename to CHANGELOG.md index 365f64b..8045a32 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.md @@ -1,3 +1,19 @@ +## 0.5.0 - 2023-3-16 + +### Added + - `90s-fixslice` feature, using RustCrypto's AES implementation + - More key exchange testing (thanks Francesco Medina) + - Examples + +### Changed +- Bumped dependencies + +### Fixed +- Documentation + +### Removed + - Unnecessary sha2 default dependencies + ## 0.4.0 - 2023-1-18 ### Added diff --git a/Cargo.toml b/Cargo.toml index e4ffe73..1237f4d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,19 +1,19 @@ [package] name = "pqc_kyber" -version = "0.4.0" +version = "0.5.0" authors = ["Mitchell Berry "] edition = "2018" license = "MIT/Apache-2.0" repository = "https://github.com/Argyle-Software/kyber" documentation = "https://docs.rs/crate/pqc_kyber/" -categories = ["algorithms", "cryptography"] +categories = ["algorithms", "cryptography", "wasm", "no-std"] description = "A rust implementation of the post-quantum Kyber KEM algorithm" keywords = ["kyber", "kem", "key-exchange", "kex", "post-quantum"] readme = "readme.md" [dependencies] rand_core = { version = "0.6.4", default-features = false } -wasm-bindgen = { version = "0.2.83", optional = true } +wasm-bindgen = { version = "0.2.84", optional = true } sha2 = { version = "0.10.6", optional = true , default-features = false } getrandom = {version = "0.2.8", features = ["js"], optional = true } zeroize = { version = "1.5.7", features = ["derive"], optional = true } diff --git a/pkg/package.json b/pkg/package.json index 2e0e287..56eafae 100644 --- a/pkg/package.json +++ b/pkg/package.json @@ -3,8 +3,8 @@ "collaborators": [ "Mitchell Berry " ], - "description": "The post-quantum Kyber KEM algorithm", - "version": "0.4.0", + "description": "The post-quantum Kyber key exchange algorithm, written in rust and compiled to wasm", + "version": "0.5.0", "license": "MIT/Apache-2.0", "repository": { "type": "git", diff --git a/pkg/pqc_kyber.js b/pkg/pqc_kyber.js index 5928f2b..855f7ce 100644 --- a/pkg/pqc_kyber.js +++ b/pkg/pqc_kyber.js @@ -1,2 +1,4 @@ import * as wasm from "./pqc_kyber_bg.wasm"; -export * from "./pqc_kyber_bg.js"; \ No newline at end of file +import { __wbg_set_wasm } from "./pqc_kyber_bg.js"; +__wbg_set_wasm(wasm); +export * from "./pqc_kyber_bg.js"; diff --git a/pkg/pqc_kyber_bg.js b/pkg/pqc_kyber_bg.js index 5d4c563..238a653 100644 --- a/pkg/pqc_kyber_bg.js +++ b/pkg/pqc_kyber_bg.js @@ -1,6 +1,10 @@ -import * as wasm from './pqc_kyber_bg.wasm'; +let wasm; +export function __wbg_set_wasm(val) { + wasm = val; +} + -const heap = new Array(32).fill(undefined); +const heap = new Array(128).fill(undefined); heap.push(undefined, null, true, false); @@ -9,7 +13,7 @@ function getObject(idx) { return heap[idx]; } let heap_next = heap.length; function dropObject(idx) { - if (idx < 36) return; + if (idx < 132) return; heap[idx] = heap_next; heap_next = idx; } @@ -26,10 +30,10 @@ let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true cachedTextDecoder.decode(); -let cachedUint8Memory0 = new Uint8Array(); +let cachedUint8Memory0 = null; function getUint8Memory0() { - if (cachedUint8Memory0.byteLength === 0) { + if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) { cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer); } return cachedUint8Memory0; @@ -170,10 +174,10 @@ function passStringToWasm0(arg, malloc, realloc) { return ptr; } -let cachedInt32Memory0 = new Int32Array(); +let cachedInt32Memory0 = null; function getInt32Memory0() { - if (cachedInt32Memory0.byteLength === 0) { + if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) { cachedInt32Memory0 = new Int32Array(wasm.memory.buffer); } return cachedInt32Memory0; @@ -470,14 +474,6 @@ export function __wbindgen_object_drop_ref(arg0) { takeObject(arg0); }; -export function __wbg_randomFillSync_6894564c2c334c42() { return handleError(function (arg0, arg1, arg2) { - getObject(arg0).randomFillSync(getArrayU8FromWasm0(arg1, arg2)); -}, arguments) }; - -export function __wbg_getRandomValues_805f1c3d65988a5a() { return handleError(function (arg0, arg1) { - getObject(arg0).getRandomValues(getObject(arg1)); -}, arguments) }; - export function __wbg_crypto_e1d53a1d73fb10b8(arg0) { const ret = getObject(arg0).crypto; return addHeapObject(ret); @@ -529,12 +525,20 @@ export function __wbindgen_string_new(arg0, arg1) { return addHeapObject(ret); }; -export function __wbg_newnoargs_b5b063fc6c2f0376(arg0, arg1) { +export function __wbg_getRandomValues_805f1c3d65988a5a() { return handleError(function (arg0, arg1) { + getObject(arg0).getRandomValues(getObject(arg1)); +}, arguments) }; + +export function __wbg_randomFillSync_6894564c2c334c42() { return handleError(function (arg0, arg1, arg2) { + getObject(arg0).randomFillSync(getArrayU8FromWasm0(arg1, arg2)); +}, arguments) }; + +export function __wbg_newnoargs_2b8b6bd7753c76ba(arg0, arg1) { const ret = new Function(getStringFromWasm0(arg0, arg1)); return addHeapObject(ret); }; -export function __wbg_call_97ae9d8645dc388b() { return handleError(function (arg0, arg1) { +export function __wbg_call_95d1ea488d03e4e8() { return handleError(function (arg0, arg1) { const ret = getObject(arg0).call(getObject(arg1)); return addHeapObject(ret); }, arguments) }; @@ -544,22 +548,22 @@ export function __wbindgen_object_clone_ref(arg0) { return addHeapObject(ret); }; -export function __wbg_self_6d479506f72c6a71() { return handleError(function () { +export function __wbg_self_e7c1f827057f6584() { return handleError(function () { const ret = self.self; return addHeapObject(ret); }, arguments) }; -export function __wbg_window_f2557cc78490aceb() { return handleError(function () { +export function __wbg_window_a09ec664e14b1b81() { return handleError(function () { const ret = window.window; return addHeapObject(ret); }, arguments) }; -export function __wbg_globalThis_7f206bda628d5286() { return handleError(function () { +export function __wbg_globalThis_87cbb8506fecf3a9() { return handleError(function () { const ret = globalThis.globalThis; return addHeapObject(ret); }, arguments) }; -export function __wbg_global_ba75c50d1cf384f4() { return handleError(function () { +export function __wbg_global_c85a9259e621f3db() { return handleError(function () { const ret = global.global; return addHeapObject(ret); }, arguments) }; @@ -569,36 +573,36 @@ export function __wbindgen_is_undefined(arg0) { return ret; }; -export function __wbg_call_168da88779e35f61() { return handleError(function (arg0, arg1, arg2) { +export function __wbg_call_9495de66fdbe016b() { return handleError(function (arg0, arg1, arg2) { const ret = getObject(arg0).call(getObject(arg1), getObject(arg2)); return addHeapObject(ret); }, arguments) }; -export function __wbg_buffer_3f3d764d4747d564(arg0) { +export function __wbg_buffer_cf65c07de34b9a08(arg0) { const ret = getObject(arg0).buffer; return addHeapObject(ret); }; -export function __wbg_new_8c3f0052272a457a(arg0) { +export function __wbg_new_537b7341ce90bb31(arg0) { const ret = new Uint8Array(getObject(arg0)); return addHeapObject(ret); }; -export function __wbg_set_83db9690f9353e79(arg0, arg1, arg2) { +export function __wbg_set_17499e8aa4003ebd(arg0, arg1, arg2) { getObject(arg0).set(getObject(arg1), arg2 >>> 0); }; -export function __wbg_length_9e1ae1900cb0fbd5(arg0) { +export function __wbg_length_27a2afe8ab42b09f(arg0) { const ret = getObject(arg0).length; return ret; }; -export function __wbg_newwithlength_f5933855e4f48a19(arg0) { +export function __wbg_newwithlength_b56c882b57805732(arg0) { const ret = new Uint8Array(arg0 >>> 0); return addHeapObject(ret); }; -export function __wbg_subarray_58ad4efbb5bcb886(arg0, arg1, arg2) { +export function __wbg_subarray_7526649b91a252a6(arg0, arg1, arg2) { const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0); return addHeapObject(ret); }; diff --git a/pkg/pqc_kyber_bg.wasm b/pkg/pqc_kyber_bg.wasm index b465427..8b225fd 100644 Binary files a/pkg/pqc_kyber_bg.wasm and b/pkg/pqc_kyber_bg.wasm differ diff --git a/readme.md b/readme.md index 14976d0..6627080 100644 --- a/readme.md +++ b/readme.md @@ -8,8 +8,9 @@ # Kyber [![Build Status](https://github.com/Argyle-Software/kyber/actions/workflows/kat.yml/badge.svg)](https://github.com/Argyle-Software/kyber/actions) [![Crates](https://img.shields.io/crates/v/pqc-kyber)](https://crates.io/crates/pqc-kyber) -[![NPM](https://img.shields.io/npm/v/pqc-kyber)](https://www.npmjs.com/package/pqc-kyber) +[![NPM](https://img.shields.io/npm/v/pqc-kyber?color=yellow)](https://www.npmjs.com/package/pqc-kyber) [![License](https://img.shields.io/crates/l/pqc_kyber)](https://github.com/Argyle-Software/kyber/blob/master/LICENSE-MIT) +[![dependency status](https://deps.rs/crate/pqc_kyber/0.4.0/status.svg)](https://deps.rs/crate/pqc_kyber/0.5.0) A rust implementation of the Kyber algorithm, a KEM standardised by the NIST Post-Quantum Standardization Project. @@ -133,7 +134,7 @@ If no security level is specified then kyber768 is used by default as recommende ```toml [dependencies] -pqc_kyber = {version = "0.4.0", features = ["kyber512", "90s", "avx2"]} +pqc_kyber = {version = "0.5.0", features = ["kyber512", "90s", "avx2"]} ``` diff --git a/release.md b/release.md new file mode 100644 index 0000000..09e4a87 --- /dev/null +++ b/release.md @@ -0,0 +1,38 @@ +# Release Checklist + +1. Bump any dependencies in **Cargo.toml** + +2. Run tests and address sanitiser checks: + ```bash + export RUSTFLAGS="${RUSTFLAGS:-} -Z sanitizer=address -C target-cpu=native -C target-feature=+aes,+avx2,+sse2,+sse4.1,+bmi2,+popcnt";\ + export RUSTDOCFLAGS="-Z sanitizer=address"; + rustup default nightly; + KAT=1 AVX2=1 NASM=1 ./tests/run_all_tests.sh; +``` + +3. Bump version in **Cargo.toml** + +4. Bump version in deps.rs badge and features section of **readme.md** + +5. Update **changelog.md** + +6. `cargo +nightly fmt` + +7. `wasm-pack build -- --features wasm` + +8. Fix autogenerated **pkg/package.json**: + * name - Replace `pqc_kyber` with `pqc-kyber` + * description - Revert line to replace with old description + +9. `git commit -m "v0.0.0"` + +10. `git tag v0.0.0` + +11. `git push origin v0.0.0` + +12. Open PR to master, confirm all CI checks pass, merge PR + +13. `cargo publish` + +14. `npm publish` +