Repository navigation
fix(wasm): secp256k1 did:key in the WASM build (LC-2431) - #21
Conversation
didkit-wasm built didkit without the secp256k1 feature, so did-method-key
had no secp256k1 support: keyToDID('key', <secp256k1 JWK>) failed with
'Unable to generate DID' and did:key:zQ3s... DIDs didn't resolve.
Adds a round-trip test (seed bytes -> JWK -> did:key -> resolved key),
runs every didkit-wasm lib test in CI instead of only the JWE ones, and
documents which DID methods work in the WASM build (did:ion and did:onion
don't).
Custard7
left a comment
There was a problem hiding this comment.
Reviewed at 7fee038. No blocking issue found. The added feature correctly propagates through didkit/secp256k1 to did-method-key's gated generation and resolution paths, and the round-trip assertion checks both public coordinates rather than only a DID prefix. Current-head CI is green, including the expanded WASM library test step and WASM package build.
Nonblocking follow-up: automate the reported Node/WASM exported-API round trip (and signature issue/verify) in CI. The new cargo test runs natively, while lib/Makefile's WASM package target builds but explicitly runs no test, so those two checks do not independently exercise the generated JS/WASM boundary. I reviewed source and hosted CI status; I did not rerun a local Rust/WASM build or independently reproduce the size figures.
Custard7 asked for the capability changes to live in the package docs, not just the PR body. lib/web/README.md gets a section listing the dropped zcap exports and the dropped did:webkey/did:onion/did:ion methods, and how to get each back. The DID methods section from #21 now says those three return methodNotSupported instead of describing their old browser failures. CHANGELOG.md gets matching Unreleased entries.
* perf(wasm): codegen-units=1 and make the zcap exports opt-in (LC-2429) Two no-risk size cuts: - codegen-units = 1 in the workspace release profile. LLVM sees the whole crate graph in one unit, so it inlines and dedupes more. - didkit-wasm default features drop invoke and delegate. Those gate the 9 zcap exports (delegateCapability, invokeCapability, verifyDelegation...), which LearnCard never calls. Build with --features invoke,delegate to get them back. The imports and helpers only those exports use are now gated too, so every feature combination still builds with -Dwarnings. * perf(wasm): leave did:webkey, did:onion and did:ion out of the WASM build (LC-2429) The three methods become default features of the didkit crate, so the CLI, HTTP server and C/Java bindings keep them. didkit-wasm already depends on didkit with default-features = false, so it drops them. None of them works in the browser today: - did:ion reads DID_ION_API_URL from the environment, which a browser doesn't have, so every resolve fails with 'Missing Sidetree API endpoint'. - did:onion sends plain HTTP to the .onion host with no Tor proxy. - did:webkey has no callers in LearnCard and is the only reason the OpenPGP stack (pgp, dsa, sha1-checked) is linked in. pgp was also the only crate turning on x25519-dalek's static_secrets feature, which jwe.rs needs, so didkit-wasm now asks for it directly. * perf(wasm): leave the schema.org and traceability contexts out (LC-2429) TAYLOR'S CALL. Turns on ssi-json-ld's omit-large-contexts for the WASM build only. The static loader stops embedding https://schema.org/ (~200 KB) and https://w3id.org/traceability/v1 (~123 KB). What breaks: a document whose @context includes either IRI no longer resolves from the built-in loader. It resolves if the caller puts the context in the context map (LearnCard's getDocumentMap does this when its context plugin can resolve the IRI, e.g. with remote contexts allowed); otherwise expansion fails with 'Unknown context'. No LearnCard-issued credential uses either context. Needs learningeconomy/ssi 0c5405a (omit-large-contexts), so CI's SSI_REF moves to it. * perf(wasm): skip JSON Schema validation in the WASM build (LC-2429) TAYLOR'S CALL. Turns on ssi-vc's omit-json-schema for the WASM build only. boon and the regex engine behind it (~925 KB raw) stop being linked in. What breaks: verifyCredential with checks: ['credentialSchema'] no longer validates the credential against its 1EdTechJsonSchemaValidator2019 schema. It returns a warning ('credentialSchema not checked: ...') and leaves credentialSchema out of checks. Proofs, status and expiry are unaffected. LearnCard's vc plugin adds that check whenever a credential has a credentialSchema (OBv3/CLR), so callers that need the check would have to validate in JS (e.g. ajv) or on a server. Needs learningeconomy/ssi 79b56b3 (omit-json-schema), so CI's SSI_REF moves to it. * ci: point the Docker build at the same ssi ref as build.yml (LC-2429) * revert: keep JSON Schema validation in the WASM build (LC-2429) Reverts 95f3369. omit-json-schema made verifyCredential return errors: [] for a signed, schema-invalid credential when the caller asked for the credentialSchema check. Taylor's call is to keep the check. This reverts commit 95f3369. * revert: keep the schema.org and traceability contexts in the WASM (LC-2429) Reverts 9d6fc98. Taylor's call is to keep both contexts in the built-in loader. With (c) and (d) gone, didkit-wasm no longer needs any ssi feature from learningeconomy/ssi#17, so build.yml's SSI_REF goes back to main's. This reverts commit 9d6fc98. * revert: point the Docker build back at main's ssi ref (LC-2429) Reverts feb932d. It only moved push_image.yml to the ssi#17 head so it matched build.yml. Nothing here needs that ref now, so both workflows go back to 9e2783f, same as main. This reverts commit feb932d. * docs(wasm): document what the default WASM build leaves out (LC-2429) Custard7 asked for the capability changes to live in the package docs, not just the PR body. lib/web/README.md gets a section listing the dropped zcap exports and the dropped did:webkey/did:onion/did:ion methods, and how to get each back. The DID methods section from #21 now says those three return methodNotSupported instead of describing their old browser failures. CHANGELOG.md gets matching Unreleased entries.
|
Acceptance Loom for LC-2431 (docs half on camera; WASM half cited via this PR’s regression test): Docs: |
Jira: LC-2431
keyToDID('key', <secp256k1 JWK>)fails in the WASM withUnable to generate DID, anddid:key:zQ3s…DIDs don't resolve either. didkit-wasm buildsdidkitwithdefault-features = falseand never turnedsecp256k1back on, sodid-method-keywas compiled without it. did:ethr and did:pkh kept working because they don't go through did-method-key.This adds
secp256k1to didkit-wasm's didkit features. That's the whole fix.Also in here:
generateSecp256k1KeyFromBytes→keyToDID('key')→resolveDID, then checks the resolved key matches. It fails on main withUnableToGenerateDID.cargo test -p didkit-wasm --lib). Before, it only ranjwe::tests, so the new test wouldn't have run.lib/web/README.mdthat lists what the WASM can generate and resolve, and says plainly that did:ion and did:onion don't resolve there. Both read their endpoint from an env var, and a browser has none. The LearnCard docs that advertised did:ion are fixed in docs: stop listing did:ion as resolvable (LC-2431) LearnCard#2066.Size
Basically nothing, which makes sense since k256 is already linked in for did:ethr (wasm-pack 0.13.1 +
wasm-opt -Ozfrom Binaryen 124, rustc 1.98.0, same flags as LearnCard's build script):Testing
cargo test --locked -p didkit-wasm --lib: 4 passed, including the new test. With the Cargo.toml change reverted, the new test fails withUnableToGenerateDID.keyToDID('key'),keyToVerificationMethod('key')andresolveDIDall work. AnEcdsaSecp256k1Signature2019VC issued by a secp256k1 did:key verifies with no errors. Every method the README lists as working generated and resolved, and did:ion/did:onion failed the way the README says.@learncard/didkit-pluginvitest against this build: 40/40, the same as the shipped WASM.To try it:
wasm-pack build lib/web --target web --locked, then in Node callkeyToDID('key', generateSecp256k1KeyFromBytes(new Uint8Array(32).fill(7))). You should get adid:key:zQ3s….LearnCard follow-up
LearnCard doesn't need a code change for this. Its own did:key comes from the Ed25519 key, so nothing in the app changes. SDK callers who pass a secp256k1 key to
keyToDid('key', …)get a DID instead of an error. LearnCard picks it up whenlib/didkitis bumped and the WASM rebuilt, which the notify-learncard workflow kicks off on merge.— Grok Bot