From 182f911a03e03ffd96cc561705a165a83ccc6163 Mon Sep 17 00:00:00 2001 From: Lann Martin Date: Sat, 1 Aug 2026 15:13:50 -0400 Subject: [PATCH] Rename packages to the placeholder family scheme; group by language under rust/ and js/ --- .cargo/mutants.toml | 4 +- .github/pages/index.html | 2 +- .github/workflows/ci.yml | 2 +- .../workflows/componentize-js-toolchain.yml | 10 +- .github/workflows/timing-lab.yml | 2 +- .gitignore | 2 +- AGENTS.md | 125 +++++++++--------- Cargo.lock | 116 ++++++++-------- Cargo.toml | 8 +- README.md | 53 ++++---- conformance/README.md | 12 +- .../adapters/composed-driver/src/lib.rs | 2 +- conformance/adapters/jco/package.json | 6 +- conformance/adapters/jco/src/run-browser.mjs | 2 +- conformance/adapters/jco/src/run-node.mjs | 2 +- conformance/adapters/wasmtime/Cargo.toml | 4 +- conformance/adapters/wasmtime/src/main.rs | 6 +- conformance/adapters/wasmtime/tests/oracle.rs | 2 +- conformance/guest/Cargo.toml | 2 +- conformance/guest/wit/world.wit | 2 +- conformance/harness/Cargo.toml | 2 +- conformance/harness/src/stream.rs | 2 +- conformance/signing-guest/Cargo.toml | 2 +- conformance/signing-guest/src/lib.rs | 4 +- conformance/targets.toml | 2 +- conformance/web/harness.mjs | 4 +- conformance/web/serve.mjs | 2 +- examples/componentize-demo/README.md | 10 +- examples/componentize-demo/app.js | 4 +- .../wit/deps/wasi-random/random.wit | 2 +- examples/componentize-demo/wit/world.wit | 2 +- examples/crypto-demo/Cargo.toml | 2 +- examples/crypto-demo/wit/world.wit | 2 +- examples/demo-driver/src/lib.rs | 2 +- examples/jco-demo/package-lock.json | 4 +- examples/jco-demo/package.json | 6 +- examples/wasmtime-demo/Cargo.toml | 8 +- examples/wasmtime-demo/src/lib.rs | 10 +- examples/wasmtime-demo/src/main.rs | 4 +- examples/wasmtime-demo/tests/demo.rs | 10 +- guest-impl/wit/deps/lann-webcrypto | 1 - guest-sdk/wit/deps/lann-webcrypto | 1 - jco-impl/wit/deps/lann-webcrypto | 1 - .../componentize}/README.md | 8 +- .../componentize}/componentize-js.rev | 0 .../componentize}/componentize-js.sha256 | 0 .../componentize}/interface-check.js | 0 .../componentize}/package-lock.json | 4 +- .../componentize}/package.json | 2 +- .../componentize}/tsconfig.json | 0 .../componentize}/types/imports.d.ts | 0 .../componentize}/webcrypto.js | 0 .../componentize}/wpt/README.md | 10 +- .../componentize}/wpt/component.sh | 22 +-- .../componentize}/wpt/expected.js | 2 +- .../componentize}/wpt/harness.js | 0 .../componentize}/wpt/install-shim-globals.js | 2 +- .../componentize}/wpt/parity-runner.js | 6 +- .../componentize}/wpt/parity/.gitignore | 0 .../componentize}/wpt/parity/baseline.mjs | 0 .../componentize}/wpt/parity/compare.mjs | 4 +- .../componentize}/wpt/parity/losses.js | 4 +- .../wpt/parity/package-lock.json | 0 .../componentize}/wpt/parity/package.json | 4 +- .../componentize}/wpt/parity/roundtrip.mjs | 2 +- .../componentize}/wpt/runner.js | 48 +++---- .../componentize}/wpt/update-expectations.sh | 6 +- .../wpt/update-toolchain-digest.sh | 6 +- .../componentize}/wpt/vendor/LICENSE.md | 0 .../componentize}/wpt/vendor/aes.js | 0 .../wpt/vendor/aes_cbc.https.any.js | 0 .../wpt/vendor/aes_cbc_vectors.js | 0 .../wpt/vendor/aes_ctr.https.any.js | 0 .../wpt/vendor/aes_ctr_vectors.js | 0 .../wpt/vendor/aes_gcm.https.any.js | 0 .../wpt/vendor/aes_gcm_96_iv_fixtures.js | 0 .../wpt/vendor/aes_gcm_vectors.js | 0 .../wpt/vendor/cfrg_curves_bits.js | 0 .../cfrg_curves_bits_curve25519.https.any.js | 0 .../wpt/vendor/cfrg_curves_bits_fixtures.js | 0 .../wpt/vendor/cfrg_curves_keys.js | 0 .../cfrg_curves_keys_curve25519.https.any.js | 0 .../wpt/vendor/digest.https.any.js | 0 .../wpt/vendor/ec_importKey.https.any.js | 0 .../ec_importKey_failures_ECDSA.https.any.js | 0 .../vendor/ec_importKey_failures_fixtures.js | 0 .../wpt/vendor/ecdsa.https.any.js | 0 .../componentize}/wpt/vendor/ecdsa.js | 0 .../componentize}/wpt/vendor/ecdsa_vectors.js | 0 .../componentize}/wpt/vendor/eddsa.js | 0 .../wpt/vendor/eddsa_curve25519.https.any.js | 0 .../eddsa_small_order_points.https.any.js | 0 .../wpt/vendor/eddsa_small_order_points.js | 0 .../componentize}/wpt/vendor/eddsa_vectors.js | 0 .../wpt/vendor/getRandomValues.any.js | 0 .../componentize}/wpt/vendor/helpers.js | 0 .../wpt/vendor/hkdf.https.any.js | 0 .../componentize}/wpt/vendor/hkdf.js | 0 .../componentize}/wpt/vendor/hkdf_vectors.js | 0 .../wpt/vendor/hmac.https.any.js | 0 .../componentize}/wpt/vendor/hmac.js | 0 .../componentize}/wpt/vendor/hmac_vectors.js | 0 .../wpt/vendor/importKey_failures.js | 0 .../componentize}/wpt/vendor/okp_importKey.js | 0 .../vendor/okp_importKey_Ed25519.https.any.js | 0 .../vendor/okp_importKey_X25519.https.any.js | 0 ...kp_importKey_failures_Ed25519.https.any.js | 0 ...okp_importKey_failures_X25519.https.any.js | 0 .../vendor/okp_importKey_failures_fixtures.js | 0 .../wpt/vendor/okp_importKey_fixtures.js | 0 .../wpt/vendor/pbkdf2.https.any.js | 0 .../componentize}/wpt/vendor/pbkdf2.js | 0 .../wpt/vendor/pbkdf2_vectors.js | 0 .../componentize}/wpt/vendor/successes.js | 0 .../wpt/vendor/successes_Ed25519.https.any.js | 0 .../wpt/vendor/successes_HMAC.https.any.js | 0 .../wpt/vendor/successes_X25519.https.any.js | 0 .../vendor/symmetric_importKey.https.any.js | 0 .../wpt/vendor/symmetric_importKey.js | 0 {jco-impl => js/jco}/interface-check.js | 0 {jco-impl => js/jco}/package-lock.json | 4 +- {jco-impl => js/jco}/package.json | 4 +- {jco-impl => js/jco}/test/admission.test.js | 0 {jco-impl => js/jco}/tsconfig.json | 0 {jco-impl => js/jco}/webcrypto.js | 0 js/jco/wit/deps/lann-webcrypto | 1 + {jco-impl => js/jco}/wit/world.wit | 0 justfile | 100 +++++++------- rust-toolchain.toml | 2 +- {impl-core => rust/core}/Cargo.toml | 8 +- {impl-core => rust/core}/src/aead.rs | 0 {impl-core => rust/core}/src/agreement.rs | 0 {impl-core => rust/core}/src/cipher.rs | 0 {impl-core => rust/core}/src/der8410.rs | 0 {impl-core => rust/core}/src/gcm.rs | 2 +- {impl-core => rust/core}/src/hash.rs | 0 {impl-core => rust/core}/src/jwk.rs | 0 {impl-core => rust/core}/src/kdf.rs | 0 {impl-core => rust/core}/src/lib.rs | 4 +- {impl-core => rust/core}/src/mac.rs | 0 {impl-core => rust/core}/src/policy.rs | 0 {impl-core => rust/core}/src/sig.rs | 0 .../guest-provider}/Cargo.toml | 4 +- {guest-impl => rust/guest-provider}/README.md | 8 +- .../guest-provider}/src/buffer.rs | 0 .../guest-provider}/src/lib.rs | 6 +- .../guest-provider}/src/provider.rs | 76 +++++------ rust/guest-provider/wit/deps/lann-webcrypto | 1 + .../guest-provider}/wit/world.wit | 4 +- {guest-sdk => rust/guest}/Cargo.toml | 1 + {guest-sdk => rust/guest}/src/aes_cbc.rs | 0 {guest-sdk => rust/guest}/src/aes_ctr.rs | 0 {guest-sdk => rust/guest}/src/aes_gcm.rs | 0 .../guest}/src/aes_gcm_internal_nonce.rs | 0 .../guest}/src/chacha20_poly1305.rs | 0 {guest-sdk => rust/guest}/src/ecdsa.rs | 0 {guest-sdk => rust/guest}/src/ed25519.rs | 0 {guest-sdk => rust/guest}/src/hmac_sha1.rs | 0 {guest-sdk => rust/guest}/src/hmac_sha2.rs | 0 {guest-sdk => rust/guest}/src/lib.rs | 0 {guest-sdk => rust/guest}/src/sha1_checked.rs | 0 {guest-sdk => rust/guest}/src/sha2.rs | 0 .../guest}/src/xchacha20_poly1305.rs | 0 .../src/xchacha20_poly1305_internal_nonce.rs | 0 rust/guest/wit/deps/lann-webcrypto | 1 + {guest-sdk => rust/guest}/wit/world.wit | 0 {wasmtime-impl => rust/wasmtime}/Cargo.toml | 4 +- .../wasmtime}/src/bindings.rs | 0 {wasmtime-impl => rust/wasmtime}/src/host.rs | 64 ++++----- {wasmtime-impl => rust/wasmtime}/src/lib.rs | 42 +++--- .../wasmtime}/src/limits.rs | 0 .../wasmtime}/src/standalone.rs | 0 .../wasmtime}/src/streams.rs | 0 rust/wasmtime/wit/deps/lann-webcrypto | 1 + .../wasmtime}/wit/world.wit | 0 scripts/setup.sh | 14 +- timing-lab/README.md | 2 +- wasmtime-impl/wit/deps/lann-webcrypto | 1 - wit/README.md | 2 +- 179 files changed, 475 insertions(+), 462 deletions(-) delete mode 120000 guest-impl/wit/deps/lann-webcrypto delete mode 120000 guest-sdk/wit/deps/lann-webcrypto delete mode 120000 jco-impl/wit/deps/lann-webcrypto rename {componentize-sdk => js/componentize}/README.md (95%) rename {componentize-sdk => js/componentize}/componentize-js.rev (100%) rename {componentize-sdk => js/componentize}/componentize-js.sha256 (100%) rename {componentize-sdk => js/componentize}/interface-check.js (100%) rename {componentize-sdk => js/componentize}/package-lock.json (88%) rename {componentize-sdk => js/componentize}/package.json (90%) rename {componentize-sdk => js/componentize}/tsconfig.json (100%) rename {componentize-sdk => js/componentize}/types/imports.d.ts (100%) rename {componentize-sdk => js/componentize}/webcrypto.js (100%) rename {componentize-sdk => js/componentize}/wpt/README.md (96%) rename {componentize-sdk => js/componentize}/wpt/component.sh (94%) rename {componentize-sdk => js/componentize}/wpt/expected.js (98%) rename {componentize-sdk => js/componentize}/wpt/harness.js (100%) rename {componentize-sdk => js/componentize}/wpt/install-shim-globals.js (87%) rename {componentize-sdk => js/componentize}/wpt/parity-runner.js (86%) rename {componentize-sdk => js/componentize}/wpt/parity/.gitignore (100%) rename {componentize-sdk => js/componentize}/wpt/parity/baseline.mjs (100%) rename {componentize-sdk => js/componentize}/wpt/parity/compare.mjs (98%) rename {componentize-sdk => js/componentize}/wpt/parity/losses.js (99%) rename {componentize-sdk => js/componentize}/wpt/parity/package-lock.json (100%) rename {componentize-sdk => js/componentize}/wpt/parity/package.json (57%) rename {componentize-sdk => js/componentize}/wpt/parity/roundtrip.mjs (94%) rename {componentize-sdk => js/componentize}/wpt/runner.js (87%) rename {componentize-sdk => js/componentize}/wpt/update-expectations.sh (90%) rename {componentize-sdk => js/componentize}/wpt/update-toolchain-digest.sh (96%) rename {componentize-sdk => js/componentize}/wpt/vendor/LICENSE.md (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/aes.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/aes_cbc.https.any.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/aes_cbc_vectors.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/aes_ctr.https.any.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/aes_ctr_vectors.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/aes_gcm.https.any.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/aes_gcm_96_iv_fixtures.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/aes_gcm_vectors.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/cfrg_curves_bits.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/cfrg_curves_bits_curve25519.https.any.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/cfrg_curves_bits_fixtures.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/cfrg_curves_keys.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/cfrg_curves_keys_curve25519.https.any.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/digest.https.any.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/ec_importKey.https.any.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/ec_importKey_failures_ECDSA.https.any.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/ec_importKey_failures_fixtures.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/ecdsa.https.any.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/ecdsa.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/ecdsa_vectors.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/eddsa.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/eddsa_curve25519.https.any.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/eddsa_small_order_points.https.any.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/eddsa_small_order_points.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/eddsa_vectors.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/getRandomValues.any.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/helpers.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/hkdf.https.any.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/hkdf.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/hkdf_vectors.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/hmac.https.any.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/hmac.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/hmac_vectors.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/importKey_failures.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/okp_importKey.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/okp_importKey_Ed25519.https.any.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/okp_importKey_X25519.https.any.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/okp_importKey_failures_Ed25519.https.any.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/okp_importKey_failures_X25519.https.any.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/okp_importKey_failures_fixtures.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/okp_importKey_fixtures.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/pbkdf2.https.any.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/pbkdf2.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/pbkdf2_vectors.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/successes.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/successes_Ed25519.https.any.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/successes_HMAC.https.any.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/successes_X25519.https.any.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/symmetric_importKey.https.any.js (100%) rename {componentize-sdk => js/componentize}/wpt/vendor/symmetric_importKey.js (100%) rename {jco-impl => js/jco}/interface-check.js (100%) rename {jco-impl => js/jco}/package-lock.json (99%) rename {jco-impl => js/jco}/package.json (77%) rename {jco-impl => js/jco}/test/admission.test.js (100%) rename {jco-impl => js/jco}/tsconfig.json (100%) rename {jco-impl => js/jco}/webcrypto.js (100%) create mode 120000 js/jco/wit/deps/lann-webcrypto rename {jco-impl => js/jco}/wit/world.wit (100%) rename {impl-core => rust/core}/Cargo.toml (91%) rename {impl-core => rust/core}/src/aead.rs (100%) rename {impl-core => rust/core}/src/agreement.rs (100%) rename {impl-core => rust/core}/src/cipher.rs (100%) rename {impl-core => rust/core}/src/der8410.rs (100%) rename {impl-core => rust/core}/src/gcm.rs (99%) rename {impl-core => rust/core}/src/hash.rs (100%) rename {impl-core => rust/core}/src/jwk.rs (100%) rename {impl-core => rust/core}/src/kdf.rs (100%) rename {impl-core => rust/core}/src/lib.rs (98%) rename {impl-core => rust/core}/src/mac.rs (100%) rename {impl-core => rust/core}/src/policy.rs (100%) rename {impl-core => rust/core}/src/sig.rs (100%) rename {guest-impl => rust/guest-provider}/Cargo.toml (91%) rename {guest-impl => rust/guest-provider}/README.md (97%) rename {guest-impl => rust/guest-provider}/src/buffer.rs (100%) rename {guest-impl => rust/guest-provider}/src/lib.rs (76%) rename {guest-impl => rust/guest-provider}/src/provider.rs (95%) create mode 120000 rust/guest-provider/wit/deps/lann-webcrypto rename {guest-impl => rust/guest-provider}/wit/world.wit (94%) rename {guest-sdk => rust/guest}/Cargo.toml (98%) rename {guest-sdk => rust/guest}/src/aes_cbc.rs (100%) rename {guest-sdk => rust/guest}/src/aes_ctr.rs (100%) rename {guest-sdk => rust/guest}/src/aes_gcm.rs (100%) rename {guest-sdk => rust/guest}/src/aes_gcm_internal_nonce.rs (100%) rename {guest-sdk => rust/guest}/src/chacha20_poly1305.rs (100%) rename {guest-sdk => rust/guest}/src/ecdsa.rs (100%) rename {guest-sdk => rust/guest}/src/ed25519.rs (100%) rename {guest-sdk => rust/guest}/src/hmac_sha1.rs (100%) rename {guest-sdk => rust/guest}/src/hmac_sha2.rs (100%) rename {guest-sdk => rust/guest}/src/lib.rs (100%) rename {guest-sdk => rust/guest}/src/sha1_checked.rs (100%) rename {guest-sdk => rust/guest}/src/sha2.rs (100%) rename {guest-sdk => rust/guest}/src/xchacha20_poly1305.rs (100%) rename {guest-sdk => rust/guest}/src/xchacha20_poly1305_internal_nonce.rs (100%) create mode 120000 rust/guest/wit/deps/lann-webcrypto rename {guest-sdk => rust/guest}/wit/world.wit (100%) rename {wasmtime-impl => rust/wasmtime}/Cargo.toml (91%) rename {wasmtime-impl => rust/wasmtime}/src/bindings.rs (100%) rename {wasmtime-impl => rust/wasmtime}/src/host.rs (97%) rename {wasmtime-impl => rust/wasmtime}/src/lib.rs (93%) rename {wasmtime-impl => rust/wasmtime}/src/limits.rs (100%) rename {wasmtime-impl => rust/wasmtime}/src/standalone.rs (100%) rename {wasmtime-impl => rust/wasmtime}/src/streams.rs (100%) create mode 120000 rust/wasmtime/wit/deps/lann-webcrypto rename {wasmtime-impl => rust/wasmtime}/wit/world.wit (100%) delete mode 120000 wasmtime-impl/wit/deps/lann-webcrypto diff --git a/.cargo/mutants.toml b/.cargo/mutants.toml index 6dfa6912..bf784564 100644 --- a/.cargo/mutants.toml +++ b/.cargo/mutants.toml @@ -6,8 +6,8 @@ # the cross-implementation cases distinguish it. test_package = [ - "webcrypto-impl-core", - "wasmtime-webcrypto", + "lann-webcrypto-core", + "lann-webcrypto-wasmtime", "conformance-adapter-wasmtime", ] diff --git a/.github/pages/index.html b/.github/pages/index.html index 9728e5b5..254f19e8 100644 --- a/.github/pages/index.html +++ b/.github/pages/index.html @@ -35,7 +35,7 @@

lann:webcrypto

browser" run
  • - wasmtime-webcrypto + lann-webcrypto-wasmtime — API docs for the Wasmtime host crate
  • diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b5f110aa..703f8848 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,7 +48,7 @@ jobs: - name: Run rust checks run: just rust-checks - # The WPT WebCryptoAPI suites against the componentize-sdk JS guest + # The WPT WebCryptoAPI suites against the webcrypto-componentize JS guest # library: componentizes the runner with the pinned componentize-js # (downloaded — see the componentize-js-toolchain workflow), composes it # with a freshly built in-guest provider and driver, and runs it under diff --git a/.github/workflows/componentize-js-toolchain.yml b/.github/workflows/componentize-js-toolchain.yml index 7023b53f..e07989a0 100644 --- a/.github/workflows/componentize-js-toolchain.yml +++ b/.github/workflows/componentize-js-toolchain.yml @@ -6,7 +6,7 @@ name: componentize-js toolchain # function of nothing but the pinned revision and the host platform, so it # is built once per (revision, platform) and published on the rolling # `toolchains` release; CI's gating jobs and contributors download it -# (componentize-sdk/wpt/component.sh). +# (js/componentize/wpt/component.sh). # # Pushing a change to the pin runs this automatically. Until it finishes, # checks that need the toolchain fail with instructions rather than silently @@ -15,7 +15,7 @@ name: componentize-js toolchain on: push: paths: - - componentize-sdk/componentize-js.rev + - js/componentize/componentize-js.rev - .github/workflows/componentize-js-toolchain.yml workflow_dispatch: @@ -48,7 +48,7 @@ jobs: id: id run: | { - echo "rev=$(cat componentize-sdk/componentize-js.rev)" + echo "rev=$(cat js/componentize/componentize-js.rev)" echo "platform=${{ matrix.platform }}" } >> "$GITHUB_OUTPUT" @@ -105,7 +105,7 @@ jobs: asset="componentize-js-${{ steps.id.outputs.rev }}-${{ steps.id.outputs.platform }}.gz" gzip -c "$RUNNER_TEMP/out/bin/componentize-js" > "$asset" echo "asset=$asset" >> "$GITHUB_ENV" - # Consumers pin these (componentize-sdk/componentize-js.sha256) and + # Consumers pin these (js/componentize/componentize-js.sha256) and # refuse to execute anything else, so surface them here rather than # making someone re-download to find out what was built. { @@ -127,7 +127,7 @@ jobs: gh release view toolchains >/dev/null 2>&1 || \ gh release create toolchains --latest=false \ --title "Toolchains (CI artifacts)" \ - --notes "componentize-js builds, one asset per pinned revision and platform. See componentize-sdk/wpt/component.sh." + --notes "componentize-js builds, one asset per pinned revision and platform. See js/componentize/wpt/component.sh." # No --clobber: a published (revision, platform) is immutable, so # that a recorded digest cannot be invalidated by replacing the # asset underneath it. Re-publishing is a deliberate act — delete diff --git a/.github/workflows/timing-lab.yml b/.github/workflows/timing-lab.yml index 99a3b0a9..8443324d 100644 --- a/.github/workflows/timing-lab.yml +++ b/.github/workflows/timing-lab.yml @@ -64,7 +64,7 @@ jobs: env: TIMING_LAB_SAMPLES: ${{ inputs.samples || '2000' }} - # Mutation testing: cargo-mutants over impl-core and wasmtime-impl, oracle = + # Mutation testing: cargo-mutants over lann-webcrypto-core and lann-webcrypto-wasmtime, oracle = # their unit tests + both conformance suites through the wasmtime adapter's # env-gated oracle test. A missed mutant fails the job: it is a change to # the crypto that no suite distinguishes — exactly the assertion-strength diff --git a/.gitignore b/.gitignore index d9df384e..6c69c169 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,7 @@ node_modules/ # Build artifacts build/ -jco-impl/generated/ +js/jco/generated/ examples/jco-demo/generated/ conformance/adapters/jco/generated/ conformance/adapters/jco/generated-signing/ diff --git a/AGENTS.md b/AGENTS.md index 3a47a716..6d41e9c5 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -27,67 +27,74 @@ wit/ # the lann:webcrypto package, one file per layer: # family files (aes/chacha/sha2/hmac/ed25519/ # ecdsa.wit) hold the minting interfaces and grow # as algorithms are added -impl-core/ # the shared RustCrypto core of both Rust - # implementations: cipher/digest dispatch, key - # validation and generation, error rendering, the - # internal-nonce wire format, signature keys (ECDSA - # signing is compiled out of wasm builds — class D); - # crate: webcrypto-impl-core -wasmtime-impl/ # Wasmtime host crate, modeled after - # wasmtime_wasi_http::p3; add_to_linker + - # WasiWebcryptoView; crate: wasmtime-webcrypto -jco-impl/ # jco host LIBRARY: webcrypto.js implements the - # imports over the browser-compatible Web Crypto - # API ONLY; no runtime dependencies, no demo code. +rust/ # the Rust library surface (directory = crate name + # minus the `lann-webcrypto-` family root) + core/ # lann-webcrypto-core: the shared RustCrypto core of + # both Rust implementations: cipher/digest + # dispatch, key validation and generation, error + # rendering, the internal-nonce wire format, + # signature keys (ECDSA signing is compiled out of + # wasm builds — class D) + wasmtime/ # lann-webcrypto-wasmtime: Wasmtime host crate, + # modeled after wasmtime_wasi_http::p3; + # add_to_linker + WasiWebcryptoView + guest/ # lann-webcrypto-guest: guest-side Rust library over + # the lann:webcrypto imports: typed wrappers with + # a byte-source abstraction, so consumers do not + # re-implement the feed-a-stream-and-await + # plumbing; the Rust counterpart of + # @lann/webcrypto-componentize + guest-provider/ # lann-webcrypto-guest-provider: wasm COMPONENT, + # RustCrypto in-guest, EXPORTS the package + # surface; composable via `wac plug`; buffer.rs + # makes input buffering fallible, so allocation + # failure is the operation's error rather than the + # instance's trap; the instance memory limit the + # embedder sets is the retention bound, + # deliberately (see the module doc); see its + # README for the timing-channel classification and + # export policy +js/ # the JS library surface (directory = npm name minus + # the `@lann/webcrypto-` family root) + jco/ # @lann/webcrypto-jco: jco host LIBRARY. + # webcrypto.js implements the imports over the + # browser-compatible Web Crypto API ONLY; no + # runtime dependencies, no demo code. # wit/world.wit names the interfaces it serves; - # `jco-transpile` derives their definitions from it and - # interface-check.js asserts the host against them - # (`just typecheck-jco`); test/ covers the - # admission subsystem conformance cannot reach -guest-impl/ # wasm COMPONENT: RustCrypto in-guest, EXPORTS the - # package surface; composable via `wac plug`; - # buffer.rs makes input buffering fallible, so - # allocation failure is the operation's error - # rather than the instance's trap; the instance - # memory limit the embedder sets is the retention - # bound, deliberately (see the module doc); - # crate: guest-webcrypto — see its README for the - # timing-channel classification and export policy -guest-sdk/ # guest-side Rust library over the lann:webcrypto - # imports: typed wrappers with a byte-source - # abstraction, so consumers do not re-implement - # the feed-a-stream-and-await plumbing; the Rust - # counterpart of componentize-sdk; - # crate: lann-webcrypto-guest -componentize-sdk/ # JS guest library for componentize-js (dicej's - # ComponentizeJS reboot): webcrypto.js exposes a - # crypto.subtle subset (HMAC-SHA-256, AES-256-GCM, - # the derive model: HKDF/PBKDF2/X25519 with - # deriveBits/deriveKey; raw and jwk keys) over the - # lann:webcrypto imports; the - # toolchain revision is pinned in + # `jco-transpile` derives their definitions from + # it and interface-check.js asserts the host + # against them (`just typecheck-jco`); test/ + # covers the admission subsystem conformance + # cannot reach + componentize/ # @lann/webcrypto-componentize: JS guest library for + # componentize-js (dicej's ComponentizeJS reboot): + # webcrypto.js exposes a crypto.subtle subset + # (HMAC-SHA-256, AES-256-GCM, the derive model: + # HKDF/PBKDF2/X25519 with deriveBits/deriveKey; + # raw and jwk keys) over the lann:webcrypto + # imports; the toolchain revision is pinned in # componentize-js.rev; interface-check.js asserts # the exported subset against the SubtleCrypto and # CryptoKey definitions TypeScript ships - # (`just typecheck-componentize-sdk`); wpt/ vendors the - # WebCryptoAPI web-platform-tests and gates in CI, - # componentizing its runner from the tree with a - # digest-pinned componentize-js build + # (`just typecheck-webcrypto-componentize`); wpt/ + # vendors the WebCryptoAPI web-platform-tests and + # gates in CI, componentizing its runner from the + # tree with a digest-pinned componentize-js build # (wpt/component.sh, componentize-js.sha256); the # run's census is pinned by wpt/expected.js examples/ crypto-demo/ # guest component exercising the primitive kinds end - # to end (reaches lann:webcrypto via guest-sdk) + # to end (reaches lann:webcrypto via lann-webcrypto-guest) demo-driver/ # CLI driver (async wasi:cli/run) for the composed # fully in-guest demo - wasmtime-demo/ # thin native host over wasmtime-impl's add_to_linker + wasmtime-demo/ # thin native host over lann-webcrypto-wasmtime's add_to_linker # + the integration test (tests/demo.rs) jco-demo/ # Node 24+ driver for the jco host: transpiles # crypto-demo with jco (one wildcard --map; async # is read from the component) and runs it against - # jco-impl/webcrypto.js + # js/jco/webcrypto.js componentize-demo/ # JS guest (componentize-js) exercising the - # componentize-sdk library; exports the same demo + # webcrypto-componentize library; exports the same demo # interface as crypto-demo, composed and run via # `just test-webcrypto-componentize` (not in ci) conformance/ # cross-implementation conformance tests — see @@ -184,17 +191,17 @@ it does. Changing an interface identifier means updating everyone who names it as a string: the guest bindings (`examples/crypto-demo/src/lib.rs`), the host -bindgen configs (`wasmtime-impl/src/bindings.rs`, +bindgen configs (`rust/wasmtime/src/bindings.rs`, `examples/wasmtime-demo/src/lib.rs`), the in-guest provider world and bindings -(`guest-impl/`), the driver's inline world +(`rust/guest-provider/`), the driver's inline world (`examples/demo-driver/src/lib.rs`), and the camelCased named export in -`jco-impl/webcrypto.js` (the transpile invocations carry one wildcard +`js/jco/webcrypto.js` (the transpile invocations carry one wildcard `--map` and enumerate nothing per interface; async-ness is read from the component — see the conventions note in that file's header). ### The in-guest provider's timing-channel policy -`guest-impl/README.md` carries the timing-channel classification (classes +`rust/guest-provider/README.md` carries the timing-channel classification (classes A–D) and this provider's policy: only class A–C algorithms are exported, always via constant-time-variant implementations; class D algorithm interfaces (RSA private-key ops, ECDSA signing, …) are **never** exported by @@ -207,22 +214,22 @@ adding algorithms, and keep class D out of the provider's world. last sentence: it asserts the conformance signing guest, whose world imports `ecdsa-sign`, does not compose with the provider. Adding a class-D export turns that composition green and fails the gate. The failure mode it guards -against is subtle — see guest-impl/README.md, "What the failure looks like": +against is subtle — see rust/guest-provider/README.md, "What the failure looks like": `wac plug` tolerates imports it cannot satisfy, so the composition breaks only because the provider exports the *generic* interface owning the key resource that the withheld minting interface mints. ### The jco host must stay browser-compatible -`jco-impl/webcrypto.js` uses only `globalThis.crypto.subtle` and +`js/jco/webcrypto.js` uses only `globalThis.crypto.subtle` and `globalThis.crypto.getRandomValues`. No `node:crypto`, no Node-only APIs: the same file must be loadable in a browser unchanged. Node is just the current runner (24+ for JSPI). ### WPT fidelity is a first-class design constraint -`componentize-sdk/webcrypto.js` re-exposes the package as `crypto.subtle`, -and the WPT harness (`componentize-sdk/wpt/`) runs the platform's own test +`js/componentize/webcrypto.js` re-exposes the package as `crypto.subtle`, +and the WPT harness (`js/componentize/wpt/`) runs the platform's own test suite through it. That round trip — WPT → shim → WIT → implementation — is the repository's instrument for a question the conformance suites cannot ask: whether `crypto.subtle`'s observable semantics survive the WIT shape. @@ -279,15 +286,15 @@ Run the recipes that cover what you changed, and fix anything they report. | `just validate-wit` | any `.wit` file. | | `just test` | any Rust host/guest code (includes the guest-under-Wasmtime integration test). | | `just build-component` | the `crypto-demo` guest or its WIT. | -| `just test-webcrypto-composed` | the `guest-impl` provider, the demo driver, or any WIT (composes guest + provider + driver with `wac plug` and runs under `wasmtime`). | -| `just typecheck-componentize-sdk` | the `componentize-sdk` library. Asserts its exported surface against the Web Cryptography API definitions TypeScript ships; no component build, nothing generated. | -| `just test-webcrypto-componentize-wpt` | the `componentize-sdk` library, its `wpt/` harness or vendored files, the in-guest provider, or any WIT. Gates in CI. The runner is componentized from your tree in seconds; the componentize-js build it needs is downloaded and digest-verified (`componentize-sdk/wpt/component.sh`), never compiled here. Changing `componentize-sdk/componentize-js.rev` triggers the `componentize-js-toolchain` workflow; this check then fails until that publishes *and* `just update-toolchain-digest` records the new digests. Intentional changes to the test census also need `just update-wpt-expectations`. | +| `just test-webcrypto-composed` | the `lann-webcrypto-guest-provider` provider, the demo driver, or any WIT (composes guest + provider + driver with `wac plug` and runs under `wasmtime`). | +| `just typecheck-webcrypto-componentize` | the `webcrypto-componentize` library. Asserts its exported surface against the Web Cryptography API definitions TypeScript ships; no component build, nothing generated. | +| `just test-webcrypto-componentize-wpt` | the `webcrypto-componentize` library, its `wpt/` harness or vendored files, the in-guest provider, or any WIT. Gates in CI. The runner is componentized from your tree in seconds; the componentize-js build it needs is downloaded and digest-verified (`js/componentize/wpt/component.sh`), never compiled here. Changing `js/componentize/componentize-js.rev` triggers the `componentize-js-toolchain` workflow; this check then fails until that publishes *and* `just update-toolchain-digest` records the new digests. Intentional changes to the test census also need `just update-wpt-expectations`. | | `just conformance` | any host/guest behavior the tests assert — the WIT surface, an implementation, the conformance guest/vectors/translation policy, or targets.toml. Intentional case changes also need `just update-conformance-lock`. Gates on the wasmtime, composed, and jco-node targets (Node 24+); jco-browser additionally gates in CI (the Actions runner ships Chrome) — locally, opt in with `CONFORMANCE_BROWSER=1` (needs Chrome/Chromium 137+). | | `just transpile` | anything affecting the component's interfaces, or the transpile flags in `examples/jco-demo/package.json`. | | `just test-jco-host` | the jco host's input-buffering admission subsystem (`configure`, the admission queue). Runs `webcrypto.js` directly under `node --test`; the conformance suite cannot reach this code, since it runs cases sequentially. | | `just typecheck-jco` | the jco host (`webcrypto.js`), its world, or any WIT. Regenerates the interface definitions and type-checks the host against them; no component build. | | `just test-node` | the jco host (`webcrypto.js`) or the component it runs. | -| `just wpt-parity` | the `componentize-sdk` library, its `wpt/` harness or vendored files, the jco host, or any WIT. Gates in CI (the jco job). Runs the vendored WPT suites against the platform's own `crypto.subtle` and through the jco-transpiled shim, holding the round trip to the baseline's pass set; the known losses are pinned in `componentize-sdk/wpt/parity/losses.js`. Intentional loss-set changes need `just update-wpt-parity`. Needs Node 24+ and the pinned componentize-js (downloaded, like the composed WPT gate). | +| `just wpt-parity` | the `webcrypto-componentize` library, its `wpt/` harness or vendored files, the jco host, or any WIT. Gates in CI (the jco job). Runs the vendored WPT suites against the platform's own `crypto.subtle` and through the jco-transpiled shim, holding the round trip to the baseline's pass set; the known losses are pinned in `js/componentize/wpt/parity/losses.js`. Intentional loss-set changes need `just update-wpt-parity`. Needs Node 24+ and the pinned componentize-js (downloaded, like the composed WPT gate). | | `just check` | broad Rust/WIT changes — the quick gate for most commits. | | `just ci` | anything touching the guest, jco host, or WIT. | @@ -445,7 +452,7 @@ closed numbers remain stable references. ## Direction (designed, not yet built) - WPT platform parity through the jco path: the measuring harness exists - (`just wpt-parity` — see componentize-sdk/wpt/README.md, "The parity + (`just wpt-parity` — see js/componentize/wpt/README.md, "The parity gate") and pins the loss set; what remains is driving that set down. Growing toward parity is tiered — first behaviors the WIT already carries but the shim does not serve (more hashes, Ed25519/ECDSA, diff --git a/Cargo.lock b/Cargo.lock index a41d53d4..cec407cc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -289,10 +289,10 @@ dependencies = [ "anyhow", "clap", "conformance-report", + "lann-webcrypto-wasmtime", "serde_json", "tokio", "wasmtime", - "wasmtime-webcrypto", ] [[package]] @@ -1022,14 +1022,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "guest-webcrypto" -version = "0.1.0" -dependencies = [ - "webcrypto-impl-core", - "wit-bindgen 0.59.0", -] - [[package]] name = "hashbrown" version = "0.16.1" @@ -1172,6 +1164,35 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "lann-webcrypto-core" +version = "0.1.0" +dependencies = [ + "aes", + "aes-gcm", + "base64", + "chacha20poly1305", + "ctr", + "der", + "ed25519-dalek", + "getrandom 0.3.4", + "ghash", + "hex-literal", + "hkdf", + "hmac", + "p256", + "p384", + "pkcs8", + "serde_json", + "sha1", + "sha1-checked", + "sha2", + "spki", + "subtle", + "x25519-dalek", + "zeroize", +] + [[package]] name = "lann-webcrypto-guest" version = "0.1.0" @@ -1182,6 +1203,24 @@ dependencies = [ "wit-bindgen 0.59.0", ] +[[package]] +name = "lann-webcrypto-guest-provider" +version = "0.1.0" +dependencies = [ + "lann-webcrypto-core", + "wit-bindgen 0.59.0", +] + +[[package]] +name = "lann-webcrypto-wasmtime" +version = "0.1.0" +dependencies = [ + "futures", + "lann-webcrypto-core", + "mea", + "wasmtime", +] + [[package]] name = "leb128fmt" version = "0.1.0" @@ -2264,6 +2303,16 @@ dependencies = [ "wit-parser 0.252.0", ] +[[package]] +name = "wasmtime-demo" +version = "0.1.0" +dependencies = [ + "anyhow", + "lann-webcrypto-wasmtime", + "tokio", + "wasmtime", +] + [[package]] name = "wasmtime-environ" version = "47.0.2" @@ -2451,26 +2500,6 @@ dependencies = [ "wit-parser 0.252.0", ] -[[package]] -name = "wasmtime-webcrypto" -version = "0.1.0" -dependencies = [ - "futures", - "mea", - "wasmtime", - "webcrypto-impl-core", -] - -[[package]] -name = "wasmtime-webcrypto-demo" -version = "0.1.0" -dependencies = [ - "anyhow", - "tokio", - "wasmtime", - "wasmtime-webcrypto", -] - [[package]] name = "wast" version = "254.0.0" @@ -2493,35 +2522,6 @@ dependencies = [ "wast", ] -[[package]] -name = "webcrypto-impl-core" -version = "0.1.0" -dependencies = [ - "aes", - "aes-gcm", - "base64", - "chacha20poly1305", - "ctr", - "der", - "ed25519-dalek", - "getrandom 0.3.4", - "ghash", - "hex-literal", - "hkdf", - "hmac", - "p256", - "p384", - "pkcs8", - "serde_json", - "sha1", - "sha1-checked", - "sha2", - "spki", - "subtle", - "x25519-dalek", - "zeroize", -] - [[package]] name = "winapi" version = "0.3.9" diff --git a/Cargo.toml b/Cargo.toml index bf4a2c6c..420c4eb5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,9 +1,9 @@ [workspace] members = [ - "impl-core", - "guest-sdk", - "wasmtime-impl", - "guest-impl", + "rust/core", + "rust/guest", + "rust/wasmtime", + "rust/guest-provider", "examples/crypto-demo", "examples/demo-driver", "examples/wasmtime-demo", diff --git a/README.md b/README.md index 26a5c267..f1833605 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ algorithm: `error` variant carries no misuse cases — incrementality comes from the streams, not from resource state. - **`crypto.subtle` fidelity is measured, not assumed.** The - `componentize-sdk` library re-exposes the package as `crypto.subtle`, and + `webcrypto-componentize` library re-exposes the package as `crypto.subtle`, and the vendored WebCryptoAPI web-platform-tests run through it in CI — WPT → shim → WIT → implementation — so the platform's own test suite meters what the interface shape preserves. Any deviation the shape forced @@ -81,26 +81,31 @@ are specified in [`wit/README.md`](wit/README.md) and the WIT doc comments. ``` wit/ # the lann:webcrypto package (defined once, here) -impl-core/ # shared RustCrypto core of both Rust - # implementations (crate: webcrypto-impl-core); - # ECDSA signing is compiled out of wasm builds -wasmtime-impl/ # Wasmtime host crate (RustCrypto); add_to_linker + - # WasiWebcryptoView; crate: wasmtime-webcrypto -jco-impl/ # jco host library: webcrypto.js, browser-compatible - # Web Crypto API only (crypto.subtle / - # getRandomValues); no dependencies -guest-impl/ # in-guest wasm component: RustCrypto in wasm, +rust/ # the Rust crates (dir = crate name minus the + # `lann-webcrypto-` family root) + core/ # shared RustCrypto core of both Rust + # implementations; ECDSA signing is compiled out + # of wasm builds + wasmtime/ # Wasmtime host crate (RustCrypto); add_to_linker + + # WasiWebcryptoView + guest/ # guest-side Rust library over the lann:webcrypto + # imports: typed wrappers and a byte-source + # abstraction, so consumers need not hand-roll + # stream plumbing + guest-provider/ # in-guest wasm component: RustCrypto in wasm, # EXPORTS the package surface, composable via # `wac plug` — see its README for the wasm # timing-channel classification & export policy -guest-sdk/ # guest-side Rust library over the lann:webcrypto - # imports (crate: lann-webcrypto-guest): typed - # wrappers and a byte-source abstraction, so - # consumers need not hand-roll stream plumbing -componentize-sdk/ # WebCrypto-subset library (crypto.subtle) for JS +js/ # the JS packages (dir = npm name minus the + # `@lann/webcrypto-` family root) + jco/ # jco host library: webcrypto.js, + # browser-compatible Web Crypto API only + # (crypto.subtle / getRandomValues); no + # dependencies + componentize/ # WebCrypto-subset library (crypto.subtle) for JS # guests built with componentize-js, backed by the # lann:webcrypto imports; the JS counterpart of - # guest-sdk + # rust/guest examples/ crypto-demo/ # guest component: known-answer vectors, chunked # streams, error taxonomy, extractability — @@ -109,9 +114,9 @@ examples/ demo-driver/ # CLI driver for the fully in-guest composed demo wasmtime-demo/ # thin native host + the integration test jco-demo/ # Node 24+ driver: transpiles crypto-demo with jco - # against the jco-impl host and runs it + # against the webcrypto-jco host and runs it componentize-demo/ # JS guest (componentize-js) exercising the - # componentize-sdk library; drives through the + # webcrypto-componentize library; drives through the # same demo interface and composed pipeline conformance/ # cross-implementation conformance tests: vendored # Wycheproof vectors + translation policy, a shared @@ -125,7 +130,7 @@ timing-lab/ # dudect-style statistical timing tests of the Components that name the package in their own WIT pull it in through `wit/deps/lann-webcrypto` symlinks back to the root `wit/`, so there is a -single copy to edit; guests built on `guest-sdk` reach it through that +single copy to edit; guests built on `lann-webcrypto-guest` reach it through that crate's bindings instead. ## Build & run @@ -141,16 +146,16 @@ just test-node # transpile and run the same guest under the jco ho just test-webcrypto-composed # compose guest + in-guest provider + driver (wac plug) # and run the whole thing under `wasmtime run` just test-webcrypto-componentize-wpt # the WPT WebCryptoAPI suites against the - # componentize-sdk JS guest library, via its + # webcrypto-componentize JS guest library, via its # published runner component (no componentize-js - # toolchain needed — see componentize-sdk/wpt/) + # toolchain needed — see js/componentize/wpt/) just test-webcrypto-componentize # the composed pipeline with the JS demo guest # (needs the componentize-js CLI — see - # componentize-sdk/README.md) + # js/componentize/README.md) just wpt-parity # the WPT suites against the platform's own # crypto.subtle and through the jco round trip; # holds the round trip to the platform's pass set - # (see componentize-sdk/wpt/README.md) + # (see js/componentize/wpt/README.md) just conformance # the Wycheproof-derived conformance tests over the # enabled targets; renders conformance/matrix.md just conformance-web # serve the conformance results viewer locally @@ -170,7 +175,7 @@ with `CONFORMANCE_BROWSER=1`; needs Chrome/Chromium 137+); the `crypto-demo` guest additionally covers the jco host end to end. A note on the in-guest provider: wasm offers no portable constant-time -guarantees, so [`guest-impl/README.md`](guest-impl/README.md) classifies +guarantees, so [`rust/guest-provider/README.md`](rust/guest-provider/README.md) classifies algorithms by how exploitable their timing channels are in wasm (classes A–D) and enforces the policy structurally — class D algorithms (e.g. RSA private-key ops) are simply never exported by it, so compositions that need diff --git a/conformance/README.md b/conformance/README.md index 070ed5f9..7507d920 100644 --- a/conformance/README.md +++ b/conformance/README.md @@ -78,10 +78,10 @@ signing-guest/ # the signing suite's host-only guest: probes for # runs under the wasmtime and jco targets only, with # its own tests.lock adapters/ - wasmtime/ # native adapter over wasmtime-webcrypto's add_to_linker + wasmtime/ # native adapter over lann-webcrypto-wasmtime's add_to_linker composed-driver/ # CLI driver for the composed in-guest target (guest + # in-guest provider via `wac plug`); prints results JSON - jco/ # Node + headless-Chromium adapters over jco-impl's + jco/ # Node + headless-Chromium adapters over webcrypto-jco's # webcrypto.js (jco-node gates everywhere; jco-browser # gates in CI, locally opt-in via CONFORMANCE_BROWSER=1 # with Chrome/Chromium 137+ installed); the browser @@ -136,7 +136,7 @@ target facts), written alongside `matrix.md` and cleared with the rest of The page is also itself a live target: **Test this browser** runs both transpiled suites (the same bundles the jco adapters use) against -`jco-impl/webcrypto.js` in the visiting browser — striped across parallel +`js/jco/webcrypto.js` in the visiting browser — striped across parallel Web Workers, each with its own instances of the guests (cases are self-contained one-shots, so shards cannot interfere), falling back to a sequential main-thread run — streaming results into a "this browser" column @@ -156,7 +156,7 @@ alongside the public crates' API docs) by the `pages` workflow: every push to main reruns the conformance tests (including the jco-browser target) and deploys the site assembled by `just conformance-web-site` — a pruned mirror of the repository layout, which the page's relative URLs and the -transpiled guests' relative imports of `jco-impl/webcrypto.js` both rely on. +transpiled guests' relative imports of `js/jco/webcrypto.js` both rely on. ## Why this suite is shaped unlike its WebRTC sibling @@ -192,7 +192,7 @@ crypto conformance tests *functions against mathematics*. `importKey` behavior is unspecified and inconsistent across engines (w3c/webcrypto#356). The private-import known answers (RFC 6979 determinism, scalar export identity, known-point derivation, scalar - range rejection) are pinned by `webcrypto-impl-core`'s unit tests for + range rejection) are pinned by `lann-webcrypto-core`'s unit tests for both Rust implementations instead. ## Deliberately deferred @@ -208,7 +208,7 @@ crypto conformance tests *functions against mathematics*. target-varying degrees of freedom. - **The timing lab** (dudect-style statistical tests of the composed in-guest provider, targeting the class B/C surfaces in - `guest-impl/README.md`): when built, it reports (a matrix column and + `rust/guest-provider/README.md`): when built, it reports (a matrix column and artifacts) but does **not** gate — statistical p-values flapping in CI train people to ignore red. diff --git a/conformance/adapters/composed-driver/src/lib.rs b/conformance/adapters/composed-driver/src/lib.rs index 3ace9853..0d826e0e 100644 --- a/conformance/adapters/composed-driver/src/lib.rs +++ b/conformance/adapters/composed-driver/src/lib.rs @@ -3,7 +3,7 @@ //! //! It imports the conformance guest's exported `conformance:webcrypto/tests` //! interface and exports an async `wasi:cli/run` (via the `wasip3` crate), so -//! the fully composed component — conformance guest + `guest-webcrypto` +//! the fully composed component — conformance guest + `lann-webcrypto-guest-provider` //! provider + this driver — runs under a plain `wasmtime run -S cli`. //! //! The composition fixes the implementation under test, so the target's diff --git a/conformance/adapters/jco/package.json b/conformance/adapters/jco/package.json index 1c479586..c405643c 100644 --- a/conformance/adapters/jco/package.json +++ b/conformance/adapters/jco/package.json @@ -3,12 +3,12 @@ "version": "0.1.0", "private": true, "type": "module", - "description": "jco conformance adapters (Node + headless browser) for lann:webcrypto: transpile the shared conformance guest against the browser-first host (jco-impl/webcrypto.js) and emit the per-target results JSON the conformance runner consumes.", + "description": "jco conformance adapters (Node + headless browser) for lann:webcrypto: transpile the shared conformance guest against the browser-first host (js/jco/webcrypto.js) and emit the per-target results JSON the conformance runner consumes.", "scripts": { - "transpile": "node ../../../scripts/jco-transpile.mjs transpile ../../guest/build/conformance-guest.component.wasm --name conformance-guest --async-mode jspi --map 'lann:webcrypto/*@0.1.0=../../../../jco-impl/webcrypto.js#*' -o generated", + "transpile": "node ../../../scripts/jco-transpile.mjs transpile ../../guest/build/conformance-guest.component.wasm --name conformance-guest --async-mode jspi --map 'lann:webcrypto/*@0.1.0=../../../../js/jco/webcrypto.js#*' -o generated", "run:node": "node --experimental-wasm-jspi src/run-node.mjs", "run:browser": "node src/run-browser.mjs", - "transpile:signing": "node ../../../scripts/jco-transpile.mjs transpile ../../signing-guest/build/conformance-signing-guest.component.wasm --name conformance-signing-guest --async-mode jspi --map 'lann:webcrypto/*@0.1.0=../../../../jco-impl/webcrypto.js#*' -o generated-signing", + "transpile:signing": "node ../../../scripts/jco-transpile.mjs transpile ../../signing-guest/build/conformance-signing-guest.component.wasm --name conformance-signing-guest --async-mode jspi --map 'lann:webcrypto/*@0.1.0=../../../../js/jco/webcrypto.js#*' -o generated-signing", "run:node-signing": "node --experimental-wasm-jspi src/run-node.mjs --signing" }, "devDependencies": { diff --git a/conformance/adapters/jco/src/run-browser.mjs b/conformance/adapters/jco/src/run-browser.mjs index bc9592c6..d04bc1b8 100644 --- a/conformance/adapters/jco/src/run-browser.mjs +++ b/conformance/adapters/jco/src/run-browser.mjs @@ -82,7 +82,7 @@ const collect = (message) => { `; /** Serve the repository root (so the guests' relative imports of - * jco-impl/webcrypto.js resolve) plus the harness page. */ + * js/jco/webcrypto.js resolve) plus the harness page. */ function serve(page) { const server = createServer(async (req, res) => { const path = new URL(req.url, "http://localhost").pathname; diff --git a/conformance/adapters/jco/src/run-node.mjs b/conformance/adapters/jco/src/run-node.mjs index 306b34d0..080136e9 100644 --- a/conformance/adapters/jco/src/run-node.mjs +++ b/conformance/adapters/jco/src/run-node.mjs @@ -1,5 +1,5 @@ // The jco Node conformance adapter: runs a conformance guest against the -// browser-first host (`jco-impl/webcrypto.js`, wired in at transpile time +// browser-first host (`js/jco/webcrypto.js`, wired in at transpile time // via `--map`) under Node and writes its results file under // `conformance/results/`. // diff --git a/conformance/adapters/wasmtime/Cargo.toml b/conformance/adapters/wasmtime/Cargo.toml index 1f8e1690..49e4cfd2 100644 --- a/conformance/adapters/wasmtime/Cargo.toml +++ b/conformance/adapters/wasmtime/Cargo.toml @@ -3,10 +3,10 @@ name = "conformance-adapter-wasmtime" version = "0.1.0" edition = "2021" publish = false -description = "Runs the conformance guest under the Wasmtime host (wasmtime-webcrypto) and writes conformance/results/wasmtime.json." +description = "Runs the conformance guest under the Wasmtime host (lann-webcrypto-wasmtime) and writes conformance/results/wasmtime.json." [dependencies] -wasmtime-webcrypto = { path = "../../../wasmtime-impl" } +lann-webcrypto-wasmtime = { path = "../../../rust/wasmtime" } wasmtime = { version = "47", features = ["component-model", "component-model-async", "async", "cranelift", "runtime"] } tokio = { version = "1", features = ["macros", "rt-multi-thread"] } anyhow = "1" diff --git a/conformance/adapters/wasmtime/src/main.rs b/conformance/adapters/wasmtime/src/main.rs index d99ed495..2b40878f 100644 --- a/conformance/adapters/wasmtime/src/main.rs +++ b/conformance/adapters/wasmtime/src/main.rs @@ -1,6 +1,6 @@ //! `conformance-adapter-wasmtime`: runs a conformance guest under the //! Wasmtime host, with the `lann:webcrypto` imports satisfied by -//! [`wasmtime_webcrypto`]'s RustCrypto implementation, and writes the +//! [`lann_webcrypto_wasmtime`]'s RustCrypto implementation, and writes the //! per-case results as JSON — or, in `--lock-out` mode, writes the suite //! lockfile (case names and feature tags) the runner validates results //! against. See `--help` for the flags. @@ -21,9 +21,9 @@ use conformance_report::{CaseResult, LockCase, Outcome, ResultsFile}; mod harness { use std::path::Path; + use lann_webcrypto_wasmtime::standalone::{self, Ctx}; + use lann_webcrypto_wasmtime::WasiWebcryptoCtx; use wasmtime::component::Accessor; - use wasmtime_webcrypto::standalone::{self, Ctx}; - use wasmtime_webcrypto::WasiWebcryptoCtx; use super::{CaseResult, LockCase, Outcome}; diff --git a/conformance/adapters/wasmtime/tests/oracle.rs b/conformance/adapters/wasmtime/tests/oracle.rs index fbd98ded..9b01dae9 100644 --- a/conformance/adapters/wasmtime/tests/oracle.rs +++ b/conformance/adapters/wasmtime/tests/oracle.rs @@ -11,7 +11,7 @@ //! //! The guests are prebuilt and referenced by absolute path: guest wasm is //! compiled from unmutated sources once, before the mutation run — the -//! subject under mutation is the host stack (impl-core + wasmtime-impl), +//! subject under mutation is the host stack (lann-webcrypto-core + lann-webcrypto-wasmtime), //! which the wasm calls into. use conformance_report::{Outcome, ResultsFile}; diff --git a/conformance/guest/Cargo.toml b/conformance/guest/Cargo.toml index 0b1a65d6..cbb50643 100644 --- a/conformance/guest/Cargo.toml +++ b/conformance/guest/Cargo.toml @@ -11,7 +11,7 @@ crate-type = ["cdylib"] [dependencies] # The lann:webcrypto bindings and stream helpers; carries the imports, so # this component's own world declares only its export. -lann-webcrypto-guest = { path = "../../guest-sdk" } +lann-webcrypto-guest = { path = "../../rust/guest" } # The world-independent half of the guest: probe table, error rendering, # missing-feature validation — shared with the signing guest. conformance-harness = { path = "../harness" } diff --git a/conformance/guest/wit/world.wit b/conformance/guest/wit/world.wit index dec75384..36f25592 100644 --- a/conformance/guest/wit/world.wit +++ b/conformance/guest/wit/world.wit @@ -4,7 +4,7 @@ // browser), or the composed in-guest provider. // // The `lann:webcrypto` package lives once at the repository root `wit/`; -// this guest reaches it through `guest-sdk`'s bindings, so no `deps` copy +// this guest reaches it through `lann-webcrypto-guest`'s bindings, so no `deps` copy // is needed here. package conformance:webcrypto@0.1.0; diff --git a/conformance/harness/Cargo.toml b/conformance/harness/Cargo.toml index 5f761fd8..0db30b12 100644 --- a/conformance/harness/Cargo.toml +++ b/conformance/harness/Cargo.toml @@ -9,7 +9,7 @@ description = "The parts of the conformance guests that are not specific to a wo # The WIT `error` type that `describe` renders and the key resources the # stream helpers drive. Both guests obtain them from here, so they render # failures and deliver inputs identically. -lann-webcrypto-guest = { path = "../../guest-sdk" } +lann-webcrypto-guest = { path = "../../rust/guest" } # `join!` runs an operation and its stream feeder concurrently within a # single cooperative task — the core of the stream helpers. futures = { version = "0.3", default-features = false, features = ["async-await"] } diff --git a/conformance/harness/src/stream.rs b/conformance/harness/src/stream.rs index 2364a19c..a53f799f 100644 --- a/conformance/harness/src/stream.rs +++ b/conformance/harness/src/stream.rs @@ -5,7 +5,7 @@ //! Every helper returns the operation's outcome and the feeder's outcome //! *separately*, so drain-rule violations (a callee closing its input //! stream early) are distinguishable from the call's own error. The -//! guest-sdk wrappers deliberately merge the two; the drain-rule probes are +//! lann-webcrypto-guest wrappers deliberately merge the two; the drain-rule probes are //! why these helpers do not. use lann_webcrypto_guest::bindings::aead::AeadKey; diff --git a/conformance/signing-guest/Cargo.toml b/conformance/signing-guest/Cargo.toml index 09ecc57b..aa1bb8e1 100644 --- a/conformance/signing-guest/Cargo.toml +++ b/conformance/signing-guest/Cargo.toml @@ -11,7 +11,7 @@ crate-type = ["cdylib"] [dependencies] # The lann:webcrypto bindings and stream helpers; carries the imports, so # this component's own world declares only its export. -lann-webcrypto-guest = { path = "../../guest-sdk" } +lann-webcrypto-guest = { path = "../../rust/guest" } # The world-independent half of the guest, shared with the shared-suite # guest: probe table, error rendering, missing-feature validation. conformance-harness = { path = "../harness" } diff --git a/conformance/signing-guest/src/lib.rs b/conformance/signing-guest/src/lib.rs index 08ca273b..a6de9875 100644 --- a/conformance/signing-guest/src/lib.rs +++ b/conformance/signing-guest/src/lib.rs @@ -1,7 +1,7 @@ //! `conformance-signing-guest`: the host-only conformance component. //! //! Probes the signature-minting surface the in-guest provider deliberately -//! does not export — `ecdsa-sign` is class D (see guest-impl/README.md) — +//! does not export — `ecdsa-sign` is class D (see rust/guest-provider/README.md) — //! which the shared `conformance-guest` therefore cannot import, since it //! must compose with that provider. This guest runs only under the //! host-backed targets (wasmtime, jco). @@ -13,7 +13,7 @@ //! import ever derives a public half (the w3c/webcrypto#356 gap). The //! Rust-side private-import known answers (the RFC 6979 A.2.5 //! deterministic signature, out-of-range scalar rejection) are pinned by -//! `webcrypto-impl-core`'s unit tests. +//! `lann-webcrypto-core`'s unit tests. wit_bindgen::generate!({ path: "../guest/wit", diff --git a/conformance/targets.toml b/conformance/targets.toml index e1e9c1b8..512758bb 100644 --- a/conformance/targets.toml +++ b/conformance/targets.toml @@ -47,7 +47,7 @@ missing-features = [] [targets.composed] # The in-guest RustCrypto provider deliberately does not export -# `ecdsa-sign` (class D — see guest-impl/README.md), which excludes the +# `ecdsa-sign` (class D — see rust/guest-provider/README.md), which excludes the # signing suite structurally. `just class-d-composition` asserts the # absent export, so this line cannot outlive the fact it records. missing-features = ["ecdsa-sign"] diff --git a/conformance/web/harness.mjs b/conformance/web/harness.mjs index d2f8930f..88cb0fbe 100644 --- a/conformance/web/harness.mjs +++ b/conformance/web/harness.mjs @@ -1,5 +1,5 @@ // The in-browser conformance harness: drives every case of both transpiled -// conformance suites against jco-impl/webcrypto.js running in *this* +// conformance suites against js/jco/webcrypto.js running in *this* // browser, reporting each result as it completes. Shared between the page's // Web Worker (worker.mjs) and the main-thread fallback (app.mjs), so both // paths run identically; the worker pool itself (`runInWorkers`) also lives @@ -9,7 +9,7 @@ // The module paths are resolved relative to this file, so they work from // any base path (the local server's repo root, or a GitHub Pages project // subpath); the transpiled guests resolve their own relative imports of -// jco-impl/webcrypto.js the same way, so the serving tree must mirror the +// js/jco/webcrypto.js the same way, so the serving tree must mirror the // repository layout (see serve.mjs and the `conformance-web-site` recipe). export const SUITES = [ diff --git a/conformance/web/serve.mjs b/conformance/web/serve.mjs index 4c590b75..9c3d648a 100644 --- a/conformance/web/serve.mjs +++ b/conformance/web/serve.mjs @@ -2,7 +2,7 @@ // Serve the conformance results viewer (conformance/web/) over the // repository root, so the page can fetch conformance/results/matrix.json // and the transpiled guests can resolve their relative imports of -// jco-impl/webcrypto.js. Dependency-free; run it with `just conformance-web` +// js/jco/webcrypto.js. Dependency-free; run it with `just conformance-web` // (which produces the results and transpiled guests first). // // PORT overrides the default port. diff --git a/examples/componentize-demo/README.md b/examples/componentize-demo/README.md index 7a079875..14ceabf7 100644 --- a/examples/componentize-demo/README.md +++ b/examples/componentize-demo/README.md @@ -2,7 +2,7 @@ A JavaScript guest component, built with [componentize-js] (the wit-dylib–based reboot of ComponentizeJS), that exercises the -WebCrypto-subset library in [`componentize-sdk/`](../../componentize-sdk) +WebCrypto-subset library in [`js/componentize/`](../../webcrypto-componentize) end to end: HMAC-SHA-256 known answers (RFC 4231), AES-256-GCM known answers (NIST GCM test case 16), round trips including the empty plaintext, and the key-capability surface (usages, extractability, malformed-input rejection). @@ -12,13 +12,13 @@ key-capability surface (usages, extractability, malformed-input rejection). The guest exports the same `demo:webcrypto-demo/demo@0.1.0` entry point as the Rust `crypto-demo` guest, so the existing `crypto-demo-driver` drives it unchanged, and its `lann:webcrypto` imports are satisfied the same way the -composed demo's are: plugged with the in-guest `guest-webcrypto` provider via +composed demo's are: plugged with the in-guest `lann-webcrypto-guest-provider` provider via `wac plug`, yielding one self-contained component that runs under plain `wasmtime run`. ``` app.js ──componentize-js──▶ componentize-demo.component.wasm - │ wac plug (provider: guest_webcrypto.wasm) + │ wac plug (provider: lann_webcrypto_guest_provider.wasm) ▼ …-with-crypto.wasm │ wac plug (driver: crypto_demo_driver.wasm) @@ -31,7 +31,7 @@ app.js ──componentize-js──▶ componentize-demo.component.wasm Everything in `scripts/setup.sh`. The componentize-js CLI build the recipes need is downloaded and digest-verified automatically on first use (`component.sh toolchain`; set `COMPONENTIZE_JS` to use your own build) — -see ["Toolchain" in the library's README](../../componentize-sdk/README.md#toolchain). +see ["Toolchain" in the library's README](../../js/componentize/README.md#toolchain). ## Running @@ -44,7 +44,7 @@ just test-webcrypto-componentize which componentizes `app.js` against [`wit/world.wit`](wit/world.wit) (module specifiers resolve against the base directory, which the recipe sets to the repository root — hence the guest's root-relative import of -`./componentize-sdk/webcrypto.js`), composes it with the provider and +`./js/componentize/webcrypto.js`), composes it with the provider and driver, and runs the result under `wasmtime`. The driver prints the guest's self-describing summary, which names every check it ran. diff --git a/examples/componentize-demo/app.js b/examples/componentize-demo/app.js index 21c06965..b5f418aa 100644 --- a/examples/componentize-demo/app.js +++ b/examples/componentize-demo/app.js @@ -1,5 +1,5 @@ // The componentize-demo guest: exercises the WebCrypto-subset library in -// `componentize-sdk/webcrypto.js` (HMAC-SHA-256 + AES-256-GCM over the +// `js/componentize/webcrypto.js` (HMAC-SHA-256 + AES-256-GCM over the // `lann:webcrypto` imports) end to end, and exports the same // `demo:webcrypto-demo/demo@0.1.0` entry point as the Rust `crypto-demo` // guest so the existing `crypto-demo-driver` component can drive it. @@ -8,7 +8,7 @@ // which the justfile recipe sets to the repository root — hence the // root-relative library path below. -import { crypto, subtle, CryptoKey, DOMException } from "./componentize-sdk/webcrypto.js"; +import { crypto, subtle, CryptoKey, DOMException } from "./js/componentize/webcrypto.js"; const encoder = new TextEncoder(); diff --git a/examples/componentize-demo/wit/deps/wasi-random/random.wit b/examples/componentize-demo/wit/deps/wasi-random/random.wit index abb4e555..44379546 100644 --- a/examples/componentize-demo/wit/deps/wasi-random/random.wit +++ b/examples/componentize-demo/wit/deps/wasi-random/random.wit @@ -1,5 +1,5 @@ /// Vendored from wasi-random 0.2.0 (the `random` interface only): the -/// world imports it so the componentize-sdk library can serve +/// world imports it so the webcrypto-componentize library can serve /// `crypto.getRandomValues` from the host's entropy. package wasi:random@0.2.0; diff --git a/examples/componentize-demo/wit/world.wit b/examples/componentize-demo/wit/world.wit index 204ee13e..5127c32f 100644 --- a/examples/componentize-demo/wit/world.wit +++ b/examples/componentize-demo/wit/world.wit @@ -7,7 +7,7 @@ package demo:componentize-webcrypto-demo@0.1.0; /// The world for a JS guest using the WebCrypto-subset library in -/// `componentize-sdk/`: it imports exactly the `lann:webcrypto` surface the +/// `js/componentize/`: it imports exactly the `lann:webcrypto` surface the /// library is backed by (HMAC-SHA-256 via `hmac-sha2`/`mac`, AES-256-GCM via /// `aes-gcm`/`aead`, and the derive model via `derivation`/`hkdf`/`pbkdf2`/ /// `key-agreement`/`x25519`, digests via `sha2`/`digest`, signatures via `signature`/`ed25519-*`/`ecdsa-verify` — never `ecdsa-sign`, which the in-guest provider's class-D policy withholds) and exports the same demo entry point as the diff --git a/examples/crypto-demo/Cargo.toml b/examples/crypto-demo/Cargo.toml index 1d535cd1..af2b933a 100644 --- a/examples/crypto-demo/Cargo.toml +++ b/examples/crypto-demo/Cargo.toml @@ -16,7 +16,7 @@ anyhow = "1" wit-bindgen = { version = "0.59", features = ["async"] } # The lann:webcrypto bindings and byte-buffer helpers; carries the imports, # so this component's own world declares only its export. -lann-webcrypto-guest = { path = "../../guest-sdk" } +lann-webcrypto-guest = { path = "../../rust/guest" } # `join!` lets the component feed a stream and await the consuming import # concurrently within a single cooperative task (no OS threads). futures = { version = "0.3", default-features = false, features = ["async-await"] } diff --git a/examples/crypto-demo/wit/world.wit b/examples/crypto-demo/wit/world.wit index d18109ce..5014874a 100644 --- a/examples/crypto-demo/wit/world.wit +++ b/examples/crypto-demo/wit/world.wit @@ -1,6 +1,6 @@ // Demo-only WIT for the `crypto-demo` example component. The shared // `lann:webcrypto` package lives once at the repository root `wit/`; this -// guest reaches it through `guest-sdk`'s bindings, so no `deps` copy is +// guest reaches it through `lann-webcrypto-guest`'s bindings, so no `deps` copy is // needed here. package demo:webcrypto-demo@0.1.0; diff --git a/examples/demo-driver/src/lib.rs b/examples/demo-driver/src/lib.rs index aef16b55..cf5ccc6f 100644 --- a/examples/demo-driver/src/lib.rs +++ b/examples/demo-driver/src/lib.rs @@ -2,7 +2,7 @@ //! //! It imports the `crypto-demo` guest's exported `demo:webcrypto-demo/demo` //! interface and exports an async `wasi:cli/run` (via the `wasip3` crate), so -//! the fully composed component — crypto-demo guest + `guest-webcrypto` +//! the fully composed component — crypto-demo guest + `lann-webcrypto-guest-provider` //! provider + this driver — runs under a plain `wasmtime run -S cli`. //! //! It drives the demo's checks to completion and prints the summary (or the diff --git a/examples/jco-demo/package-lock.json b/examples/jco-demo/package-lock.json index af12f7af..462ff393 100644 --- a/examples/jco-demo/package-lock.json +++ b/examples/jco-demo/package-lock.json @@ -1,11 +1,11 @@ { - "name": "@lann/jco-webcrypto-demo", + "name": "@lann/webcrypto-jco-demo", "version": "0.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "@lann/jco-webcrypto-demo", + "name": "@lann/webcrypto-jco-demo", "version": "0.1.0", "devDependencies": { "@bytecodealliance/jco-transpile": "^0.5.2" diff --git a/examples/jco-demo/package.json b/examples/jco-demo/package.json index 2cee7e48..b39aa483 100644 --- a/examples/jco-demo/package.json +++ b/examples/jco-demo/package.json @@ -1,12 +1,12 @@ { - "name": "@lann/jco-webcrypto-demo", + "name": "@lann/webcrypto-jco-demo", "version": "0.1.0", "private": true, "type": "module", - "description": "crypto-demo driver for the jco host (jco-impl/webcrypto.js): transpiles the guest with jco and runs it on Node 24+.", + "description": "crypto-demo driver for the jco host (js/jco/webcrypto.js): transpiles the guest with jco and runs it on Node 24+.", "scripts": { "build:component": "cd ../.. && just build-component", - "transpile": "node ../../scripts/jco-transpile.mjs transpile ../crypto-demo/build/crypto-demo.component.wasm --name crypto-demo --async-mode jspi --map 'lann:webcrypto/*@0.1.0=../../../jco-impl/webcrypto.js#*' -o generated", + "transpile": "node ../../scripts/jco-transpile.mjs transpile ../crypto-demo/build/crypto-demo.component.wasm --name crypto-demo --async-mode jspi --map 'lann:webcrypto/*@0.1.0=../../../js/jco/webcrypto.js#*' -o generated", "start": "node --experimental-wasm-jspi src/run.mjs", "test": "node --experimental-wasm-jspi src/run.mjs" }, diff --git a/examples/wasmtime-demo/Cargo.toml b/examples/wasmtime-demo/Cargo.toml index 4cab8251..de09648e 100644 --- a/examples/wasmtime-demo/Cargo.toml +++ b/examples/wasmtime-demo/Cargo.toml @@ -1,18 +1,18 @@ [package] -name = "wasmtime-webcrypto-demo" +name = "wasmtime-demo" version = "0.1.0" edition = "2021" publish = false -description = "Thin native host running the crypto-demo component over wasmtime-webcrypto's add_to_linker." +description = "Thin native host running the crypto-demo component over lann-webcrypto-wasmtime's add_to_linker." [[bin]] -name = "wasmtime-webcrypto-host" +name = "wasmtime-demo-host" path = "src/main.rs" [dependencies] # The `lann:webcrypto` host implementation lives in this crate; the binary # obtains its imports from its `add_to_linker`. -wasmtime-webcrypto = { path = "../../wasmtime-impl" } +lann-webcrypto-wasmtime = { path = "../../rust/wasmtime" } wasmtime = { version = "47", features = ["component-model", "component-model-async", "async", "cranelift", "runtime"] } tokio = { version = "1", features = ["macros", "rt-multi-thread", "time"] } anyhow = "1" diff --git a/examples/wasmtime-demo/src/lib.rs b/examples/wasmtime-demo/src/lib.rs index 7476af4c..39780a32 100644 --- a/examples/wasmtime-demo/src/lib.rs +++ b/examples/wasmtime-demo/src/lib.rs @@ -1,17 +1,17 @@ //! Wasmtime host for the `crypto-demo` component, backed by -//! [`wasmtime_webcrypto`]'s RustCrypto implementation of `lann:webcrypto`. +//! [`lann_webcrypto_wasmtime`]'s RustCrypto implementation of `lann:webcrypto`. //! //! It is the non-browser counterpart to the jco (browser WebCrypto) host: it //! loads the same `crypto-demo` component and invokes the component's //! exported async `run`. The component drives every check itself through the //! standard `lann:webcrypto` interfaces, so this host provisions nothing -//! beyond [`wasmtime_webcrypto::standalone`]'s canned embedding. +//! beyond [`lann_webcrypto_wasmtime::standalone`]'s canned embedding. use std::path::Path; +use lann_webcrypto_wasmtime::standalone::{self, Ctx}; +use lann_webcrypto_wasmtime::WasiWebcryptoCtx; use wasmtime::component::Accessor; -use wasmtime_webcrypto::standalone::{self, Ctx}; -use wasmtime_webcrypto::WasiWebcryptoCtx; mod bindings { wasmtime::component::bindgen!({ @@ -27,7 +27,7 @@ mod bindings { } /// Instantiate the `crypto-demo` component at `component_path` with the -/// `lann:webcrypto` imports satisfied by [`wasmtime_webcrypto`], call its +/// `lann:webcrypto` imports satisfied by [`lann_webcrypto_wasmtime`], call its /// exported async `run`, and return the summary string it produces. /// /// A check failure reported by the guest (its `result` `err` diff --git a/examples/wasmtime-demo/src/main.rs b/examples/wasmtime-demo/src/main.rs index 5e1e4421..baa978d1 100644 --- a/examples/wasmtime-demo/src/main.rs +++ b/examples/wasmtime-demo/src/main.rs @@ -1,4 +1,4 @@ -//! Thin CLI over [`wasmtime_webcrypto_demo::run_demo`]: load the +//! Thin CLI over [`wasmtime_demo::run_demo`]: load the //! `crypto-demo` component (path from argument 1, defaulting to the //! repository's build location) and print the summary its `run` export //! returns. @@ -12,7 +12,7 @@ async fn main() -> anyhow::Result<()> { .map(PathBuf::from) .unwrap_or_else(|| PathBuf::from("examples/crypto-demo/build/crypto-demo.component.wasm")); - let summary = wasmtime_webcrypto_demo::run_demo(&path).await?; + let summary = wasmtime_demo::run_demo(&path).await?; println!("crypto-demo (Wasmtime / RustCrypto host) result:"); println!(" {summary}"); Ok(()) diff --git a/examples/wasmtime-demo/tests/demo.rs b/examples/wasmtime-demo/tests/demo.rs index 76c5d3ca..f6424cd1 100644 --- a/examples/wasmtime-demo/tests/demo.rs +++ b/examples/wasmtime-demo/tests/demo.rs @@ -33,7 +33,7 @@ async fn crypto_demo_all_checks_pass() { let workspace_root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../.."); let component = build_component(&workspace_root); - let summary = wasmtime_webcrypto_demo::run_demo(&component) + let summary = wasmtime_demo::run_demo(&component) .await .expect("run_demo failed"); // The summary's declared count must agree with the checks it lists — @@ -60,9 +60,9 @@ async fn tiny_buffer_limit_fails_recoverably() { let workspace_root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../.."); let component = build_component(&workspace_root); - let mut ctx = wasmtime_webcrypto::WasiWebcryptoCtx::new(); + let mut ctx = lann_webcrypto_wasmtime::WasiWebcryptoCtx::new(); ctx.set_per_call_buffer_limit(Some(4)); - let err = wasmtime_webcrypto_demo::run_demo_with(&component, ctx) + let err = wasmtime_demo::run_demo_with(&component, ctx) .await .expect_err("a 4-byte buffer limit must fail the demo's checks"); let rendered = format!("{err:#}"); @@ -90,12 +90,12 @@ async fn checks_complete_under_a_contended_pool() { let workspace_root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../.."); let component = build_component(&workspace_root); - let mut ctx = wasmtime_webcrypto::WasiWebcryptoCtx::new(); + let mut ctx = lann_webcrypto_wasmtime::WasiWebcryptoCtx::new(); ctx.set_per_call_buffer_limit(Some(32 * 1024)); ctx.set_total_buffer_limit(Some(64 * 1024)); let summary = tokio::time::timeout( std::time::Duration::from_secs(120), - wasmtime_webcrypto_demo::run_demo_with(&component, ctx), + wasmtime_demo::run_demo_with(&component, ctx), ) .await .expect("the demo deadlocked against the contended pool") diff --git a/guest-impl/wit/deps/lann-webcrypto b/guest-impl/wit/deps/lann-webcrypto deleted file mode 120000 index b0ff8663..00000000 --- a/guest-impl/wit/deps/lann-webcrypto +++ /dev/null @@ -1 +0,0 @@ -../../../wit \ No newline at end of file diff --git a/guest-sdk/wit/deps/lann-webcrypto b/guest-sdk/wit/deps/lann-webcrypto deleted file mode 120000 index b0ff8663..00000000 --- a/guest-sdk/wit/deps/lann-webcrypto +++ /dev/null @@ -1 +0,0 @@ -../../../wit \ No newline at end of file diff --git a/jco-impl/wit/deps/lann-webcrypto b/jco-impl/wit/deps/lann-webcrypto deleted file mode 120000 index b0ff8663..00000000 --- a/jco-impl/wit/deps/lann-webcrypto +++ /dev/null @@ -1 +0,0 @@ -../../../wit \ No newline at end of file diff --git a/componentize-sdk/README.md b/js/componentize/README.md similarity index 95% rename from componentize-sdk/README.md rename to js/componentize/README.md index e85000e9..59996347 100644 --- a/componentize-sdk/README.md +++ b/js/componentize/README.md @@ -1,9 +1,9 @@ -# componentize-sdk +# webcrypto-componentize A WebCrypto-subset library for JavaScript guests componentized with [componentize-js] (the wit-dylib–based reboot of ComponentizeJS), backed by the `lann:webcrypto` interfaces. This is the JS-guest counterpart of the Rust -[`guest-sdk`](../guest-sdk): where `guest-sdk` wraps the raw bindings in +[`lann-webcrypto-guest`](../lann-webcrypto-guest): where `lann-webcrypto-guest` wraps the raw bindings in ergonomic Rust newtypes, `webcrypto.js` wraps them in the API JS code already knows — `crypto.subtle`. @@ -70,7 +70,7 @@ needed to *run* one. Nobody here builds it: building compiles SpiderMonkey to wasm and needs WASI-SDK 30 and Clang 19+, so the [`componentize-js-toolchain`](../.github/workflows/componentize-js-toolchain.yml) workflow builds one per (revision, platform) and publishes it on the rolling -`toolchains` release, and `componentize-sdk/wpt/component.sh toolchain` +`toolchains` release, and `js/componentize/wpt/component.sh toolchain` downloads it into `target/toolchains/` on first use — verified against the digests in [`componentize-js.sha256`](componentize-js.sha256), since this binary compiles the component the WPT gate tests. Changing the revision @@ -91,7 +91,7 @@ a revision you are evaluating — put it on `COMPONENTIZE_JS`: ```sh git clone https://github.com/dicej/componentize-js cd componentize-js -git checkout "$(cat path/to/componentize-sdk/componentize-js.rev)" +git checkout "$(cat path/to/js/componentize/componentize-js.rev)" # Needs WASI-SDK 30 on WASI_SDK_PATH; see that repository's README. cargo install --path . export COMPONENTIZE_JS="$(command -v componentize-js)" diff --git a/componentize-sdk/componentize-js.rev b/js/componentize/componentize-js.rev similarity index 100% rename from componentize-sdk/componentize-js.rev rename to js/componentize/componentize-js.rev diff --git a/componentize-sdk/componentize-js.sha256 b/js/componentize/componentize-js.sha256 similarity index 100% rename from componentize-sdk/componentize-js.sha256 rename to js/componentize/componentize-js.sha256 diff --git a/componentize-sdk/interface-check.js b/js/componentize/interface-check.js similarity index 100% rename from componentize-sdk/interface-check.js rename to js/componentize/interface-check.js diff --git a/componentize-sdk/package-lock.json b/js/componentize/package-lock.json similarity index 88% rename from componentize-sdk/package-lock.json rename to js/componentize/package-lock.json index aae8a42a..0f43b330 100644 --- a/componentize-sdk/package-lock.json +++ b/js/componentize/package-lock.json @@ -1,11 +1,11 @@ { - "name": "@lann/componentize-webcrypto", + "name": "@lann/webcrypto-componentize", "version": "0.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "@lann/componentize-webcrypto", + "name": "@lann/webcrypto-componentize", "version": "0.1.0", "devDependencies": { "typescript": "^5.9.3" diff --git a/componentize-sdk/package.json b/js/componentize/package.json similarity index 90% rename from componentize-sdk/package.json rename to js/componentize/package.json index 68abb631..d2a6aace 100644 --- a/componentize-sdk/package.json +++ b/js/componentize/package.json @@ -1,5 +1,5 @@ { - "name": "@lann/componentize-webcrypto", + "name": "@lann/webcrypto-componentize", "version": "0.1.0", "private": true, "type": "module", diff --git a/componentize-sdk/tsconfig.json b/js/componentize/tsconfig.json similarity index 100% rename from componentize-sdk/tsconfig.json rename to js/componentize/tsconfig.json diff --git a/componentize-sdk/types/imports.d.ts b/js/componentize/types/imports.d.ts similarity index 100% rename from componentize-sdk/types/imports.d.ts rename to js/componentize/types/imports.d.ts diff --git a/componentize-sdk/webcrypto.js b/js/componentize/webcrypto.js similarity index 100% rename from componentize-sdk/webcrypto.js rename to js/componentize/webcrypto.js diff --git a/componentize-sdk/wpt/README.md b/js/componentize/wpt/README.md similarity index 96% rename from componentize-sdk/wpt/README.md rename to js/componentize/wpt/README.md index 13469da6..c29bb817 100644 --- a/componentize-sdk/wpt/README.md +++ b/js/componentize/wpt/README.md @@ -1,8 +1,8 @@ -# WPT harness for the componentize-sdk library +# WPT harness for the webcrypto-componentize library Runs the [web-platform-tests] WebCryptoAPI suites covering this library's -surface against `componentize-sdk/webcrypto.js` inside a componentize-js -guest, composed with the in-guest `guest-webcrypto` provider — the same +surface against `js/componentize/webcrypto.js` inside a componentize-js +guest, composed with the in-guest `lann-webcrypto-guest-provider` provider — the same pipeline as `examples/componentize-demo`. Run it from the repository root with: @@ -19,7 +19,7 @@ artifacts involved have very different costs, and are handled accordingly: every run. There is no published runner and no input lock: the check always exercises the tree under test, and a stale artifact is not representable. The in-guest provider and driver it is composed with are - likewise built fresh, so `impl-core`/`guest-impl` changes are always + likewise built fresh, so `lann-webcrypto-core`/`lann-webcrypto-guest-provider` changes are always exercised. - The **toolchain** takes about twenty minutes, and depends on nothing but the revision in [`../componentize-js.rev`](../componentize-js.rev). The @@ -89,7 +89,7 @@ round trip: WPT tests ► shim ► WIT ► component ABI ► jco ► platform c `parity/baseline.mjs` runs the suite bundles directly on this Node's `crypto.subtle`; `parity-runner.js` (componentized from the tree like the gating runner, but ungated — it reports every result and asserts nothing -in-guest) is transpiled by jco against `jco-impl/webcrypto.js` and run by +in-guest) is transpiled by jco against `js/jco/webcrypto.js` and run by `parity/roundtrip.mjs`. Because both legs end at the identical platform engine, the platform's own coverage cancels out: whatever it does not implement fails both legs, with no exclusion list to maintain. Every test diff --git a/componentize-sdk/wpt/component.sh b/js/componentize/wpt/component.sh similarity index 94% rename from componentize-sdk/wpt/component.sh rename to js/componentize/wpt/component.sh index 4977bef6..2620fcc9 100755 --- a/componentize-sdk/wpt/component.sh +++ b/js/componentize/wpt/component.sh @@ -9,7 +9,7 @@ # keep honest and no way to test a stale artifact. The *toolchain* is the # expensive one — componentize-js embeds a SpiderMonkey build that takes # ~20 minutes to compile — and it depends on nothing but the revision in -# componentize-sdk/componentize-js.rev, so it is built once per (revision, +# js/componentize/componentize-js.rev, so it is built once per (revision, # platform) by the componentize-js-toolchain workflow and published. Every # other consumer, CI and contributor alike, downloads it. # @@ -31,11 +31,11 @@ # COMPONENTIZE_JS_RELEASE override the release URL downloads come from set -euo pipefail -cd "$(dirname "${BASH_SOURCE[0]}")/../.." +cd "$(dirname "${BASH_SOURCE[0]}")/../../.." -V=componentize-sdk/wpt/vendor -B=componentize-sdk/wpt/build -REV="$(cat componentize-sdk/componentize-js.rev)" +V=js/componentize/wpt/vendor +B=js/componentize/wpt/build +REV="$(cat js/componentize/componentize-js.rev)" TOOLCHAIN_DIR=target/toolchains COMPONENTIZE_JS_RELEASE="${COMPONENTIZE_JS_RELEASE:-https://github.com/lann/component-webcrypto/releases/download/toolchains}" @@ -91,11 +91,11 @@ ${REV} on $(platform). A toolchain is published per (revision, platform) by the componentize-js-toolchain workflow, which runs when -componentize-sdk/componentize-js.rev changes. Either: +js/componentize/componentize-js.rev changes. Either: - run that workflow for this revision (it takes ~20 minutes; pushing a change to the pin triggers it automatically), or - build componentize-js yourself and point COMPONENTIZE_JS at it — see - componentize-sdk/README.md. + js/componentize/README.md. EOF exit 1 } @@ -103,10 +103,10 @@ EOF # Load this platform's pinned digests into ASSET_SHA256 / BINARY_SHA256. read_pinned_digests() { local line - line="$(grep -v '^#' componentize-sdk/componentize-js.sha256 | awk -v p="$(platform)" '$1 == p { print }')" + line="$(grep -v '^#' js/componentize/componentize-js.sha256 | awk -v p="$(platform)" '$1 == p { print }')" if [ -z "$line" ]; then cat >&2 < 0) { /** @param {string[]} keys */ function writeLosses(keys) { const header = `// The WPT parity ratchet: every test the platform baseline passes that the -// round trip (shim -> WIT -> jco -> jco-impl) does not, keyed +// round trip (shim -> WIT -> jco -> webcrypto-jco) does not, keyed // \`group :: test name\`. Generated by \`just update-wpt-parity\`; compare.mjs // fails on any loss not listed here and on any listed loss no longer // observed, so this file only changes deliberately and only shrinks as the // shim serves more of the platform's behavior. Which kind each loss is — // unserved or WIT-forced — is the shim header's deviations registry's to -// say (componentize-sdk/webcrypto.js). +// say (js/componentize/webcrypto.js). `; const body = keys .sort() diff --git a/componentize-sdk/wpt/parity/losses.js b/js/componentize/wpt/parity/losses.js similarity index 99% rename from componentize-sdk/wpt/parity/losses.js rename to js/componentize/wpt/parity/losses.js index a1186376..418b5925 100644 --- a/componentize-sdk/wpt/parity/losses.js +++ b/js/componentize/wpt/parity/losses.js @@ -1,11 +1,11 @@ // The WPT parity ratchet: every test the platform baseline passes that the -// round trip (shim -> WIT -> jco -> jco-impl) does not, keyed +// round trip (shim -> WIT -> jco -> webcrypto-jco) does not, keyed // `group :: test name`. Generated by `just update-wpt-parity`; compare.mjs // fails on any loss not listed here and on any listed loss no longer // observed, so this file only changes deliberately and only shrinks as the // shim serves more of the platform's behavior. Which kind each loss is — // unserved or WIT-forced — is the shim header's deviations registry's to -// say (componentize-sdk/webcrypto.js). +// say (js/componentize/webcrypto.js). export const KNOWN_LOSSES = [ "derive_bits_keys/cfrg_curves_bits (X25519) :: X25519 mismatched algorithms", "derive_bits_keys/cfrg_curves_keys (X25519) :: X25519 mismatched algorithms", diff --git a/componentize-sdk/wpt/parity/package-lock.json b/js/componentize/wpt/parity/package-lock.json similarity index 100% rename from componentize-sdk/wpt/parity/package-lock.json rename to js/componentize/wpt/parity/package-lock.json diff --git a/componentize-sdk/wpt/parity/package.json b/js/componentize/wpt/parity/package.json similarity index 57% rename from componentize-sdk/wpt/parity/package.json rename to js/componentize/wpt/parity/package.json index d495561e..f80ffddf 100644 --- a/componentize-sdk/wpt/parity/package.json +++ b/js/componentize/wpt/parity/package.json @@ -3,9 +3,9 @@ "version": "0.1.0", "private": true, "type": "module", - "description": "WPT parity gate: the vendored WebCryptoAPI suites run directly against the platform's crypto.subtle (baseline) and through the componentized shim transpiled by jco against jco-impl (round trip); compare.mjs holds the round trip to the baseline's pass set.", + "description": "WPT parity gate: the vendored WebCryptoAPI suites run directly against the platform's crypto.subtle (baseline) and through the componentized shim transpiled by jco against webcrypto-jco (round trip); compare.mjs holds the round trip to the baseline's pass set.", "scripts": { - "transpile": "node ../../../scripts/jco-transpile.mjs transpile ../build/parity-runner.component.wasm --name parity-runner --async-mode jspi --map 'lann:webcrypto/*@0.1.0=../../../../jco-impl/webcrypto.js#*' -o generated", + "transpile": "node ../../../../scripts/jco-transpile.mjs transpile ../build/parity-runner.component.wasm --name parity-runner --async-mode jspi --map 'lann:webcrypto/*@0.1.0=../../../../../js/jco/webcrypto.js#*' -o generated", "baseline": "node baseline.mjs", "roundtrip": "node --experimental-wasm-jspi roundtrip.mjs", "compare": "node compare.mjs" diff --git a/componentize-sdk/wpt/parity/roundtrip.mjs b/js/componentize/wpt/parity/roundtrip.mjs similarity index 94% rename from componentize-sdk/wpt/parity/roundtrip.mjs rename to js/componentize/wpt/parity/roundtrip.mjs index 8b708273..e02e9d97 100644 --- a/componentize-sdk/wpt/parity/roundtrip.mjs +++ b/js/componentize/wpt/parity/roundtrip.mjs @@ -1,6 +1,6 @@ // The round-trip leg of the WPT parity gate: the same vendored WPT suites, // but through the full carrier stack — shim, WIT, component ABI, jco, -// jco-impl — terminating in the same platform `crypto.subtle` the baseline +// webcrypto-jco — terminating in the same platform `crypto.subtle` the baseline // leg measured. Any test the baseline passes and this leg does not is a // loss introduced by that stack. // diff --git a/componentize-sdk/wpt/runner.js b/js/componentize/wpt/runner.js similarity index 87% rename from componentize-sdk/wpt/runner.js rename to js/componentize/wpt/runner.js index a94872aa..7c0bc6e6 100644 --- a/componentize-sdk/wpt/runner.js +++ b/js/componentize/wpt/runner.js @@ -1,6 +1,6 @@ // The WPT runner guest: runs the vendored WPT WebCryptoAPI tests (see // vendor/) against the WebCrypto-subset library in -// `componentize-sdk/webcrypto.js`, inside a componentize-js component. It +// `js/componentize/webcrypto.js`, inside a componentize-js component. It // exports the same `demo:webcrypto-demo/demo@0.1.0` entry point as the demo // guests, so the existing `crypto-demo-driver` drives it through the same // composed pipeline. @@ -21,28 +21,28 @@ // Module specifiers resolve against componentize-js's `--base-directory`, // which the justfile recipe sets to the repository root. -import "./componentize-sdk/wpt/install-shim-globals.js"; -import { EXPECTED } from "./componentize-sdk/wpt/expected.js"; -import { drain, takeResults } from "./componentize-sdk/wpt/harness.js"; -import { run_test as runHmac } from "./componentize-sdk/wpt/build/group-hmac.js"; -import { run_test as runAesGcm } from "./componentize-sdk/wpt/build/group-aes-gcm.js"; -import { run_test as runAesCbc } from "./componentize-sdk/wpt/build/group-aes-cbc.js"; -import { run_test as runAesCtr } from "./componentize-sdk/wpt/build/group-aes-ctr.js"; -import { runTests as runImportKey } from "./componentize-sdk/wpt/build/group-import-key.js"; -import { run_test as runGenerateKey } from "./componentize-sdk/wpt/build/group-generate-key.js"; -import { define_tests_25519 as defineCfrgBits } from "./componentize-sdk/wpt/build/group-cfrg-bits.js"; -import { define_tests_25519 as defineCfrgKeys } from "./componentize-sdk/wpt/build/group-cfrg-keys.js"; -import { runTests as runOkpImportKey } from "./componentize-sdk/wpt/build/group-okp-import-key.js"; -import { run_test as runOkpImportKeyFailures } from "./componentize-sdk/wpt/build/group-okp-import-key-failures.js"; -import { run_digest_tests as runDigest } from "./componentize-sdk/wpt/build/group-digest.js"; -import { run_test as runEddsa } from "./componentize-sdk/wpt/build/group-eddsa.js"; -import { run_test as runEddsaSmallOrder } from "./componentize-sdk/wpt/build/group-eddsa-small-order.js"; -import { run_test as runEcdsa } from "./componentize-sdk/wpt/build/group-ecdsa.js"; -import { run_ec_import_tests as runEcImportKey } from "./componentize-sdk/wpt/build/group-ec-import-key.js"; -import { run_test as runEcImportKeyFailures } from "./componentize-sdk/wpt/build/group-ec-import-key-failures.js"; -import { run_get_random_values_tests as runGetRandomValues } from "./componentize-sdk/wpt/build/group-get-random-values.js"; -import { define_tests as defineHkdf } from "./componentize-sdk/wpt/build/group-hkdf-derive.js"; -import { define_tests as definePbkdf2 } from "./componentize-sdk/wpt/build/group-pbkdf2-derive.js"; +import "./js/componentize/wpt/install-shim-globals.js"; +import { EXPECTED } from "./js/componentize/wpt/expected.js"; +import { drain, takeResults } from "./js/componentize/wpt/harness.js"; +import { run_test as runHmac } from "./js/componentize/wpt/build/group-hmac.js"; +import { run_test as runAesGcm } from "./js/componentize/wpt/build/group-aes-gcm.js"; +import { run_test as runAesCbc } from "./js/componentize/wpt/build/group-aes-cbc.js"; +import { run_test as runAesCtr } from "./js/componentize/wpt/build/group-aes-ctr.js"; +import { runTests as runImportKey } from "./js/componentize/wpt/build/group-import-key.js"; +import { run_test as runGenerateKey } from "./js/componentize/wpt/build/group-generate-key.js"; +import { define_tests_25519 as defineCfrgBits } from "./js/componentize/wpt/build/group-cfrg-bits.js"; +import { define_tests_25519 as defineCfrgKeys } from "./js/componentize/wpt/build/group-cfrg-keys.js"; +import { runTests as runOkpImportKey } from "./js/componentize/wpt/build/group-okp-import-key.js"; +import { run_test as runOkpImportKeyFailures } from "./js/componentize/wpt/build/group-okp-import-key-failures.js"; +import { run_digest_tests as runDigest } from "./js/componentize/wpt/build/group-digest.js"; +import { run_test as runEddsa } from "./js/componentize/wpt/build/group-eddsa.js"; +import { run_test as runEddsaSmallOrder } from "./js/componentize/wpt/build/group-eddsa-small-order.js"; +import { run_test as runEcdsa } from "./js/componentize/wpt/build/group-ecdsa.js"; +import { run_ec_import_tests as runEcImportKey } from "./js/componentize/wpt/build/group-ec-import-key.js"; +import { run_test as runEcImportKeyFailures } from "./js/componentize/wpt/build/group-ec-import-key-failures.js"; +import { run_get_random_values_tests as runGetRandomValues } from "./js/componentize/wpt/build/group-get-random-values.js"; +import { define_tests as defineHkdf } from "./js/componentize/wpt/build/group-hkdf-derive.js"; +import { define_tests as definePbkdf2 } from "./js/componentize/wpt/build/group-pbkdf2-derive.js"; // --- the subset definition, one classifier per group --------------------------- @@ -407,7 +407,7 @@ export const demoWebcryptoDemoDemo010 = { const drift = censusDrift(EXPECTED, census); if (drift.length > 0) { throw new ComponentError( - `WPT census does not match componentize-sdk/wpt/expected.js:\n` + + `WPT census does not match js/componentize/wpt/expected.js:\n` + drift.join("\n") + `\nRe-record with \`just update-wpt-expectations\` once the change is understood.` + `\n${censusLine}`, diff --git a/componentize-sdk/wpt/update-expectations.sh b/js/componentize/wpt/update-expectations.sh similarity index 90% rename from componentize-sdk/wpt/update-expectations.sh rename to js/componentize/wpt/update-expectations.sh index f185f9bd..f5f221e4 100755 --- a/componentize-sdk/wpt/update-expectations.sh +++ b/js/componentize/wpt/update-expectations.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# Re-record componentize-sdk/wpt/expected.js from an actual run. +# Re-record js/componentize/wpt/expected.js from an actual run. # # The runner emits its observed census on every run, passing or failing, so # this works whether the current expectations are stale, empty, or wrong — @@ -10,10 +10,10 @@ # Usage: update-expectations.sh set -euo pipefail -cd "$(dirname "${BASH_SOURCE[0]}")/../.." +cd "$(dirname "${BASH_SOURCE[0]}")/../../.." COMPOSED="${1:?usage: update-expectations.sh }" -EXPECTED=componentize-sdk/wpt/expected.js +EXPECTED=js/componentize/wpt/expected.js output="$(timeout 600 wasmtime run -W component-model-async=y -S cli "$COMPOSED" 2>&1 || true)" census="$(printf '%s\n' "$output" | sed -n 's/.*WPT-CENSUS //p' | tail -1)" diff --git a/componentize-sdk/wpt/update-toolchain-digest.sh b/js/componentize/wpt/update-toolchain-digest.sh similarity index 96% rename from componentize-sdk/wpt/update-toolchain-digest.sh rename to js/componentize/wpt/update-toolchain-digest.sh index 6f40c91a..6d496e25 100755 --- a/componentize-sdk/wpt/update-toolchain-digest.sh +++ b/js/componentize/wpt/update-toolchain-digest.sh @@ -11,10 +11,10 @@ # Usage: update-toolchain-digest.sh [platform] (default: this host's) set -euo pipefail -cd "$(dirname "${BASH_SOURCE[0]}")/../.." +cd "$(dirname "${BASH_SOURCE[0]}")/../../.." -REV="$(cat componentize-sdk/componentize-js.rev)" -PINS=componentize-sdk/componentize-js.sha256 +REV="$(cat js/componentize/componentize-js.rev)" +PINS=js/componentize/componentize-js.sha256 RELEASE="${COMPONENTIZE_JS_RELEASE:-https://github.com/lann/component-webcrypto/releases/download/toolchains}" REPO="${COMPONENTIZE_JS_REPO:-lann/component-webcrypto}" WORKFLOW=".github/workflows/componentize-js-toolchain.yml" diff --git a/componentize-sdk/wpt/vendor/LICENSE.md b/js/componentize/wpt/vendor/LICENSE.md similarity index 100% rename from componentize-sdk/wpt/vendor/LICENSE.md rename to js/componentize/wpt/vendor/LICENSE.md diff --git a/componentize-sdk/wpt/vendor/aes.js b/js/componentize/wpt/vendor/aes.js similarity index 100% rename from componentize-sdk/wpt/vendor/aes.js rename to js/componentize/wpt/vendor/aes.js diff --git a/componentize-sdk/wpt/vendor/aes_cbc.https.any.js b/js/componentize/wpt/vendor/aes_cbc.https.any.js similarity index 100% rename from componentize-sdk/wpt/vendor/aes_cbc.https.any.js rename to js/componentize/wpt/vendor/aes_cbc.https.any.js diff --git a/componentize-sdk/wpt/vendor/aes_cbc_vectors.js b/js/componentize/wpt/vendor/aes_cbc_vectors.js similarity index 100% rename from componentize-sdk/wpt/vendor/aes_cbc_vectors.js rename to js/componentize/wpt/vendor/aes_cbc_vectors.js diff --git a/componentize-sdk/wpt/vendor/aes_ctr.https.any.js b/js/componentize/wpt/vendor/aes_ctr.https.any.js similarity index 100% rename from componentize-sdk/wpt/vendor/aes_ctr.https.any.js rename to js/componentize/wpt/vendor/aes_ctr.https.any.js diff --git a/componentize-sdk/wpt/vendor/aes_ctr_vectors.js b/js/componentize/wpt/vendor/aes_ctr_vectors.js similarity index 100% rename from componentize-sdk/wpt/vendor/aes_ctr_vectors.js rename to js/componentize/wpt/vendor/aes_ctr_vectors.js diff --git a/componentize-sdk/wpt/vendor/aes_gcm.https.any.js b/js/componentize/wpt/vendor/aes_gcm.https.any.js similarity index 100% rename from componentize-sdk/wpt/vendor/aes_gcm.https.any.js rename to js/componentize/wpt/vendor/aes_gcm.https.any.js diff --git a/componentize-sdk/wpt/vendor/aes_gcm_96_iv_fixtures.js b/js/componentize/wpt/vendor/aes_gcm_96_iv_fixtures.js similarity index 100% rename from componentize-sdk/wpt/vendor/aes_gcm_96_iv_fixtures.js rename to js/componentize/wpt/vendor/aes_gcm_96_iv_fixtures.js diff --git a/componentize-sdk/wpt/vendor/aes_gcm_vectors.js b/js/componentize/wpt/vendor/aes_gcm_vectors.js similarity index 100% rename from componentize-sdk/wpt/vendor/aes_gcm_vectors.js rename to js/componentize/wpt/vendor/aes_gcm_vectors.js diff --git a/componentize-sdk/wpt/vendor/cfrg_curves_bits.js b/js/componentize/wpt/vendor/cfrg_curves_bits.js similarity index 100% rename from componentize-sdk/wpt/vendor/cfrg_curves_bits.js rename to js/componentize/wpt/vendor/cfrg_curves_bits.js diff --git a/componentize-sdk/wpt/vendor/cfrg_curves_bits_curve25519.https.any.js b/js/componentize/wpt/vendor/cfrg_curves_bits_curve25519.https.any.js similarity index 100% rename from componentize-sdk/wpt/vendor/cfrg_curves_bits_curve25519.https.any.js rename to js/componentize/wpt/vendor/cfrg_curves_bits_curve25519.https.any.js diff --git a/componentize-sdk/wpt/vendor/cfrg_curves_bits_fixtures.js b/js/componentize/wpt/vendor/cfrg_curves_bits_fixtures.js similarity index 100% rename from componentize-sdk/wpt/vendor/cfrg_curves_bits_fixtures.js rename to js/componentize/wpt/vendor/cfrg_curves_bits_fixtures.js diff --git a/componentize-sdk/wpt/vendor/cfrg_curves_keys.js b/js/componentize/wpt/vendor/cfrg_curves_keys.js similarity index 100% rename from componentize-sdk/wpt/vendor/cfrg_curves_keys.js rename to js/componentize/wpt/vendor/cfrg_curves_keys.js diff --git a/componentize-sdk/wpt/vendor/cfrg_curves_keys_curve25519.https.any.js b/js/componentize/wpt/vendor/cfrg_curves_keys_curve25519.https.any.js similarity index 100% rename from componentize-sdk/wpt/vendor/cfrg_curves_keys_curve25519.https.any.js rename to js/componentize/wpt/vendor/cfrg_curves_keys_curve25519.https.any.js diff --git a/componentize-sdk/wpt/vendor/digest.https.any.js b/js/componentize/wpt/vendor/digest.https.any.js similarity index 100% rename from componentize-sdk/wpt/vendor/digest.https.any.js rename to js/componentize/wpt/vendor/digest.https.any.js diff --git a/componentize-sdk/wpt/vendor/ec_importKey.https.any.js b/js/componentize/wpt/vendor/ec_importKey.https.any.js similarity index 100% rename from componentize-sdk/wpt/vendor/ec_importKey.https.any.js rename to js/componentize/wpt/vendor/ec_importKey.https.any.js diff --git a/componentize-sdk/wpt/vendor/ec_importKey_failures_ECDSA.https.any.js b/js/componentize/wpt/vendor/ec_importKey_failures_ECDSA.https.any.js similarity index 100% rename from componentize-sdk/wpt/vendor/ec_importKey_failures_ECDSA.https.any.js rename to js/componentize/wpt/vendor/ec_importKey_failures_ECDSA.https.any.js diff --git a/componentize-sdk/wpt/vendor/ec_importKey_failures_fixtures.js b/js/componentize/wpt/vendor/ec_importKey_failures_fixtures.js similarity index 100% rename from componentize-sdk/wpt/vendor/ec_importKey_failures_fixtures.js rename to js/componentize/wpt/vendor/ec_importKey_failures_fixtures.js diff --git a/componentize-sdk/wpt/vendor/ecdsa.https.any.js b/js/componentize/wpt/vendor/ecdsa.https.any.js similarity index 100% rename from componentize-sdk/wpt/vendor/ecdsa.https.any.js rename to js/componentize/wpt/vendor/ecdsa.https.any.js diff --git a/componentize-sdk/wpt/vendor/ecdsa.js b/js/componentize/wpt/vendor/ecdsa.js similarity index 100% rename from componentize-sdk/wpt/vendor/ecdsa.js rename to js/componentize/wpt/vendor/ecdsa.js diff --git a/componentize-sdk/wpt/vendor/ecdsa_vectors.js b/js/componentize/wpt/vendor/ecdsa_vectors.js similarity index 100% rename from componentize-sdk/wpt/vendor/ecdsa_vectors.js rename to js/componentize/wpt/vendor/ecdsa_vectors.js diff --git a/componentize-sdk/wpt/vendor/eddsa.js b/js/componentize/wpt/vendor/eddsa.js similarity index 100% rename from componentize-sdk/wpt/vendor/eddsa.js rename to js/componentize/wpt/vendor/eddsa.js diff --git a/componentize-sdk/wpt/vendor/eddsa_curve25519.https.any.js b/js/componentize/wpt/vendor/eddsa_curve25519.https.any.js similarity index 100% rename from componentize-sdk/wpt/vendor/eddsa_curve25519.https.any.js rename to js/componentize/wpt/vendor/eddsa_curve25519.https.any.js diff --git a/componentize-sdk/wpt/vendor/eddsa_small_order_points.https.any.js b/js/componentize/wpt/vendor/eddsa_small_order_points.https.any.js similarity index 100% rename from componentize-sdk/wpt/vendor/eddsa_small_order_points.https.any.js rename to js/componentize/wpt/vendor/eddsa_small_order_points.https.any.js diff --git a/componentize-sdk/wpt/vendor/eddsa_small_order_points.js b/js/componentize/wpt/vendor/eddsa_small_order_points.js similarity index 100% rename from componentize-sdk/wpt/vendor/eddsa_small_order_points.js rename to js/componentize/wpt/vendor/eddsa_small_order_points.js diff --git a/componentize-sdk/wpt/vendor/eddsa_vectors.js b/js/componentize/wpt/vendor/eddsa_vectors.js similarity index 100% rename from componentize-sdk/wpt/vendor/eddsa_vectors.js rename to js/componentize/wpt/vendor/eddsa_vectors.js diff --git a/componentize-sdk/wpt/vendor/getRandomValues.any.js b/js/componentize/wpt/vendor/getRandomValues.any.js similarity index 100% rename from componentize-sdk/wpt/vendor/getRandomValues.any.js rename to js/componentize/wpt/vendor/getRandomValues.any.js diff --git a/componentize-sdk/wpt/vendor/helpers.js b/js/componentize/wpt/vendor/helpers.js similarity index 100% rename from componentize-sdk/wpt/vendor/helpers.js rename to js/componentize/wpt/vendor/helpers.js diff --git a/componentize-sdk/wpt/vendor/hkdf.https.any.js b/js/componentize/wpt/vendor/hkdf.https.any.js similarity index 100% rename from componentize-sdk/wpt/vendor/hkdf.https.any.js rename to js/componentize/wpt/vendor/hkdf.https.any.js diff --git a/componentize-sdk/wpt/vendor/hkdf.js b/js/componentize/wpt/vendor/hkdf.js similarity index 100% rename from componentize-sdk/wpt/vendor/hkdf.js rename to js/componentize/wpt/vendor/hkdf.js diff --git a/componentize-sdk/wpt/vendor/hkdf_vectors.js b/js/componentize/wpt/vendor/hkdf_vectors.js similarity index 100% rename from componentize-sdk/wpt/vendor/hkdf_vectors.js rename to js/componentize/wpt/vendor/hkdf_vectors.js diff --git a/componentize-sdk/wpt/vendor/hmac.https.any.js b/js/componentize/wpt/vendor/hmac.https.any.js similarity index 100% rename from componentize-sdk/wpt/vendor/hmac.https.any.js rename to js/componentize/wpt/vendor/hmac.https.any.js diff --git a/componentize-sdk/wpt/vendor/hmac.js b/js/componentize/wpt/vendor/hmac.js similarity index 100% rename from componentize-sdk/wpt/vendor/hmac.js rename to js/componentize/wpt/vendor/hmac.js diff --git a/componentize-sdk/wpt/vendor/hmac_vectors.js b/js/componentize/wpt/vendor/hmac_vectors.js similarity index 100% rename from componentize-sdk/wpt/vendor/hmac_vectors.js rename to js/componentize/wpt/vendor/hmac_vectors.js diff --git a/componentize-sdk/wpt/vendor/importKey_failures.js b/js/componentize/wpt/vendor/importKey_failures.js similarity index 100% rename from componentize-sdk/wpt/vendor/importKey_failures.js rename to js/componentize/wpt/vendor/importKey_failures.js diff --git a/componentize-sdk/wpt/vendor/okp_importKey.js b/js/componentize/wpt/vendor/okp_importKey.js similarity index 100% rename from componentize-sdk/wpt/vendor/okp_importKey.js rename to js/componentize/wpt/vendor/okp_importKey.js diff --git a/componentize-sdk/wpt/vendor/okp_importKey_Ed25519.https.any.js b/js/componentize/wpt/vendor/okp_importKey_Ed25519.https.any.js similarity index 100% rename from componentize-sdk/wpt/vendor/okp_importKey_Ed25519.https.any.js rename to js/componentize/wpt/vendor/okp_importKey_Ed25519.https.any.js diff --git a/componentize-sdk/wpt/vendor/okp_importKey_X25519.https.any.js b/js/componentize/wpt/vendor/okp_importKey_X25519.https.any.js similarity index 100% rename from componentize-sdk/wpt/vendor/okp_importKey_X25519.https.any.js rename to js/componentize/wpt/vendor/okp_importKey_X25519.https.any.js diff --git a/componentize-sdk/wpt/vendor/okp_importKey_failures_Ed25519.https.any.js b/js/componentize/wpt/vendor/okp_importKey_failures_Ed25519.https.any.js similarity index 100% rename from componentize-sdk/wpt/vendor/okp_importKey_failures_Ed25519.https.any.js rename to js/componentize/wpt/vendor/okp_importKey_failures_Ed25519.https.any.js diff --git a/componentize-sdk/wpt/vendor/okp_importKey_failures_X25519.https.any.js b/js/componentize/wpt/vendor/okp_importKey_failures_X25519.https.any.js similarity index 100% rename from componentize-sdk/wpt/vendor/okp_importKey_failures_X25519.https.any.js rename to js/componentize/wpt/vendor/okp_importKey_failures_X25519.https.any.js diff --git a/componentize-sdk/wpt/vendor/okp_importKey_failures_fixtures.js b/js/componentize/wpt/vendor/okp_importKey_failures_fixtures.js similarity index 100% rename from componentize-sdk/wpt/vendor/okp_importKey_failures_fixtures.js rename to js/componentize/wpt/vendor/okp_importKey_failures_fixtures.js diff --git a/componentize-sdk/wpt/vendor/okp_importKey_fixtures.js b/js/componentize/wpt/vendor/okp_importKey_fixtures.js similarity index 100% rename from componentize-sdk/wpt/vendor/okp_importKey_fixtures.js rename to js/componentize/wpt/vendor/okp_importKey_fixtures.js diff --git a/componentize-sdk/wpt/vendor/pbkdf2.https.any.js b/js/componentize/wpt/vendor/pbkdf2.https.any.js similarity index 100% rename from componentize-sdk/wpt/vendor/pbkdf2.https.any.js rename to js/componentize/wpt/vendor/pbkdf2.https.any.js diff --git a/componentize-sdk/wpt/vendor/pbkdf2.js b/js/componentize/wpt/vendor/pbkdf2.js similarity index 100% rename from componentize-sdk/wpt/vendor/pbkdf2.js rename to js/componentize/wpt/vendor/pbkdf2.js diff --git a/componentize-sdk/wpt/vendor/pbkdf2_vectors.js b/js/componentize/wpt/vendor/pbkdf2_vectors.js similarity index 100% rename from componentize-sdk/wpt/vendor/pbkdf2_vectors.js rename to js/componentize/wpt/vendor/pbkdf2_vectors.js diff --git a/componentize-sdk/wpt/vendor/successes.js b/js/componentize/wpt/vendor/successes.js similarity index 100% rename from componentize-sdk/wpt/vendor/successes.js rename to js/componentize/wpt/vendor/successes.js diff --git a/componentize-sdk/wpt/vendor/successes_Ed25519.https.any.js b/js/componentize/wpt/vendor/successes_Ed25519.https.any.js similarity index 100% rename from componentize-sdk/wpt/vendor/successes_Ed25519.https.any.js rename to js/componentize/wpt/vendor/successes_Ed25519.https.any.js diff --git a/componentize-sdk/wpt/vendor/successes_HMAC.https.any.js b/js/componentize/wpt/vendor/successes_HMAC.https.any.js similarity index 100% rename from componentize-sdk/wpt/vendor/successes_HMAC.https.any.js rename to js/componentize/wpt/vendor/successes_HMAC.https.any.js diff --git a/componentize-sdk/wpt/vendor/successes_X25519.https.any.js b/js/componentize/wpt/vendor/successes_X25519.https.any.js similarity index 100% rename from componentize-sdk/wpt/vendor/successes_X25519.https.any.js rename to js/componentize/wpt/vendor/successes_X25519.https.any.js diff --git a/componentize-sdk/wpt/vendor/symmetric_importKey.https.any.js b/js/componentize/wpt/vendor/symmetric_importKey.https.any.js similarity index 100% rename from componentize-sdk/wpt/vendor/symmetric_importKey.https.any.js rename to js/componentize/wpt/vendor/symmetric_importKey.https.any.js diff --git a/componentize-sdk/wpt/vendor/symmetric_importKey.js b/js/componentize/wpt/vendor/symmetric_importKey.js similarity index 100% rename from componentize-sdk/wpt/vendor/symmetric_importKey.js rename to js/componentize/wpt/vendor/symmetric_importKey.js diff --git a/jco-impl/interface-check.js b/js/jco/interface-check.js similarity index 100% rename from jco-impl/interface-check.js rename to js/jco/interface-check.js diff --git a/jco-impl/package-lock.json b/js/jco/package-lock.json similarity index 99% rename from jco-impl/package-lock.json rename to js/jco/package-lock.json index 4703ddc8..fcf28c4d 100644 --- a/jco-impl/package-lock.json +++ b/js/jco/package-lock.json @@ -1,11 +1,11 @@ { - "name": "@lann/jco-webcrypto", + "name": "@lann/webcrypto-jco", "version": "0.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "@lann/jco-webcrypto", + "name": "@lann/webcrypto-jco", "version": "0.1.0", "devDependencies": { "@bytecodealliance/jco-transpile": "^0.5.2", diff --git a/jco-impl/package.json b/js/jco/package.json similarity index 77% rename from jco-impl/package.json rename to js/jco/package.json index c3aa0cff..baa27030 100644 --- a/jco-impl/package.json +++ b/js/jco/package.json @@ -1,12 +1,12 @@ { - "name": "@lann/jco-webcrypto", + "name": "@lann/webcrypto-jco", "version": "0.1.0", "private": true, "type": "module", "description": "Browser-compatible host for lann:webcrypto over the Web Crypto API. No dependencies; map the lann:webcrypto imports to webcrypto.js when transpiling with jco.", "exports": "./webcrypto.js", "scripts": { - "types": "node ../scripts/jco-transpile.mjs types wit --world-name imports --async-mode jspi -o generated", + "types": "node ../../scripts/jco-transpile.mjs types wit --world-name imports --async-mode jspi -o generated", "typecheck": "npm run types && tsc --noEmit -p tsconfig.json", "test": "node --test 'test/*.test.js'" }, diff --git a/jco-impl/test/admission.test.js b/js/jco/test/admission.test.js similarity index 100% rename from jco-impl/test/admission.test.js rename to js/jco/test/admission.test.js diff --git a/jco-impl/tsconfig.json b/js/jco/tsconfig.json similarity index 100% rename from jco-impl/tsconfig.json rename to js/jco/tsconfig.json diff --git a/jco-impl/webcrypto.js b/js/jco/webcrypto.js similarity index 100% rename from jco-impl/webcrypto.js rename to js/jco/webcrypto.js diff --git a/js/jco/wit/deps/lann-webcrypto b/js/jco/wit/deps/lann-webcrypto new file mode 120000 index 00000000..4a5c5bb1 --- /dev/null +++ b/js/jco/wit/deps/lann-webcrypto @@ -0,0 +1 @@ +../../../../wit \ No newline at end of file diff --git a/jco-impl/wit/world.wit b/js/jco/wit/world.wit similarity index 100% rename from jco-impl/wit/world.wit rename to js/jco/wit/world.wit diff --git a/justfile b/justfile index 82da5205..00a2328e 100644 --- a/justfile +++ b/justfile @@ -22,9 +22,9 @@ jco-checks: @just _step wpt-parity # Everything the componentize CI job runs: the WPT WebCryptoAPI suites -# against the componentize-sdk JS guest library. +# against the webcrypto-componentize JS guest library. componentize-checks: - @just _step typecheck-componentize-sdk + @just _step typecheck-webcrypto-componentize @just _step test-webcrypto-componentize-wpt # Run one recipe, wrapped in GitHub Actions log groups (and, on failure, an @@ -52,15 +52,15 @@ fmt-check: # Run clippy across all crates (the wasm crates on their wasm targets). clippy: - cargo clippy --workspace --exclude crypto-demo --exclude guest-webcrypto --exclude crypto-demo-driver --exclude conformance-guest --exclude conformance-signing-guest --exclude conformance-composed-driver --exclude timing-lab -- -D warnings + cargo clippy --workspace --exclude crypto-demo --exclude lann-webcrypto-guest-provider --exclude crypto-demo-driver --exclude conformance-guest --exclude conformance-signing-guest --exclude conformance-composed-driver --exclude timing-lab -- -D warnings cargo clippy -p crypto-demo --target wasm32-unknown-unknown -- -D warnings cargo clippy -p conformance-guest --target wasm32-unknown-unknown -- -D warnings cargo clippy -p conformance-signing-guest --target wasm32-unknown-unknown -- -D warnings - cargo clippy -p guest-webcrypto --target wasm32-wasip2 -- -D warnings + cargo clippy -p lann-webcrypto-guest-provider --target wasm32-wasip2 -- -D warnings cargo clippy -p crypto-demo-driver --target wasm32-wasip2 -- -D warnings cargo clippy -p timing-lab --target wasm32-wasip2 -- -D warnings cargo clippy -p conformance-composed-driver --target wasm32-wasip2 -- -D warnings - # guest-sdk's optional source adaptors are only compiled with their + # lann-webcrypto-guest's optional source adaptors are only compiled with their # features on, and one of them holds the only code path that can produce # `Error::Read` — the crate's subtlest behaviour. Nothing in the # workspace enables them, so without this they are never checked. @@ -69,9 +69,9 @@ clippy: # Validate WIT packages. validate-wit: wasm-tools component wit wit - wasm-tools component wit wasmtime-impl/wit - wasm-tools component wit jco-impl/wit - wasm-tools component wit guest-impl/wit + wasm-tools component wit rust/wasmtime/wit + wasm-tools component wit js/jco/wit + wasm-tools component wit rust/guest-provider/wit wasm-tools component wit examples/crypto-demo/wit wasm-tools component wit examples/componentize-demo/wit wasm-tools component wit conformance/guest/wit @@ -101,30 +101,30 @@ test-node: transpile # Run the jco host's own unit tests: the input-buffering admission subsystem, # which the conformance suite cannot reach because it runs cases sequentially. test-jco-host: - cd jco-impl && npm test + cd js/jco && npm test # Type-check the jco host against the interface definitions jco-transpile # derives from `wit/`. The definitions are generated on demand, so there is # no checked-in copy to go stale. typecheck-jco: - cd jco-impl && npm run typecheck + cd js/jco && npm run typecheck # Type-check the componentize-js guest library against the Web Cryptography # API definitions TypeScript ships. Nothing is generated, so nothing can go # stale; no component build. -typecheck-componentize-sdk: - cd componentize-sdk && npm run typecheck +typecheck-webcrypto-componentize: + cd js/componentize && npm run typecheck # Run the Wasmtime (native, RustCrypto) host demo. demo-wasmtime: build-component - cargo run --release --bin wasmtime-webcrypto-host -- \ + cargo run --release --bin wasmtime-demo-host -- \ examples/crypto-demo/build/crypto-demo.component.wasm # Build the in-guest provider component (RustCrypto entirely in-guest; it # exports the lann:webcrypto surface) into -# target/wasm32-wasip2/release/guest_webcrypto.wasm. +# target/wasm32-wasip2/release/lann_webcrypto_guest_provider.wasm. build-guest-provider: - cargo build --release -p guest-webcrypto --target wasm32-wasip2 + cargo build --release -p lann-webcrypto-guest-provider --target wasm32-wasip2 # Compose `guest` with the in-guest provider and plug `driver` (a # wasm32-wasip2 bin crate) on top, yielding one self-contained component at @@ -136,7 +136,7 @@ _compose stem guest driver: build-guest-provider cargo build --release -p {{driver}} --target wasm32-wasip2 driver_wasm="target/wasm32-wasip2/release/$(echo '{{driver}}' | tr - _).wasm" wac plug {{guest}} \ - --plug target/wasm32-wasip2/release/guest_webcrypto.wasm \ + --plug target/wasm32-wasip2/release/lann_webcrypto_guest_provider.wasm \ -o target/{{stem}}-with-crypto.wasm wac plug "$driver_wasm" \ --plug target/{{stem}}-with-crypto.wasm \ @@ -163,15 +163,15 @@ test-webcrypto-composed: compose-demo # componentize-js-toolchain workflow publishes one build per pinned revision # and platform, and `component.sh toolchain` downloads it into # target/toolchains on first use (set COMPONENTIZE_JS to use your own build -# instead). The pinned revision lives in componentize-sdk/componentize-js.rev. +# instead). The pinned revision lives in js/componentize/componentize-js.rev. -# Componentize the JS WebCrypto-subset demo guest (componentize-sdk library + +# Componentize the JS WebCrypto-subset demo guest (webcrypto-componentize library + # examples/componentize-demo app) into examples/componentize-demo/build/. # The base directory is the repository root, so the app's module specifiers -# (./componentize-sdk/webcrypto.js) resolve against it. +# (./js/componentize/webcrypto.js) resolve against it. build-componentize-demo: mkdir -p examples/componentize-demo/build - "$(componentize-sdk/wpt/component.sh toolchain)" \ + "$(js/componentize/wpt/component.sh toolchain)" \ -q -d examples/componentize-demo/wit -w componentize-demo \ componentize examples/componentize-demo/app.js -p . \ -o examples/componentize-demo/build/componentize-demo.component.wasm @@ -196,11 +196,11 @@ test-webcrypto-componentize: compose-componentize-demo # refuses to execute it. Pass a platform to record one you are not running # on, e.g. `just update-toolchain-digest linux-x86_64`. update-toolchain-digest platform="": - componentize-sdk/wpt/update-toolchain-digest.sh {{platform}} + js/componentize/wpt/update-toolchain-digest.sh {{platform}} # Run the vendored web-platform-tests WebCryptoAPI suites against the -# componentize-sdk library: every in-subset test must pass; out-of-subset -# tests are reported by count (componentize-sdk/wpt/README.md has the +# webcrypto-componentize library: every in-subset test must pass; out-of-subset +# tests are reported by count (js/componentize/wpt/README.md has the # vendoring and subset policy). The runner is componentized from the working # tree with the pinned componentize-js (downloaded on first use), then # composed with a freshly built in-guest provider and driver and run under @@ -211,55 +211,55 @@ test-webcrypto-componentize-wpt: compose-wpt-runner # Componentize the WPT runner from the working tree and compose it with a # freshly built in-guest provider and driver. -compose-wpt-runner: _componentize-wpt-runner (_compose "wpt-runner" "componentize-sdk/wpt/build/runner.component.wasm" "crypto-demo-driver") +compose-wpt-runner: _componentize-wpt-runner (_compose "wpt-runner" "js/componentize/wpt/build/runner.component.wasm" "crypto-demo-driver") # Componentize the WPT runner from the working tree with the pinned # componentize-js (downloaded on first use). _componentize-wpt-runner: - componentize-sdk/wpt/component.sh build + js/componentize/wpt/component.sh build -# Re-record componentize-sdk/wpt/expected.js from an actual run: run this +# Re-record js/componentize/wpt/expected.js from an actual run: run this # when a change legitimately moves a count, and review the diff — each moved # number is a test that appeared, vanished, or crossed the in-subset # boundary. update-wpt-expectations: compose-wpt-runner - componentize-sdk/wpt/update-expectations.sh target/wpt-runner-composed.wasm + js/componentize/wpt/update-expectations.sh target/wpt-runner-composed.wasm # --- WPT parity (jco path) ------------------------------------------------------ # Run the WPT parity gate: the vendored WPT suites run twice — directly # against this platform's own crypto.subtle (the baseline) and through the -# componentized shim transpiled by jco against jco-impl/webcrypto.js (the +# componentized shim transpiled by jco against js/jco/webcrypto.js (the # round trip) — and the comparator holds the round trip to the baseline's -# pass set, with known losses pinned in componentize-sdk/wpt/parity/losses.js. +# pass set, with known losses pinned in js/componentize/wpt/parity/losses.js. # Both legs end at the same platform crypto, so the delta isolates exactly # what the carrier stack (shim, WIT shape, component ABI, jco) loses. # Needs Node 24+ and the pinned componentize-js (downloaded — see -# componentize-sdk/wpt/component.sh). +# js/componentize/wpt/component.sh). wpt-parity: _wpt-parity-legs - node componentize-sdk/wpt/parity/compare.mjs \ - componentize-sdk/wpt/build/parity-baseline.json \ - componentize-sdk/wpt/build/parity-roundtrip.json + node js/componentize/wpt/parity/compare.mjs \ + js/componentize/wpt/build/parity-baseline.json \ + js/componentize/wpt/build/parity-roundtrip.json -# Re-record componentize-sdk/wpt/parity/losses.js from an actual run: run +# Re-record js/componentize/wpt/parity/losses.js from an actual run: run # this when a change legitimately moves the loss set, and review the diff — # every removed line is a platform behavior the round trip now preserves, # and every added line needs a classification in the shim header's # deviations registry. update-wpt-parity: _wpt-parity-legs - node componentize-sdk/wpt/parity/compare.mjs \ - componentize-sdk/wpt/build/parity-baseline.json \ - componentize-sdk/wpt/build/parity-roundtrip.json --update + node js/componentize/wpt/parity/compare.mjs \ + js/componentize/wpt/build/parity-baseline.json \ + js/componentize/wpt/build/parity-roundtrip.json --update -# Produce both parity legs' results under componentize-sdk/wpt/build/: +# Produce both parity legs' results under js/componentize/wpt/build/: # componentize the ungated parity runner from the tree, transpile it with # jco against the jco host, and run each leg on this Node. _wpt-parity-legs: - componentize-sdk/wpt/component.sh build-parity - cd componentize-sdk/wpt/parity && npm run -s transpile - node componentize-sdk/wpt/parity/baseline.mjs \ - > componentize-sdk/wpt/build/parity-baseline.json - cd componentize-sdk/wpt/parity && node --experimental-wasm-jspi roundtrip.mjs \ + js/componentize/wpt/component.sh build-parity + cd js/componentize/wpt/parity && npm run -s transpile + node js/componentize/wpt/parity/baseline.mjs \ + > js/componentize/wpt/build/parity-baseline.json + cd js/componentize/wpt/parity && node --experimental-wasm-jspi roundtrip.mjs \ > ../build/parity-roundtrip.json # --- conformance ------------------------------------------------------------- @@ -314,12 +314,12 @@ class-d-composition: build-signing-guest build-guest-provider set -uo pipefail output=$(wac plug \ conformance/signing-guest/build/conformance-signing-guest.component.wasm \ - --plug target/wasm32-wasip2/release/guest_webcrypto.wasm \ + --plug target/wasm32-wasip2/release/lann_webcrypto_guest_provider.wasm \ -o target/class-d-composition.wasm 2>&1) status=$? if [ $status -eq 0 ]; then echo "class-D gate: composing the signing guest with the in-guest provider SUCCEEDED." >&2 - echo "The provider must not export lann:webcrypto/ecdsa-sign (guest-impl/wit/world.wit)." >&2 + echo "The provider must not export lann:webcrypto/ecdsa-sign (rust/guest-provider/wit/world.wit)." >&2 exit 1 fi if ! printf '%s' "$output" | grep -q 'lann:webcrypto/ecdsa-sign'; then @@ -340,7 +340,7 @@ conformance-web: conformance # lint-gates there), giving one rustdoc tree with a shared search index in # target/doc. rust-docs: - cargo doc --no-deps -p wasmtime-webcrypto -p lann-webcrypto-guest + cargo doc --no-deps -p lann-webcrypto-wasmtime -p lann-webcrypto-guest # Assemble the Pages site in target/conformance-site: the results viewer # (used by the pages workflow; assumes a conformance run already produced @@ -352,14 +352,14 @@ conformance-web-site: rust-docs rm -rf target/conformance-site mkdir -p target/conformance-site/conformance/results \ target/conformance-site/conformance/adapters/jco \ - target/conformance-site/jco-impl + target/conformance-site/js/jco cp -r conformance/web target/conformance-site/conformance/web rm target/conformance-site/conformance/web/serve.mjs cp conformance/results/matrix.json target/conformance-site/conformance/results/ cp -r conformance/adapters/jco/generated \ conformance/adapters/jco/generated-signing \ target/conformance-site/conformance/adapters/jco/ - cp jco-impl/webcrypto.js target/conformance-site/jco-impl/ + cp js/jco/webcrypto.js target/conformance-site/js/jco/ cp -r target/doc target/conformance-site/doc cp .github/pages/index.html target/conformance-site/index.html @@ -457,7 +457,7 @@ conformance-jco-browser: build-conformance-guest build-signing-guest compose-timing-lab: build-guest-provider cargo build --release -p timing-lab --target wasm32-wasip2 wac plug target/wasm32-wasip2/release/timing_lab.wasm \ - --plug target/wasm32-wasip2/release/guest_webcrypto.wasm \ + --plug target/wasm32-wasip2/release/lann_webcrypto_guest_provider.wasm \ -o target/timing-lab-composed.wasm # Run the dudect-style timing lab against the composed in-guest provider. @@ -538,7 +538,7 @@ mutants shard="": build-conformance-guest build-signing-guest CONFORMANCE_ORACLE_SHARED_GUEST="$(pwd)/conformance/guest/build/conformance-guest.component.wasm" \ CONFORMANCE_ORACLE_SIGNING_GUEST="$(pwd)/conformance/signing-guest/build/conformance-signing-guest.component.wasm" \ cargo mutants --jobs 2 --profile mutants \ - -p webcrypto-impl-core -p wasmtime-webcrypto \ + -p lann-webcrypto-core -p lann-webcrypto-wasmtime \ {{ if shard != "" { "--shard " + shard } else { "" } }} status=$? if [ "$status" -eq 3 ] && [ -f mutants.out/missed.txt ] && ! [ -s mutants.out/missed.txt ]; then diff --git a/rust-toolchain.toml b/rust-toolchain.toml index dc987eaf..9b0109fa 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -7,6 +7,6 @@ components = ["rustfmt", "clippy"] targets = [ # crypto-demo (the example guest component) "wasm32-unknown-unknown", - # guest-webcrypto (the in-guest provider) and crypto-demo-driver + # lann-webcrypto-guest-provider (the in-guest provider) and crypto-demo-driver "wasm32-wasip2", ] diff --git a/impl-core/Cargo.toml b/rust/core/Cargo.toml similarity index 91% rename from impl-core/Cargo.toml rename to rust/core/Cargo.toml index 6d26624f..21eccccd 100644 --- a/impl-core/Cargo.toml +++ b/rust/core/Cargo.toml @@ -1,15 +1,15 @@ [package] -name = "webcrypto-impl-core" +name = "lann-webcrypto-core" version = "0.1.0" edition = "2021" publish = false -description = "Shared RustCrypto core for the Rust implementations of the lann:webcrypto interfaces (wasmtime-impl and guest-impl)." +description = "Shared RustCrypto core for the Rust implementations of the lann:webcrypto interfaces (lann-webcrypto-wasmtime and lann-webcrypto-guest-provider)." [dependencies] # RustCrypto backing implementations, declared exactly once for both Rust # implementations so their algorithm versions and features cannot drift. # On wasm targets `aes-gcm` selects the soft (fixsliced, table-free) AES -# backend — what makes AES-GCM acceptable in-guest; see guest-impl's README +# backend — what makes AES-GCM acceptable in-guest; see lann-webcrypto-guest-provider's README # timing-channel classification. sha2 = "0.10" # SHA-1 with sha1dc collision detection (the `sha1-checked` interface). @@ -45,7 +45,7 @@ base64 = "0.22" chacha20poly1305 = "0.10" # Signature algorithms. The ECDSA crates back verification on every target; # ECDSA *signing* is compiled only on non-wasm targets (class D — see -# guest-impl's README timing-channel classification). +# lann-webcrypto-guest-provider's README timing-channel classification). ed25519-dalek = { version = "2", features = ["pkcs8"] } # X25519 agreement; static_secrets because imported/held secret keys are the # point of the key-agreement kind (dalek gates non-ephemeral use behind it). diff --git a/impl-core/src/aead.rs b/rust/core/src/aead.rs similarity index 100% rename from impl-core/src/aead.rs rename to rust/core/src/aead.rs diff --git a/impl-core/src/agreement.rs b/rust/core/src/agreement.rs similarity index 100% rename from impl-core/src/agreement.rs rename to rust/core/src/agreement.rs diff --git a/impl-core/src/cipher.rs b/rust/core/src/cipher.rs similarity index 100% rename from impl-core/src/cipher.rs rename to rust/core/src/cipher.rs diff --git a/impl-core/src/der8410.rs b/rust/core/src/der8410.rs similarity index 100% rename from impl-core/src/der8410.rs rename to rust/core/src/der8410.rs diff --git a/impl-core/src/gcm.rs b/rust/core/src/gcm.rs similarity index 99% rename from impl-core/src/gcm.rs rename to rust/core/src/gcm.rs index 9f5ef410..48dcf312 100644 --- a/impl-core/src/gcm.rs +++ b/rust/core/src/gcm.rs @@ -6,7 +6,7 @@ //! GCM is assembled per NIST SP 800-38D from the same primitives the //! `aes-gcm` crate composes: `ghash` (masked-multiply universal hash) and //! `ctr` over the fixsliced `aes`, so the timing-channel classification is -//! unchanged (see guest-impl's README). The standard-parameter path +//! unchanged (see lann-webcrypto-guest-provider's README). The standard-parameter path //! (96-bit nonce, 16-byte tag) does not come through here: callers route //! it to the `aes-gcm` crate, and the unit tests pin this module to the //! crate's output on the shared parameter point. diff --git a/impl-core/src/hash.rs b/rust/core/src/hash.rs similarity index 100% rename from impl-core/src/hash.rs rename to rust/core/src/hash.rs diff --git a/impl-core/src/jwk.rs b/rust/core/src/jwk.rs similarity index 100% rename from impl-core/src/jwk.rs rename to rust/core/src/jwk.rs diff --git a/impl-core/src/kdf.rs b/rust/core/src/kdf.rs similarity index 100% rename from impl-core/src/kdf.rs rename to rust/core/src/kdf.rs diff --git a/impl-core/src/lib.rs b/rust/core/src/lib.rs similarity index 98% rename from impl-core/src/lib.rs rename to rust/core/src/lib.rs index ca9392e8..04ca8acb 100644 --- a/impl-core/src/lib.rs +++ b/rust/core/src/lib.rs @@ -1,5 +1,5 @@ //! The shared RustCrypto core of the two Rust implementations of -//! `lann:webcrypto`: `wasmtime-impl` (native host) and `guest-impl` (in-guest +//! `lann:webcrypto`: `lann-webcrypto-wasmtime` (native host) and `lann-webcrypto-guest-provider` (in-guest //! wasm component). //! //! Everything algorithm-shaped lives here exactly once — cipher and digest @@ -27,7 +27,7 @@ //! ## Class-D policy: ECDSA signing is not compiled for wasm //! //! ECDSA signing handles a per-signature secret nonce whose timing leakage -//! is key-recovering — class D in guest-impl's timing-channel +//! is key-recovering — class D in lann-webcrypto-guest-provider's timing-channel //! classification. The load-bearing enforcement is the in-guest provider's //! world, which never exports `ecdsa-sign`: a composition that needs it //! fails at `wac plug` time. This crate adds a second layer — the ECDSA diff --git a/impl-core/src/mac.rs b/rust/core/src/mac.rs similarity index 100% rename from impl-core/src/mac.rs rename to rust/core/src/mac.rs diff --git a/impl-core/src/policy.rs b/rust/core/src/policy.rs similarity index 100% rename from impl-core/src/policy.rs rename to rust/core/src/policy.rs diff --git a/impl-core/src/sig.rs b/rust/core/src/sig.rs similarity index 100% rename from impl-core/src/sig.rs rename to rust/core/src/sig.rs diff --git a/guest-impl/Cargo.toml b/rust/guest-provider/Cargo.toml similarity index 91% rename from guest-impl/Cargo.toml rename to rust/guest-provider/Cargo.toml index 342b785c..7adbd3d0 100644 --- a/guest-impl/Cargo.toml +++ b/rust/guest-provider/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "guest-webcrypto" +name = "lann-webcrypto-guest-provider" version = "0.1.0" edition = "2021" publish = false @@ -17,4 +17,4 @@ wit-bindgen = { version = "0.59", features = ["async", "async-spawn"] } # wasm target the core selects the soft (fixsliced, table-free) AES backend # — what makes AES-GCM acceptable in-guest (see the README's timing-channel # classification) — and compiles no ECDSA signing code (class D). -webcrypto-impl-core = { path = "../impl-core" } +lann-webcrypto-core = { path = "../core" } diff --git a/guest-impl/README.md b/rust/guest-provider/README.md similarity index 97% rename from guest-impl/README.md rename to rust/guest-provider/README.md index ee1ef0c6..340a8180 100644 --- a/guest-impl/README.md +++ b/rust/guest-provider/README.md @@ -1,4 +1,4 @@ -# `guest-webcrypto` +# `lann-webcrypto-guest-provider` The in-guest implementation of `lann:webcrypto`: a wasm component (built for `wasm32-wasip2`) that runs RustCrypto entirely inside the guest and **exports** @@ -38,8 +38,8 @@ Two facts frame the residual risk: the remaining channel; memory is closed. When a host-side implementation is available, prefer it. The side-channel -ordering of this repository's implementations is: `jco-impl` (platform Web -Crypto — native, hardware-accelerated, best studied), then `wasmtime-impl` +ordering of this repository's implementations is: `webcrypto-jco` (platform Web +Crypto — native, hardware-accelerated, best studied), then `lann-webcrypto-wasmtime` (native RustCrypto), then this provider. ## Timing-channel classification @@ -59,7 +59,7 @@ JIT), weighted by how **forgiving of failure** the construction is Class D is enforced structurally, not by documentation: this provider simply does not export those algorithm interfaces, so a composition that needs them **fails at `wac plug` time** rather than running quietly degraded — and one -level deeper, the shared `webcrypto-impl-core` compiles no ECDSA signing +level deeper, the shared `lann-webcrypto-core` compiles no ECDSA signing code for wasm targets at all (`#[cfg(not(target_family = "wasm"))]`), so the class-D code is absent from this component's binary, not merely unexported. Choose a host-side provider for them. diff --git a/guest-impl/src/buffer.rs b/rust/guest-provider/src/buffer.rs similarity index 100% rename from guest-impl/src/buffer.rs rename to rust/guest-provider/src/buffer.rs diff --git a/guest-impl/src/lib.rs b/rust/guest-provider/src/lib.rs similarity index 76% rename from guest-impl/src/lib.rs rename to rust/guest-provider/src/lib.rs index 39b1ec24..cfa71632 100644 --- a/guest-impl/src/lib.rs +++ b/rust/guest-provider/src/lib.rs @@ -1,8 +1,8 @@ -//! `guest-webcrypto`: a wasm **component** that runs RustCrypto *in-guest* +//! `lann-webcrypto-guest-provider`: a wasm **component** that runs RustCrypto *in-guest* //! and exports the `lann:webcrypto` package surface. //! -//! This is the third implementation alongside the `wasmtime-impl` (RustCrypto, -//! native) and `jco-impl` (browser Web Crypto) hosts. Unlike those two — which +//! This is the third implementation alongside the `lann-webcrypto-wasmtime` (RustCrypto, +//! native) and `webcrypto-jco` (browser Web Crypto) hosts. Unlike those two — which //! satisfy the guest's imports host-side — this one is itself a component: the //! cryptography runs entirely inside wasm, and key generation draws on the //! WASI random imports the standard library links in. diff --git a/guest-impl/src/provider.rs b/rust/guest-provider/src/provider.rs similarity index 95% rename from guest-impl/src/provider.rs rename to rust/guest-provider/src/provider.rs index 18bc43a1..6171a8aa 100644 --- a/guest-impl/src/provider.rs +++ b/rust/guest-provider/src/provider.rs @@ -1,6 +1,6 @@ //! The exported `lann:webcrypto` resources and key-minting functions. //! -//! The cryptography itself lives in `webcrypto-impl-core`, shared verbatim +//! The cryptography itself lives in `lann-webcrypto-core`, shared verbatim //! with the Wasmtime host; this module contributes only what is //! guest-specific — stream plumbing, the exported resource types, and the //! bindings glue converting the generated types to the core's. @@ -12,7 +12,7 @@ use std::cell::Cell; -use webcrypto_impl_core::{ +use lann_webcrypto_core::{ served_sha2, AeadKeyMaterial, AeadPolicy, AgreementPolicy, CipherKeyMaterial, CipherMode, CipherPolicy, InternalNoncePolicy, MacKeyMaterial, MacPolicy, SigPublic, SigningKeyMaterial, SigningPolicy, HMAC_NAME, @@ -76,7 +76,7 @@ pub struct Component; // --- bindings glue ------------------------------------------------------------- -webcrypto_impl_core::impl_conversions! { +lann_webcrypto_core::impl_conversions! { error: Error, extension: crate::lann::webcrypto::types::ExtensionError, sha2: Sha2Variant, @@ -86,7 +86,7 @@ webcrypto_impl_core::impl_conversions! { /// Unwrap an entropy result: the WASI random source backing the guest's /// `getrandom` is always available, so a failure is unreachable. -fn rng_infallible(result: Result) -> T { +fn rng_infallible(result: Result) -> T { result.expect("WASI random source is always available") } @@ -369,7 +369,7 @@ impl DigestGuest for Component { /// `compute` is one-shot and stateless per call, so the resource is /// reusable. pub struct Digest { - variant: webcrypto_impl_core::DigestKind, + variant: lann_webcrypto_core::DigestKind, } impl GuestDigest for Digest { @@ -391,7 +391,7 @@ impl GuestDigest for Digest { impl BytesGuest for Component { fn constant_time_equal(a: Vec, b: Vec) -> bool { - webcrypto_impl_core::constant_time_equal(&a, &b) + lann_webcrypto_core::constant_time_equal(&a, &b) } } @@ -401,7 +401,7 @@ impl Sha2Guest for Component { fn make_digest(variant: Sha2Variant) -> Result { let variant = served_sha2(variant.into())?; Ok(digest::Digest::new(Digest { - variant: webcrypto_impl_core::DigestKind::Sha2(variant), + variant: lann_webcrypto_core::DigestKind::Sha2(variant), })) } } @@ -411,16 +411,16 @@ impl Sha2Guest for Component { impl Sha1CheckedGuest for Component { fn make_rejecting_digest() -> Result { Ok(digest::Digest::new(Digest { - variant: webcrypto_impl_core::DigestKind::Sha1Checked( - webcrypto_impl_core::Sha1Posture::Reject, + variant: lann_webcrypto_core::DigestKind::Sha1Checked( + lann_webcrypto_core::Sha1Posture::Reject, ), })) } fn make_mitigating_digest() -> Result { Ok(digest::Digest::new(Digest { - variant: webcrypto_impl_core::DigestKind::Sha1Checked( - webcrypto_impl_core::Sha1Posture::Mitigate, + variant: lann_webcrypto_core::DigestKind::Sha1Checked( + lann_webcrypto_core::Sha1Posture::Mitigate, ), })) } @@ -466,7 +466,7 @@ impl HmacSha2Guest for Component { options: mac::MacKeyOptions, ) -> Result { let policy = options.get::().policy.get(); - let material = webcrypto_impl_core::derive_mac_key( + let material = lann_webcrypto_core::derive_mac_key( &input.get::().material, variant.into(), length, @@ -510,7 +510,7 @@ impl HmacSha1Guest for Component { options: mac::MacKeyOptions, ) -> Result { let policy = options.get::().policy.get(); - let material = webcrypto_impl_core::derive_mac_key_sha1( + let material = lann_webcrypto_core::derive_mac_key_sha1( &input.get::().material, length, policy, @@ -525,7 +525,7 @@ impl HkdfSha1Guest for Component { salt: Vec, info: Vec, ) -> Result { - let material = webcrypto_impl_core::DeriveInputMaterial::prepare_sha1( + let material = lann_webcrypto_core::DeriveInputMaterial::prepare_sha1( &input.get::().material, &salt, info, @@ -538,7 +538,7 @@ impl HkdfSha1Guest for Component { salt: Vec, info: Vec, ) -> Result { - let material = webcrypto_impl_core::DeriveInputMaterial::prepare_from_sha1( + let material = lann_webcrypto_core::DeriveInputMaterial::prepare_from_sha1( &input.get::().material, &salt, info, @@ -553,7 +553,7 @@ impl Pbkdf2Sha1Guest for Component { salt: Vec, iterations: u32, ) -> Result { - let material = webcrypto_impl_core::DeriveInputMaterial::prepare_pbkdf2_sha1( + let material = lann_webcrypto_core::DeriveInputMaterial::prepare_pbkdf2_sha1( &input.get::().material, salt, iterations, @@ -571,25 +571,25 @@ impl DerivationGuest for Component { /// An exported `derive-options`. See [`MacKeyOptions`]. pub struct DeriveOptions { - policy: Cell, + policy: Cell, } impl GuestDeriveOptions for DeriveOptions { fn new() -> Self { Self { - policy: Cell::new(webcrypto_impl_core::DerivePolicy::default()), + policy: Cell::new(lann_webcrypto_core::DerivePolicy::default()), } } fn can_derive_bits(&self, allowed: bool) { - self.policy.set(webcrypto_impl_core::DerivePolicy { + self.policy.set(lann_webcrypto_core::DerivePolicy { derive_bits: allowed, ..self.policy.get() }); } fn can_derive_key(&self, allowed: bool) { - self.policy.set(webcrypto_impl_core::DerivePolicy { + self.policy.set(lann_webcrypto_core::DerivePolicy { derive_key: allowed, ..self.policy.get() }); @@ -599,7 +599,7 @@ impl GuestDeriveOptions for DeriveOptions { /// An exported `derive-input`: the shared core's parameterized derivation /// (run eagerly at `prepare` — the PRK, not the base secret). pub struct DeriveInput { - material: webcrypto_impl_core::DeriveInputMaterial, + material: lann_webcrypto_core::DeriveInputMaterial, } impl GuestDeriveInput for DeriveInput { @@ -624,7 +624,7 @@ impl HkdfGuest for Component { options: derivation::DeriveOptions, ) -> Result { let policy = options.get::().policy.get(); - let material = webcrypto_impl_core::IkmMaterial::import(raw, policy)?; + let material = lann_webcrypto_core::IkmMaterial::import(raw, policy)?; Ok(hkdf_iface::Ikm::new(Ikm { material })) } } @@ -636,7 +636,7 @@ impl HkdfSha2Guest for Component { salt: Vec, info: Vec, ) -> Result { - let material = webcrypto_impl_core::DeriveInputMaterial::prepare( + let material = lann_webcrypto_core::DeriveInputMaterial::prepare( variant.into(), &input.get::().material, &salt, @@ -651,7 +651,7 @@ impl HkdfSha2Guest for Component { salt: Vec, info: Vec, ) -> Result { - let material = webcrypto_impl_core::DeriveInputMaterial::prepare_from( + let material = lann_webcrypto_core::DeriveInputMaterial::prepare_from( variant.into(), &input.get::().material, &salt, @@ -663,7 +663,7 @@ impl HkdfSha2Guest for Component { /// An exported `hkdf.ikm`: the shared core's input keying material. pub struct Ikm { - material: webcrypto_impl_core::IkmMaterial, + material: lann_webcrypto_core::IkmMaterial, } impl GuestIkm for Ikm { @@ -684,7 +684,7 @@ impl Pbkdf2Guest for Component { options: derivation::DeriveOptions, ) -> Result { let policy = options.get::().policy.get(); - let material = webcrypto_impl_core::PasswordMaterial::import(raw, policy)?; + let material = lann_webcrypto_core::PasswordMaterial::import(raw, policy)?; Ok(pbkdf2_iface::Password::new(Password { material })) } } @@ -696,7 +696,7 @@ impl Pbkdf2Sha2Guest for Component { salt: Vec, iterations: u32, ) -> Result { - let material = webcrypto_impl_core::DeriveInputMaterial::prepare_pbkdf2( + let material = lann_webcrypto_core::DeriveInputMaterial::prepare_pbkdf2( variant.into(), &input.get::().material, salt, @@ -708,7 +708,7 @@ impl Pbkdf2Sha2Guest for Component { /// An exported `pbkdf2.password`: the shared core's password material. pub struct Password { - material: webcrypto_impl_core::PasswordMaterial, + material: lann_webcrypto_core::PasswordMaterial, } impl GuestPassword for Password { @@ -765,7 +765,7 @@ impl GuestAgreementKeyOptions for AgreementKeyOptions { /// An exported `key-agreement.public-key`: public material only. pub struct AgreementPublicKey { - material: webcrypto_impl_core::AgreementPublicMaterial, + material: lann_webcrypto_core::AgreementPublicMaterial, } impl GuestPublicKey for AgreementPublicKey { @@ -790,7 +790,7 @@ impl GuestPublicKey for AgreementPublicKey { /// (dalek's constant-time Montgomery ladder — class B; see the README's /// classification table). pub struct AgreementSecretKey { - material: webcrypto_impl_core::AgreementSecretMaterial, + material: lann_webcrypto_core::AgreementSecretMaterial, } impl GuestSecretKey for AgreementSecretKey { @@ -831,7 +831,7 @@ impl GuestSecretKey for AgreementSecretKey { impl X25519Guest for Component { async fn import_public_key_raw(raw: Vec) -> Result { - let material = webcrypto_impl_core::AgreementPublicMaterial::import(&raw)?; + let material = lann_webcrypto_core::AgreementPublicMaterial::import(&raw)?; Ok(key_agreement_iface::PublicKey::new(AgreementPublicKey { material, })) @@ -840,14 +840,14 @@ impl X25519Guest for Component { async fn import_public_key_spki( spki: Vec, ) -> Result { - let material = webcrypto_impl_core::AgreementPublicMaterial::import_spki(&spki)?; + let material = lann_webcrypto_core::AgreementPublicMaterial::import_spki(&spki)?; Ok(key_agreement_iface::PublicKey::new(AgreementPublicKey { material, })) } async fn import_public_key_jwk(jwk: String) -> Result { - let material = webcrypto_impl_core::AgreementPublicMaterial::import_jwk(&jwk)?; + let material = lann_webcrypto_core::AgreementPublicMaterial::import_jwk(&jwk)?; Ok(key_agreement_iface::PublicKey::new(AgreementPublicKey { material, })) @@ -858,7 +858,7 @@ impl X25519Guest for Component { options: key_agreement_iface::AgreementKeyOptions, ) -> Result { let policy = options.get::().policy.get(); - let material = webcrypto_impl_core::AgreementSecretMaterial::import_pkcs8(&pkcs8, policy)?; + let material = lann_webcrypto_core::AgreementSecretMaterial::import_pkcs8(&pkcs8, policy)?; Ok(key_agreement_iface::SecretKey::new(AgreementSecretKey { material, })) @@ -869,7 +869,7 @@ impl X25519Guest for Component { options: key_agreement_iface::AgreementKeyOptions, ) -> Result { let policy = options.get::().policy.get(); - let material = webcrypto_impl_core::AgreementSecretMaterial::import_jwk(&jwk, policy)?; + let material = lann_webcrypto_core::AgreementSecretMaterial::import_jwk(&jwk, policy)?; Ok(key_agreement_iface::SecretKey::new(AgreementSecretKey { material, })) @@ -886,7 +886,7 @@ impl X25519Guest for Component { > { let policy = options.get::().policy.get(); let (secret, public) = rng_infallible( - webcrypto_impl_core::AgreementSecretMaterial::generate(policy), + lann_webcrypto_core::AgreementSecretMaterial::generate(policy), )?; Ok(( key_agreement_iface::SecretKey::new(AgreementSecretKey { material: secret }), @@ -933,7 +933,7 @@ impl AesGcmGuest for Component { options: ExportedAeadKeyOptions, ) -> Result { let policy = options.get::().policy.get(); - let material = webcrypto_impl_core::derive_aes_gcm_key( + let material = lann_webcrypto_core::derive_aes_gcm_key( &input.get::().material, variant.into(), policy, @@ -1116,7 +1116,7 @@ macro_rules! cipher_minting { options: ExportedCipherKeyOptions, ) -> Result { let policy = options.get::().policy.get(); - let material = webcrypto_impl_core::derive_cipher_key( + let material = lann_webcrypto_core::derive_cipher_key( &input.get::().material, $mode, variant.into(), diff --git a/rust/guest-provider/wit/deps/lann-webcrypto b/rust/guest-provider/wit/deps/lann-webcrypto new file mode 120000 index 00000000..4a5c5bb1 --- /dev/null +++ b/rust/guest-provider/wit/deps/lann-webcrypto @@ -0,0 +1 @@ +../../../../wit \ No newline at end of file diff --git a/guest-impl/wit/world.wit b/rust/guest-provider/wit/world.wit similarity index 94% rename from guest-impl/wit/world.wit rename to rust/guest-provider/wit/world.wit index b4fbbb68..e108b601 100644 --- a/guest-impl/wit/world.wit +++ b/rust/guest-provider/wit/world.wit @@ -1,7 +1,7 @@ -// The `guest-webcrypto` component world. +// The `lann-webcrypto-guest-provider` component world. // // This is the third implementation of `lann:webcrypto`, alongside the -// `wasmtime-impl` (RustCrypto, native) and `jco-impl` (browser Web Crypto) +// `lann-webcrypto-wasmtime` (RustCrypto, native) and `webcrypto-jco` (browser Web Crypto) // hosts. Unlike those two, this implementation is itself a **wasm component**: // it runs RustCrypto in-guest and *exports* the package surface. // diff --git a/guest-sdk/Cargo.toml b/rust/guest/Cargo.toml similarity index 98% rename from guest-sdk/Cargo.toml rename to rust/guest/Cargo.toml index f9271ed2..5edee8ae 100644 --- a/guest-sdk/Cargo.toml +++ b/rust/guest/Cargo.toml @@ -2,6 +2,7 @@ name = "lann-webcrypto-guest" version = "0.1.0" edition = "2021" +publish = false description = "Guest-side bindings and ergonomic helpers for the lann:webcrypto interfaces" [features] diff --git a/guest-sdk/src/aes_cbc.rs b/rust/guest/src/aes_cbc.rs similarity index 100% rename from guest-sdk/src/aes_cbc.rs rename to rust/guest/src/aes_cbc.rs diff --git a/guest-sdk/src/aes_ctr.rs b/rust/guest/src/aes_ctr.rs similarity index 100% rename from guest-sdk/src/aes_ctr.rs rename to rust/guest/src/aes_ctr.rs diff --git a/guest-sdk/src/aes_gcm.rs b/rust/guest/src/aes_gcm.rs similarity index 100% rename from guest-sdk/src/aes_gcm.rs rename to rust/guest/src/aes_gcm.rs diff --git a/guest-sdk/src/aes_gcm_internal_nonce.rs b/rust/guest/src/aes_gcm_internal_nonce.rs similarity index 100% rename from guest-sdk/src/aes_gcm_internal_nonce.rs rename to rust/guest/src/aes_gcm_internal_nonce.rs diff --git a/guest-sdk/src/chacha20_poly1305.rs b/rust/guest/src/chacha20_poly1305.rs similarity index 100% rename from guest-sdk/src/chacha20_poly1305.rs rename to rust/guest/src/chacha20_poly1305.rs diff --git a/guest-sdk/src/ecdsa.rs b/rust/guest/src/ecdsa.rs similarity index 100% rename from guest-sdk/src/ecdsa.rs rename to rust/guest/src/ecdsa.rs diff --git a/guest-sdk/src/ed25519.rs b/rust/guest/src/ed25519.rs similarity index 100% rename from guest-sdk/src/ed25519.rs rename to rust/guest/src/ed25519.rs diff --git a/guest-sdk/src/hmac_sha1.rs b/rust/guest/src/hmac_sha1.rs similarity index 100% rename from guest-sdk/src/hmac_sha1.rs rename to rust/guest/src/hmac_sha1.rs diff --git a/guest-sdk/src/hmac_sha2.rs b/rust/guest/src/hmac_sha2.rs similarity index 100% rename from guest-sdk/src/hmac_sha2.rs rename to rust/guest/src/hmac_sha2.rs diff --git a/guest-sdk/src/lib.rs b/rust/guest/src/lib.rs similarity index 100% rename from guest-sdk/src/lib.rs rename to rust/guest/src/lib.rs diff --git a/guest-sdk/src/sha1_checked.rs b/rust/guest/src/sha1_checked.rs similarity index 100% rename from guest-sdk/src/sha1_checked.rs rename to rust/guest/src/sha1_checked.rs diff --git a/guest-sdk/src/sha2.rs b/rust/guest/src/sha2.rs similarity index 100% rename from guest-sdk/src/sha2.rs rename to rust/guest/src/sha2.rs diff --git a/guest-sdk/src/xchacha20_poly1305.rs b/rust/guest/src/xchacha20_poly1305.rs similarity index 100% rename from guest-sdk/src/xchacha20_poly1305.rs rename to rust/guest/src/xchacha20_poly1305.rs diff --git a/guest-sdk/src/xchacha20_poly1305_internal_nonce.rs b/rust/guest/src/xchacha20_poly1305_internal_nonce.rs similarity index 100% rename from guest-sdk/src/xchacha20_poly1305_internal_nonce.rs rename to rust/guest/src/xchacha20_poly1305_internal_nonce.rs diff --git a/rust/guest/wit/deps/lann-webcrypto b/rust/guest/wit/deps/lann-webcrypto new file mode 120000 index 00000000..4a5c5bb1 --- /dev/null +++ b/rust/guest/wit/deps/lann-webcrypto @@ -0,0 +1 @@ +../../../../wit \ No newline at end of file diff --git a/guest-sdk/wit/world.wit b/rust/guest/wit/world.wit similarity index 100% rename from guest-sdk/wit/world.wit rename to rust/guest/wit/world.wit diff --git a/wasmtime-impl/Cargo.toml b/rust/wasmtime/Cargo.toml similarity index 91% rename from wasmtime-impl/Cargo.toml rename to rust/wasmtime/Cargo.toml index 25966cd7..8ec36cb5 100644 --- a/wasmtime-impl/Cargo.toml +++ b/rust/wasmtime/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "wasmtime-webcrypto" +name = "lann-webcrypto-wasmtime" version = "0.1.0" edition = "2021" publish = false @@ -17,5 +17,5 @@ futures = "0.3" # waiter are the parts a hand-written queue here got wrong. mea = "0.6" # The cryptography itself, shared verbatim with the in-guest provider. -webcrypto-impl-core = { path = "../impl-core" } +lann-webcrypto-core = { path = "../core" } diff --git a/wasmtime-impl/src/bindings.rs b/rust/wasmtime/src/bindings.rs similarity index 100% rename from wasmtime-impl/src/bindings.rs rename to rust/wasmtime/src/bindings.rs diff --git a/wasmtime-impl/src/host.rs b/rust/wasmtime/src/host.rs similarity index 97% rename from wasmtime-impl/src/host.rs rename to rust/wasmtime/src/host.rs index f1374ecc..aa88a0c7 100644 --- a/wasmtime-impl/src/host.rs +++ b/rust/wasmtime/src/host.rs @@ -6,19 +6,19 @@ //! the async `Accessor` are implemented for the [`WasiWebcrypto`] `HasData` //! marker. //! -//! The cryptography itself lives in `webcrypto-impl-core`, shared verbatim +//! The cryptography itself lives in `lann-webcrypto-core`, shared verbatim //! with the in-guest provider; this module contributes only what is //! host-specific — the resource table and the shapes every operation //! shares (mint into the table, drain-then-compute, drain-then-stream-out), //! over the stream plumbing in [`crate::streams`] and the admission in //! [`crate::limits`]. -use wasmtime::component::{Accessor, Resource, StreamReader}; -use wasmtime::Result; -use webcrypto_impl_core::{ +use lann_webcrypto_core::{ served_sha2, AeadKeyMaterial, DigestKind, MacKeyMaterial, Sha1Posture, SigPublic, SigningKeyMaterial, HMAC_NAME, }; +use wasmtime::component::{Accessor, Resource, StreamReader}; +use wasmtime::Result; use crate::bindings::webcrypto::aead::{self, HostAeadKey, HostAeadKeyWithStore}; use crate::bindings::webcrypto::aead_internal_nonce::{ @@ -64,7 +64,7 @@ use crate::{ // --- bindings glue ------------------------------------------------------------- -webcrypto_impl_core::impl_conversions! { +lann_webcrypto_core::impl_conversions! { error: Error, extension: types::ExtensionError, sha2: sha2_iface::Sha2Variant, @@ -75,7 +75,7 @@ webcrypto_impl_core::impl_conversions! { /// Render an entropy failure as the trap-shaped host error for key or nonce /// generation: the host treats a failing random source as an operational /// host fault, never a guest-visible WIT error. -fn rng_trap(what: &str) -> impl Fn(webcrypto_impl_core::RngError) -> wasmtime::Error + '_ { +fn rng_trap(what: &str) -> impl Fn(lann_webcrypto_core::RngError) -> wasmtime::Error + '_ { move |err| wasmtime::Error::msg(format!("{what} failed: {err}")) } @@ -94,7 +94,7 @@ async fn take_options( /// a resource handle, a WIT error flows to the caller. async fn mint( accessor: &Accessor, - minted: std::result::Result, + minted: std::result::Result, ) -> Result, Error>> { match minted { Ok(resource) => accessor.with(|mut access| Ok(Ok(access.get().table.push(resource)?))), @@ -177,7 +177,7 @@ impl types::Host for WasiWebcryptoCtxView<'_> {} impl bytes_iface::Host for WasiWebcryptoCtxView<'_> { fn constant_time_equal(&mut self, a: Vec, b: Vec) -> Result { - Ok(webcrypto_impl_core::constant_time_equal(&a, &b)) + Ok(lann_webcrypto_core::constant_time_equal(&a, &b)) } } @@ -606,7 +606,7 @@ macro_rules! cipher_minting { options: Resource, ) -> Result, Error>> { let policy = take_options(accessor, options).await?.policy; - let material = webcrypto_impl_core::CipherKeyMaterial::import( + let material = lann_webcrypto_core::CipherKeyMaterial::import( $mode, variant.into(), raw, @@ -622,7 +622,7 @@ macro_rules! cipher_minting { options: Resource, ) -> Result, Error>> { let policy = take_options(accessor, options).await?.policy; - let material = webcrypto_impl_core::CipherKeyMaterial::import_jwk( + let material = lann_webcrypto_core::CipherKeyMaterial::import_jwk( $mode, variant.into(), &jwk, @@ -637,7 +637,7 @@ macro_rules! cipher_minting { options: Resource, ) -> Result, Error>> { let policy = take_options(accessor, options).await?.policy; - let material = webcrypto_impl_core::CipherKeyMaterial::generate( + let material = lann_webcrypto_core::CipherKeyMaterial::generate( $mode, variant.into(), policy, @@ -654,7 +654,7 @@ macro_rules! cipher_minting { ) -> Result, Error>> { let policy = take_options(accessor, options).await?.policy; let material = with_resource(accessor, input, |input| { - webcrypto_impl_core::derive_cipher_key( + lann_webcrypto_core::derive_cipher_key( &input.material, $mode, variant.into(), @@ -669,8 +669,8 @@ macro_rules! cipher_minting { }; } -cipher_minting!(aes_cbc_iface, webcrypto_impl_core::CipherMode::Cbc); -cipher_minting!(aes_ctr_iface, webcrypto_impl_core::CipherMode::Ctr); +cipher_minting!(aes_cbc_iface, lann_webcrypto_core::CipherMode::Cbc); +cipher_minting!(aes_ctr_iface, lann_webcrypto_core::CipherMode::Ctr); // --- derivation ------------------------------------------------------------- @@ -764,7 +764,7 @@ impl hkdf_iface::HostWithStore for WasiWebcrypto { options: Resource, ) -> Result, Error>> { let policy = take_options(accessor, options).await?.policy; - let material = webcrypto_impl_core::IkmMaterial::import(raw, policy); + let material = lann_webcrypto_core::IkmMaterial::import(raw, policy); mint(accessor, material.map(|material| Ikm { material })).await } } @@ -780,7 +780,7 @@ impl hkdf_sha2_iface::HostWithStore for WasiWebcrypto { info: Vec, ) -> Result, Error>> { let material = with_resource(accessor, input, |ikm| { - webcrypto_impl_core::DeriveInputMaterial::prepare( + lann_webcrypto_core::DeriveInputMaterial::prepare( variant.into(), &ikm.material, &salt, @@ -799,7 +799,7 @@ impl hkdf_sha2_iface::HostWithStore for WasiWebcrypto { info: Vec, ) -> Result, Error>> { let material = with_resource(accessor, input, |upstream| { - webcrypto_impl_core::DeriveInputMaterial::prepare_from( + lann_webcrypto_core::DeriveInputMaterial::prepare_from( variant.into(), &upstream.material, &salt, @@ -855,7 +855,7 @@ impl hmac_sha1_iface::HostWithStore for WasiWebcrypto { ) -> Result, Error>> { let policy = take_options(accessor, options).await?.policy; let material = with_resource(accessor, input, |input| { - webcrypto_impl_core::derive_mac_key_sha1(&input.material, length, policy) + lann_webcrypto_core::derive_mac_key_sha1(&input.material, length, policy) }) .await?; mint(accessor, material.map(|material| MacKey { material })).await @@ -872,7 +872,7 @@ impl hkdf_sha1_iface::HostWithStore for WasiWebcrypto { info: Vec, ) -> Result, Error>> { let material = with_resource(accessor, input, |ikm| { - webcrypto_impl_core::DeriveInputMaterial::prepare_sha1(&ikm.material, &salt, info) + lann_webcrypto_core::DeriveInputMaterial::prepare_sha1(&ikm.material, &salt, info) }) .await?; mint(accessor, material.map(|material| DeriveInput { material })).await @@ -885,7 +885,7 @@ impl hkdf_sha1_iface::HostWithStore for WasiWebcrypto { info: Vec, ) -> Result, Error>> { let material = with_resource(accessor, input, |upstream| { - webcrypto_impl_core::DeriveInputMaterial::prepare_from_sha1( + lann_webcrypto_core::DeriveInputMaterial::prepare_from_sha1( &upstream.material, &salt, info, @@ -906,7 +906,7 @@ impl pbkdf2_sha1_iface::HostWithStore for WasiWebcrypto { iterations: u32, ) -> Result, Error>> { let material = with_resource(accessor, input, |password| { - webcrypto_impl_core::DeriveInputMaterial::prepare_pbkdf2_sha1( + lann_webcrypto_core::DeriveInputMaterial::prepare_pbkdf2_sha1( &password.material, salt.clone(), iterations, @@ -944,7 +944,7 @@ impl pbkdf2_iface::HostWithStore for WasiWebcrypto { options: Resource, ) -> Result, Error>> { let policy = take_options(accessor, options).await?.policy; - let material = webcrypto_impl_core::PasswordMaterial::import(raw, policy); + let material = lann_webcrypto_core::PasswordMaterial::import(raw, policy); mint(accessor, material.map(|material| Password { material })).await } } @@ -960,7 +960,7 @@ impl pbkdf2_sha2_iface::HostWithStore for WasiWebcrypto { iterations: u32, ) -> Result, Error>> { let material = with_resource(accessor, input, |password| { - webcrypto_impl_core::DeriveInputMaterial::prepare_pbkdf2( + lann_webcrypto_core::DeriveInputMaterial::prepare_pbkdf2( variant.into(), &password.material, salt, @@ -1118,7 +1118,7 @@ impl x25519_iface::HostWithStore for WasiWebcrypto { accessor: &Accessor, raw: Vec, ) -> Result, Error>> { - let material = webcrypto_impl_core::AgreementPublicMaterial::import(&raw); + let material = lann_webcrypto_core::AgreementPublicMaterial::import(&raw); mint( accessor, material.map(|material| AgreementPublicKey { material }), @@ -1130,7 +1130,7 @@ impl x25519_iface::HostWithStore for WasiWebcrypto { accessor: &Accessor, spki: Vec, ) -> Result, Error>> { - let material = webcrypto_impl_core::AgreementPublicMaterial::import_spki(&spki); + let material = lann_webcrypto_core::AgreementPublicMaterial::import_spki(&spki); mint( accessor, material.map(|material| AgreementPublicKey { material }), @@ -1142,7 +1142,7 @@ impl x25519_iface::HostWithStore for WasiWebcrypto { accessor: &Accessor, jwk: String, ) -> Result, Error>> { - let material = webcrypto_impl_core::AgreementPublicMaterial::import_jwk(&jwk); + let material = lann_webcrypto_core::AgreementPublicMaterial::import_jwk(&jwk); mint( accessor, material.map(|material| AgreementPublicKey { material }), @@ -1156,7 +1156,7 @@ impl x25519_iface::HostWithStore for WasiWebcrypto { options: Resource, ) -> Result, Error>> { let policy = take_options(accessor, options).await?.policy; - let material = webcrypto_impl_core::AgreementSecretMaterial::import_pkcs8(&pkcs8, policy); + let material = lann_webcrypto_core::AgreementSecretMaterial::import_pkcs8(&pkcs8, policy); mint( accessor, material.map(|material| AgreementSecretKey { material }), @@ -1170,7 +1170,7 @@ impl x25519_iface::HostWithStore for WasiWebcrypto { options: Resource, ) -> Result, Error>> { let policy = take_options(accessor, options).await?.policy; - let material = webcrypto_impl_core::AgreementSecretMaterial::import_jwk(&jwk, policy); + let material = lann_webcrypto_core::AgreementSecretMaterial::import_jwk(&jwk, policy); mint( accessor, material.map(|material| AgreementSecretKey { material }), @@ -1185,7 +1185,7 @@ impl x25519_iface::HostWithStore for WasiWebcrypto { std::result::Result<(Resource, Resource), Error>, > { let policy = take_options(accessor, options).await?.policy; - let material = webcrypto_impl_core::AgreementSecretMaterial::generate(policy) + let material = lann_webcrypto_core::AgreementSecretMaterial::generate(policy) .map_err(rng_trap("random key generation"))?; match material { Ok((secret, public)) => accessor.with(|mut access| { @@ -1311,7 +1311,7 @@ impl hmac_sha2_iface::HostWithStore for WasiWebcrypto { ) -> Result, Error>> { let policy = take_options(accessor, options).await?.policy; let material = with_resource(accessor, input, |input| { - webcrypto_impl_core::derive_mac_key(&input.material, variant.into(), length, policy) + lann_webcrypto_core::derive_mac_key(&input.material, variant.into(), length, policy) }) .await?; mint(accessor, material.map(|material| MacKey { material })).await @@ -1364,7 +1364,7 @@ impl aes_gcm_iface::HostWithStore for WasiWebcrypto { ) -> Result, Error>> { let policy = take_options(accessor, options).await?.policy; let material = with_resource(accessor, input, |input| { - webcrypto_impl_core::derive_aes_gcm_key(&input.material, variant.into(), policy) + lann_webcrypto_core::derive_aes_gcm_key(&input.material, variant.into(), policy) }) .await?; mint(accessor, material.map(|material| AeadKey { material })).await @@ -1958,7 +1958,7 @@ impl ecdsa_sign_iface::HostWithStore for WasiWebcrypto { #[cfg(test)] mod tests { use crate::MacKey; - use webcrypto_impl_core::{MacKeyMaterial, MacPolicy, Sha2Variant}; + use lann_webcrypto_core::{MacKeyMaterial, MacPolicy, Sha2Variant}; /// `Debug` on key-holding types never prints key material: the bytes /// are redacted (in the shared core's material types, which these diff --git a/wasmtime-impl/src/lib.rs b/rust/wasmtime/src/lib.rs similarity index 93% rename from wasmtime-impl/src/lib.rs rename to rust/wasmtime/src/lib.rs index 7d763186..c318003b 100644 --- a/wasmtime-impl/src/lib.rs +++ b/rust/wasmtime/src/lib.rs @@ -64,7 +64,7 @@ use wasmtime::component::{HasData, Linker, ResourceTable}; /// component model provides to a component callee (`backpressure.{inc,dec}`) /// and does not expose to a host import. (The in-guest provider, which could /// use it, deliberately does not: it has essentially one caller, so its -/// instance memory limit is its bound — see guest-impl's `buffer` module.) +/// instance memory limit is its bound — see lann-webcrypto-guest-provider's `buffer` module.) /// /// The pool's budget is resolved **once**, at the first operation that /// buffers, and belongs to the pool from then on (see `limits.rs` for why @@ -183,50 +183,50 @@ impl HasData for WasiWebcrypto { /// setters, consumed by a mint. #[derive(Debug, Default)] pub struct MacKeyOptions { - pub(crate) policy: webcrypto_impl_core::MacPolicy, + pub(crate) policy: lann_webcrypto_core::MacPolicy, } /// An `aead-key-options` resource. See [`MacKeyOptions`]. #[derive(Debug, Default)] pub struct AeadKeyOptions { - pub(crate) policy: webcrypto_impl_core::AeadPolicy, + pub(crate) policy: lann_webcrypto_core::AeadPolicy, } /// A `cipher-key-options` resource. See [`MacKeyOptions`]. #[derive(Debug, Default)] pub struct CipherKeyOptions { - pub(crate) policy: webcrypto_impl_core::CipherPolicy, + pub(crate) policy: lann_webcrypto_core::CipherPolicy, } /// An `internal-nonce-key-options` resource. See [`MacKeyOptions`]. #[derive(Debug, Default)] pub struct InternalNonceKeyOptions { - pub(crate) policy: webcrypto_impl_core::InternalNoncePolicy, + pub(crate) policy: lann_webcrypto_core::InternalNoncePolicy, } /// A `signing-key-options` resource. See [`MacKeyOptions`]. #[derive(Debug, Default)] pub struct SigningKeyOptions { - pub(crate) policy: webcrypto_impl_core::SigningPolicy, + pub(crate) policy: lann_webcrypto_core::SigningPolicy, } /// A `derive-options` resource. See [`MacKeyOptions`]. #[derive(Debug, Default)] pub struct DeriveOptions { - pub(crate) policy: webcrypto_impl_core::DerivePolicy, + pub(crate) policy: lann_webcrypto_core::DerivePolicy, } /// An `agreement-key-options` resource. See [`MacKeyOptions`]. #[derive(Debug, Default)] pub struct AgreementKeyOptions { - pub(crate) policy: webcrypto_impl_core::AgreementPolicy, + pub(crate) policy: lann_webcrypto_core::AgreementPolicy, } /// Backing type for the `key-agreement.public-key` resource: public /// material only, exchangeable and secret-free. #[derive(Debug)] pub struct AgreementPublicKey { - pub(crate) material: webcrypto_impl_core::AgreementPublicMaterial, + pub(crate) material: lann_webcrypto_core::AgreementPublicMaterial, } /// Backing type for the `key-agreement.secret-key` resource. `agree` is @@ -234,21 +234,21 @@ pub struct AgreementPublicKey { /// `derive-input` it mints. #[derive(Debug)] pub struct AgreementSecretKey { - pub(crate) material: webcrypto_impl_core::AgreementSecretMaterial, + pub(crate) material: lann_webcrypto_core::AgreementSecretMaterial, } /// Backing type for the `hkdf.ikm` resource: input keying material, never /// readable through the API under any grant. #[derive(Debug)] pub struct Ikm { - pub(crate) material: webcrypto_impl_core::IkmMaterial, + pub(crate) material: lann_webcrypto_core::IkmMaterial, } /// Backing type for the `pbkdf2.password` resource: a password, never /// readable through the API under any grant. #[derive(Debug)] pub struct Password { - pub(crate) material: webcrypto_impl_core::PasswordMaterial, + pub(crate) material: lann_webcrypto_core::PasswordMaterial, } /// Backing type for the `derivation.derive-input` resource: a @@ -256,7 +256,7 @@ pub struct Password { /// `prepare`, so this retains the PRK rather than the base secret). #[derive(Debug)] pub struct DeriveInput { - pub(crate) material: webcrypto_impl_core::DeriveInputMaterial, + pub(crate) material: lann_webcrypto_core::DeriveInputMaterial, } /// Backing type for the `mac.mac-key` resource. @@ -268,7 +268,7 @@ pub struct DeriveInput { /// lives host-side either way. #[derive(Debug)] pub struct MacKey { - pub(crate) material: webcrypto_impl_core::MacKeyMaterial, + pub(crate) material: lann_webcrypto_core::MacKeyMaterial, } /// Backing type for the `aead.aead-key` resource. @@ -279,13 +279,13 @@ pub struct MacKey { /// carries no per-operation state. #[derive(Debug)] pub struct AeadKey { - pub(crate) material: webcrypto_impl_core::AeadKeyMaterial, + pub(crate) material: lann_webcrypto_core::AeadKeyMaterial, } /// Backing type for the `cipher.cipher-key` resource: the unauthenticated /// AES modes' key material. pub struct CipherKey { - pub(crate) material: webcrypto_impl_core::CipherKeyMaterial, + pub(crate) material: lann_webcrypto_core::CipherKeyMaterial, } /// Backing type for the `aead-internal-nonce.internal-nonce-key` resource. @@ -296,7 +296,7 @@ pub struct CipherKey { /// (`error.key-exhausted`) for 12-byte-nonce algorithms. #[derive(Debug)] pub struct InternalNonceKey { - pub(crate) material: webcrypto_impl_core::AeadKeyMaterial, + pub(crate) material: lann_webcrypto_core::AeadKeyMaterial, /// The number of `seal` invocations so far, counted against the /// algorithm's nonce budget. pub(crate) sealed: u64, @@ -311,7 +311,7 @@ pub struct InternalNonceKey { #[derive(Debug)] pub struct Digest { /// The digest algorithm this resource is bound to. - pub(crate) variant: webcrypto_impl_core::DigestKind, + pub(crate) variant: lann_webcrypto_core::DigestKind, } /// Backing type for the `signature.verifying-key` resource. @@ -322,7 +322,7 @@ pub struct Digest { pub struct VerifyingKey { /// The public key, bound to its algorithm (and, for ECDSA, its /// curve/digest variant) at minting. - pub(crate) public: webcrypto_impl_core::SigPublic, + pub(crate) public: lann_webcrypto_core::SigPublic, } /// Backing type for the `signature.signing-key` resource. @@ -331,7 +331,7 @@ pub struct VerifyingKey { /// per-operation state. `extractable` gates `%export` only. #[derive(Debug)] pub struct SigningKey { - pub(crate) material: webcrypto_impl_core::SigningKeyMaterial, + pub(crate) material: lann_webcrypto_core::SigningKeyMaterial, } // `Debug` derives on the key-holding types print through the shared @@ -353,7 +353,7 @@ pub struct SigningKey { /// ```no_run /// use wasmtime::component::{Linker, ResourceTable}; /// use wasmtime::{Engine, Result}; -/// use wasmtime_webcrypto::{ +/// use lann_webcrypto_wasmtime::{ /// add_to_linker, WasiWebcryptoCtx, WasiWebcryptoCtxView, WasiWebcryptoView, /// }; /// diff --git a/wasmtime-impl/src/limits.rs b/rust/wasmtime/src/limits.rs similarity index 100% rename from wasmtime-impl/src/limits.rs rename to rust/wasmtime/src/limits.rs diff --git a/wasmtime-impl/src/standalone.rs b/rust/wasmtime/src/standalone.rs similarity index 100% rename from wasmtime-impl/src/standalone.rs rename to rust/wasmtime/src/standalone.rs diff --git a/wasmtime-impl/src/streams.rs b/rust/wasmtime/src/streams.rs similarity index 100% rename from wasmtime-impl/src/streams.rs rename to rust/wasmtime/src/streams.rs diff --git a/rust/wasmtime/wit/deps/lann-webcrypto b/rust/wasmtime/wit/deps/lann-webcrypto new file mode 120000 index 00000000..4a5c5bb1 --- /dev/null +++ b/rust/wasmtime/wit/deps/lann-webcrypto @@ -0,0 +1 @@ +../../../../wit \ No newline at end of file diff --git a/wasmtime-impl/wit/world.wit b/rust/wasmtime/wit/world.wit similarity index 100% rename from wasmtime-impl/wit/world.wit rename to rust/wasmtime/wit/world.wit diff --git a/scripts/setup.sh b/scripts/setup.sh index 6257ddd3..67f2ac0b 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -13,7 +13,7 @@ # - wasmtime, the host runtime that runs the composed in-guest crypto # integration test (`just test-webcrypto-composed`) # - the npm dependencies of every JS tree in the repository (jco host, -# demos, conformance adapter, componentize-sdk and its parity harness) +# demos, conformance adapter, webcrypto-componentize and its parity harness) # # Prerequisites (not installed here): a Rust toolchain via rustup, and — for # the jco host — Node 24+ with npm (jco's async ABI uses JSPI, which Node @@ -70,16 +70,16 @@ if ! have wasmtime; then fi if [ "${SKIP_NODE:-}" != "1" ]; then - log "Installing the componentize-sdk's npm dependencies (componentize-sdk)" - (cd "$REPO_ROOT/componentize-sdk" && npm install) - log "Installing the jco host's npm dependencies (jco-impl)" - (cd "$REPO_ROOT/jco-impl" && npm install) + log "Installing the webcrypto-componentize's npm dependencies (webcrypto-componentize)" + (cd "$REPO_ROOT/js/componentize" && npm install) + log "Installing the jco host's npm dependencies (webcrypto-jco)" + (cd "$REPO_ROOT/js/jco" && npm install) log "Installing the jco demo driver's npm dependencies (examples/jco-demo)" (cd "$REPO_ROOT/examples/jco-demo" && npm install) log "Installing the conformance jco adapter's npm dependencies (conformance/adapters/jco)" (cd "$REPO_ROOT/conformance/adapters/jco" && npm install) - log "Installing the WPT parity gate's npm dependencies (componentize-sdk/wpt/parity)" - (cd "$REPO_ROOT/componentize-sdk/wpt/parity" && npm install) + log "Installing the WPT parity gate's npm dependencies (js/componentize/wpt/parity)" + (cd "$REPO_ROOT/js/componentize/wpt/parity" && npm install) fi log "Done." diff --git a/timing-lab/README.md b/timing-lab/README.md index d4d626f1..e7cbd1f6 100644 --- a/timing-lab/README.md +++ b/timing-lab/README.md @@ -120,7 +120,7 @@ not how small a leak it would catch. ## Relation to the timing-channel classes -`guest-impl/README.md` classifies each algorithm's timing behavior (classes +`rust/guest-provider/README.md` classifies each algorithm's timing behavior (classes A–D) by *construction* — argument from the code's shape. The lab is the *empirical* companion: it can confirm the positive claims are not obviously wrong (ChaCha20-Poly1305's class A + B should be the boring, quiet row) and diff --git a/wasmtime-impl/wit/deps/lann-webcrypto b/wasmtime-impl/wit/deps/lann-webcrypto deleted file mode 120000 index b0ff8663..00000000 --- a/wasmtime-impl/wit/deps/lann-webcrypto +++ /dev/null @@ -1 +0,0 @@ -../../../wit \ No newline at end of file diff --git a/wit/README.md b/wit/README.md index f6755416..05feb8f8 100644 --- a/wit/README.md +++ b/wit/README.md @@ -215,7 +215,7 @@ key-recovering. Providers that execute inside an attacker-observable timing domain should not export such interfaces; a composition that requires one then fails at composition (`wac plug`) time rather than at run time. This repository's in-guest provider documents its classification and policy in -`guest-impl/README.md`. +`rust/guest-provider/README.md`. ## Design notes