{"name":"@silencelaboratories/eddsa-wasm-node","version":"1.0.0-pre.6","license":"SEE LICENSE IN LICENSE","_id":"@silencelaboratories/eddsa-wasm-node@1.0.0-pre.6","maintainers":[{"name":"leontiad","email":"iraklis@silencelaboratories.com"},{"name":"kartikchoubisa1","email":"kartik@silencelaboratories.com"},{"name":"andreisl","email":"reg@silencelaboratories.com"},{"name":"sl-arm","email":"artem@silencelaboratories.com"},{"name":"dakshgarg","email":"daksh@silencelaboratories.com"},{"name":"noahsilencelab","email":"noah@silencelaboratories.com"},{"name":"sushisilence","email":"susheendhar@silencelaboratories.com"},{"name":"bhaskarsl","email":"bhaskar@silencelaboratories.com"},{"name":"rhonstin_silencelaboratories","email":"bohdan@silencelaboratories.com"},{"name":"szymon.silence","email":"szymon@silencelaboratories.com"},{"name":"samdan07","email":"samdan@silencelaboratories.com"},{"name":"toriningen","email":"toriningen.me@gmail.com"}],"dist":{"shasum":"0b5f5fc4f70b7eb9b893896dd86e7b8608c7fb8d","tarball":"http://registry-npm.ywwl.com/@silencelaboratories/eddsa-wasm-node/download/@silencelaboratories/eddsa-wasm-node-1.0.0-pre.6.tgz","fileCount":6,"integrity":"sha512-YRVRCHF3UJ44tlRdEnW7SB1cTBhDmf7Zemdhr4MISwiJ9jjLcL5tQOGUP+kepluawiFyu3Zdn3NuGN5VYYXHZw==","signatures":[{"sig":"MEUCIASTmyMq1f1KrIK1HiG5Dp56icmGzv/hAikaUWBhKNpgAiEA4I2euQXFYEYXWedzJ0ldZkhchjUHduh1vknLuMs/x5g=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":752887,"size":289871,"noattachment":false,"key":"/@silencelaboratories/eddsa-wasm-node/-/@silencelaboratories/eddsa-wasm-node-1.0.0-pre.6.tgz"},"main":"eddsa-wasm-node.js","types":"eddsa-wasm-node.d.ts","_npmUser":{"name":"sl-arm","email":"artem@silencelaboratories.com"},"_npmVersion":"10.9.8","description":"This crate exposes Silence Laboratories' threshold signing engines as a WebAssembly bundle. The bindings let JavaScript or TypeScript applications run multi-party key generation, signing, and key maintenance flows entirely in the browser, Node.js, or Deno","directories":{},"_nodeVersion":"22.22.3","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/eddsa-wasm-node_1.0.0-pre.6_1779127824307_0.9929274018513121","host":"s3://npm-registry-packages-npm-production"},"readme":"# eddsa-wasm-ll\n\nThis crate exposes Silence Laboratories' threshold signing engines as a\nWebAssembly bundle. The bindings let JavaScript or TypeScript applications run\nmulti-party key generation, signing, and key maintenance flows entirely in the\nbrowser, Node.js, or Deno.\n\nThe exported API mirrors the Rust implementation found in `src/` and the Deno\nexamples in `tests/test-eddsa.ts`, `tests/test-redpallas.ts` and `tests/test-hard-derive.ts` This document pulls the core usage patterns from\nthose tests so you can bootstrap an integration quickly.\n\n## Installation\n\nThe repository ships six npm artefacts: three targets for each curve family.\n\n- `@silencelaboratories/eddsa-wasm-web`\n- `@silencelaboratories/eddsa-wasm-node`\n- `@silencelaboratories/eddsa-wasm-bundler`\n- `@silencelaboratories/redpallas-wasm-web`\n- `@silencelaboratories/redpallas-wasm-node`\n- `@silencelaboratories/redpallas-wasm-bundler`\n\nInstall the flavour that matches your environment:\n\n```bash\nnpm install @silencelaboratories/eddsa-wasm-web\n```\n\nThe package exposes an async default export that initialises the WASM module.\nAlways `await` it before touching any other primitive.\n\n```ts\nimport initEddsa, {\n  KeygenSession,\n  Keyshare,\n  SignSession,\n  Message,\n  generateEncryptionKeypair,\n} from \"@silencelaboratories/eddsa-wasm-web\";\n\nawait initEddsa();\n```\n\n## Distributed Key Generation (DKG)\n\nA DKG flow lets `participants` parties derive a shared key where any\n`threshold` subset can sign. The example below mirrors the helpers in\n`tests/test-eddsa.ts` and demonstrates the complete three-round protocol.\n\n```ts\nconst participants = 3;\nconst threshold = 2;\n\n// Generate the per-party key material used by the protocol.\nconst { secrets, publicKeys } = generateEncryptionMaterial(participants);\n\n// Spin up a session per participant.\nconst sessions = secrets.map((secret, party_id) =>\n  createKeygenSession(participants, threshold, party_id, secret, publicKeys),\n);\n\n// `queue` models the message transport between parties.\nconst queue = sessions.map((session) => session.createFirstMessage());\nwhile (queue.length > 0) {\n  const msg = queue.shift()!;\n  const sender = msg.sender();\n  const receiver = msg.receiver();\n\n  if (receiver === undefined) {\n    for (let partyId = 0; partyId < sessions.length; partyId++) {\n      if (partyId === sender) continue;\n      queue.push(...sessions[partyId].receiveMessage(msg.clone()));\n    }\n  } else {\n    queue.push(...sessions[receiver].receiveMessage(msg.clone()));\n  }\n}\n\n// and capture the resulting key shares.\nconst shares = sessions.map((session) => session.keyshare());\n```\n\nSupporting helpers lifted from the test suite:\n\n```ts\ntype DkgMaterial = {\n  secrets: Uint8Array[];\n  publicKeys: Uint8Array;\n};\n\ntype DkgResult = DkgMaterial & { shares: Keyshare[] };\n\nfunction generateEncryptionMaterial(participants: number): DkgMaterial {\n  const secrets: Uint8Array[] = [];\n  const publicKeys: Uint8Array[] = [];\n\n  for (let i = 0; i < participants; i++) {\n    const pair = generateEncryptionKeypair();\n    secrets.push(pair.secretKey);    // random 32 bytes\n    publicKeys.push(pair.publicKey); // ed25519 public key\n    pair.free();\n  }\n\n  return { secrets, publicKeys: concatBytes(publicKeys) };\n}\n\nfunction createKeygenSession(\n  participants: number,\n  threshold: number,\n  partyId: number,\n  secretKey: Uint8Array,\n  aggregatedPublicKeys: Uint8Array,\n): KeygenSession {\n  const flattened = aggregatedPublicKeys.slice();\n  return new KeygenSession(participants, threshold, partyId, secretKey, flattened);\n}\n\nfunction concatBytes(chunks: Uint8Array[]): Uint8Array {\n  const total = chunks.reduce((sum, chunk) => sum + chunk.length, 0);\n  const result = new Uint8Array(total);\n  let offset = 0;\n  for (const chunk of chunks) {\n    result.set(chunk, offset);\n    offset += chunk.length;\n  }\n  return result;\n}\n```\n\nThe resulting `shares` carry metadata such as the party id, threshold, and\npublic key. See `tests/test-eddsa.ts` for assertions that confirm the shape of the\noutput.\n\nFor the RedPallas curve family (`@silencelaboratories/redpallas-wasm-*`), use the\nsame DKG helpers as in `tests/test-redpallas.ts`.\n\n## Zcash Orchard derived keys (RedPallas)\n\nWhen built with the `redpallas` feature (the default for this crate and the\n`redpallas-wasm-*` npm packages), DKG is followed by an additional distributed\nderivation round. Every participant runs the same message loop as in the DKG\nsection above; once `isFinished()` is true, each party holds identical Orchard\nkey material in addition to its threshold signing share.\n\n `derivedKeys()` returns a `DerivedOrchardKeys`\nobject:\n\n| Property | Role |\n| --- | --- |\n| `ask` | Authorizing key component of the Orchard full viewing key (FVK) |\n| `nk` | Nullifier-deriving key component of the FVK |\n| `rivk` | Incoming viewing key component of the FVK |\n| `internalIvk` | Incoming viewing key for the internal (change) address scope |\n| `externalIvk` | Incoming viewing key for the external (payment) address scope |\n\nTogether, `ask`, `nk`, and `rivk` are the serialized components needed to\nreconstruct the Orchard **full viewing key** in a Zcash wallet or indexer. The\n`internalIvk` and `externalIvk` fields are the scope-specific incoming viewing\nkeys derived alongside the FVK; use them when your integration scans or\ndecrypts notes on internal vs external Orchard addresses.\n\n```ts\nimport initRedpallas, {\n  KeygenSession,\n  DerivedOrchardKeys,\n  generateEncryptionKeypair,\n} from \"@silencelaboratories/redpallas-wasm-web\";\n\nawait initRedpallas();\n\n// ... run the same DKG message loop as above on KeygenSession instances ...\n\nif (!sessions.every((s) => s.isFinished())) {\n  throw new Error(\"dkg did not complete\");\n}\n\n// All parties must agree on the derived Orchard material (see server_web_dkg.rs).\nconst keys: DerivedOrchardKeys = sessions[0].derivedKeys()!;\nfor (const session of sessions.slice(1)) {\n  const peer = session.derivedKeys()!;\n  const match =\n    peer.ask.every((b, i) => b === keys.ask[i]) &&\n    peer.nk.every((b, i) => b === keys.nk[i]) &&\n    peer.rivk.every((b, i) => b === keys.rivk[i]);\n  if (!match) {\n    throw new Error(\"derived Orchard keys mismatch across parties\");\n  }\n}\n\nconst fvk = { ask: keys.ask, nk: keys.nk, rivk: keys.rivk };\nconst internalIvk = keys.internalIvk;\nconst externalIvk = keys.externalIvk;\n\nconst shares = sessions.map((s) => s.keyshare());\n```\n\nThe pattern above mirrors `tests/server_web_dkg.rs`, which mixes native\n`zcash` server sessions with WASM `KeygenSession` parties and asserts that\n`ask`, `nk`, and `rivk` match across every participant before extracting\nkey shares. `tests/test-redpallas.ts` exercises the full RedPallas DKG and\nthreshold-signing path end-to-end; wire `derivedKeys()` into your application\nthe same way once the session reports finished.\n\n## Keyshare Rerandomization (RedPallas)\n\nWhen built with `redpallas`, a threshold quorum can rerandomize existing\nkeyshares via `RerandomizeSession`. The protocol runs three rounds (commit →\nopen → tweak). Each party adds the same scalar `alpha = H(∑ randomizer_i)` to\nits share and `G·alpha` to the public key. Use any `threshold` subset of\nshares from DKG; the resulting shares keep the same threshold but advertise a\nnew group public key. Read `session.alpha` (32 bytes) before `keyshare()`,\nwhich consumes the session. Every party returns the same `alpha`.\n\nThe flow mirrors `tests/test-redpallas.ts` (`Rerand 2-of-3 then DSG`):\n\n```ts\nimport initRedpallas, {\n  Keyshare,\n  RerandomizeSession,\n  SignSession,\n  Message,\n} from \"@silencelaboratories/redpallas-wasm-web\";\n\nawait initRedpallas();\n\n// `shares` from a prior RedPallas DKG; pick any threshold-sized subset.\nconst subset: Keyshare[] = shares.slice(0, threshold);\n\nconst sessions = subset.map((share) => new RerandomizeSession(share));\n\nconst msg1: Message[] = sessions.map((s) => s.createFirstMessage());\nconst msg2: Message[] = sessions.flatMap((s) =>\n  s.handleMessages(msg1.map((m) => m.clone())),\n);\n\nsessions.forEach((s) => {\n  const out = s.handleMessages(msg2.map((m) => m.clone()));\n  if (out.length !== 0 || !s.isFinished()) {\n    throw new Error(\"rerandomize did not complete\");\n  }\n});\n\nconst alphas = sessions.map((s) => s.alpha);\nconst newShares = sessions.map((s) => s.keyshare());\n\n// Every party computed the same alpha, and the public key changed.\nif (alphas[0].length !== 32) {\n  throw new Error(\"alpha must be 32 bytes\");\n}\n\n// Sign with the rerandomized shares (same DSG loop as below).\n```\n\nSession state can be checkpointed mid-protocol with `toBytes()` /\n`fromBytes()` (see `Rerand session toBytes/fromBytes roundtrip then DSG` in\n`tests/test-redpallas.ts` and `rerand_session_roundtrip` in\n`tests/keygen.rs`). Treat thrown errors as fatal, the same as other sessions;\ninspect `session.error()` after a failure.\n\n## Threshold Signing (DSG)\n\nSigning reuses the key shares produced during DKG. The snippet below follows\nthe `dsg` helper from the test suite and shows the three interaction rounds\nbetween `threshold` parties.\n\n```ts\nconst message = crypto.getRandomValues(new Uint8Array(32));\nconst sharesToUse = shares.slice(0, threshold);\n\nconst sessions = sharesToUse.map((share) => new SignSession(share, message, \"m\"));\n\nconst msg1 = sessions.map((session) => session.createFirstMessage());\nconst msg2 = sessions.flatMap((session) =>\n  session.handleMessages(msg1.map((m) => m.clone()))\n);\nconst msg3 = sessions.flatMap((session) =>\n  session.handleMessages(msg2.map((m) => m.clone()))\n);\n\nsessions.forEach((session) => {\n  session.handleMessages(msg3.map((m) => m.clone()));\n});\n\nconst signatures = sessions.map((session) => session.signature());\n```\n\nThe final signatures are raw encodings for the active curve (Ed25519 for the\n`eddsa-wasm-*` packages, RedPallas for `redpallas-wasm-*`). Each\n`SignSession` is single-use; discard it after calling `signature()`.\n\n## Key Rotation and Share Recovery\n\nThe library exposes additional helpers that allow rotating key shares or\nrecovering lost participants:\n\n- `KeygenSession.initKeyRotation(share, secretKey,\n  aggregatedPublicKeys)`\n- `KeygenSession.initKeyRecovery(share, lostPartyIds, secretKey,\n  aggregatedPublicKeys)`\n- `KeygenSession.initLostShareRecovery(participants, threshold,\n  partyId, expectedPublicKey, lostPartyIds, secretKey,\n  aggregatedPublicKeys)`\n\nThe Deno test suite demonstrates a full rotation flow (`Key rotation`)\nand a lost-share recovery path (`key share recovery`) that feed into the\nsession-based DKG helper again to reach steady state. Those tests are excellent\nreferences when wiring up similar logic on the application side.\n\n## Error Handling\n\nSession methods throw JavaScript exceptions when progress is\nimpossible. Examples from the test suite include:\n\n- Re-playing a round method, e.g. calling `createFirstMessage()` twice.\n- Passing a party its own outgoing message.\n\nTreat these errors as fatal: the protocol state is no longer usable\nonce a method throws. If you need structured errors, inspect the\noptional `session.error()` accessor on `KeygenSession`, `SignSession`, and\n`RerandomizeSession`.\n\n## Testing Locally\n\nRun these from `wrapper/wasm-ll/`. This crate’s **Cargo defaults** are\n`console_error_panic_hook` + `redpallas` (which pulls the private `zcash`\ncrate). Ed25519 lives behind `eddsa`; VRF types (`VrfKeygenSession`,\n`HardDeriveSession`, …) behind `vrf`. Pass explicit features for each suite:\n\n| Suite | Features |\n| --- | --- |\n| Ed25519 DKG / DSG | `console_error_panic_hook,eddsa` |\n| VRF DKG + hard derive | `console_error_panic_hook,eddsa,vrf` |\n| RedPallas DKG / DSG | `console_error_panic_hook,redpallas` |\n| Orchard server/web interop | `redpallas,zcash-dkg` |\n\nAlways pass `--no-default-features` when building a non-RedPallas flavour locally.\n\n- Deno integration tests (build WASM first, then test):\n\n  ```bash\n  # Ed25519\n  wasm-pack build -t web . -- --no-default-features --features console_error_panic_hook,eddsa\n  deno test -A tests/test-eddsa.ts\n\n  # VRF hard derivation\n  wasm-pack build -t web . -- --no-default-features --features console_error_panic_hook,eddsa,vrf\n  deno test -A tests/test-hard-derive.ts\n\n  # RedPallas (requires a Kellnr registry token for the optional zcash dependency)\n  wasm-pack build -t web . -- --no-default-features --features console_error_panic_hook,redpallas\n  deno test -A tests/test-redpallas.ts\n  ```\n\n- Rust / WASM harnesses:\n\n  ```bash\n  # Ed25519\n  cargo test --no-default-features --features eddsa\n  wasm-pack test --node --no-default-features --features eddsa\n\n  # VRF (integration tests in tests/vrf.rs + wasm_bindgen tests)\n  cargo test --no-default-features --features eddsa,vrf\n  wasm-pack test --node --no-default-features --features eddsa,vrf\n  ```\n\n- Orchard derivation interop between native server sessions and WASM web\n  parties (`tests/server_web_dkg.rs`):\n\n  ```bash\n  cargo test -r --no-default-features --features redpallas,zcash-dkg \\\n    --test server_web_dkg test_server_web_dkg_derivation_interop\n  ```\n\n- VRF DKG + hard-derive interop between native server sessions and WASM web\n  parties (`tests/server_web_vrf.rs`):\n\n  ```bash\n  cargo test -r --no-default-features --features eddsa,vrf --test server_web_vrf\n  ```\n\nFrom the repo root, add `-p eddsa-wasm-ll` to `cargo test` commands.\n\n## Licensing\n\nThis wrapper is released under the Silence Laboratories License Agreement. See\n`LICENSE` for the full text.\n","publish_time":1779127824544,"_cnpm_publish_time":1779127824544,"dist-tags":{"latest":"1.0.0-pre.13","next":"1.0.0-pre.10"}}