@maatara/core-pqc 0.4.5 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -293,7 +293,7 @@ async function createAttestation(operation, signerKeys, expiresInSeconds = 3600)
293
293
  // Build deterministic preimage for the operation
294
294
  const preimage = await jcsCanonicalize({ type: operation.type, payload: operation.payload });
295
295
  const preimageBytes = new TextEncoder().encode(preimage);
296
- const operationHash = await sha256B64u(preimageBytes);
296
+ const operationHash = await sha3_384_b64u(preimageBytes);
297
297
  const msgB64u = b64uEncode(preimageBytes);
298
298
  // Sign the preimage
299
299
  const sig = await dilithiumSign(msgB64u, signerKeys.secretKeyB64u);
@@ -316,7 +316,7 @@ async function verifyAttestation(attestation, operation) {
316
316
  // Rebuild expected operation hash
317
317
  const preimage = await jcsCanonicalize({ type: operation.type, payload: operation.payload });
318
318
  const preimageBytes = new TextEncoder().encode(preimage);
319
- const expectedHash = await sha256B64u(preimageBytes);
319
+ const expectedHash = await sha3_384_b64u(preimageBytes);
320
320
  if (attestation.operationHash !== expectedHash) {
321
321
  return { valid: false, error: 'Operation hash mismatch' };
322
322
  }
@@ -370,14 +370,14 @@ async function createProvenanceCommitment(assetBytes, keys) {
370
370
  await initWasm();
371
371
  // Generate random salt
372
372
  const salt = crypto.getRandomValues(new Uint8Array(32));
373
- // Compute commitment hash = SHA256(asset || salt || publicKey)
373
+ // Compute commitment hash = SHA3-384(asset || salt || publicKey)
374
374
  const publicKeyBytes = b64uDecode(keys.publicKeyB64u);
375
375
  const preimage = new Uint8Array(assetBytes.length + salt.length + publicKeyBytes.length);
376
376
  preimage.set(assetBytes, 0);
377
377
  preimage.set(salt, assetBytes.length);
378
378
  preimage.set(publicKeyBytes, assetBytes.length + salt.length);
379
- const commitmentHash = await sha256B64u(preimage);
380
- const assetHash = await sha256B64u(assetBytes);
379
+ const commitmentHash = await sha3_384_b64u(preimage);
380
+ const assetHash = await sha3_384_b64u(assetBytes);
381
381
  // Build commitment object (without signature)
382
382
  const commitmentData = {
383
383
  type: 'ProvenanceCommitment',
@@ -432,7 +432,7 @@ async function verifyCommitmentReveal(commitment, assetBytes, reveal) {
432
432
  return { valid: false, error: `Commitment signature invalid: ${sigResult.error}` };
433
433
  }
434
434
  // Verify asset hash matches
435
- const computedAssetHash = await sha256B64u(assetBytes);
435
+ const computedAssetHash = await sha3_384_b64u(assetBytes);
436
436
  if (computedAssetHash !== reveal.assetHash) {
437
437
  return { valid: false, error: 'Asset hash does not match reveal' };
438
438
  }
@@ -443,18 +443,88 @@ async function verifyCommitmentReveal(commitment, assetBytes, reveal) {
443
443
  preimage.set(assetBytes, 0);
444
444
  preimage.set(salt, assetBytes.length);
445
445
  preimage.set(publicKeyBytes, assetBytes.length + salt.length);
446
- const computedCommitmentHash = await sha256B64u(preimage);
446
+ const computedCommitmentHash = await sha3_384_b64u(preimage);
447
447
  if (computedCommitmentHash !== commitment.commitmentHash) {
448
448
  return { valid: false, error: 'Commitment hash does not match reveal' };
449
449
  }
450
450
  return { valid: true };
451
451
  }
452
452
  // ============================================================================
453
- // HELPER: SHA-256 with base64url output
454
453
  // ============================================================================
455
- async function sha256B64u(data) {
456
- const hashBuffer = await crypto.subtle.digest('SHA-256', data);
457
- return b64uEncode(new Uint8Array(hashBuffer));
454
+ // SHA3-384 HASHING (PQC Compliant)
455
+ // ============================================================================
456
+ // All SHA3-384 operations use the WASM module - no external dependencies required
457
+ // Import SHA3-384 functions from WASM
458
+ const wasm_sha3_384_bytes = wasmPkg__namespace.sha3_384_hash;
459
+ const wasm_sha3_384_string = wasmPkg__namespace.sha3_384_hash_string;
460
+ const wasm_sha3_384_bytes_b64u = wasmPkg__namespace.sha3_384_hash_b64u;
461
+ const wasm_sha3_384_string_b64u = wasmPkg__namespace.sha3_384_hash_string_b64u;
462
+ const wasm_sha3_384_truncated = wasmPkg__namespace.sha3_384_hash_truncated_32;
463
+ /**
464
+ * Compute SHA3-384 hash of raw bytes.
465
+ * Returns both hex and base64url encodings.
466
+ *
467
+ * @example
468
+ * ```typescript
469
+ * const data = new TextEncoder().encode('hello');
470
+ * const { hex, b64u } = await sha3_384(data);
471
+ * // hex = "720aea11019ef06440fbf05d87aa24680a2153df3907b2..." (96 chars)
472
+ * // b64u = "cgrqEQGe8GRA-_BdOKokaDCAoVPfOQe..." (64 chars)
473
+ * ```
474
+ */
475
+ async function sha3_384(data) {
476
+ await initWasm();
477
+ if (!wasm_sha3_384_bytes || !wasm_sha3_384_bytes_b64u) {
478
+ throw new Error('SHA3-384 WASM functions not available - ensure WASM module is initialized');
479
+ }
480
+ return {
481
+ hex: wasm_sha3_384_bytes(data),
482
+ b64u: wasm_sha3_384_bytes_b64u(data),
483
+ };
484
+ }
485
+ /**
486
+ * Compute SHA3-384 hash of a UTF-8 string.
487
+ * Returns both hex and base64url encodings.
488
+ *
489
+ * @example
490
+ * ```typescript
491
+ * const { hex, b64u } = await sha3_384_string('hello world');
492
+ * ```
493
+ */
494
+ async function sha3_384_string(data) {
495
+ await initWasm();
496
+ if (!wasm_sha3_384_string || !wasm_sha3_384_string_b64u) {
497
+ throw new Error('SHA3-384 WASM functions not available - ensure WASM module is initialized');
498
+ }
499
+ return {
500
+ hex: wasm_sha3_384_string(data),
501
+ b64u: wasm_sha3_384_string_b64u(data),
502
+ };
503
+ }
504
+ /**
505
+ * Compute SHA3-384 hash truncated to 32 bytes (for EVM bytes32 compatibility).
506
+ * Uses the first 32 bytes of the full 48-byte hash.
507
+ *
508
+ * @example
509
+ * ```typescript
510
+ * const hex32 = await sha3_384_truncated32(data);
511
+ * // Returns 64-char hex string suitable for Ethereum bytes32
512
+ * ```
513
+ */
514
+ async function sha3_384_truncated32(data) {
515
+ await initWasm();
516
+ if (!wasm_sha3_384_truncated) {
517
+ throw new Error('SHA3-384 truncation WASM function not available');
518
+ }
519
+ return wasm_sha3_384_truncated(data);
520
+ }
521
+ /**
522
+ * Compute SHA3-384 hash with base64url output (internal helper, also exported for convenience).
523
+ * This is the 64-character base64url encoding of the 48-byte hash.
524
+ */
525
+ async function sha3_384_b64u(data) {
526
+ const result = await sha3_384(data);
527
+ return result.b64u;
458
528
  }
459
529
  // ============================================================================
460
530
  // ALGORITHMIC OPTIMIZATIONS (arXiv:2501.02305, arXiv:2504.17033)
@@ -611,9 +681,9 @@ async function createAccumulatorLeaf(userId, chainId, blockHash, blockIndex, has
611
681
  * Compute Merkle root from an array of leaf hashes.
612
682
  *
613
683
  * @param leaves - Array of hex hash strings
614
- * @param hashAlg - Hash algorithm ('sha256' or 'sha3-384')
684
+ * @param hashAlg - Hash algorithm (defaults to 'sha3-384' for PQC compliance)
615
685
  */
616
- async function computeMerkleRoot(leaves, hashAlg = 'sha256') {
686
+ async function computeMerkleRoot(leaves, hashAlg = 'sha3-384') {
617
687
  await initWasm();
618
688
  return JSON.parse(wasm_compute_merkle_root(JSON.stringify(leaves), hashAlg));
619
689
  }
@@ -725,6 +795,9 @@ exports.jcsCanonicalize = jcsCanonicalize;
725
795
  exports.kyberDecaps = kyberDecaps;
726
796
  exports.kyberEncaps = kyberEncaps;
727
797
  exports.kyberKeygen = kyberKeygen;
798
+ exports.sha3_384 = sha3_384;
799
+ exports.sha3_384_string = sha3_384_string;
800
+ exports.sha3_384_truncated32 = sha3_384_truncated32;
728
801
  exports.truncateToBytes32 = truncateToBytes32;
729
802
  exports.validateRoyalty = validateRoyalty;
730
803
  exports.verifyAttestation = verifyAttestation;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../src/index.ts"],"sourcesContent":["// Ma'atara Core PQC Toolkit\n// Post-Quantum Cryptography for Browser and Node.js\n// \n// SECURITY NOTICE: This library implements FIPS 204 (ML-DSA) and FIPS 203 (ML-KEM)\n// post-quantum cryptographic algorithms. Key material should be:\n// 1. Stored securely (encrypted at rest)\n// 2. Transmitted only over secure channels\n// 3. Zeroized after use when possible\n// 4. Protected by hardware security modules for high-value operations\n//\n// See docs/WASM_SECURITY_MODEL.md for browser-specific security considerations.\n\n// ============================================================================\n// SECURITY CONSTANTS\n// ============================================================================\nconst MAX_MESSAGE_SIZE = 16 * 1024 * 1024; // 16MB - prevent memory exhaustion\nconst MAX_KEY_SIZE = 1024 * 1024; // 1MB - reasonable for PQC keys\nconst MAX_ATTESTATION_COUNT = 100; // Prevent DoS from large attestation arrays\n\nexport interface KyberKeypair {\n public_b64u: string;\n secret_b64u: string;\n}\n\nexport interface KyberEncap {\n kem_ct_b64u: string;\n shared_b64u: string;\n}\n\nexport interface AesGcmWrap {\n iv_b64u: string;\n ct_b64u: string;\n}\n\nexport interface DilithiumKeypair {\n algorithm: string;\n public_b64u: string;\n secret_b64u: string;\n}\n\nexport interface DilithiumSignResult {\n signature_b64u: string;\n algorithm: string;\n}\n\nexport interface DilithiumVerifyResult {\n is_valid: boolean;\n algorithm: string;\n}\n\nexport interface HkdfResult {\n key_b64u: string;\n}\n\nexport interface AesGcmUnwrapResult {\n dek_b64u: string;\n}\n\n// Import WASM functions (namespace import for better bundler compatibility)\nimport * as wasmPkg from '@maatara/core-pqc-wasm';\nconst wasm_kyber_keygen = (wasmPkg as any).kyber_keygen as () => string;\nconst wasm_kyber_encaps = (wasmPkg as any).kyber_encaps as (p: string) => string;\nconst wasm_kyber_decaps = (wasmPkg as any).kyber_decaps as (s: string, c: string) => string;\nconst wasm_hkdf_sha256 = (wasmPkg as any).hkdf_sha256 as (s: string, i: string, salt?: string, len?: number) => string;\nconst wasm_aes_gcm_wrap = (wasmPkg as any).aes_gcm_wrap as (k: string, d: string, a: string) => string;\nconst wasm_aes_gcm_unwrap = (wasmPkg as any).aes_gcm_unwrap as (k: string, iv: string, ct: string, a: string) => string;\nconst wasm_dilithium_keygen = (wasmPkg as any).dilithium_keygen as () => string;\nconst wasm_dilithium_sign = (wasmPkg as any).dilithium_sign as (m: string, s: string) => string;\nconst wasm_dilithium_verify = (wasmPkg as any).dilithium_verify as (m: string, sig: string, p: string) => string;\n\n// Deterministic/canonicalization and governance helpers\nexport interface CanonicalOut { canonical: string; msg_b64u?: string; msgB64u?: string }\n\n// Initialize WASM\nlet wasmReady = false;\n\n/**\n * Initialize the underlying WASM module.\n * - In browsers/bundlers where the glue knows how to fetch the .wasm, you can call without params.\n * - If your bundler provides a URL or Module for the .wasm, pass it as the first argument.\n */\nexport async function initWasm(wasmInput?: any): Promise<void> {\n if (wasmReady) return;\n const maybeInit = (wasmPkg as any).default;\n if (typeof maybeInit === 'function') {\n // Some environments require a URL/Module/bytes for initialization.\n // We forward the optional value if provided; otherwise let the glue resolve it.\n if (wasmInput !== undefined) {\n await maybeInit(wasmInput);\n } else {\n await maybeInit();\n }\n }\n wasmReady = true;\n}\n\n// Kyber functions\nexport async function kyberKeygen(): Promise<KyberKeypair> {\n await initWasm();\n const result = JSON.parse(wasm_kyber_keygen());\n if (result.error) throw new Error(result.error);\n return result;\n}\n\nexport async function kyberEncaps(publicB64u: string): Promise<KyberEncap> {\n await initWasm();\n const result = JSON.parse(wasm_kyber_encaps(publicB64u));\n if (result.error) throw new Error(result.error);\n return result;\n}\n\nexport async function kyberDecaps(secretB64u: string, kemCtB64u: string): Promise<{ shared_b64u: string }> {\n await initWasm();\n const result = JSON.parse(wasm_kyber_decaps(secretB64u, kemCtB64u));\n if (result.error) throw new Error(result.error);\n return result;\n}\n\n// HKDF functions\nexport async function hkdfSha256(\n secretB64u: string,\n infoB64u: string,\n saltB64u?: string,\n len: number = 32\n): Promise<HkdfResult> {\n await initWasm();\n const result = JSON.parse(wasm_hkdf_sha256(secretB64u, infoB64u, saltB64u, len));\n if (result.error) throw new Error(result.error);\n return result;\n}\n\n// AES-GCM functions\nexport async function aesGcmWrap(\n keyB64u: string,\n dekB64u: string,\n aadB64u: string\n): Promise<AesGcmWrap> {\n await initWasm();\n const result = JSON.parse(wasm_aes_gcm_wrap(keyB64u, dekB64u, aadB64u));\n if (result.error) throw new Error(result.error);\n return result;\n}\n\nexport async function aesGcmUnwrap(\n keyB64u: string,\n ivB64u: string,\n ctB64u: string,\n aadB64u: string\n): Promise<AesGcmUnwrapResult> {\n await initWasm();\n const result = JSON.parse(wasm_aes_gcm_unwrap(keyB64u, ivB64u, ctB64u, aadB64u));\n if (result.error) throw new Error(result.error);\n return result;\n}\n\n// Dilithium functions\n\n/**\n * Generate a new ML-DSA-65 (Dilithium) keypair.\n * SECURITY: Keys should be stored encrypted at rest.\n * For high-value operations, consider hardware security modules.\n */\nexport async function dilithiumKeygen(): Promise<DilithiumKeypair> {\n await initWasm();\n const result = JSON.parse(wasm_dilithium_keygen());\n if (result.error) throw new Error(result.error);\n return result;\n}\n\n/**\n * Sign a message using ML-DSA-65 (Dilithium).\n * @param messageB64u - Base64url-encoded message to sign\n * @param secretB64u - Base64url-encoded secret key\n * SECURITY: Secret key should be zeroized after use if possible.\n */\nexport async function dilithiumSign(\n messageB64u: string,\n secretB64u: string\n): Promise<DilithiumSignResult> {\n // Input validation - prevent memory exhaustion attacks\n if (messageB64u.length > MAX_MESSAGE_SIZE) {\n throw new Error(`Message exceeds maximum size of ${MAX_MESSAGE_SIZE} bytes`);\n }\n if (secretB64u.length > MAX_KEY_SIZE) {\n throw new Error(`Secret key exceeds maximum size of ${MAX_KEY_SIZE} bytes`);\n }\n \n await initWasm();\n const result = JSON.parse(wasm_dilithium_sign(messageB64u, secretB64u));\n if (result.error) throw new Error(result.error);\n return result;\n}\n\n/**\n * Verify a ML-DSA-65 (Dilithium) signature.\n * @param messageB64u - Base64url-encoded message\n * @param signatureB64u - Base64url-encoded signature\n * @param publicB64u - Base64url-encoded public key\n */\nexport async function dilithiumVerify(\n messageB64u: string,\n signatureB64u: string,\n publicB64u: string\n): Promise<DilithiumVerifyResult> {\n // Input validation - prevent memory exhaustion attacks\n if (messageB64u.length > MAX_MESSAGE_SIZE) {\n throw new Error(`Message exceeds maximum size of ${MAX_MESSAGE_SIZE} bytes`);\n }\n if (signatureB64u.length > MAX_KEY_SIZE || publicB64u.length > MAX_KEY_SIZE) {\n throw new Error(`Signature or public key exceeds maximum size`);\n }\n \n await initWasm();\n const result = JSON.parse(wasm_dilithium_verify(messageB64u, signatureB64u, publicB64u));\n if (result.error) throw new Error(result.error);\n return result;\n}\n\n// ---- Deterministic helpers (multisig/art token) ----\nexport async function jcsCanonicalize(json: unknown): Promise<string> {\n await initWasm();\n const raw = (wasmPkg as any).jcs_canonicalize(JSON.stringify(json));\n const out = typeof raw === 'string' ? JSON.parse(raw) : raw;\n if (out?.error) throw new Error(out.error);\n return out.canonical as string;\n}\n\nexport async function buildPolicyPreimage(policy: unknown): Promise<CanonicalOut> {\n await initWasm();\n const raw = (wasmPkg as any).preimage_governance(JSON.stringify(policy));\n const out = typeof raw === 'string' ? JSON.parse(raw) : raw;\n if (out?.error) throw new Error(out.error);\n return { canonical: out.canonical, msg_b64u: out.msg_b64u, msgB64u: out.msg_b64u };\n}\n\nexport async function buildMintPreimage(header: unknown, asset: unknown): Promise<CanonicalOut> {\n await initWasm();\n const raw = (wasmPkg as any).preimage_asset_mint(JSON.stringify(header), JSON.stringify(asset));\n const out = typeof raw === 'string' ? JSON.parse(raw) : raw;\n if (out?.error) throw new Error(out.error);\n return { canonical: out.canonical, msg_b64u: out.msg_b64u, msgB64u: out.msg_b64u };\n}\n\nexport async function buildTransferPreimage(header: unknown): Promise<CanonicalOut> {\n await initWasm();\n const raw = (wasmPkg as any).preimage_asset_transfer(JSON.stringify(header));\n const out = typeof raw === 'string' ? JSON.parse(raw) : raw;\n if (out?.error) throw new Error(out.error);\n return { canonical: out.canonical, msg_b64u: out.msg_b64u, msgB64u: out.msg_b64u };\n}\n\nexport async function buildAnchorPreimage(userId: string, rootHex: string, epoch: string, chains: unknown): Promise<CanonicalOut> {\n await initWasm();\n const raw = (wasmPkg as any).preimage_anchor(userId, rootHex, epoch, JSON.stringify(chains));\n const out = typeof raw === 'string' ? JSON.parse(raw) : raw;\n if (out?.error) throw new Error(out.error);\n return { canonical: out.canonical, msg_b64u: out.msg_b64u, msgB64u: out.msg_b64u };\n}\n\n// ---- Veritas Block Preimage (NEW v2 JCS canonical form) ----\n// We migrate block signing to a canonical (JCS) JSON similar to other preimages.\n// Legacy (v1) blocks used a hand-crafted JSON.stringify of a plain object with fixed insertion order.\n// This helper produces a canonical JSON string and msg_b64u = b64url(UTF-8(canonical JSON)).\n// NOTE: We intentionally EXCLUDE signature, encryptionKeyHash, and any runtime-only fields.\n// Fields included (ordered via JCS lexical ordering):\n// contentType, dataHash, index, metadataHash, ownerPublicKey, previousHash, signatureAlg, timestamp, version\n// index & timestamp MUST be strings representing decimal integers (BigInt safe) – caller responsibility.\nexport interface BlockPreimageInput {\n index: string | number | bigint;\n timestamp: string | number | bigint;\n previousHash: string;\n dataHash: string;\n metadataHash: string;\n signatureAlg: string; // e.g. 'dilithium2'\n ownerPublicKey: string; // Dilithium public key (base64url)\n contentType?: string; // default 'application/json'\n version: number; // block format / protocol version\n}\n\nexport async function buildBlockPreimage(block: BlockPreimageInput): Promise<CanonicalOut> {\n await initWasm();\n // Normalize fields per spec\n const normalized = {\n contentType: block.contentType || 'application/json',\n dataHash: block.dataHash,\n index: block.index.toString(),\n metadataHash: block.metadataHash,\n ownerPublicKey: block.ownerPublicKey,\n previousHash: block.previousHash,\n signatureAlg: block.signatureAlg,\n timestamp: block.timestamp.toString(),\n version: block.version,\n };\n // Use JCS canonicalization via wasm jcs_canonicalize (already exposed through jcsCanonicalize helper)\n const canonical = await jcsCanonicalize(normalized);\n const msg_b64u = b64uEncode(new TextEncoder().encode(canonical));\n return { canonical, msg_b64u, msgB64u: msg_b64u };\n}\n\nexport async function validateRoyalty(receiver: string, bps: number): Promise<boolean> {\n await initWasm();\n const raw = (wasmPkg as any).validate_royalty(receiver, bps);\n const out = typeof raw === 'string' ? JSON.parse(raw) : raw;\n if (out?.error) return false;\n return !!out.ok;\n}\n\nexport async function verifyAttestations(msgB64u: string, attestations: Array<{ alg: string; publicKeyB64u: string; signatureB64u: string }>, allowedPublicKeys?: string[]): Promise<number> {\n await initWasm();\n const raw = (wasmPkg as any).verify_attestations(msgB64u, JSON.stringify(attestations), allowedPublicKeys ? JSON.stringify(allowedPublicKeys) : undefined);\n const out = typeof raw === 'string' ? JSON.parse(raw) : raw;\n if (out?.error) throw new Error(out.error);\n return Number(out.valid_count || 0);\n}\n\n// Utility functions\n// Cross-env base64url helpers (browser + Node)\nfunction _fromByteArray(bytes: Uint8Array): string {\n if (typeof btoa === 'function') {\n // Browser\n let s = '';\n for (let i = 0; i < bytes.length; i++) s += String.fromCharCode(bytes[i]);\n return btoa(s);\n }\n // Node\n return Buffer.from(bytes).toString('base64');\n}\n\nfunction _toByteArray(b64: string): Uint8Array {\n if (typeof atob === 'function') {\n const binary = atob(b64);\n const out = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) out[i] = binary.charCodeAt(i);\n return out;\n }\n return new Uint8Array(Buffer.from(b64, 'base64'));\n}\n\nexport function b64uEncode(data: Uint8Array): string {\n return _fromByteArray(data)\n .replace(/\\+/g, '-')\n .replace(/\\//g, '_')\n .replace(/=+/g, '');\n}\n\nexport function b64uDecode(str: string): Uint8Array {\n const b64 = str.replace(/-/g, '+').replace(/_/g, '/').padEnd(Math.ceil(str.length / 4) * 4, '=');\n return _toByteArray(b64);\n}\n\nexport function constantTimeEqual(a: Uint8Array, b: Uint8Array): boolean {\n if (a.length !== b.length) return false;\n let result = 0;\n for (let i = 0; i < a.length; i++) {\n result |= a[i] ^ b[i];\n }\n return result === 0;\n}\n\n// ============================================================================\n// THRESHOLD SIGNATURES & GOVERNANCE\n// ============================================================================\n\nexport interface GovernancePolicy {\n policyId: string;\n version: number;\n chainId: string;\n threshold: number;\n signers: Array<{\n publicKeyB64u: string;\n keyId: string;\n weight: number;\n role: 'owner' | 'guardian' | 'delegate' | 'recovery';\n }>;\n operations: Array<{\n action: string;\n requiredThreshold?: number;\n requiredRoles?: string[];\n maxValue?: string;\n timelock?: number;\n }>;\n validFrom: number;\n validUntil: number;\n createdAt: number;\n createdBy: string;\n policySignature: string;\n}\n\nexport interface Attestation {\n signerKeyId: string;\n signerPublicKeyB64u: string;\n operationHash: string;\n operationType: string;\n attestedAt: number;\n expiresAt: number;\n signatureAlg: 'dilithium2';\n signatureB64u: string;\n}\n\nexport interface AggregatedSignature {\n policyId: string;\n policyVersion: number;\n operationHash: string;\n attestations: Attestation[];\n totalWeight: number;\n thresholdMet: boolean;\n verifiedAt: number;\n}\n\n/**\n * Create an attestation for a threshold signature operation.\n */\nexport async function createAttestation(\n operation: { type: string; payload: unknown },\n signerKeys: { keyId: string; publicKeyB64u: string; secretKeyB64u: string },\n expiresInSeconds: number = 3600\n): Promise<Attestation> {\n await initWasm();\n \n // Build deterministic preimage for the operation\n const preimage = await jcsCanonicalize({ type: operation.type, payload: operation.payload });\n const preimageBytes = new TextEncoder().encode(preimage);\n const operationHash = await sha256B64u(preimageBytes);\n const msgB64u = b64uEncode(preimageBytes);\n \n // Sign the preimage\n const sig = await dilithiumSign(msgB64u, signerKeys.secretKeyB64u);\n \n return {\n signerKeyId: signerKeys.keyId,\n signerPublicKeyB64u: signerKeys.publicKeyB64u,\n operationHash,\n operationType: operation.type,\n attestedAt: Date.now(),\n expiresAt: Date.now() + expiresInSeconds * 1000,\n signatureAlg: 'dilithium2',\n signatureB64u: sig.signature_b64u\n };\n}\n\n/**\n * Verify an attestation signature.\n */\nexport async function verifyAttestation(\n attestation: Attestation,\n operation: { type: string; payload: unknown }\n): Promise<{ valid: boolean; error?: string }> {\n await initWasm();\n \n // Rebuild expected operation hash\n const preimage = await jcsCanonicalize({ type: operation.type, payload: operation.payload });\n const preimageBytes = new TextEncoder().encode(preimage);\n const expectedHash = await sha256B64u(preimageBytes);\n \n if (attestation.operationHash !== expectedHash) {\n return { valid: false, error: 'Operation hash mismatch' };\n }\n \n // Check expiry\n if (attestation.expiresAt < Date.now()) {\n return { valid: false, error: 'Attestation expired' };\n }\n \n // Verify signature\n const msgB64u = b64uEncode(preimageBytes);\n const result = await dilithiumVerify(msgB64u, attestation.signatureB64u, attestation.signerPublicKeyB64u);\n \n if (!result.is_valid) {\n return { valid: false, error: 'Invalid signature' };\n }\n \n return { valid: true };\n}\n\n/**\n * Verify that an aggregated signature meets the threshold policy.\n */\nexport async function verifyThreshold(\n aggregated: AggregatedSignature,\n operation: { type: string; payload: unknown },\n policy: GovernancePolicy\n): Promise<{ valid: boolean; errors: string[] }> {\n const errors: string[] = [];\n \n // Check policy match\n if (aggregated.policyId !== policy.policyId) {\n errors.push('Policy ID mismatch');\n }\n \n // Verify each attestation and compute weight\n let validWeight = 0;\n for (const attestation of aggregated.attestations) {\n const signer = policy.signers.find(s => s.publicKeyB64u === attestation.signerPublicKeyB64u);\n if (!signer) {\n errors.push(`Signer ${attestation.signerKeyId} not in policy`);\n continue;\n }\n \n const result = await verifyAttestation(attestation, operation);\n if (!result.valid) {\n errors.push(`Attestation from ${attestation.signerKeyId}: ${result.error}`);\n continue;\n }\n \n validWeight += signer.weight;\n }\n \n // Check threshold\n if (validWeight < policy.threshold) {\n errors.push(`Threshold not met: weight ${validWeight} < required ${policy.threshold}`);\n }\n \n return { valid: errors.length === 0, errors };\n}\n\n// ============================================================================\n// PRE-REGISTRATION COMMITMENT SCHEME\n// ============================================================================\n\nexport interface ProvenanceCommitment {\n type: 'ProvenanceCommitment';\n version: 1;\n commitmentHash: string;\n creatorPublicKey: string;\n timestamp: number;\n signature: string;\n}\n\nexport interface CommitmentReveal {\n commitmentHash: string;\n salt: string;\n assetHash: string;\n}\n\n/**\n * Create a provenance commitment for an asset before public disclosure.\n * This establishes a timestamped claim without revealing the asset content.\n */\nexport async function createProvenanceCommitment(\n assetBytes: Uint8Array,\n keys: { publicKeyB64u: string; secretKeyB64u: string }\n): Promise<{ commitment: ProvenanceCommitment; reveal: CommitmentReveal }> {\n await initWasm();\n \n // Generate random salt\n const salt = crypto.getRandomValues(new Uint8Array(32));\n \n // Compute commitment hash = SHA256(asset || salt || publicKey)\n const publicKeyBytes = b64uDecode(keys.publicKeyB64u);\n const preimage = new Uint8Array(assetBytes.length + salt.length + publicKeyBytes.length);\n preimage.set(assetBytes, 0);\n preimage.set(salt, assetBytes.length);\n preimage.set(publicKeyBytes, assetBytes.length + salt.length);\n \n const commitmentHash = await sha256B64u(preimage);\n const assetHash = await sha256B64u(assetBytes);\n \n // Build commitment object (without signature)\n const commitmentData = {\n type: 'ProvenanceCommitment' as const,\n version: 1 as const,\n commitmentHash,\n creatorPublicKey: keys.publicKeyB64u,\n timestamp: Date.now()\n };\n \n // Sign the commitment\n const canonical = await jcsCanonicalize(commitmentData);\n const sig = await dilithiumSign(b64uEncode(new TextEncoder().encode(canonical)), keys.secretKeyB64u);\n \n const commitment: ProvenanceCommitment = {\n ...commitmentData,\n signature: sig.signature_b64u\n };\n \n const reveal: CommitmentReveal = {\n commitmentHash,\n salt: b64uEncode(salt),\n assetHash\n };\n \n return { commitment, reveal };\n}\n\n/**\n * Verify a provenance commitment signature.\n */\nexport async function verifyProvenanceCommitment(\n commitment: ProvenanceCommitment\n): Promise<{ valid: boolean; error?: string }> {\n await initWasm();\n \n // Reconstruct the signed data (without signature field)\n const commitmentData = {\n type: commitment.type,\n version: commitment.version,\n commitmentHash: commitment.commitmentHash,\n creatorPublicKey: commitment.creatorPublicKey,\n timestamp: commitment.timestamp\n };\n \n const canonical = await jcsCanonicalize(commitmentData);\n const msgB64u = b64uEncode(new TextEncoder().encode(canonical));\n \n const result = await dilithiumVerify(msgB64u, commitment.signature, commitment.creatorPublicKey);\n \n if (!result.is_valid) {\n return { valid: false, error: 'Invalid commitment signature' };\n }\n \n return { valid: true };\n}\n\n/**\n * Verify that a revealed asset matches a commitment.\n */\nexport async function verifyCommitmentReveal(\n commitment: ProvenanceCommitment,\n assetBytes: Uint8Array,\n reveal: CommitmentReveal\n): Promise<{ valid: boolean; error?: string }> {\n await initWasm();\n \n // First verify the commitment signature\n const sigResult = await verifyProvenanceCommitment(commitment);\n if (!sigResult.valid) {\n return { valid: false, error: `Commitment signature invalid: ${sigResult.error}` };\n }\n \n // Verify asset hash matches\n const computedAssetHash = await sha256B64u(assetBytes);\n if (computedAssetHash !== reveal.assetHash) {\n return { valid: false, error: 'Asset hash does not match reveal' };\n }\n \n // Reconstruct commitment hash\n const salt = b64uDecode(reveal.salt);\n const publicKeyBytes = b64uDecode(commitment.creatorPublicKey);\n \n const preimage = new Uint8Array(assetBytes.length + salt.length + publicKeyBytes.length);\n preimage.set(assetBytes, 0);\n preimage.set(salt, assetBytes.length);\n preimage.set(publicKeyBytes, assetBytes.length + salt.length);\n \n const computedCommitmentHash = await sha256B64u(preimage);\n \n if (computedCommitmentHash !== commitment.commitmentHash) {\n return { valid: false, error: 'Commitment hash does not match reveal' };\n }\n \n return { valid: true };\n}\n\n// ============================================================================\n// HELPER: SHA-256 with base64url output\n// ============================================================================\n\nasync function sha256B64u(data: Uint8Array): Promise<string> {\n const hashBuffer = await crypto.subtle.digest('SHA-256', data as unknown as BufferSource);\n return b64uEncode(new Uint8Array(hashBuffer));\n}\n\n// ============================================================================\n// ALGORITHMIC OPTIMIZATIONS (arXiv:2501.02305, arXiv:2504.17033)\n// ============================================================================\n// High-performance data structures for verification operations\n\n// WASM bindings for algorithm functions\nconst wasm_create_nonce_cache = (wasmPkg as any).create_nonce_cache as (capacity: number, ttl_ms: number) => string;\nconst wasm_nonce_cache_info = (wasmPkg as any).nonce_cache_info as () => string;\nconst wasm_sssp_config = (wasmPkg as any).sssp_config as (nodes: number) => string;\nconst wasm_provenance_path_config = (wasmPkg as any).provenance_path_config as (chain_length: number, branches: number) => string;\nconst wasm_elastic_hash_config = (wasmPkg as any).elastic_hash_config as (capacity: number, load_factor: number) => string;\n\n/**\n * Nonce Cache Configuration\n * Uses Elastic Hashing (arXiv:2501.02305) for O(1) amortized lookup\n */\nexport interface NonceCacheConfig {\n type: string;\n capacity: number;\n ttl_ms: number;\n algorithm: string;\n complexity: string;\n}\n\n/**\n * Create a nonce cache configuration for replay attack prevention.\n * Based on Elastic Hashing - O(1) amortized, O(log(1/δ)) worst-case.\n * \n * @param capacity - Maximum number of nonces to track\n * @param ttlMs - Time-to-live in milliseconds before nonces expire\n */\nexport async function createNonceCacheConfig(capacity: number, ttlMs: number): Promise<NonceCacheConfig> {\n await initWasm();\n return JSON.parse(wasm_create_nonce_cache(capacity, ttlMs));\n}\n\n/**\n * Get information about the nonce cache algorithm.\n */\nexport async function getNonceCacheInfo(): Promise<{\n name: string;\n paper: string;\n probe_complexity: string;\n load_factor: number;\n features: string[];\n}> {\n await initWasm();\n return JSON.parse(wasm_nonce_cache_info());\n}\n\n/**\n * SSSP (Single-Source Shortest Path) Configuration\n * Uses Frontier-Reduced algorithm (arXiv:2504.17033)\n */\nexport interface SSSPConfig {\n name: string;\n paper: string;\n complexity: string;\n nodes: number;\n pivots_k: number;\n batch_t: number;\n use_cases: string[];\n}\n\n/**\n * Get optimal SSSP configuration for graph verification.\n * Uses Frontier-Reduced SSSP - O(m × log^(2/3)(n)) complexity.\n * \n * @param nodes - Expected number of nodes in the graph\n */\nexport async function getSSSPConfig(nodes: number): Promise<SSSPConfig> {\n await initWasm();\n return JSON.parse(wasm_sssp_config(nodes));\n}\n\n/**\n * Provenance Path Configuration\n * Optimized parameters for chain of custody verification\n */\nexport interface ProvenancePathConfig {\n algorithm: string;\n chain_length: number;\n branches: number;\n estimated_nodes: number;\n estimated_edges: number;\n pivots_k: number;\n batch_t: number;\n complexity: string;\n verification_mode: string;\n}\n\n/**\n * Get optimized configuration for provenance chain verification.\n * \n * @param chainLength - Number of blocks in the provenance chain\n * @param branches - Average number of branches per block\n */\nexport async function getProvenancePathConfig(chainLength: number, branches: number): Promise<ProvenancePathConfig> {\n await initWasm();\n return JSON.parse(wasm_provenance_path_config(chainLength, branches));\n}\n\n/**\n * Elastic Hash Configuration\n * High-performance hash table for key caching\n */\nexport interface ElasticHashConfig {\n algorithm: string;\n paper: string;\n capacity: number;\n load_factor: number;\n levels: number;\n probe_complexity: {\n amortized: string;\n worst_case: string;\n };\n use_cases: string[];\n}\n\n/**\n * Get elastic hash table configuration for key caching.\n * Optimal for PQC public key caching with O(1) amortized lookups.\n * \n * @param capacity - Maximum number of entries\n * @param loadFactor - Target load factor (0.0 to 1.0, recommend 0.95)\n */\nexport async function getElasticHashConfig(capacity: number, loadFactor: number = 0.95): Promise<ElasticHashConfig> {\n await initWasm();\n return JSON.parse(wasm_elastic_hash_config(capacity, loadFactor));\n}\n\n// ============================================================================\n// CROSS-CHAIN ANCHORING (Roadmap M8)\n// ============================================================================\n// Merkle root submission to Ethereum, Bitcoin, and L2s for timestamping\n\n// WASM bindings for anchoring functions\nconst wasm_anchor_chains_info = (wasmPkg as any).anchor_chains_info as () => string;\nconst wasm_create_accumulator_leaf = (wasmPkg as any).create_accumulator_leaf as (userId: string, chainId: string, blockHash: string, blockIndex: bigint) => string;\nconst wasm_create_accumulator_leaf_with_alg = (wasmPkg as any).create_accumulator_leaf_with_alg as (userId: string, chainId: string, blockHash: string, blockIndex: bigint, hashAlg: string) => string;\nconst wasm_compute_merkle_root = (wasmPkg as any).compute_merkle_root as (leavesJson: string, hashAlg: string) => string;\nconst wasm_generate_evm_anchor_calldata = (wasmPkg as any).generate_evm_anchor_calldata as (rootHex: string, epoch: bigint) => string;\nconst wasm_generate_bitcoin_anchor_payload = (wasmPkg as any).generate_bitcoin_anchor_payload as (rootHex: string, epoch: bigint) => string;\nconst wasm_decode_bitcoin_anchor_payload = (wasmPkg as any).decode_bitcoin_anchor_payload as (payloadHex: string) => string;\nconst wasm_truncate_to_bytes32 = (wasmPkg as any).truncate_to_bytes32 as (hashHex: string) => string;\nconst wasm_anchor_config_info = (wasmPkg as any).anchor_config_info as () => string;\n\n/**\n * Supported blockchain chains for anchoring\n */\nexport interface AnchorChainInfo {\n id: string;\n name: string;\n chain_id?: number;\n type: 'evm' | 'evm_l2' | 'bitcoin';\n contract?: string;\n method?: string;\n payload_size?: number;\n}\n\n/**\n * Get information about supported anchor chains\n */\nexport async function getAnchorChainsInfo(): Promise<{ chains: AnchorChainInfo[] }> {\n await initWasm();\n return JSON.parse(wasm_anchor_chains_info());\n}\n\n/**\n * Accumulator leaf representing a chain's current state\n */\nexport interface AccumulatorLeaf {\n user_id: string;\n chain_id: string;\n block_hash: string;\n block_index: number;\n timestamp: number;\n leaf_hash: string;\n hash_alg?: string;\n}\n\n/**\n * Create a Merkle accumulator leaf for a chain state.\n * This is the fundamental unit for batching chain updates into super-roots.\n * \n * @param userId - User ID (64 hex chars)\n * @param chainId - Chain identifier within user's chains\n * @param blockHash - Hash of the latest block (64 hex chars)\n * @param blockIndex - Block height/index (number or bigint)\n * @param hashAlg - Hash algorithm for leaf hash ('sha256' or 'sha3-384')\n * @throws Error if inputs are invalid\n */\nexport async function createAccumulatorLeaf(\n userId: string,\n chainId: string,\n blockHash: string,\n blockIndex: number | bigint,\n hashAlg: 'sha256' | 'sha3-384' = 'sha3-384'\n): Promise<AccumulatorLeaf> {\n await initWasm();\n \n // Input validation with helpful error messages\n if (typeof userId !== 'string' || userId.length !== 64) {\n throw new Error(`Invalid userId: must be 64 hex characters (got ${typeof userId === 'string' ? userId.length : typeof userId})`);\n }\n if (!/^[0-9a-fA-F]{64}$/.test(userId)) {\n throw new Error('Invalid userId: must contain only hex characters (0-9, a-f, A-F)');\n }\n \n if (typeof chainId !== 'string' || chainId.length === 0) {\n throw new Error('Invalid chainId: must be a non-empty string');\n }\n \n if (typeof blockHash !== 'string' || blockHash.length !== 64) {\n throw new Error(`Invalid blockHash: must be 64 hex characters (got ${typeof blockHash === 'string' ? blockHash.length : typeof blockHash})`);\n }\n if (!/^[0-9a-fA-F]{64}$/.test(blockHash)) {\n throw new Error('Invalid blockHash: must contain only hex characters (0-9, a-f, A-F)');\n }\n \n // Convert blockIndex to bigint (WASM expects bigint for u64)\n let indexBigInt: bigint;\n if (typeof blockIndex === 'bigint') {\n indexBigInt = blockIndex;\n } else if (typeof blockIndex === 'number') {\n if (!Number.isInteger(blockIndex) || blockIndex < 0) {\n throw new Error('Invalid blockIndex: must be a non-negative integer');\n }\n if (!Number.isSafeInteger(blockIndex)) {\n throw new Error('Invalid blockIndex: number exceeds MAX_SAFE_INTEGER; use bigint instead');\n }\n indexBigInt = BigInt(blockIndex);\n } else {\n throw new Error(`Invalid blockIndex: must be a number or bigint (got ${typeof blockIndex})`);\n }\n \n if (indexBigInt < 0n) {\n throw new Error('Invalid blockIndex: must be non-negative');\n }\n \n try {\n const result = typeof wasm_create_accumulator_leaf_with_alg === 'function'\n ? wasm_create_accumulator_leaf_with_alg(userId, chainId, blockHash, indexBigInt, hashAlg)\n : wasm_create_accumulator_leaf(userId, chainId, blockHash, indexBigInt);\n const parsed = JSON.parse(result);\n if (parsed.error) {\n throw new Error(parsed.error);\n }\n return parsed;\n } catch (e) {\n if (e instanceof Error) {\n // Re-throw our validation errors\n if (e.message.startsWith('Invalid ')) {\n throw e;\n }\n // Wrap WASM errors\n throw new Error(`WASM error in createAccumulatorLeaf: ${e.message}`);\n }\n throw new Error(`Unknown error in createAccumulatorLeaf: ${String(e)}`);\n }\n}\n\n/**\n * Merkle root computation result\n */\nexport interface MerkleRootResult {\n root: string;\n leaf_count: number;\n hash_alg: string;\n}\n\n/**\n * Compute Merkle root from an array of leaf hashes.\n * \n * @param leaves - Array of hex hash strings\n * @param hashAlg - Hash algorithm ('sha256' or 'sha3-384')\n */\nexport async function computeMerkleRoot(\n leaves: string[],\n hashAlg: 'sha256' | 'sha3-384' = 'sha256'\n): Promise<MerkleRootResult> {\n await initWasm();\n return JSON.parse(wasm_compute_merkle_root(JSON.stringify(leaves), hashAlg));\n}\n\n/**\n * EVM anchor calldata for AnchorRegistry contract\n */\nexport interface EvmAnchorCalldata {\n calldata: string;\n root: string;\n epoch: number;\n method: string;\n selector: string;\n}\n\n/**\n * Generate EVM calldata for AnchorRegistry.anchor(bytes32, uint256).\n * Ready to use in an Ethereum transaction.\n * \n * @param rootHex - 32-byte Merkle root (64 hex chars, with or without 0x prefix)\n * @param epoch - Epoch number (number or bigint)\n */\nexport async function generateEvmAnchorCalldata(\n rootHex: string,\n epoch: number | bigint\n): Promise<EvmAnchorCalldata> {\n await initWasm();\n let epochBigInt: bigint;\n if (typeof epoch === 'bigint') {\n epochBigInt = epoch;\n } else {\n if (!Number.isInteger(epoch) || epoch < 0) {\n throw new Error('Invalid epoch: must be a non-negative integer');\n }\n if (!Number.isSafeInteger(epoch)) {\n throw new Error('Invalid epoch: number exceeds MAX_SAFE_INTEGER; use bigint instead');\n }\n epochBigInt = BigInt(epoch);\n }\n return JSON.parse(wasm_generate_evm_anchor_calldata(rootHex, epochBigInt));\n}\n\n/**\n * Bitcoin OP_RETURN anchor payload\n */\nexport interface BitcoinAnchorPayload {\n payload_hex: string;\n payload_size: number;\n magic: string;\n epoch: number;\n root: string;\n}\n\n/**\n * Generate Bitcoin OP_RETURN payload for anchoring.\n * 45 bytes: \"MTARA\" (5) + epoch (8) + root32 (32)\n * \n * @param rootHex - 32-byte Merkle root (64 hex chars)\n * @param epoch - Epoch number (number or bigint)\n */\nexport async function generateBitcoinAnchorPayload(\n rootHex: string,\n epoch: number | bigint\n): Promise<BitcoinAnchorPayload> {\n await initWasm();\n let epochBigInt: bigint;\n if (typeof epoch === 'bigint') {\n epochBigInt = epoch;\n } else {\n if (!Number.isInteger(epoch) || epoch < 0) {\n throw new Error('Invalid epoch: must be a non-negative integer');\n }\n if (!Number.isSafeInteger(epoch)) {\n throw new Error('Invalid epoch: number exceeds MAX_SAFE_INTEGER; use bigint instead');\n }\n epochBigInt = BigInt(epoch);\n }\n return JSON.parse(wasm_generate_bitcoin_anchor_payload(rootHex, epochBigInt));\n}\n\n/**\n * Decoded Bitcoin anchor payload\n */\nexport interface DecodedBitcoinPayload {\n magic: string;\n epoch: number;\n root: string;\n}\n\n/**\n * Decode a Bitcoin OP_RETURN anchor payload.\n * \n * @param payloadHex - Hex-encoded payload bytes\n */\nexport async function decodeBitcoinAnchorPayload(\n payloadHex: string\n): Promise<DecodedBitcoinPayload> {\n await initWasm();\n return JSON.parse(wasm_decode_bitcoin_anchor_payload(payloadHex));\n}\n\n/**\n * Truncation result for SHA3-384 to bytes32\n */\nexport interface TruncationResult {\n original: string;\n original_bytes: number;\n truncated: string;\n truncated_bytes: number;\n}\n\n/**\n * Truncate a hash to 32 bytes for EVM compatibility.\n * Used when anchoring SHA3-384 hashes to Ethereum.\n * \n * @param hashHex - Hash to truncate (with or without 0x prefix)\n */\nexport async function truncateToBytes32(hashHex: string): Promise<TruncationResult> {\n await initWasm();\n return JSON.parse(wasm_truncate_to_bytes32(hashHex));\n}\n\n/**\n * Anchor configuration and estimates\n */\nexport interface AnchorConfigInfo {\n accumulator: {\n max_leaves_per_epoch: number;\n hash_algorithms: string[];\n default_hash: string;\n };\n ethereum: {\n contract: string;\n function: string;\n selector: string;\n estimated_gas: number;\n calldata_size: number;\n };\n bitcoin: {\n method: string;\n magic: string;\n payload_size: number;\n estimated_fee_sats: number;\n };\n recommended_schedule: {\n production: string;\n high_frequency: string;\n };\n}\n\n/**\n * Get anchor configuration and gas/fee estimates.\n */\nexport async function getAnchorConfigInfo(): Promise<AnchorConfigInfo> {\n await initWasm();\n return JSON.parse(wasm_anchor_config_info());\n}\n"],"names":["wasmPkg"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA,MAAM,gBAAgB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAC1C,MAAM,YAAY,GAAG,IAAI,GAAG,IAAI,CAAC;AA4CjC,MAAM,iBAAiB,GAAIA,kBAAe,CAAC,YAA4B;AACvE,MAAM,iBAAiB,GAAIA,kBAAe,CAAC,YAAqC;AAChF,MAAM,iBAAiB,GAAIA,kBAAe,CAAC,YAAgD;AAC3F,MAAM,gBAAgB,GAAIA,kBAAe,CAAC,WAA4E;AACtH,MAAM,iBAAiB,GAAIA,kBAAe,CAAC,YAA2D;AACtG,MAAM,mBAAmB,GAAIA,kBAAe,CAAC,cAA0E;AACvH,MAAM,qBAAqB,G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,CAAC;AACnE;AAYA;;;;;AAKG;AACI,eAAe,iBAAiB,CAAC,OAAe,EAAA;IACrD,MAAM,QAAQ,EAAE;IAChB,OAAO,IAAI,CAAC,KAAK,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC;AACtD;AA8BA;;AAEG;AACI,eAAe,mBAAmB,GAAA;IACvC,MAAM,QAAQ,EAAE;AAChB,IAAA,OAAO,IAAI,CAAC,KAAK,CAAC,uBAAuB,EAAE,CAAC;AAC9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../../src/index.ts"],"sourcesContent":["// Ma'atara Core PQC Toolkit\n// Post-Quantum Cryptography for Browser and Node.js\n// \n// SECURITY NOTICE: This library implements FIPS 204 (ML-DSA) and FIPS 203 (ML-KEM)\n// post-quantum cryptographic algorithms. Key material should be:\n// 1. Stored securely (encrypted at rest)\n// 2. Transmitted only over secure channels\n// 3. Zeroized after use when possible\n// 4. Protected by hardware security modules for high-value operations\n//\n// See docs/WASM_SECURITY_MODEL.md for browser-specific security considerations.\n\n// ============================================================================\n// SECURITY CONSTANTS\n// ============================================================================\nconst MAX_MESSAGE_SIZE = 16 * 1024 * 1024; // 16MB - prevent memory exhaustion\nconst MAX_KEY_SIZE = 1024 * 1024; // 1MB - reasonable for PQC keys\nconst MAX_ATTESTATION_COUNT = 100; // Prevent DoS from large attestation arrays\n\nexport interface KyberKeypair {\n public_b64u: string;\n secret_b64u: string;\n}\n\nexport interface KyberEncap {\n kem_ct_b64u: string;\n shared_b64u: string;\n}\n\nexport interface AesGcmWrap {\n iv_b64u: string;\n ct_b64u: string;\n}\n\nexport interface DilithiumKeypair {\n algorithm: string;\n public_b64u: string;\n secret_b64u: string;\n}\n\nexport interface DilithiumSignResult {\n signature_b64u: string;\n algorithm: string;\n}\n\nexport interface DilithiumVerifyResult {\n is_valid: boolean;\n algorithm: string;\n}\n\nexport interface HkdfResult {\n key_b64u: string;\n}\n\nexport interface AesGcmUnwrapResult {\n dek_b64u: string;\n}\n\n// Import WASM functions (namespace import for better bundler compatibility)\nimport * as wasmPkg from '@maatara/core-pqc-wasm';\nconst wasm_kyber_keygen = (wasmPkg as any).kyber_keygen as () => string;\nconst wasm_kyber_encaps = (wasmPkg as any).kyber_encaps as (p: string) => string;\nconst wasm_kyber_decaps = (wasmPkg as any).kyber_decaps as (s: string, c: string) => string;\nconst wasm_hkdf_sha256 = (wasmPkg as any).hkdf_sha256 as (s: string, i: string, salt?: string, len?: number) => string;\nconst wasm_aes_gcm_wrap = (wasmPkg as any).aes_gcm_wrap as (k: string, d: string, a: string) => string;\nconst wasm_aes_gcm_unwrap = (wasmPkg as any).aes_gcm_unwrap as (k: string, iv: string, ct: string, a: string) => string;\nconst wasm_dilithium_keygen = (wasmPkg as any).dilithium_keygen as () => string;\nconst wasm_dilithium_sign = (wasmPkg as any).dilithium_sign as (m: string, s: string) => string;\nconst wasm_dilithium_verify = (wasmPkg as any).dilithium_verify as (m: string, sig: string, p: string) => string;\n\n// Deterministic/canonicalization and governance helpers\nexport interface CanonicalOut { canonical: string; msg_b64u?: string; msgB64u?: string }\n\n// Initialize WASM\nlet wasmReady = false;\n\n/**\n * Initialize the underlying WASM module.\n * - In browsers/bundlers where the glue knows how to fetch the .wasm, you can call without params.\n * - If your bundler provides a URL or Module for the .wasm, pass it as the first argument.\n */\nexport async function initWasm(wasmInput?: any): Promise<void> {\n if (wasmReady) return;\n const maybeInit = (wasmPkg as any).default;\n if (typeof maybeInit === 'function') {\n // Some environments require a URL/Module/bytes for initialization.\n // We forward the optional value if provided; otherwise let the glue resolve it.\n if (wasmInput !== undefined) {\n await maybeInit(wasmInput);\n } else {\n await maybeInit();\n }\n }\n wasmReady = true;\n}\n\n// Kyber functions\nexport async function kyberKeygen(): Promise<KyberKeypair> {\n await initWasm();\n const result = JSON.parse(wasm_kyber_keygen());\n if (result.error) throw new Error(result.error);\n return result;\n}\n\nexport async function kyberEncaps(publicB64u: string): Promise<KyberEncap> {\n await initWasm();\n const result = JSON.parse(wasm_kyber_encaps(publicB64u));\n if (result.error) throw new Error(result.error);\n return result;\n}\n\nexport async function kyberDecaps(secretB64u: string, kemCtB64u: string): Promise<{ shared_b64u: string }> {\n await initWasm();\n const result = JSON.parse(wasm_kyber_decaps(secretB64u, kemCtB64u));\n if (result.error) throw new Error(result.error);\n return result;\n}\n\n// HKDF functions\nexport async function hkdfSha256(\n secretB64u: string,\n infoB64u: string,\n saltB64u?: string,\n len: number = 32\n): Promise<HkdfResult> {\n await initWasm();\n const result = JSON.parse(wasm_hkdf_sha256(secretB64u, infoB64u, saltB64u, len));\n if (result.error) throw new Error(result.error);\n return result;\n}\n\n// AES-GCM functions\nexport async function aesGcmWrap(\n keyB64u: string,\n dekB64u: string,\n aadB64u: string\n): Promise<AesGcmWrap> {\n await initWasm();\n const result = JSON.parse(wasm_aes_gcm_wrap(keyB64u, dekB64u, aadB64u));\n if (result.error) throw new Error(result.error);\n return result;\n}\n\nexport async function aesGcmUnwrap(\n keyB64u: string,\n ivB64u: string,\n ctB64u: string,\n aadB64u: string\n): Promise<AesGcmUnwrapResult> {\n await initWasm();\n const result = JSON.parse(wasm_aes_gcm_unwrap(keyB64u, ivB64u, ctB64u, aadB64u));\n if (result.error) throw new Error(result.error);\n return result;\n}\n\n// Dilithium functions\n\n/**\n * Generate a new ML-DSA-65 (Dilithium) keypair.\n * SECURITY: Keys should be stored encrypted at rest.\n * For high-value operations, consider hardware security modules.\n */\nexport async function dilithiumKeygen(): Promise<DilithiumKeypair> {\n await initWasm();\n const result = JSON.parse(wasm_dilithium_keygen());\n if (result.error) throw new Error(result.error);\n return result;\n}\n\n/**\n * Sign a message using ML-DSA-65 (Dilithium).\n * @param messageB64u - Base64url-encoded message to sign\n * @param secretB64u - Base64url-encoded secret key\n * SECURITY: Secret key should be zeroized after use if possible.\n */\nexport async function dilithiumSign(\n messageB64u: string,\n secretB64u: string\n): Promise<DilithiumSignResult> {\n // Input validation - prevent memory exhaustion attacks\n if (messageB64u.length > MAX_MESSAGE_SIZE) {\n throw new Error(`Message exceeds maximum size of ${MAX_MESSAGE_SIZE} bytes`);\n }\n if (secretB64u.length > MAX_KEY_SIZE) {\n throw new Error(`Secret key exceeds maximum size of ${MAX_KEY_SIZE} bytes`);\n }\n \n await initWasm();\n const result = JSON.parse(wasm_dilithium_sign(messageB64u, secretB64u));\n if (result.error) throw new Error(result.error);\n return result;\n}\n\n/**\n * Verify a ML-DSA-65 (Dilithium) signature.\n * @param messageB64u - Base64url-encoded message\n * @param signatureB64u - Base64url-encoded signature\n * @param publicB64u - Base64url-encoded public key\n */\nexport async function dilithiumVerify(\n messageB64u: string,\n signatureB64u: string,\n publicB64u: string\n): Promise<DilithiumVerifyResult> {\n // Input validation - prevent memory exhaustion attacks\n if (messageB64u.length > MAX_MESSAGE_SIZE) {\n throw new Error(`Message exceeds maximum size of ${MAX_MESSAGE_SIZE} bytes`);\n }\n if (signatureB64u.length > MAX_KEY_SIZE || publicB64u.length > MAX_KEY_SIZE) {\n throw new Error(`Signature or public key exceeds maximum size`);\n }\n \n await initWasm();\n const result = JSON.parse(wasm_dilithium_verify(messageB64u, signatureB64u, publicB64u));\n if (result.error) throw new Error(result.error);\n return result;\n}\n\n// ---- Deterministic helpers (multisig/art token) ----\nexport async function jcsCanonicalize(json: unknown): Promise<string> {\n await initWasm();\n const raw = (wasmPkg as any).jcs_canonicalize(JSON.stringify(json));\n const out = typeof raw === 'string' ? JSON.parse(raw) : raw;\n if (out?.error) throw new Error(out.error);\n return out.canonical as string;\n}\n\nexport async function buildPolicyPreimage(policy: unknown): Promise<CanonicalOut> {\n await initWasm();\n const raw = (wasmPkg as any).preimage_governance(JSON.stringify(policy));\n const out = typeof raw === 'string' ? JSON.parse(raw) : raw;\n if (out?.error) throw new Error(out.error);\n return { canonical: out.canonical, msg_b64u: out.msg_b64u, msgB64u: out.msg_b64u };\n}\n\nexport async function buildMintPreimage(header: unknown, asset: unknown): Promise<CanonicalOut> {\n await initWasm();\n const raw = (wasmPkg as any).preimage_asset_mint(JSON.stringify(header), JSON.stringify(asset));\n const out = typeof raw === 'string' ? JSON.parse(raw) : raw;\n if (out?.error) throw new Error(out.error);\n return { canonical: out.canonical, msg_b64u: out.msg_b64u, msgB64u: out.msg_b64u };\n}\n\nexport async function buildTransferPreimage(header: unknown): Promise<CanonicalOut> {\n await initWasm();\n const raw = (wasmPkg as any).preimage_asset_transfer(JSON.stringify(header));\n const out = typeof raw === 'string' ? JSON.parse(raw) : raw;\n if (out?.error) throw new Error(out.error);\n return { canonical: out.canonical, msg_b64u: out.msg_b64u, msgB64u: out.msg_b64u };\n}\n\nexport async function buildAnchorPreimage(userId: string, rootHex: string, epoch: string, chains: unknown): Promise<CanonicalOut> {\n await initWasm();\n const raw = (wasmPkg as any).preimage_anchor(userId, rootHex, epoch, JSON.stringify(chains));\n const out = typeof raw === 'string' ? JSON.parse(raw) : raw;\n if (out?.error) throw new Error(out.error);\n return { canonical: out.canonical, msg_b64u: out.msg_b64u, msgB64u: out.msg_b64u };\n}\n\n// ---- Veritas Block Preimage (NEW v2 JCS canonical form) ----\n// We migrate block signing to a canonical (JCS) JSON similar to other preimages.\n// Legacy (v1) blocks used a hand-crafted JSON.stringify of a plain object with fixed insertion order.\n// This helper produces a canonical JSON string and msg_b64u = b64url(UTF-8(canonical JSON)).\n// NOTE: We intentionally EXCLUDE signature, encryptionKeyHash, and any runtime-only fields.\n// Fields included (ordered via JCS lexical ordering):\n// contentType, dataHash, index, metadataHash, ownerPublicKey, previousHash, signatureAlg, timestamp, version\n// index & timestamp MUST be strings representing decimal integers (BigInt safe) – caller responsibility.\nexport interface BlockPreimageInput {\n index: string | number | bigint;\n timestamp: string | number | bigint;\n previousHash: string;\n dataHash: string;\n metadataHash: string;\n signatureAlg: string; // e.g. 'dilithium2'\n ownerPublicKey: string; // Dilithium public key (base64url)\n contentType?: string; // default 'application/json'\n version: number; // block format / protocol version\n}\n\nexport async function buildBlockPreimage(block: BlockPreimageInput): Promise<CanonicalOut> {\n await initWasm();\n // Normalize fields per spec\n const normalized = {\n contentType: block.contentType || 'application/json',\n dataHash: block.dataHash,\n index: block.index.toString(),\n metadataHash: block.metadataHash,\n ownerPublicKey: block.ownerPublicKey,\n previousHash: block.previousHash,\n signatureAlg: block.signatureAlg,\n timestamp: block.timestamp.toString(),\n version: block.version,\n };\n // Use JCS canonicalization via wasm jcs_canonicalize (already exposed through jcsCanonicalize helper)\n const canonical = await jcsCanonicalize(normalized);\n const msg_b64u = b64uEncode(new TextEncoder().encode(canonical));\n return { canonical, msg_b64u, msgB64u: msg_b64u };\n}\n\nexport async function validateRoyalty(receiver: string, bps: number): Promise<boolean> {\n await initWasm();\n const raw = (wasmPkg as any).validate_royalty(receiver, bps);\n const out = typeof raw === 'string' ? JSON.parse(raw) : raw;\n if (out?.error) return false;\n return !!out.ok;\n}\n\nexport async function verifyAttestations(msgB64u: string, attestations: Array<{ alg: string; publicKeyB64u: string; signatureB64u: string }>, allowedPublicKeys?: string[]): Promise<number> {\n await initWasm();\n const raw = (wasmPkg as any).verify_attestations(msgB64u, JSON.stringify(attestations), allowedPublicKeys ? JSON.stringify(allowedPublicKeys) : undefined);\n const out = typeof raw === 'string' ? JSON.parse(raw) : raw;\n if (out?.error) throw new Error(out.error);\n return Number(out.valid_count || 0);\n}\n\n// Utility functions\n// Cross-env base64url helpers (browser + Node)\nfunction _fromByteArray(bytes: Uint8Array): string {\n if (typeof btoa === 'function') {\n // Browser\n let s = '';\n for (let i = 0; i < bytes.length; i++) s += String.fromCharCode(bytes[i]);\n return btoa(s);\n }\n // Node\n return Buffer.from(bytes).toString('base64');\n}\n\nfunction _toByteArray(b64: string): Uint8Array {\n if (typeof atob === 'function') {\n const binary = atob(b64);\n const out = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) out[i] = binary.charCodeAt(i);\n return out;\n }\n return new Uint8Array(Buffer.from(b64, 'base64'));\n}\n\nexport function b64uEncode(data: Uint8Array): string {\n return _fromByteArray(data)\n .replace(/\\+/g, '-')\n .replace(/\\//g, '_')\n .replace(/=+/g, '');\n}\n\nexport function b64uDecode(str: string): Uint8Array {\n const b64 = str.replace(/-/g, '+').replace(/_/g, '/').padEnd(Math.ceil(str.length / 4) * 4, '=');\n return _toByteArray(b64);\n}\n\nexport function constantTimeEqual(a: Uint8Array, b: Uint8Array): boolean {\n if (a.length !== b.length) return false;\n let result = 0;\n for (let i = 0; i < a.length; i++) {\n result |= a[i] ^ b[i];\n }\n return result === 0;\n}\n\n// ============================================================================\n// THRESHOLD SIGNATURES & GOVERNANCE\n// ============================================================================\n\nexport interface GovernancePolicy {\n policyId: string;\n version: number;\n chainId: string;\n threshold: number;\n signers: Array<{\n publicKeyB64u: string;\n keyId: string;\n weight: number;\n role: 'owner' | 'guardian' | 'delegate' | 'recovery';\n }>;\n operations: Array<{\n action: string;\n requiredThreshold?: number;\n requiredRoles?: string[];\n maxValue?: string;\n timelock?: number;\n }>;\n validFrom: number;\n validUntil: number;\n createdAt: number;\n createdBy: string;\n policySignature: string;\n}\n\nexport interface Attestation {\n signerKeyId: string;\n signerPublicKeyB64u: string;\n operationHash: string;\n operationType: string;\n attestedAt: number;\n expiresAt: number;\n signatureAlg: 'dilithium2';\n signatureB64u: string;\n}\n\nexport interface AggregatedSignature {\n policyId: string;\n policyVersion: number;\n operationHash: string;\n attestations: Attestation[];\n totalWeight: number;\n thresholdMet: boolean;\n verifiedAt: number;\n}\n\n/**\n * Create an attestation for a threshold signature operation.\n */\nexport async function createAttestation(\n operation: { type: string; payload: unknown },\n signerKeys: { keyId: string; publicKeyB64u: string; secretKeyB64u: string },\n expiresInSeconds: number = 3600\n): Promise<Attestation> {\n await initWasm();\n \n // Build deterministic preimage for the operation\n const preimage = await jcsCanonicalize({ type: operation.type, payload: operation.payload });\n const preimageBytes = new TextEncoder().encode(preimage);\n const operationHash = await sha3_384_b64u(preimageBytes);\n const msgB64u = b64uEncode(preimageBytes);\n \n // Sign the preimage\n const sig = await dilithiumSign(msgB64u, signerKeys.secretKeyB64u);\n \n return {\n signerKeyId: signerKeys.keyId,\n signerPublicKeyB64u: signerKeys.publicKeyB64u,\n operationHash,\n operationType: operation.type,\n attestedAt: Date.now(),\n expiresAt: Date.now() + expiresInSeconds * 1000,\n signatureAlg: 'dilithium2',\n signatureB64u: sig.signature_b64u\n };\n}\n\n/**\n * Verify an attestation signature.\n */\nexport async function verifyAttestation(\n attestation: Attestation,\n operation: { type: string; payload: unknown }\n): Promise<{ valid: boolean; error?: string }> {\n await initWasm();\n \n // Rebuild expected operation hash\n const preimage = await jcsCanonicalize({ type: operation.type, payload: operation.payload });\n const preimageBytes = new TextEncoder().encode(preimage);\n const expectedHash = await sha3_384_b64u(preimageBytes);\n \n if (attestation.operationHash !== expectedHash) {\n return { valid: false, error: 'Operation hash mismatch' };\n }\n \n // Check expiry\n if (attestation.expiresAt < Date.now()) {\n return { valid: false, error: 'Attestation expired' };\n }\n \n // Verify signature\n const msgB64u = b64uEncode(preimageBytes);\n const result = await dilithiumVerify(msgB64u, attestation.signatureB64u, attestation.signerPublicKeyB64u);\n \n if (!result.is_valid) {\n return { valid: false, error: 'Invalid signature' };\n }\n \n return { valid: true };\n}\n\n/**\n * Verify that an aggregated signature meets the threshold policy.\n */\nexport async function verifyThreshold(\n aggregated: AggregatedSignature,\n operation: { type: string; payload: unknown },\n policy: GovernancePolicy\n): Promise<{ valid: boolean; errors: string[] }> {\n const errors: string[] = [];\n \n // Check policy match\n if (aggregated.policyId !== policy.policyId) {\n errors.push('Policy ID mismatch');\n }\n \n // Verify each attestation and compute weight\n let validWeight = 0;\n for (const attestation of aggregated.attestations) {\n const signer = policy.signers.find(s => s.publicKeyB64u === attestation.signerPublicKeyB64u);\n if (!signer) {\n errors.push(`Signer ${attestation.signerKeyId} not in policy`);\n continue;\n }\n \n const result = await verifyAttestation(attestation, operation);\n if (!result.valid) {\n errors.push(`Attestation from ${attestation.signerKeyId}: ${result.error}`);\n continue;\n }\n \n validWeight += signer.weight;\n }\n \n // Check threshold\n if (validWeight < policy.threshold) {\n errors.push(`Threshold not met: weight ${validWeight} < required ${policy.threshold}`);\n }\n \n return { valid: errors.length === 0, errors };\n}\n\n// ============================================================================\n// PRE-REGISTRATION COMMITMENT SCHEME\n// ============================================================================\n\nexport interface ProvenanceCommitment {\n type: 'ProvenanceCommitment';\n version: 1;\n commitmentHash: string;\n creatorPublicKey: string;\n timestamp: number;\n signature: string;\n}\n\nexport interface CommitmentReveal {\n commitmentHash: string;\n salt: string;\n assetHash: string;\n}\n\n/**\n * Create a provenance commitment for an asset before public disclosure.\n * This establishes a timestamped claim without revealing the asset content.\n */\nexport async function createProvenanceCommitment(\n assetBytes: Uint8Array,\n keys: { publicKeyB64u: string; secretKeyB64u: string }\n): Promise<{ commitment: ProvenanceCommitment; reveal: CommitmentReveal }> {\n await initWasm();\n \n // Generate random salt\n const salt = crypto.getRandomValues(new Uint8Array(32));\n \n // Compute commitment hash = SHA3-384(asset || salt || publicKey)\n const publicKeyBytes = b64uDecode(keys.publicKeyB64u);\n const preimage = new Uint8Array(assetBytes.length + salt.length + publicKeyBytes.length);\n preimage.set(assetBytes, 0);\n preimage.set(salt, assetBytes.length);\n preimage.set(publicKeyBytes, assetBytes.length + salt.length);\n \n const commitmentHash = await sha3_384_b64u(preimage);\n const assetHash = await sha3_384_b64u(assetBytes);\n \n // Build commitment object (without signature)\n const commitmentData = {\n type: 'ProvenanceCommitment' as const,\n version: 1 as const,\n commitmentHash,\n creatorPublicKey: keys.publicKeyB64u,\n timestamp: Date.now()\n };\n \n // Sign the commitment\n const canonical = await jcsCanonicalize(commitmentData);\n const sig = await dilithiumSign(b64uEncode(new TextEncoder().encode(canonical)), keys.secretKeyB64u);\n \n const commitment: ProvenanceCommitment = {\n ...commitmentData,\n signature: sig.signature_b64u\n };\n \n const reveal: CommitmentReveal = {\n commitmentHash,\n salt: b64uEncode(salt),\n assetHash\n };\n \n return { commitment, reveal };\n}\n\n/**\n * Verify a provenance commitment signature.\n */\nexport async function verifyProvenanceCommitment(\n commitment: ProvenanceCommitment\n): Promise<{ valid: boolean; error?: string }> {\n await initWasm();\n \n // Reconstruct the signed data (without signature field)\n const commitmentData = {\n type: commitment.type,\n version: commitment.version,\n commitmentHash: commitment.commitmentHash,\n creatorPublicKey: commitment.creatorPublicKey,\n timestamp: commitment.timestamp\n };\n \n const canonical = await jcsCanonicalize(commitmentData);\n const msgB64u = b64uEncode(new TextEncoder().encode(canonical));\n \n const result = await dilithiumVerify(msgB64u, commitment.signature, commitment.creatorPublicKey);\n \n if (!result.is_valid) {\n return { valid: false, error: 'Invalid commitment signature' };\n }\n \n return { valid: true };\n}\n\n/**\n * Verify that a revealed asset matches a commitment.\n */\nexport async function verifyCommitmentReveal(\n commitment: ProvenanceCommitment,\n assetBytes: Uint8Array,\n reveal: CommitmentReveal\n): Promise<{ valid: boolean; error?: string }> {\n await initWasm();\n \n // First verify the commitment signature\n const sigResult = await verifyProvenanceCommitment(commitment);\n if (!sigResult.valid) {\n return { valid: false, error: `Commitment signature invalid: ${sigResult.error}` };\n }\n \n // Verify asset hash matches\n const computedAssetHash = await sha3_384_b64u(assetBytes);\n if (computedAssetHash !== reveal.assetHash) {\n return { valid: false, error: 'Asset hash does not match reveal' };\n }\n \n // Reconstruct commitment hash\n const salt = b64uDecode(reveal.salt);\n const publicKeyBytes = b64uDecode(commitment.creatorPublicKey);\n \n const preimage = new Uint8Array(assetBytes.length + salt.length + publicKeyBytes.length);\n preimage.set(assetBytes, 0);\n preimage.set(salt, assetBytes.length);\n preimage.set(publicKeyBytes, assetBytes.length + salt.length);\n \n const computedCommitmentHash = await sha3_384_b64u(preimage);\n \n if (computedCommitmentHash !== commitment.commitmentHash) {\n return { valid: false, error: 'Commitment hash does not match reveal' };\n }\n \n return { valid: true };\n}\n\n// ============================================================================\n// ============================================================================\n// SHA3-384 HASHING (PQC Compliant)\n// ============================================================================\n// All SHA3-384 operations use the WASM module - no external dependencies required\n\n// Import SHA3-384 functions from WASM\nconst wasm_sha3_384_bytes = (wasmPkg as any).sha3_384_hash as ((data: Uint8Array) => string) | undefined;\nconst wasm_sha3_384_string = (wasmPkg as any).sha3_384_hash_string as ((data: string) => string) | undefined;\nconst wasm_sha3_384_bytes_b64u = (wasmPkg as any).sha3_384_hash_b64u as ((data: Uint8Array) => string) | undefined;\nconst wasm_sha3_384_string_b64u = (wasmPkg as any).sha3_384_hash_string_b64u as ((data: string) => string) | undefined;\nconst wasm_sha3_384_truncated = (wasmPkg as any).sha3_384_hash_truncated_32 as ((data: Uint8Array) => string) | undefined;\n\n/**\n * SHA3-384 Hash Result\n */\nexport interface Sha3HashResult {\n /** 96-character lowercase hex string (48 bytes) */\n hex: string;\n /** 64-character base64url string (no padding) */\n b64u: string;\n}\n\n/**\n * Compute SHA3-384 hash of raw bytes.\n * Returns both hex and base64url encodings.\n * \n * @example\n * ```typescript\n * const data = new TextEncoder().encode('hello');\n * const { hex, b64u } = await sha3_384(data);\n * // hex = \"720aea11019ef06440fbf05d87aa24680a2153df3907b2...\" (96 chars)\n * // b64u = \"cgrqEQGe8GRA-_BdOKokaDCAoVPfOQe...\" (64 chars)\n * ```\n */\nexport async function sha3_384(data: Uint8Array): Promise<Sha3HashResult> {\n await initWasm();\n if (!wasm_sha3_384_bytes || !wasm_sha3_384_bytes_b64u) {\n throw new Error('SHA3-384 WASM functions not available - ensure WASM module is initialized');\n }\n return {\n hex: wasm_sha3_384_bytes(data),\n b64u: wasm_sha3_384_bytes_b64u(data),\n };\n}\n\n/**\n * Compute SHA3-384 hash of a UTF-8 string.\n * Returns both hex and base64url encodings.\n * \n * @example\n * ```typescript\n * const { hex, b64u } = await sha3_384_string('hello world');\n * ```\n */\nexport async function sha3_384_string(data: string): Promise<Sha3HashResult> {\n await initWasm();\n if (!wasm_sha3_384_string || !wasm_sha3_384_string_b64u) {\n throw new Error('SHA3-384 WASM functions not available - ensure WASM module is initialized');\n }\n return {\n hex: wasm_sha3_384_string(data),\n b64u: wasm_sha3_384_string_b64u(data),\n };\n}\n\n/**\n * Compute SHA3-384 hash truncated to 32 bytes (for EVM bytes32 compatibility).\n * Uses the first 32 bytes of the full 48-byte hash.\n * \n * @example\n * ```typescript\n * const hex32 = await sha3_384_truncated32(data);\n * // Returns 64-char hex string suitable for Ethereum bytes32\n * ```\n */\nexport async function sha3_384_truncated32(data: Uint8Array): Promise<string> {\n await initWasm();\n if (!wasm_sha3_384_truncated) {\n throw new Error('SHA3-384 truncation WASM function not available');\n }\n return wasm_sha3_384_truncated(data);\n}\n\n/**\n * Compute SHA3-384 hash with base64url output (internal helper, also exported for convenience).\n * This is the 64-character base64url encoding of the 48-byte hash.\n */\nasync function sha3_384_b64u(data: Uint8Array): Promise<string> {\n const result = await sha3_384(data);\n return result.b64u;\n}\n\n// ============================================================================\n// ALGORITHMIC OPTIMIZATIONS (arXiv:2501.02305, arXiv:2504.17033)\n// ============================================================================\n// High-performance data structures for verification operations\n\n// WASM bindings for algorithm functions\nconst wasm_create_nonce_cache = (wasmPkg as any).create_nonce_cache as (capacity: number, ttl_ms: number) => string;\nconst wasm_nonce_cache_info = (wasmPkg as any).nonce_cache_info as () => string;\nconst wasm_sssp_config = (wasmPkg as any).sssp_config as (nodes: number) => string;\nconst wasm_provenance_path_config = (wasmPkg as any).provenance_path_config as (chain_length: number, branches: number) => string;\nconst wasm_elastic_hash_config = (wasmPkg as any).elastic_hash_config as (capacity: number, load_factor: number) => string;\n\n/**\n * Nonce Cache Configuration\n * Uses Elastic Hashing (arXiv:2501.02305) for O(1) amortized lookup\n */\nexport interface NonceCacheConfig {\n type: string;\n capacity: number;\n ttl_ms: number;\n algorithm: string;\n complexity: string;\n}\n\n/**\n * Create a nonce cache configuration for replay attack prevention.\n * Based on Elastic Hashing - O(1) amortized, O(log(1/δ)) worst-case.\n * \n * @param capacity - Maximum number of nonces to track\n * @param ttlMs - Time-to-live in milliseconds before nonces expire\n */\nexport async function createNonceCacheConfig(capacity: number, ttlMs: number): Promise<NonceCacheConfig> {\n await initWasm();\n return JSON.parse(wasm_create_nonce_cache(capacity, ttlMs));\n}\n\n/**\n * Get information about the nonce cache algorithm.\n */\nexport async function getNonceCacheInfo(): Promise<{\n name: string;\n paper: string;\n probe_complexity: string;\n load_factor: number;\n features: string[];\n}> {\n await initWasm();\n return JSON.parse(wasm_nonce_cache_info());\n}\n\n/**\n * SSSP (Single-Source Shortest Path) Configuration\n * Uses Frontier-Reduced algorithm (arXiv:2504.17033)\n */\nexport interface SSSPConfig {\n name: string;\n paper: string;\n complexity: string;\n nodes: number;\n pivots_k: number;\n batch_t: number;\n use_cases: string[];\n}\n\n/**\n * Get optimal SSSP configuration for graph verification.\n * Uses Frontier-Reduced SSSP - O(m × log^(2/3)(n)) complexity.\n * \n * @param nodes - Expected number of nodes in the graph\n */\nexport async function getSSSPConfig(nodes: number): Promise<SSSPConfig> {\n await initWasm();\n return JSON.parse(wasm_sssp_config(nodes));\n}\n\n/**\n * Provenance Path Configuration\n * Optimized parameters for chain of custody verification\n */\nexport interface ProvenancePathConfig {\n algorithm: string;\n chain_length: number;\n branches: number;\n estimated_nodes: number;\n estimated_edges: number;\n pivots_k: number;\n batch_t: number;\n complexity: string;\n verification_mode: string;\n}\n\n/**\n * Get optimized configuration for provenance chain verification.\n * \n * @param chainLength - Number of blocks in the provenance chain\n * @param branches - Average number of branches per block\n */\nexport async function getProvenancePathConfig(chainLength: number, branches: number): Promise<ProvenancePathConfig> {\n await initWasm();\n return JSON.parse(wasm_provenance_path_config(chainLength, branches));\n}\n\n/**\n * Elastic Hash Configuration\n * High-performance hash table for key caching\n */\nexport interface ElasticHashConfig {\n algorithm: string;\n paper: string;\n capacity: number;\n load_factor: number;\n levels: number;\n probe_complexity: {\n amortized: string;\n worst_case: string;\n };\n use_cases: string[];\n}\n\n/**\n * Get elastic hash table configuration for key caching.\n * Optimal for PQC public key caching with O(1) amortized lookups.\n * \n * @param capacity - Maximum number of entries\n * @param loadFactor - Target load factor (0.0 to 1.0, recommend 0.95)\n */\nexport async function getElasticHashConfig(capacity: number, loadFactor: number = 0.95): Promise<ElasticHashConfig> {\n await initWasm();\n return JSON.parse(wasm_elastic_hash_config(capacity, loadFactor));\n}\n\n// ============================================================================\n// CROSS-CHAIN ANCHORING (Roadmap M8)\n// ============================================================================\n// Merkle root submission to Ethereum, Bitcoin, and L2s for timestamping\n\n// WASM bindings for anchoring functions\nconst wasm_anchor_chains_info = (wasmPkg as any).anchor_chains_info as () => string;\nconst wasm_create_accumulator_leaf = (wasmPkg as any).create_accumulator_leaf as (userId: string, chainId: string, blockHash: string, blockIndex: bigint) => string;\nconst wasm_create_accumulator_leaf_with_alg = (wasmPkg as any).create_accumulator_leaf_with_alg as (userId: string, chainId: string, blockHash: string, blockIndex: bigint, hashAlg: string) => string;\nconst wasm_compute_merkle_root = (wasmPkg as any).compute_merkle_root as (leavesJson: string, hashAlg: string) => string;\nconst wasm_generate_evm_anchor_calldata = (wasmPkg as any).generate_evm_anchor_calldata as (rootHex: string, epoch: bigint) => string;\nconst wasm_generate_bitcoin_anchor_payload = (wasmPkg as any).generate_bitcoin_anchor_payload as (rootHex: string, epoch: bigint) => string;\nconst wasm_decode_bitcoin_anchor_payload = (wasmPkg as any).decode_bitcoin_anchor_payload as (payloadHex: string) => string;\nconst wasm_truncate_to_bytes32 = (wasmPkg as any).truncate_to_bytes32 as (hashHex: string) => string;\nconst wasm_anchor_config_info = (wasmPkg as any).anchor_config_info as () => string;\n\n/**\n * Supported blockchain chains for anchoring\n */\nexport interface AnchorChainInfo {\n id: string;\n name: string;\n chain_id?: number;\n type: 'evm' | 'evm_l2' | 'bitcoin';\n contract?: string;\n method?: string;\n payload_size?: number;\n}\n\n/**\n * Get information about supported anchor chains\n */\nexport async function getAnchorChainsInfo(): Promise<{ chains: AnchorChainInfo[] }> {\n await initWasm();\n return JSON.parse(wasm_anchor_chains_info());\n}\n\n/**\n * Accumulator leaf representing a chain's current state\n */\nexport interface AccumulatorLeaf {\n user_id: string;\n chain_id: string;\n block_hash: string;\n block_index: number;\n timestamp: number;\n leaf_hash: string;\n hash_alg?: string;\n}\n\n/**\n * Create a Merkle accumulator leaf for a chain state.\n * This is the fundamental unit for batching chain updates into super-roots.\n * \n * @param userId - User ID (64 hex chars)\n * @param chainId - Chain identifier within user's chains\n * @param blockHash - Hash of the latest block (64 hex chars)\n * @param blockIndex - Block height/index (number or bigint)\n * @param hashAlg - Hash algorithm for leaf hash ('sha256' or 'sha3-384')\n * @throws Error if inputs are invalid\n */\nexport async function createAccumulatorLeaf(\n userId: string,\n chainId: string,\n blockHash: string,\n blockIndex: number | bigint,\n hashAlg: 'sha256' | 'sha3-384' = 'sha3-384'\n): Promise<AccumulatorLeaf> {\n await initWasm();\n \n // Input validation with helpful error messages\n if (typeof userId !== 'string' || userId.length !== 64) {\n throw new Error(`Invalid userId: must be 64 hex characters (got ${typeof userId === 'string' ? userId.length : typeof userId})`);\n }\n if (!/^[0-9a-fA-F]{64}$/.test(userId)) {\n throw new Error('Invalid userId: must contain only hex characters (0-9, a-f, A-F)');\n }\n \n if (typeof chainId !== 'string' || chainId.length === 0) {\n throw new Error('Invalid chainId: must be a non-empty string');\n }\n \n if (typeof blockHash !== 'string' || blockHash.length !== 64) {\n throw new Error(`Invalid blockHash: must be 64 hex characters (got ${typeof blockHash === 'string' ? blockHash.length : typeof blockHash})`);\n }\n if (!/^[0-9a-fA-F]{64}$/.test(blockHash)) {\n throw new Error('Invalid blockHash: must contain only hex characters (0-9, a-f, A-F)');\n }\n \n // Convert blockIndex to bigint (WASM expects bigint for u64)\n let indexBigInt: bigint;\n if (typeof blockIndex === 'bigint') {\n indexBigInt = blockIndex;\n } else if (typeof blockIndex === 'number') {\n if (!Number.isInteger(blockIndex) || blockIndex < 0) {\n throw new Error('Invalid blockIndex: must be a non-negative integer');\n }\n if (!Number.isSafeInteger(blockIndex)) {\n throw new Error('Invalid blockIndex: number exceeds MAX_SAFE_INTEGER; use bigint instead');\n }\n indexBigInt = BigInt(blockIndex);\n } else {\n throw new Error(`Invalid blockIndex: must be a number or bigint (got ${typeof blockIndex})`);\n }\n \n if (indexBigInt < 0n) {\n throw new Error('Invalid blockIndex: must be non-negative');\n }\n \n try {\n const result = typeof wasm_create_accumulator_leaf_with_alg === 'function'\n ? wasm_create_accumulator_leaf_with_alg(userId, chainId, blockHash, indexBigInt, hashAlg)\n : wasm_create_accumulator_leaf(userId, chainId, blockHash, indexBigInt);\n const parsed = JSON.parse(result);\n if (parsed.error) {\n throw new Error(parsed.error);\n }\n return parsed;\n } catch (e) {\n if (e instanceof Error) {\n // Re-throw our validation errors\n if (e.message.startsWith('Invalid ')) {\n throw e;\n }\n // Wrap WASM errors\n throw new Error(`WASM error in createAccumulatorLeaf: ${e.message}`);\n }\n throw new Error(`Unknown error in createAccumulatorLeaf: ${String(e)}`);\n }\n}\n\n/**\n * Merkle root computation result\n */\nexport interface MerkleRootResult {\n root: string;\n leaf_count: number;\n hash_alg: string;\n}\n\n/**\n * Compute Merkle root from an array of leaf hashes.\n * \n * @param leaves - Array of hex hash strings\n * @param hashAlg - Hash algorithm (defaults to 'sha3-384' for PQC compliance)\n */\nexport async function computeMerkleRoot(\n leaves: string[],\n hashAlg: 'sha3-384' = 'sha3-384'\n): Promise<MerkleRootResult> {\n await initWasm();\n return JSON.parse(wasm_compute_merkle_root(JSON.stringify(leaves), hashAlg));\n}\n\n/**\n * EVM anchor calldata for AnchorRegistry contract\n */\nexport interface EvmAnchorCalldata {\n calldata: string;\n root: string;\n epoch: number;\n method: string;\n selector: string;\n}\n\n/**\n * Generate EVM calldata for AnchorRegistry.anchor(bytes32, uint256).\n * Ready to use in an Ethereum transaction.\n * \n * @param rootHex - 32-byte Merkle root (64 hex chars, with or without 0x prefix)\n * @param epoch - Epoch number (number or bigint)\n */\nexport async function generateEvmAnchorCalldata(\n rootHex: string,\n epoch: number | bigint\n): Promise<EvmAnchorCalldata> {\n await initWasm();\n let epochBigInt: bigint;\n if (typeof epoch === 'bigint') {\n epochBigInt = epoch;\n } else {\n if (!Number.isInteger(epoch) || epoch < 0) {\n throw new Error('Invalid epoch: must be a non-negative integer');\n }\n if (!Number.isSafeInteger(epoch)) {\n throw new Error('Invalid epoch: number exceeds MAX_SAFE_INTEGER; use bigint instead');\n }\n epochBigInt = BigInt(epoch);\n }\n return JSON.parse(wasm_generate_evm_anchor_calldata(rootHex, epochBigInt));\n}\n\n/**\n * Bitcoin OP_RETURN anchor payload\n */\nexport interface BitcoinAnchorPayload {\n payload_hex: string;\n payload_size: number;\n magic: string;\n epoch: number;\n root: string;\n}\n\n/**\n * Generate Bitcoin OP_RETURN payload for anchoring.\n * 45 bytes: \"MTARA\" (5) + epoch (8) + root32 (32)\n * \n * @param rootHex - 32-byte Merkle root (64 hex chars)\n * @param epoch - Epoch number (number or bigint)\n */\nexport async function generateBitcoinAnchorPayload(\n rootHex: string,\n epoch: number | bigint\n): Promise<BitcoinAnchorPayload> {\n await initWasm();\n let epochBigInt: bigint;\n if (typeof epoch === 'bigint') {\n epochBigInt = epoch;\n } else {\n if (!Number.isInteger(epoch) || epoch < 0) {\n throw new Error('Invalid epoch: must be a non-negative integer');\n }\n if (!Number.isSafeInteger(epoch)) {\n throw new Error('Invalid epoch: number exceeds MAX_SAFE_INTEGER; use bigint instead');\n }\n epochBigInt = BigInt(epoch);\n }\n return JSON.parse(wasm_generate_bitcoin_anchor_payload(rootHex, epochBigInt));\n}\n\n/**\n * Decoded Bitcoin anchor payload\n */\nexport interface DecodedBitcoinPayload {\n magic: string;\n epoch: number;\n root: string;\n}\n\n/**\n * Decode a Bitcoin OP_RETURN anchor payload.\n * \n * @param payloadHex - Hex-encoded payload bytes\n */\nexport async function decodeBitcoinAnchorPayload(\n payloadHex: string\n): Promise<DecodedBitcoinPayload> {\n await initWasm();\n return JSON.parse(wasm_decode_bitcoin_anchor_payload(payloadHex));\n}\n\n/**\n * Truncation result for SHA3-384 to bytes32\n */\nexport interface TruncationResult {\n original: string;\n original_bytes: number;\n truncated: string;\n truncated_bytes: number;\n}\n\n/**\n * Truncate a hash to 32 bytes for EVM compatibility.\n * Used when anchoring SHA3-384 hashes to Ethereum.\n * \n * @param hashHex - Hash to truncate (with or without 0x prefix)\n */\nexport async function truncateToBytes32(hashHex: string): Promise<TruncationResult> {\n await initWasm();\n return JSON.parse(wasm_truncate_to_bytes32(hashHex));\n}\n\n/**\n * Anchor configuration and estimates\n */\nexport interface AnchorConfigInfo {\n accumulator: {\n max_leaves_per_epoch: number;\n hash_algorithms: string[];\n default_hash: string;\n };\n ethereum: {\n contract: string;\n function: string;\n selector: string;\n estimated_gas: number;\n calldata_size: number;\n };\n bitcoin: {\n method: string;\n magic: string;\n payload_size: number;\n estimated_fee_sats: number;\n };\n recommended_schedule: {\n production: string;\n high_frequency: string;\n };\n}\n\n/**\n * Get anchor configuration and gas/fee estimates.\n */\nexport async function getAnchorConfigInfo(): Promise<AnchorConfigInfo> {\n await initWasm();\n return JSON.parse(wasm_anchor_config_info());\n}\n"],"names":["wasmPkg"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA,MAAM,gBAAgB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAC1C,MAAM,YAAY,GAAG,IAAI,GAAG,IAAI,CAAC;AA4CjC,MAAM,iBAAiB,GAAIA,kBAAe,CAAC,YAA4B;AACvE,MAAM,iBAAiB,GAAIA,kBAAe,CAAC,YAAqC;AAChF,MAAM,iBAAiB,GAAIA,kBAAe,CAAC,YAAgD;AAC3F,MAAM,gBAAgB,GAAIA,kBAAe,CAAC,WAA4E;AACtH,MAAM,iBAAiB,GAAIA,kBAAe,CAAC,YAA2D;AACtG,MAAM,mBAAmB,GAAIA,kBAAe,CAAC,cAA0E;AACvH,MAAM,qBAAqB,GAAIA,kBAAe,CAAC,gBAAgC;AAC/E,MAAM,mBAAmB,GAAIA,kBAAe,CAAC,cAAkD;AAC/F,MAAM,qBAAqB,GAAIA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AAC,KAAK,CAAC,uBAAuB,EAAE,CAAC;AAC9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.mjs CHANGED
@@ -272,7 +272,7 @@ async function createAttestation(operation, signerKeys, expiresInSeconds = 3600)
272
272
  // Build deterministic preimage for the operation
273
273
  const preimage = await jcsCanonicalize({ type: operation.type, payload: operation.payload });
274
274
  const preimageBytes = new TextEncoder().encode(preimage);
275
- const operationHash = await sha256B64u(preimageBytes);
275
+ const operationHash = await sha3_384_b64u(preimageBytes);
276
276
  const msgB64u = b64uEncode(preimageBytes);
277
277
  // Sign the preimage
278
278
  const sig = await dilithiumSign(msgB64u, signerKeys.secretKeyB64u);
@@ -295,7 +295,7 @@ async function verifyAttestation(attestation, operation) {
295
295
  // Rebuild expected operation hash
296
296
  const preimage = await jcsCanonicalize({ type: operation.type, payload: operation.payload });
297
297
  const preimageBytes = new TextEncoder().encode(preimage);
298
- const expectedHash = await sha256B64u(preimageBytes);
298
+ const expectedHash = await sha3_384_b64u(preimageBytes);
299
299
  if (attestation.operationHash !== expectedHash) {
300
300
  return { valid: false, error: 'Operation hash mismatch' };
301
301
  }
@@ -349,14 +349,14 @@ async function createProvenanceCommitment(assetBytes, keys) {
349
349
  await initWasm();
350
350
  // Generate random salt
351
351
  const salt = crypto.getRandomValues(new Uint8Array(32));
352
- // Compute commitment hash = SHA256(asset || salt || publicKey)
352
+ // Compute commitment hash = SHA3-384(asset || salt || publicKey)
353
353
  const publicKeyBytes = b64uDecode(keys.publicKeyB64u);
354
354
  const preimage = new Uint8Array(assetBytes.length + salt.length + publicKeyBytes.length);
355
355
  preimage.set(assetBytes, 0);
356
356
  preimage.set(salt, assetBytes.length);
357
357
  preimage.set(publicKeyBytes, assetBytes.length + salt.length);
358
- const commitmentHash = await sha256B64u(preimage);
359
- const assetHash = await sha256B64u(assetBytes);
358
+ const commitmentHash = await sha3_384_b64u(preimage);
359
+ const assetHash = await sha3_384_b64u(assetBytes);
360
360
  // Build commitment object (without signature)
361
361
  const commitmentData = {
362
362
  type: 'ProvenanceCommitment',
@@ -411,7 +411,7 @@ async function verifyCommitmentReveal(commitment, assetBytes, reveal) {
411
411
  return { valid: false, error: `Commitment signature invalid: ${sigResult.error}` };
412
412
  }
413
413
  // Verify asset hash matches
414
- const computedAssetHash = await sha256B64u(assetBytes);
414
+ const computedAssetHash = await sha3_384_b64u(assetBytes);
415
415
  if (computedAssetHash !== reveal.assetHash) {
416
416
  return { valid: false, error: 'Asset hash does not match reveal' };
417
417
  }
@@ -422,18 +422,88 @@ async function verifyCommitmentReveal(commitment, assetBytes, reveal) {
422
422
  preimage.set(assetBytes, 0);
423
423
  preimage.set(salt, assetBytes.length);
424
424
  preimage.set(publicKeyBytes, assetBytes.length + salt.length);
425
- const computedCommitmentHash = await sha256B64u(preimage);
425
+ const computedCommitmentHash = await sha3_384_b64u(preimage);
426
426
  if (computedCommitmentHash !== commitment.commitmentHash) {
427
427
  return { valid: false, error: 'Commitment hash does not match reveal' };
428
428
  }
429
429
  return { valid: true };
430
430
  }
431
431
  // ============================================================================
432
- // HELPER: SHA-256 with base64url output
433
432
  // ============================================================================
434
- async function sha256B64u(data) {
435
- const hashBuffer = await crypto.subtle.digest('SHA-256', data);
436
- return b64uEncode(new Uint8Array(hashBuffer));
433
+ // SHA3-384 HASHING (PQC Compliant)
434
+ // ============================================================================
435
+ // All SHA3-384 operations use the WASM module - no external dependencies required
436
+ // Import SHA3-384 functions from WASM
437
+ const wasm_sha3_384_bytes = wasmPkg.sha3_384_hash;
438
+ const wasm_sha3_384_string = wasmPkg.sha3_384_hash_string;
439
+ const wasm_sha3_384_bytes_b64u = wasmPkg.sha3_384_hash_b64u;
440
+ const wasm_sha3_384_string_b64u = wasmPkg.sha3_384_hash_string_b64u;
441
+ const wasm_sha3_384_truncated = wasmPkg.sha3_384_hash_truncated_32;
442
+ /**
443
+ * Compute SHA3-384 hash of raw bytes.
444
+ * Returns both hex and base64url encodings.
445
+ *
446
+ * @example
447
+ * ```typescript
448
+ * const data = new TextEncoder().encode('hello');
449
+ * const { hex, b64u } = await sha3_384(data);
450
+ * // hex = "720aea11019ef06440fbf05d87aa24680a2153df3907b2..." (96 chars)
451
+ * // b64u = "cgrqEQGe8GRA-_BdOKokaDCAoVPfOQe..." (64 chars)
452
+ * ```
453
+ */
454
+ async function sha3_384(data) {
455
+ await initWasm();
456
+ if (!wasm_sha3_384_bytes || !wasm_sha3_384_bytes_b64u) {
457
+ throw new Error('SHA3-384 WASM functions not available - ensure WASM module is initialized');
458
+ }
459
+ return {
460
+ hex: wasm_sha3_384_bytes(data),
461
+ b64u: wasm_sha3_384_bytes_b64u(data),
462
+ };
463
+ }
464
+ /**
465
+ * Compute SHA3-384 hash of a UTF-8 string.
466
+ * Returns both hex and base64url encodings.
467
+ *
468
+ * @example
469
+ * ```typescript
470
+ * const { hex, b64u } = await sha3_384_string('hello world');
471
+ * ```
472
+ */
473
+ async function sha3_384_string(data) {
474
+ await initWasm();
475
+ if (!wasm_sha3_384_string || !wasm_sha3_384_string_b64u) {
476
+ throw new Error('SHA3-384 WASM functions not available - ensure WASM module is initialized');
477
+ }
478
+ return {
479
+ hex: wasm_sha3_384_string(data),
480
+ b64u: wasm_sha3_384_string_b64u(data),
481
+ };
482
+ }
483
+ /**
484
+ * Compute SHA3-384 hash truncated to 32 bytes (for EVM bytes32 compatibility).
485
+ * Uses the first 32 bytes of the full 48-byte hash.
486
+ *
487
+ * @example
488
+ * ```typescript
489
+ * const hex32 = await sha3_384_truncated32(data);
490
+ * // Returns 64-char hex string suitable for Ethereum bytes32
491
+ * ```
492
+ */
493
+ async function sha3_384_truncated32(data) {
494
+ await initWasm();
495
+ if (!wasm_sha3_384_truncated) {
496
+ throw new Error('SHA3-384 truncation WASM function not available');
497
+ }
498
+ return wasm_sha3_384_truncated(data);
499
+ }
500
+ /**
501
+ * Compute SHA3-384 hash with base64url output (internal helper, also exported for convenience).
502
+ * This is the 64-character base64url encoding of the 48-byte hash.
503
+ */
504
+ async function sha3_384_b64u(data) {
505
+ const result = await sha3_384(data);
506
+ return result.b64u;
437
507
  }
438
508
  // ============================================================================
439
509
  // ALGORITHMIC OPTIMIZATIONS (arXiv:2501.02305, arXiv:2504.17033)
@@ -590,9 +660,9 @@ async function createAccumulatorLeaf(userId, chainId, blockHash, blockIndex, has
590
660
  * Compute Merkle root from an array of leaf hashes.
591
661
  *
592
662
  * @param leaves - Array of hex hash strings
593
- * @param hashAlg - Hash algorithm ('sha256' or 'sha3-384')
663
+ * @param hashAlg - Hash algorithm (defaults to 'sha3-384' for PQC compliance)
594
664
  */
595
- async function computeMerkleRoot(leaves, hashAlg = 'sha256') {
665
+ async function computeMerkleRoot(leaves, hashAlg = 'sha3-384') {
596
666
  await initWasm();
597
667
  return JSON.parse(wasm_compute_merkle_root(JSON.stringify(leaves), hashAlg));
598
668
  }
@@ -671,5 +741,5 @@ async function getAnchorConfigInfo() {
671
741
  return JSON.parse(wasm_anchor_config_info());
672
742
  }
673
743
 
674
- export { aesGcmUnwrap, aesGcmWrap, b64uDecode, b64uEncode, buildAnchorPreimage, buildBlockPreimage, buildMintPreimage, buildPolicyPreimage, buildTransferPreimage, computeMerkleRoot, constantTimeEqual, createAccumulatorLeaf, createAttestation, createNonceCacheConfig, createProvenanceCommitment, decodeBitcoinAnchorPayload, dilithiumKeygen, dilithiumSign, dilithiumVerify, generateBitcoinAnchorPayload, generateEvmAnchorCalldata, getAnchorChainsInfo, getAnchorConfigInfo, getElasticHashConfig, getNonceCacheInfo, getProvenancePathConfig, getSSSPConfig, hkdfSha256, initWasm, jcsCanonicalize, kyberDecaps, kyberEncaps, kyberKeygen, truncateToBytes32, validateRoyalty, verifyAttestation, verifyAttestations, verifyCommitmentReveal, verifyProvenanceCommitment, verifyThreshold };
744
+ export { aesGcmUnwrap, aesGcmWrap, b64uDecode, b64uEncode, buildAnchorPreimage, buildBlockPreimage, buildMintPreimage, buildPolicyPreimage, buildTransferPreimage, computeMerkleRoot, constantTimeEqual, createAccumulatorLeaf, createAttestation, createNonceCacheConfig, createProvenanceCommitment, decodeBitcoinAnchorPayload, dilithiumKeygen, dilithiumSign, dilithiumVerify, generateBitcoinAnchorPayload, generateEvmAnchorCalldata, getAnchorChainsInfo, getAnchorConfigInfo, getElasticHashConfig, getNonceCacheInfo, getProvenancePathConfig, getSSSPConfig, hkdfSha256, initWasm, jcsCanonicalize, kyberDecaps, kyberEncaps, kyberKeygen, sha3_384, sha3_384_string, sha3_384_truncated32, truncateToBytes32, validateRoyalty, verifyAttestation, verifyAttestations, verifyCommitmentReveal, verifyProvenanceCommitment, verifyThreshold };
675
745
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../src/index.ts"],"sourcesContent":["// Ma'atara Core PQC Toolkit\n// Post-Quantum Cryptography for Browser and Node.js\n// \n// SECURITY NOTICE: This library implements FIPS 204 (ML-DSA) and FIPS 203 (ML-KEM)\n// post-quantum cryptographic algorithms. Key material should be:\n// 1. Stored securely (encrypted at rest)\n// 2. Transmitted only over secure channels\n// 3. Zeroized after use when possible\n// 4. Protected by hardware security modules for high-value operations\n//\n// See docs/WASM_SECURITY_MODEL.md for browser-specific security considerations.\n\n// ============================================================================\n// SECURITY CONSTANTS\n// ============================================================================\nconst MAX_MESSAGE_SIZE = 16 * 1024 * 1024; // 16MB - prevent memory exhaustion\nconst MAX_KEY_SIZE = 1024 * 1024; // 1MB - reasonable for PQC keys\nconst MAX_ATTESTATION_COUNT = 100; // Prevent DoS from large attestation arrays\n\nexport interface KyberKeypair {\n public_b64u: string;\n secret_b64u: string;\n}\n\nexport interface KyberEncap {\n kem_ct_b64u: string;\n shared_b64u: string;\n}\n\nexport interface AesGcmWrap {\n iv_b64u: string;\n ct_b64u: string;\n}\n\nexport interface DilithiumKeypair {\n algorithm: string;\n public_b64u: string;\n secret_b64u: string;\n}\n\nexport interface DilithiumSignResult {\n signature_b64u: string;\n algorithm: string;\n}\n\nexport interface DilithiumVerifyResult {\n is_valid: boolean;\n algorithm: string;\n}\n\nexport interface HkdfResult {\n key_b64u: string;\n}\n\nexport interface AesGcmUnwrapResult {\n dek_b64u: string;\n}\n\n// Import WASM functions (namespace import for better bundler compatibility)\nimport * as wasmPkg from '@maatara/core-pqc-wasm';\nconst wasm_kyber_keygen = (wasmPkg as any).kyber_keygen as () => string;\nconst wasm_kyber_encaps = (wasmPkg as any).kyber_encaps as (p: string) => string;\nconst wasm_kyber_decaps = (wasmPkg as any).kyber_decaps as (s: string, c: string) => string;\nconst wasm_hkdf_sha256 = (wasmPkg as any).hkdf_sha256 as (s: string, i: string, salt?: string, len?: number) => string;\nconst wasm_aes_gcm_wrap = (wasmPkg as any).aes_gcm_wrap as (k: string, d: string, a: string) => string;\nconst wasm_aes_gcm_unwrap = (wasmPkg as any).aes_gcm_unwrap as (k: string, iv: string, ct: string, a: string) => string;\nconst wasm_dilithium_keygen = (wasmPkg as any).dilithium_keygen as () => string;\nconst wasm_dilithium_sign = (wasmPkg as any).dilithium_sign as (m: string, s: string) => string;\nconst wasm_dilithium_verify = (wasmPkg as any).dilithium_verify as (m: string, sig: string, p: string) => string;\n\n// Deterministic/canonicalization and governance helpers\nexport interface CanonicalOut { canonical: string; msg_b64u?: string; msgB64u?: string }\n\n// Initialize WASM\nlet wasmReady = false;\n\n/**\n * Initialize the underlying WASM module.\n * - In browsers/bundlers where the glue knows how to fetch the .wasm, you can call without params.\n * - If your bundler provides a URL or Module for the .wasm, pass it as the first argument.\n */\nexport async function initWasm(wasmInput?: any): Promise<void> {\n if (wasmReady) return;\n const maybeInit = (wasmPkg as any).default;\n if (typeof maybeInit === 'function') {\n // Some environments require a URL/Module/bytes for initialization.\n // We forward the optional value if provided; otherwise let the glue resolve it.\n if (wasmInput !== undefined) {\n await maybeInit(wasmInput);\n } else {\n await maybeInit();\n }\n }\n wasmReady = true;\n}\n\n// Kyber functions\nexport async function kyberKeygen(): Promise<KyberKeypair> {\n await initWasm();\n const result = JSON.parse(wasm_kyber_keygen());\n if (result.error) throw new Error(result.error);\n return result;\n}\n\nexport async function kyberEncaps(publicB64u: string): Promise<KyberEncap> {\n await initWasm();\n const result = JSON.parse(wasm_kyber_encaps(publicB64u));\n if (result.error) throw new Error(result.error);\n return result;\n}\n\nexport async function kyberDecaps(secretB64u: string, kemCtB64u: string): Promise<{ shared_b64u: string }> {\n await initWasm();\n const result = JSON.parse(wasm_kyber_decaps(secretB64u, kemCtB64u));\n if (result.error) throw new Error(result.error);\n return result;\n}\n\n// HKDF functions\nexport async function hkdfSha256(\n secretB64u: string,\n infoB64u: string,\n saltB64u?: string,\n len: number = 32\n): Promise<HkdfResult> {\n await initWasm();\n const result = JSON.parse(wasm_hkdf_sha256(secretB64u, infoB64u, saltB64u, len));\n if (result.error) throw new Error(result.error);\n return result;\n}\n\n// AES-GCM functions\nexport async function aesGcmWrap(\n keyB64u: string,\n dekB64u: string,\n aadB64u: string\n): Promise<AesGcmWrap> {\n await initWasm();\n const result = JSON.parse(wasm_aes_gcm_wrap(keyB64u, dekB64u, aadB64u));\n if (result.error) throw new Error(result.error);\n return result;\n}\n\nexport async function aesGcmUnwrap(\n keyB64u: string,\n ivB64u: string,\n ctB64u: string,\n aadB64u: string\n): Promise<AesGcmUnwrapResult> {\n await initWasm();\n const result = JSON.parse(wasm_aes_gcm_unwrap(keyB64u, ivB64u, ctB64u, aadB64u));\n if (result.error) throw new Error(result.error);\n return result;\n}\n\n// Dilithium functions\n\n/**\n * Generate a new ML-DSA-65 (Dilithium) keypair.\n * SECURITY: Keys should be stored encrypted at rest.\n * For high-value operations, consider hardware security modules.\n */\nexport async function dilithiumKeygen(): Promise<DilithiumKeypair> {\n await initWasm();\n const result = JSON.parse(wasm_dilithium_keygen());\n if (result.error) throw new Error(result.error);\n return result;\n}\n\n/**\n * Sign a message using ML-DSA-65 (Dilithium).\n * @param messageB64u - Base64url-encoded message to sign\n * @param secretB64u - Base64url-encoded secret key\n * SECURITY: Secret key should be zeroized after use if possible.\n */\nexport async function dilithiumSign(\n messageB64u: string,\n secretB64u: string\n): Promise<DilithiumSignResult> {\n // Input validation - prevent memory exhaustion attacks\n if (messageB64u.length > MAX_MESSAGE_SIZE) {\n throw new Error(`Message exceeds maximum size of ${MAX_MESSAGE_SIZE} bytes`);\n }\n if (secretB64u.length > MAX_KEY_SIZE) {\n throw new Error(`Secret key exceeds maximum size of ${MAX_KEY_SIZE} bytes`);\n }\n \n await initWasm();\n const result = JSON.parse(wasm_dilithium_sign(messageB64u, secretB64u));\n if (result.error) throw new Error(result.error);\n return result;\n}\n\n/**\n * Verify a ML-DSA-65 (Dilithium) signature.\n * @param messageB64u - Base64url-encoded message\n * @param signatureB64u - Base64url-encoded signature\n * @param publicB64u - Base64url-encoded public key\n */\nexport async function dilithiumVerify(\n messageB64u: string,\n signatureB64u: string,\n publicB64u: string\n): Promise<DilithiumVerifyResult> {\n // Input validation - prevent memory exhaustion attacks\n if (messageB64u.length > MAX_MESSAGE_SIZE) {\n throw new Error(`Message exceeds maximum size of ${MAX_MESSAGE_SIZE} bytes`);\n }\n if (signatureB64u.length > MAX_KEY_SIZE || publicB64u.length > MAX_KEY_SIZE) {\n throw new Error(`Signature or public key exceeds maximum size`);\n }\n \n await initWasm();\n const result = JSON.parse(wasm_dilithium_verify(messageB64u, signatureB64u, publicB64u));\n if (result.error) throw new Error(result.error);\n return result;\n}\n\n// ---- Deterministic helpers (multisig/art token) ----\nexport async function jcsCanonicalize(json: unknown): Promise<string> {\n await initWasm();\n const raw = (wasmPkg as any).jcs_canonicalize(JSON.stringify(json));\n const out = typeof raw === 'string' ? JSON.parse(raw) : raw;\n if (out?.error) throw new Error(out.error);\n return out.canonical as string;\n}\n\nexport async function buildPolicyPreimage(policy: unknown): Promise<CanonicalOut> {\n await initWasm();\n const raw = (wasmPkg as any).preimage_governance(JSON.stringify(policy));\n const out = typeof raw === 'string' ? JSON.parse(raw) : raw;\n if (out?.error) throw new Error(out.error);\n return { canonical: out.canonical, msg_b64u: out.msg_b64u, msgB64u: out.msg_b64u };\n}\n\nexport async function buildMintPreimage(header: unknown, asset: unknown): Promise<CanonicalOut> {\n await initWasm();\n const raw = (wasmPkg as any).preimage_asset_mint(JSON.stringify(header), JSON.stringify(asset));\n const out = typeof raw === 'string' ? JSON.parse(raw) : raw;\n if (out?.error) throw new Error(out.error);\n return { canonical: out.canonical, msg_b64u: out.msg_b64u, msgB64u: out.msg_b64u };\n}\n\nexport async function buildTransferPreimage(header: unknown): Promise<CanonicalOut> {\n await initWasm();\n const raw = (wasmPkg as any).preimage_asset_transfer(JSON.stringify(header));\n const out = typeof raw === 'string' ? JSON.parse(raw) : raw;\n if (out?.error) throw new Error(out.error);\n return { canonical: out.canonical, msg_b64u: out.msg_b64u, msgB64u: out.msg_b64u };\n}\n\nexport async function buildAnchorPreimage(userId: string, rootHex: string, epoch: string, chains: unknown): Promise<CanonicalOut> {\n await initWasm();\n const raw = (wasmPkg as any).preimage_anchor(userId, rootHex, epoch, JSON.stringify(chains));\n const out = typeof raw === 'string' ? JSON.parse(raw) : raw;\n if (out?.error) throw new Error(out.error);\n return { canonical: out.canonical, msg_b64u: out.msg_b64u, msgB64u: out.msg_b64u };\n}\n\n// ---- Veritas Block Preimage (NEW v2 JCS canonical form) ----\n// We migrate block signing to a canonical (JCS) JSON similar to other preimages.\n// Legacy (v1) blocks used a hand-crafted JSON.stringify of a plain object with fixed insertion order.\n// This helper produces a canonical JSON string and msg_b64u = b64url(UTF-8(canonical JSON)).\n// NOTE: We intentionally EXCLUDE signature, encryptionKeyHash, and any runtime-only fields.\n// Fields included (ordered via JCS lexical ordering):\n// contentType, dataHash, index, metadataHash, ownerPublicKey, previousHash, signatureAlg, timestamp, version\n// index & timestamp MUST be strings representing decimal integers (BigInt safe) – caller responsibility.\nexport interface BlockPreimageInput {\n index: string | number | bigint;\n timestamp: string | number | bigint;\n previousHash: string;\n dataHash: string;\n metadataHash: string;\n signatureAlg: string; // e.g. 'dilithium2'\n ownerPublicKey: string; // Dilithium public key (base64url)\n contentType?: string; // default 'application/json'\n version: number; // block format / protocol version\n}\n\nexport async function buildBlockPreimage(block: BlockPreimageInput): Promise<CanonicalOut> {\n await initWasm();\n // Normalize fields per spec\n const normalized = {\n contentType: block.contentType || 'application/json',\n dataHash: block.dataHash,\n index: block.index.toString(),\n metadataHash: block.metadataHash,\n ownerPublicKey: block.ownerPublicKey,\n previousHash: block.previousHash,\n signatureAlg: block.signatureAlg,\n timestamp: block.timestamp.toString(),\n version: block.version,\n };\n // Use JCS canonicalization via wasm jcs_canonicalize (already exposed through jcsCanonicalize helper)\n const canonical = await jcsCanonicalize(normalized);\n const msg_b64u = b64uEncode(new TextEncoder().encode(canonical));\n return { canonical, msg_b64u, msgB64u: msg_b64u };\n}\n\nexport async function validateRoyalty(receiver: string, bps: number): Promise<boolean> {\n await initWasm();\n const raw = (wasmPkg as any).validate_royalty(receiver, bps);\n const out = typeof raw === 'string' ? JSON.parse(raw) : raw;\n if (out?.error) return false;\n return !!out.ok;\n}\n\nexport async function verifyAttestations(msgB64u: string, attestations: Array<{ alg: string; publicKeyB64u: string; signatureB64u: string }>, allowedPublicKeys?: string[]): Promise<number> {\n await initWasm();\n const raw = (wasmPkg as any).verify_attestations(msgB64u, JSON.stringify(attestations), allowedPublicKeys ? JSON.stringify(allowedPublicKeys) : undefined);\n const out = typeof raw === 'string' ? JSON.parse(raw) : raw;\n if (out?.error) throw new Error(out.error);\n return Number(out.valid_count || 0);\n}\n\n// Utility functions\n// Cross-env base64url helpers (browser + Node)\nfunction _fromByteArray(bytes: Uint8Array): string {\n if (typeof btoa === 'function') {\n // Browser\n let s = '';\n for (let i = 0; i < bytes.length; i++) s += String.fromCharCode(bytes[i]);\n return btoa(s);\n }\n // Node\n return Buffer.from(bytes).toString('base64');\n}\n\nfunction _toByteArray(b64: string): Uint8Array {\n if (typeof atob === 'function') {\n const binary = atob(b64);\n const out = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) out[i] = binary.charCodeAt(i);\n return out;\n }\n return new Uint8Array(Buffer.from(b64, 'base64'));\n}\n\nexport function b64uEncode(data: Uint8Array): string {\n return _fromByteArray(data)\n .replace(/\\+/g, '-')\n .replace(/\\//g, '_')\n .replace(/=+/g, '');\n}\n\nexport function b64uDecode(str: string): Uint8Array {\n const b64 = str.replace(/-/g, '+').replace(/_/g, '/').padEnd(Math.ceil(str.length / 4) * 4, '=');\n return _toByteArray(b64);\n}\n\nexport function constantTimeEqual(a: Uint8Array, b: Uint8Array): boolean {\n if (a.length !== b.length) return false;\n let result = 0;\n for (let i = 0; i < a.length; i++) {\n result |= a[i] ^ b[i];\n }\n return result === 0;\n}\n\n// ============================================================================\n// THRESHOLD SIGNATURES & GOVERNANCE\n// ============================================================================\n\nexport interface GovernancePolicy {\n policyId: string;\n version: number;\n chainId: string;\n threshold: number;\n signers: Array<{\n publicKeyB64u: string;\n keyId: string;\n weight: number;\n role: 'owner' | 'guardian' | 'delegate' | 'recovery';\n }>;\n operations: Array<{\n action: string;\n requiredThreshold?: number;\n requiredRoles?: string[];\n maxValue?: string;\n timelock?: number;\n }>;\n validFrom: number;\n validUntil: number;\n createdAt: number;\n createdBy: string;\n policySignature: string;\n}\n\nexport interface Attestation {\n signerKeyId: string;\n signerPublicKeyB64u: string;\n operationHash: string;\n operationType: string;\n attestedAt: number;\n expiresAt: number;\n signatureAlg: 'dilithium2';\n signatureB64u: string;\n}\n\nexport interface AggregatedSignature {\n policyId: string;\n policyVersion: number;\n operationHash: string;\n attestations: Attestation[];\n totalWeight: number;\n thresholdMet: boolean;\n verifiedAt: number;\n}\n\n/**\n * Create an attestation for a threshold signature operation.\n */\nexport async function createAttestation(\n operation: { type: string; payload: unknown },\n signerKeys: { keyId: string; publicKeyB64u: string; secretKeyB64u: string },\n expiresInSeconds: number = 3600\n): Promise<Attestation> {\n await initWasm();\n \n // Build deterministic preimage for the operation\n const preimage = await jcsCanonicalize({ type: operation.type, payload: operation.payload });\n const preimageBytes = new TextEncoder().encode(preimage);\n const operationHash = await sha256B64u(preimageBytes);\n const msgB64u = b64uEncode(preimageBytes);\n \n // Sign the preimage\n const sig = await dilithiumSign(msgB64u, signerKeys.secretKeyB64u);\n \n return {\n signerKeyId: signerKeys.keyId,\n signerPublicKeyB64u: signerKeys.publicKeyB64u,\n operationHash,\n operationType: operation.type,\n attestedAt: Date.now(),\n expiresAt: Date.now() + expiresInSeconds * 1000,\n signatureAlg: 'dilithium2',\n signatureB64u: sig.signature_b64u\n };\n}\n\n/**\n * Verify an attestation signature.\n */\nexport async function verifyAttestation(\n attestation: Attestation,\n operation: { type: string; payload: unknown }\n): Promise<{ valid: boolean; error?: string }> {\n await initWasm();\n \n // Rebuild expected operation hash\n const preimage = await jcsCanonicalize({ type: operation.type, payload: operation.payload });\n const preimageBytes = new TextEncoder().encode(preimage);\n const expectedHash = await sha256B64u(preimageBytes);\n \n if (attestation.operationHash !== expectedHash) {\n return { valid: false, error: 'Operation hash mismatch' };\n }\n \n // Check expiry\n if (attestation.expiresAt < Date.now()) {\n return { valid: false, error: 'Attestation expired' };\n }\n \n // Verify signature\n const msgB64u = b64uEncode(preimageBytes);\n const result = await dilithiumVerify(msgB64u, attestation.signatureB64u, attestation.signerPublicKeyB64u);\n \n if (!result.is_valid) {\n return { valid: false, error: 'Invalid signature' };\n }\n \n return { valid: true };\n}\n\n/**\n * Verify that an aggregated signature meets the threshold policy.\n */\nexport async function verifyThreshold(\n aggregated: AggregatedSignature,\n operation: { type: string; payload: unknown },\n policy: GovernancePolicy\n): Promise<{ valid: boolean; errors: string[] }> {\n const errors: string[] = [];\n \n // Check policy match\n if (aggregated.policyId !== policy.policyId) {\n errors.push('Policy ID mismatch');\n }\n \n // Verify each attestation and compute weight\n let validWeight = 0;\n for (const attestation of aggregated.attestations) {\n const signer = policy.signers.find(s => s.publicKeyB64u === attestation.signerPublicKeyB64u);\n if (!signer) {\n errors.push(`Signer ${attestation.signerKeyId} not in policy`);\n continue;\n }\n \n const result = await verifyAttestation(attestation, operation);\n if (!result.valid) {\n errors.push(`Attestation from ${attestation.signerKeyId}: ${result.error}`);\n continue;\n }\n \n validWeight += signer.weight;\n }\n \n // Check threshold\n if (validWeight < policy.threshold) {\n errors.push(`Threshold not met: weight ${validWeight} < required ${policy.threshold}`);\n }\n \n return { valid: errors.length === 0, errors };\n}\n\n// ============================================================================\n// PRE-REGISTRATION COMMITMENT SCHEME\n// ============================================================================\n\nexport interface ProvenanceCommitment {\n type: 'ProvenanceCommitment';\n version: 1;\n commitmentHash: string;\n creatorPublicKey: string;\n timestamp: number;\n signature: string;\n}\n\nexport interface CommitmentReveal {\n commitmentHash: string;\n salt: string;\n assetHash: string;\n}\n\n/**\n * Create a provenance commitment for an asset before public disclosure.\n * This establishes a timestamped claim without revealing the asset content.\n */\nexport async function createProvenanceCommitment(\n assetBytes: Uint8Array,\n keys: { publicKeyB64u: string; secretKeyB64u: string }\n): Promise<{ commitment: ProvenanceCommitment; reveal: CommitmentReveal }> {\n await initWasm();\n \n // Generate random salt\n const salt = crypto.getRandomValues(new Uint8Array(32));\n \n // Compute commitment hash = SHA256(asset || salt || publicKey)\n const publicKeyBytes = b64uDecode(keys.publicKeyB64u);\n const preimage = new Uint8Array(assetBytes.length + salt.length + publicKeyBytes.length);\n preimage.set(assetBytes, 0);\n preimage.set(salt, assetBytes.length);\n preimage.set(publicKeyBytes, assetBytes.length + salt.length);\n \n const commitmentHash = await sha256B64u(preimage);\n const assetHash = await sha256B64u(assetBytes);\n \n // Build commitment object (without signature)\n const commitmentData = {\n type: 'ProvenanceCommitment' as const,\n version: 1 as const,\n commitmentHash,\n creatorPublicKey: keys.publicKeyB64u,\n timestamp: Date.now()\n };\n \n // Sign the commitment\n const canonical = await jcsCanonicalize(commitmentData);\n const sig = await dilithiumSign(b64uEncode(new TextEncoder().encode(canonical)), keys.secretKeyB64u);\n \n const commitment: ProvenanceCommitment = {\n ...commitmentData,\n signature: sig.signature_b64u\n };\n \n const reveal: CommitmentReveal = {\n commitmentHash,\n salt: b64uEncode(salt),\n assetHash\n };\n \n return { commitment, reveal };\n}\n\n/**\n * Verify a provenance commitment signature.\n */\nexport async function verifyProvenanceCommitment(\n commitment: ProvenanceCommitment\n): Promise<{ valid: boolean; error?: string }> {\n await initWasm();\n \n // Reconstruct the signed data (without signature field)\n const commitmentData = {\n type: commitment.type,\n version: commitment.version,\n commitmentHash: commitment.commitmentHash,\n creatorPublicKey: commitment.creatorPublicKey,\n timestamp: commitment.timestamp\n };\n \n const canonical = await jcsCanonicalize(commitmentData);\n const msgB64u = b64uEncode(new TextEncoder().encode(canonical));\n \n const result = await dilithiumVerify(msgB64u, commitment.signature, commitment.creatorPublicKey);\n \n if (!result.is_valid) {\n return { valid: false, error: 'Invalid commitment signature' };\n }\n \n return { valid: true };\n}\n\n/**\n * Verify that a revealed asset matches a commitment.\n */\nexport async function verifyCommitmentReveal(\n commitment: ProvenanceCommitment,\n assetBytes: Uint8Array,\n reveal: CommitmentReveal\n): Promise<{ valid: boolean; error?: string }> {\n await initWasm();\n \n // First verify the commitment signature\n const sigResult = await verifyProvenanceCommitment(commitment);\n if (!sigResult.valid) {\n return { valid: false, error: `Commitment signature invalid: ${sigResult.error}` };\n }\n \n // Verify asset hash matches\n const computedAssetHash = await sha256B64u(assetBytes);\n if (computedAssetHash !== reveal.assetHash) {\n return { valid: false, error: 'Asset hash does not match reveal' };\n }\n \n // Reconstruct commitment hash\n const salt = b64uDecode(reveal.salt);\n const publicKeyBytes = b64uDecode(commitment.creatorPublicKey);\n \n const preimage = new Uint8Array(assetBytes.length + salt.length + publicKeyBytes.length);\n preimage.set(assetBytes, 0);\n preimage.set(salt, assetBytes.length);\n preimage.set(publicKeyBytes, assetBytes.length + salt.length);\n \n const computedCommitmentHash = await sha256B64u(preimage);\n \n if (computedCommitmentHash !== commitment.commitmentHash) {\n return { valid: false, error: 'Commitment hash does not match reveal' };\n }\n \n return { valid: true };\n}\n\n// ============================================================================\n// HELPER: SHA-256 with base64url output\n// ============================================================================\n\nasync function sha256B64u(data: Uint8Array): Promise<string> {\n const hashBuffer = await crypto.subtle.digest('SHA-256', data as unknown as BufferSource);\n return b64uEncode(new Uint8Array(hashBuffer));\n}\n\n// ============================================================================\n// ALGORITHMIC OPTIMIZATIONS (arXiv:2501.02305, arXiv:2504.17033)\n// ============================================================================\n// High-performance data structures for verification operations\n\n// WASM bindings for algorithm functions\nconst wasm_create_nonce_cache = (wasmPkg as any).create_nonce_cache as (capacity: number, ttl_ms: number) => string;\nconst wasm_nonce_cache_info = (wasmPkg as any).nonce_cache_info as () => string;\nconst wasm_sssp_config = (wasmPkg as any).sssp_config as (nodes: number) => string;\nconst wasm_provenance_path_config = (wasmPkg as any).provenance_path_config as (chain_length: number, branches: number) => string;\nconst wasm_elastic_hash_config = (wasmPkg as any).elastic_hash_config as (capacity: number, load_factor: number) => string;\n\n/**\n * Nonce Cache Configuration\n * Uses Elastic Hashing (arXiv:2501.02305) for O(1) amortized lookup\n */\nexport interface NonceCacheConfig {\n type: string;\n capacity: number;\n ttl_ms: number;\n algorithm: string;\n complexity: string;\n}\n\n/**\n * Create a nonce cache configuration for replay attack prevention.\n * Based on Elastic Hashing - O(1) amortized, O(log(1/δ)) worst-case.\n * \n * @param capacity - Maximum number of nonces to track\n * @param ttlMs - Time-to-live in milliseconds before nonces expire\n */\nexport async function createNonceCacheConfig(capacity: number, ttlMs: number): Promise<NonceCacheConfig> {\n await initWasm();\n return JSON.parse(wasm_create_nonce_cache(capacity, ttlMs));\n}\n\n/**\n * Get information about the nonce cache algorithm.\n */\nexport async function getNonceCacheInfo(): Promise<{\n name: string;\n paper: string;\n probe_complexity: string;\n load_factor: number;\n features: string[];\n}> {\n await initWasm();\n return JSON.parse(wasm_nonce_cache_info());\n}\n\n/**\n * SSSP (Single-Source Shortest Path) Configuration\n * Uses Frontier-Reduced algorithm (arXiv:2504.17033)\n */\nexport interface SSSPConfig {\n name: string;\n paper: string;\n complexity: string;\n nodes: number;\n pivots_k: number;\n batch_t: number;\n use_cases: string[];\n}\n\n/**\n * Get optimal SSSP configuration for graph verification.\n * Uses Frontier-Reduced SSSP - O(m × log^(2/3)(n)) complexity.\n * \n * @param nodes - Expected number of nodes in the graph\n */\nexport async function getSSSPConfig(nodes: number): Promise<SSSPConfig> {\n await initWasm();\n return JSON.parse(wasm_sssp_config(nodes));\n}\n\n/**\n * Provenance Path Configuration\n * Optimized parameters for chain of custody verification\n */\nexport interface ProvenancePathConfig {\n algorithm: string;\n chain_length: number;\n branches: number;\n estimated_nodes: number;\n estimated_edges: number;\n pivots_k: number;\n batch_t: number;\n complexity: string;\n verification_mode: string;\n}\n\n/**\n * Get optimized configuration for provenance chain verification.\n * \n * @param chainLength - Number of blocks in the provenance chain\n * @param branches - Average number of branches per block\n */\nexport async function getProvenancePathConfig(chainLength: number, branches: number): Promise<ProvenancePathConfig> {\n await initWasm();\n return JSON.parse(wasm_provenance_path_config(chainLength, branches));\n}\n\n/**\n * Elastic Hash Configuration\n * High-performance hash table for key caching\n */\nexport interface ElasticHashConfig {\n algorithm: string;\n paper: string;\n capacity: number;\n load_factor: number;\n levels: number;\n probe_complexity: {\n amortized: string;\n worst_case: string;\n };\n use_cases: string[];\n}\n\n/**\n * Get elastic hash table configuration for key caching.\n * Optimal for PQC public key caching with O(1) amortized lookups.\n * \n * @param capacity - Maximum number of entries\n * @param loadFactor - Target load factor (0.0 to 1.0, recommend 0.95)\n */\nexport async function getElasticHashConfig(capacity: number, loadFactor: number = 0.95): Promise<ElasticHashConfig> {\n await initWasm();\n return JSON.parse(wasm_elastic_hash_config(capacity, loadFactor));\n}\n\n// ============================================================================\n// CROSS-CHAIN ANCHORING (Roadmap M8)\n// ============================================================================\n// Merkle root submission to Ethereum, Bitcoin, and L2s for timestamping\n\n// WASM bindings for anchoring functions\nconst wasm_anchor_chains_info = (wasmPkg as any).anchor_chains_info as () => string;\nconst wasm_create_accumulator_leaf = (wasmPkg as any).create_accumulator_leaf as (userId: string, chainId: string, blockHash: string, blockIndex: bigint) => string;\nconst wasm_create_accumulator_leaf_with_alg = (wasmPkg as any).create_accumulator_leaf_with_alg as (userId: string, chainId: string, blockHash: string, blockIndex: bigint, hashAlg: string) => string;\nconst wasm_compute_merkle_root = (wasmPkg as any).compute_merkle_root as (leavesJson: string, hashAlg: string) => string;\nconst wasm_generate_evm_anchor_calldata = (wasmPkg as any).generate_evm_anchor_calldata as (rootHex: string, epoch: bigint) => string;\nconst wasm_generate_bitcoin_anchor_payload = (wasmPkg as any).generate_bitcoin_anchor_payload as (rootHex: string, epoch: bigint) => string;\nconst wasm_decode_bitcoin_anchor_payload = (wasmPkg as any).decode_bitcoin_anchor_payload as (payloadHex: string) => string;\nconst wasm_truncate_to_bytes32 = (wasmPkg as any).truncate_to_bytes32 as (hashHex: string) => string;\nconst wasm_anchor_config_info = (wasmPkg as any).anchor_config_info as () => string;\n\n/**\n * Supported blockchain chains for anchoring\n */\nexport interface AnchorChainInfo {\n id: string;\n name: string;\n chain_id?: number;\n type: 'evm' | 'evm_l2' | 'bitcoin';\n contract?: string;\n method?: string;\n payload_size?: number;\n}\n\n/**\n * Get information about supported anchor chains\n */\nexport async function getAnchorChainsInfo(): Promise<{ chains: AnchorChainInfo[] }> {\n await initWasm();\n return JSON.parse(wasm_anchor_chains_info());\n}\n\n/**\n * Accumulator leaf representing a chain's current state\n */\nexport interface AccumulatorLeaf {\n user_id: string;\n chain_id: string;\n block_hash: string;\n block_index: number;\n timestamp: number;\n leaf_hash: string;\n hash_alg?: string;\n}\n\n/**\n * Create a Merkle accumulator leaf for a chain state.\n * This is the fundamental unit for batching chain updates into super-roots.\n * \n * @param userId - User ID (64 hex chars)\n * @param chainId - Chain identifier within user's chains\n * @param blockHash - Hash of the latest block (64 hex chars)\n * @param blockIndex - Block height/index (number or bigint)\n * @param hashAlg - Hash algorithm for leaf hash ('sha256' or 'sha3-384')\n * @throws Error if inputs are invalid\n */\nexport async function createAccumulatorLeaf(\n userId: string,\n chainId: string,\n blockHash: string,\n blockIndex: number | bigint,\n hashAlg: 'sha256' | 'sha3-384' = 'sha3-384'\n): Promise<AccumulatorLeaf> {\n await initWasm();\n \n // Input validation with helpful error messages\n if (typeof userId !== 'string' || userId.length !== 64) {\n throw new Error(`Invalid userId: must be 64 hex characters (got ${typeof userId === 'string' ? userId.length : typeof userId})`);\n }\n if (!/^[0-9a-fA-F]{64}$/.test(userId)) {\n throw new Error('Invalid userId: must contain only hex characters (0-9, a-f, A-F)');\n }\n \n if (typeof chainId !== 'string' || chainId.length === 0) {\n throw new Error('Invalid chainId: must be a non-empty string');\n }\n \n if (typeof blockHash !== 'string' || blockHash.length !== 64) {\n throw new Error(`Invalid blockHash: must be 64 hex characters (got ${typeof blockHash === 'string' ? blockHash.length : typeof blockHash})`);\n }\n if (!/^[0-9a-fA-F]{64}$/.test(blockHash)) {\n throw new Error('Invalid blockHash: must contain only hex characters (0-9, a-f, A-F)');\n }\n \n // Convert blockIndex to bigint (WASM expects bigint for u64)\n let indexBigInt: bigint;\n if (typeof blockIndex === 'bigint') {\n indexBigInt = blockIndex;\n } else if (typeof blockIndex === 'number') {\n if (!Number.isInteger(blockIndex) || blockIndex < 0) {\n throw new Error('Invalid blockIndex: must be a non-negative integer');\n }\n if (!Number.isSafeInteger(blockIndex)) {\n throw new Error('Invalid blockIndex: number exceeds MAX_SAFE_INTEGER; use bigint instead');\n }\n indexBigInt = BigInt(blockIndex);\n } else {\n throw new Error(`Invalid blockIndex: must be a number or bigint (got ${typeof blockIndex})`);\n }\n \n if (indexBigInt < 0n) {\n throw new Error('Invalid blockIndex: must be non-negative');\n }\n \n try {\n const result = typeof wasm_create_accumulator_leaf_with_alg === 'function'\n ? wasm_create_accumulator_leaf_with_alg(userId, chainId, blockHash, indexBigInt, hashAlg)\n : wasm_create_accumulator_leaf(userId, chainId, blockHash, indexBigInt);\n const parsed = JSON.parse(result);\n if (parsed.error) {\n throw new Error(parsed.error);\n }\n return parsed;\n } catch (e) {\n if (e instanceof Error) {\n // Re-throw our validation errors\n if (e.message.startsWith('Invalid ')) {\n throw e;\n }\n // Wrap WASM errors\n throw new Error(`WASM error in createAccumulatorLeaf: ${e.message}`);\n }\n throw new Error(`Unknown error in createAccumulatorLeaf: ${String(e)}`);\n }\n}\n\n/**\n * Merkle root computation result\n */\nexport interface MerkleRootResult {\n root: string;\n leaf_count: number;\n hash_alg: string;\n}\n\n/**\n * Compute Merkle root from an array of leaf hashes.\n * \n * @param leaves - Array of hex hash strings\n * @param hashAlg - Hash algorithm ('sha256' or 'sha3-384')\n */\nexport async function computeMerkleRoot(\n leaves: string[],\n hashAlg: 'sha256' | 'sha3-384' = 'sha256'\n): Promise<MerkleRootResult> {\n await initWasm();\n return JSON.parse(wasm_compute_merkle_root(JSON.stringify(leaves), hashAlg));\n}\n\n/**\n * EVM anchor calldata for AnchorRegistry contract\n */\nexport interface EvmAnchorCalldata {\n calldata: string;\n root: string;\n epoch: number;\n method: string;\n selector: string;\n}\n\n/**\n * Generate EVM calldata for AnchorRegistry.anchor(bytes32, uint256).\n * Ready to use in an Ethereum transaction.\n * \n * @param rootHex - 32-byte Merkle root (64 hex chars, with or without 0x prefix)\n * @param epoch - Epoch number (number or bigint)\n */\nexport async function generateEvmAnchorCalldata(\n rootHex: string,\n epoch: number | bigint\n): Promise<EvmAnchorCalldata> {\n await initWasm();\n let epochBigInt: bigint;\n if (typeof epoch === 'bigint') {\n epochBigInt = epoch;\n } else {\n if (!Number.isInteger(epoch) || epoch < 0) {\n throw new Error('Invalid epoch: must be a non-negative integer');\n }\n if (!Number.isSafeInteger(epoch)) {\n throw new Error('Invalid epoch: number exceeds MAX_SAFE_INTEGER; use bigint instead');\n }\n epochBigInt = BigInt(epoch);\n }\n return JSON.parse(wasm_generate_evm_anchor_calldata(rootHex, epochBigInt));\n}\n\n/**\n * Bitcoin OP_RETURN anchor payload\n */\nexport interface BitcoinAnchorPayload {\n payload_hex: string;\n payload_size: number;\n magic: string;\n epoch: number;\n root: string;\n}\n\n/**\n * Generate Bitcoin OP_RETURN payload for anchoring.\n * 45 bytes: \"MTARA\" (5) + epoch (8) + root32 (32)\n * \n * @param rootHex - 32-byte Merkle root (64 hex chars)\n * @param epoch - Epoch number (number or bigint)\n */\nexport async function generateBitcoinAnchorPayload(\n rootHex: string,\n epoch: number | bigint\n): Promise<BitcoinAnchorPayload> {\n await initWasm();\n let epochBigInt: bigint;\n if (typeof epoch === 'bigint') {\n epochBigInt = epoch;\n } else {\n if (!Number.isInteger(epoch) || epoch < 0) {\n throw new Error('Invalid epoch: must be a non-negative integer');\n }\n if (!Number.isSafeInteger(epoch)) {\n throw new Error('Invalid epoch: number exceeds MAX_SAFE_INTEGER; use bigint instead');\n }\n epochBigInt = BigInt(epoch);\n }\n return JSON.parse(wasm_generate_bitcoin_anchor_payload(rootHex, epochBigInt));\n}\n\n/**\n * Decoded Bitcoin anchor payload\n */\nexport interface DecodedBitcoinPayload {\n magic: string;\n epoch: number;\n root: string;\n}\n\n/**\n * Decode a Bitcoin OP_RETURN anchor payload.\n * \n * @param payloadHex - Hex-encoded payload bytes\n */\nexport async function decodeBitcoinAnchorPayload(\n payloadHex: string\n): Promise<DecodedBitcoinPayload> {\n await initWasm();\n return JSON.parse(wasm_decode_bitcoin_anchor_payload(payloadHex));\n}\n\n/**\n * Truncation result for SHA3-384 to bytes32\n */\nexport interface TruncationResult {\n original: string;\n original_bytes: number;\n truncated: string;\n truncated_bytes: number;\n}\n\n/**\n * Truncate a hash to 32 bytes for EVM compatibility.\n * Used when anchoring SHA3-384 hashes to Ethereum.\n * \n * @param hashHex - Hash to truncate (with or without 0x prefix)\n */\nexport async function truncateToBytes32(hashHex: string): Promise<TruncationResult> {\n await initWasm();\n return JSON.parse(wasm_truncate_to_bytes32(hashHex));\n}\n\n/**\n * Anchor configuration and estimates\n */\nexport interface AnchorConfigInfo {\n accumulator: {\n max_leaves_per_epoch: number;\n hash_algorithms: string[];\n default_hash: string;\n };\n ethereum: {\n contract: string;\n function: string;\n selector: string;\n estimated_gas: number;\n calldata_size: number;\n };\n bitcoin: {\n method: string;\n magic: string;\n payload_size: number;\n estimated_fee_sats: number;\n };\n recommended_schedule: {\n production: string;\n high_frequency: string;\n };\n}\n\n/**\n * Get anchor configuration and gas/fee estimates.\n */\nexport async function getAnchorConfigInfo(): Promise<AnchorConfigInfo> {\n await initWasm();\n return JSON.parse(wasm_anchor_config_info());\n}\n"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA,MAAM,gBAAgB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAC1C,MAAM,YAAY,GAAG,IAAI,GAAG,IAAI,CAAC;AA4CjC,MAAM,iBAAiB,GAAI,OAAe,CAAC,YAA4B;AACvE,MAAM,iBAAiB,GAAI,OAAe,CAAC,YAAqC;AAChF,MAAM,iBAAiB,GAAI,OAAe,CAAC,YAAgD;AAC3F,MAAM,gBAAgB,GAAI,OAAe,CAAC,WAA4E;AACtH,MAAM,iBAAiB,GAAI,OAAe,CAAC,YAA2D;AACtG,MAAM,mBAAmB,GAAI,OAAe,CAAC,cAA0E;AACvH,MAAM,qBAAqB,GAAI,OAAe,CAAC,gBAAgC;AAC/E,MAAM,mBAAmB,GAAI,OAAe,CAAC,cAAkD;AAC/F,MAAM,qBAAqB,GAAI,OAAe,CAAC,gBAAiE;AAKhH;AACA,IAAI,SAAS,GAAG,KAAK;AAErB;;;;AAIG;AACI,eAAe,QAAQ,CAAC,SAAe,EAAA;AAC5C,IAAA,IAAI,SAAS;QAAE;AACf,IAAA,MAAM,SAAS,GAAI,OAAe,CAAC,OAAO;AAC1C,IAAA,IAAI,OAAO,SAAS,KAAK,UAAU,EAAE;;;AAGnC,QAAA,IAAI,SAAS,KAAK,SAAS,EAAE;AAC3B,YAAA,MAAM,SAAS,CAAC,SAAS,CAAC;QAC5B;aAAO;YACL,MAAM,SAAS,EAAE;QACnB;IACF;IACA,SAAS,GAAG,IAAI;AAClB;AAEA;AACO,eAAe,WAAW,GAAA;I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AI,WAAmB;AACvB,IAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,WAAW,GAAG,KAAK;IACrB;SAAO;AACL,QAAA,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE;AACzC,YAAA,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC;QAClE;QACA,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE;AAChC,YAAA,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC;QACvF;AACA,QAAA,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC;IAC7B;IACA,OAAO,IAAI,CAAC,KAAK,CAAC,oCAAoC,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;AAC/E;AAWA;;;;AAIG;AACI,eAAe,0BAA0B,CAC9C,UAAkB,EAAA;IAElB,MAAM,QAAQ,EAAE;IAChB,OAAO,IAAI,CAAC,KAAK,CAAC,kCAAkC,CAAC,UAAU,CAAC,CAAC;AACnE;AAYA;;;;;AAKG;AACI,eAAe,iBAAiB,CAAC,OAAe,EAAA;IACrD,MAAM,QAAQ,EAAE;IAChB,OAAO,IAAI,CAAC,KAAK,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC;AACtD;AA8BA;;AAEG;AACI,eAAe,mBAAmB,GAAA;IACvC,MAAM,QAAQ,EAAE;AAChB,IAAA,OAAO,IAAI,CAAC,KAAK,CAAC,uBAAuB,EAAE,CAAC;AAC9C;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../src/index.ts"],"sourcesContent":["// Ma'atara Core PQC Toolkit\n// Post-Quantum Cryptography for Browser and Node.js\n// \n// SECURITY NOTICE: This library implements FIPS 204 (ML-DSA) and FIPS 203 (ML-KEM)\n// post-quantum cryptographic algorithms. Key material should be:\n// 1. Stored securely (encrypted at rest)\n// 2. Transmitted only over secure channels\n// 3. Zeroized after use when possible\n// 4. Protected by hardware security modules for high-value operations\n//\n// See docs/WASM_SECURITY_MODEL.md for browser-specific security considerations.\n\n// ============================================================================\n// SECURITY CONSTANTS\n// ============================================================================\nconst MAX_MESSAGE_SIZE = 16 * 1024 * 1024; // 16MB - prevent memory exhaustion\nconst MAX_KEY_SIZE = 1024 * 1024; // 1MB - reasonable for PQC keys\nconst MAX_ATTESTATION_COUNT = 100; // Prevent DoS from large attestation arrays\n\nexport interface KyberKeypair {\n public_b64u: string;\n secret_b64u: string;\n}\n\nexport interface KyberEncap {\n kem_ct_b64u: string;\n shared_b64u: string;\n}\n\nexport interface AesGcmWrap {\n iv_b64u: string;\n ct_b64u: string;\n}\n\nexport interface DilithiumKeypair {\n algorithm: string;\n public_b64u: string;\n secret_b64u: string;\n}\n\nexport interface DilithiumSignResult {\n signature_b64u: string;\n algorithm: string;\n}\n\nexport interface DilithiumVerifyResult {\n is_valid: boolean;\n algorithm: string;\n}\n\nexport interface HkdfResult {\n key_b64u: string;\n}\n\nexport interface AesGcmUnwrapResult {\n dek_b64u: string;\n}\n\n// Import WASM functions (namespace import for better bundler compatibility)\nimport * as wasmPkg from '@maatara/core-pqc-wasm';\nconst wasm_kyber_keygen = (wasmPkg as any).kyber_keygen as () => string;\nconst wasm_kyber_encaps = (wasmPkg as any).kyber_encaps as (p: string) => string;\nconst wasm_kyber_decaps = (wasmPkg as any).kyber_decaps as (s: string, c: string) => string;\nconst wasm_hkdf_sha256 = (wasmPkg as any).hkdf_sha256 as (s: string, i: string, salt?: string, len?: number) => string;\nconst wasm_aes_gcm_wrap = (wasmPkg as any).aes_gcm_wrap as (k: string, d: string, a: string) => string;\nconst wasm_aes_gcm_unwrap = (wasmPkg as any).aes_gcm_unwrap as (k: string, iv: string, ct: string, a: string) => string;\nconst wasm_dilithium_keygen = (wasmPkg as any).dilithium_keygen as () => string;\nconst wasm_dilithium_sign = (wasmPkg as any).dilithium_sign as (m: string, s: string) => string;\nconst wasm_dilithium_verify = (wasmPkg as any).dilithium_verify as (m: string, sig: string, p: string) => string;\n\n// Deterministic/canonicalization and governance helpers\nexport interface CanonicalOut { canonical: string; msg_b64u?: string; msgB64u?: string }\n\n// Initialize WASM\nlet wasmReady = false;\n\n/**\n * Initialize the underlying WASM module.\n * - In browsers/bundlers where the glue knows how to fetch the .wasm, you can call without params.\n * - If your bundler provides a URL or Module for the .wasm, pass it as the first argument.\n */\nexport async function initWasm(wasmInput?: any): Promise<void> {\n if (wasmReady) return;\n const maybeInit = (wasmPkg as any).default;\n if (typeof maybeInit === 'function') {\n // Some environments require a URL/Module/bytes for initialization.\n // We forward the optional value if provided; otherwise let the glue resolve it.\n if (wasmInput !== undefined) {\n await maybeInit(wasmInput);\n } else {\n await maybeInit();\n }\n }\n wasmReady = true;\n}\n\n// Kyber functions\nexport async function kyberKeygen(): Promise<KyberKeypair> {\n await initWasm();\n const result = JSON.parse(wasm_kyber_keygen());\n if (result.error) throw new Error(result.error);\n return result;\n}\n\nexport async function kyberEncaps(publicB64u: string): Promise<KyberEncap> {\n await initWasm();\n const result = JSON.parse(wasm_kyber_encaps(publicB64u));\n if (result.error) throw new Error(result.error);\n return result;\n}\n\nexport async function kyberDecaps(secretB64u: string, kemCtB64u: string): Promise<{ shared_b64u: string }> {\n await initWasm();\n const result = JSON.parse(wasm_kyber_decaps(secretB64u, kemCtB64u));\n if (result.error) throw new Error(result.error);\n return result;\n}\n\n// HKDF functions\nexport async function hkdfSha256(\n secretB64u: string,\n infoB64u: string,\n saltB64u?: string,\n len: number = 32\n): Promise<HkdfResult> {\n await initWasm();\n const result = JSON.parse(wasm_hkdf_sha256(secretB64u, infoB64u, saltB64u, len));\n if (result.error) throw new Error(result.error);\n return result;\n}\n\n// AES-GCM functions\nexport async function aesGcmWrap(\n keyB64u: string,\n dekB64u: string,\n aadB64u: string\n): Promise<AesGcmWrap> {\n await initWasm();\n const result = JSON.parse(wasm_aes_gcm_wrap(keyB64u, dekB64u, aadB64u));\n if (result.error) throw new Error(result.error);\n return result;\n}\n\nexport async function aesGcmUnwrap(\n keyB64u: string,\n ivB64u: string,\n ctB64u: string,\n aadB64u: string\n): Promise<AesGcmUnwrapResult> {\n await initWasm();\n const result = JSON.parse(wasm_aes_gcm_unwrap(keyB64u, ivB64u, ctB64u, aadB64u));\n if (result.error) throw new Error(result.error);\n return result;\n}\n\n// Dilithium functions\n\n/**\n * Generate a new ML-DSA-65 (Dilithium) keypair.\n * SECURITY: Keys should be stored encrypted at rest.\n * For high-value operations, consider hardware security modules.\n */\nexport async function dilithiumKeygen(): Promise<DilithiumKeypair> {\n await initWasm();\n const result = JSON.parse(wasm_dilithium_keygen());\n if (result.error) throw new Error(result.error);\n return result;\n}\n\n/**\n * Sign a message using ML-DSA-65 (Dilithium).\n * @param messageB64u - Base64url-encoded message to sign\n * @param secretB64u - Base64url-encoded secret key\n * SECURITY: Secret key should be zeroized after use if possible.\n */\nexport async function dilithiumSign(\n messageB64u: string,\n secretB64u: string\n): Promise<DilithiumSignResult> {\n // Input validation - prevent memory exhaustion attacks\n if (messageB64u.length > MAX_MESSAGE_SIZE) {\n throw new Error(`Message exceeds maximum size of ${MAX_MESSAGE_SIZE} bytes`);\n }\n if (secretB64u.length > MAX_KEY_SIZE) {\n throw new Error(`Secret key exceeds maximum size of ${MAX_KEY_SIZE} bytes`);\n }\n \n await initWasm();\n const result = JSON.parse(wasm_dilithium_sign(messageB64u, secretB64u));\n if (result.error) throw new Error(result.error);\n return result;\n}\n\n/**\n * Verify a ML-DSA-65 (Dilithium) signature.\n * @param messageB64u - Base64url-encoded message\n * @param signatureB64u - Base64url-encoded signature\n * @param publicB64u - Base64url-encoded public key\n */\nexport async function dilithiumVerify(\n messageB64u: string,\n signatureB64u: string,\n publicB64u: string\n): Promise<DilithiumVerifyResult> {\n // Input validation - prevent memory exhaustion attacks\n if (messageB64u.length > MAX_MESSAGE_SIZE) {\n throw new Error(`Message exceeds maximum size of ${MAX_MESSAGE_SIZE} bytes`);\n }\n if (signatureB64u.length > MAX_KEY_SIZE || publicB64u.length > MAX_KEY_SIZE) {\n throw new Error(`Signature or public key exceeds maximum size`);\n }\n \n await initWasm();\n const result = JSON.parse(wasm_dilithium_verify(messageB64u, signatureB64u, publicB64u));\n if (result.error) throw new Error(result.error);\n return result;\n}\n\n// ---- Deterministic helpers (multisig/art token) ----\nexport async function jcsCanonicalize(json: unknown): Promise<string> {\n await initWasm();\n const raw = (wasmPkg as any).jcs_canonicalize(JSON.stringify(json));\n const out = typeof raw === 'string' ? JSON.parse(raw) : raw;\n if (out?.error) throw new Error(out.error);\n return out.canonical as string;\n}\n\nexport async function buildPolicyPreimage(policy: unknown): Promise<CanonicalOut> {\n await initWasm();\n const raw = (wasmPkg as any).preimage_governance(JSON.stringify(policy));\n const out = typeof raw === 'string' ? JSON.parse(raw) : raw;\n if (out?.error) throw new Error(out.error);\n return { canonical: out.canonical, msg_b64u: out.msg_b64u, msgB64u: out.msg_b64u };\n}\n\nexport async function buildMintPreimage(header: unknown, asset: unknown): Promise<CanonicalOut> {\n await initWasm();\n const raw = (wasmPkg as any).preimage_asset_mint(JSON.stringify(header), JSON.stringify(asset));\n const out = typeof raw === 'string' ? JSON.parse(raw) : raw;\n if (out?.error) throw new Error(out.error);\n return { canonical: out.canonical, msg_b64u: out.msg_b64u, msgB64u: out.msg_b64u };\n}\n\nexport async function buildTransferPreimage(header: unknown): Promise<CanonicalOut> {\n await initWasm();\n const raw = (wasmPkg as any).preimage_asset_transfer(JSON.stringify(header));\n const out = typeof raw === 'string' ? JSON.parse(raw) : raw;\n if (out?.error) throw new Error(out.error);\n return { canonical: out.canonical, msg_b64u: out.msg_b64u, msgB64u: out.msg_b64u };\n}\n\nexport async function buildAnchorPreimage(userId: string, rootHex: string, epoch: string, chains: unknown): Promise<CanonicalOut> {\n await initWasm();\n const raw = (wasmPkg as any).preimage_anchor(userId, rootHex, epoch, JSON.stringify(chains));\n const out = typeof raw === 'string' ? JSON.parse(raw) : raw;\n if (out?.error) throw new Error(out.error);\n return { canonical: out.canonical, msg_b64u: out.msg_b64u, msgB64u: out.msg_b64u };\n}\n\n// ---- Veritas Block Preimage (NEW v2 JCS canonical form) ----\n// We migrate block signing to a canonical (JCS) JSON similar to other preimages.\n// Legacy (v1) blocks used a hand-crafted JSON.stringify of a plain object with fixed insertion order.\n// This helper produces a canonical JSON string and msg_b64u = b64url(UTF-8(canonical JSON)).\n// NOTE: We intentionally EXCLUDE signature, encryptionKeyHash, and any runtime-only fields.\n// Fields included (ordered via JCS lexical ordering):\n// contentType, dataHash, index, metadataHash, ownerPublicKey, previousHash, signatureAlg, timestamp, version\n// index & timestamp MUST be strings representing decimal integers (BigInt safe) – caller responsibility.\nexport interface BlockPreimageInput {\n index: string | number | bigint;\n timestamp: string | number | bigint;\n previousHash: string;\n dataHash: string;\n metadataHash: string;\n signatureAlg: string; // e.g. 'dilithium2'\n ownerPublicKey: string; // Dilithium public key (base64url)\n contentType?: string; // default 'application/json'\n version: number; // block format / protocol version\n}\n\nexport async function buildBlockPreimage(block: BlockPreimageInput): Promise<CanonicalOut> {\n await initWasm();\n // Normalize fields per spec\n const normalized = {\n contentType: block.contentType || 'application/json',\n dataHash: block.dataHash,\n index: block.index.toString(),\n metadataHash: block.metadataHash,\n ownerPublicKey: block.ownerPublicKey,\n previousHash: block.previousHash,\n signatureAlg: block.signatureAlg,\n timestamp: block.timestamp.toString(),\n version: block.version,\n };\n // Use JCS canonicalization via wasm jcs_canonicalize (already exposed through jcsCanonicalize helper)\n const canonical = await jcsCanonicalize(normalized);\n const msg_b64u = b64uEncode(new TextEncoder().encode(canonical));\n return { canonical, msg_b64u, msgB64u: msg_b64u };\n}\n\nexport async function validateRoyalty(receiver: string, bps: number): Promise<boolean> {\n await initWasm();\n const raw = (wasmPkg as any).validate_royalty(receiver, bps);\n const out = typeof raw === 'string' ? JSON.parse(raw) : raw;\n if (out?.error) return false;\n return !!out.ok;\n}\n\nexport async function verifyAttestations(msgB64u: string, attestations: Array<{ alg: string; publicKeyB64u: string; signatureB64u: string }>, allowedPublicKeys?: string[]): Promise<number> {\n await initWasm();\n const raw = (wasmPkg as any).verify_attestations(msgB64u, JSON.stringify(attestations), allowedPublicKeys ? JSON.stringify(allowedPublicKeys) : undefined);\n const out = typeof raw === 'string' ? JSON.parse(raw) : raw;\n if (out?.error) throw new Error(out.error);\n return Number(out.valid_count || 0);\n}\n\n// Utility functions\n// Cross-env base64url helpers (browser + Node)\nfunction _fromByteArray(bytes: Uint8Array): string {\n if (typeof btoa === 'function') {\n // Browser\n let s = '';\n for (let i = 0; i < bytes.length; i++) s += String.fromCharCode(bytes[i]);\n return btoa(s);\n }\n // Node\n return Buffer.from(bytes).toString('base64');\n}\n\nfunction _toByteArray(b64: string): Uint8Array {\n if (typeof atob === 'function') {\n const binary = atob(b64);\n const out = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) out[i] = binary.charCodeAt(i);\n return out;\n }\n return new Uint8Array(Buffer.from(b64, 'base64'));\n}\n\nexport function b64uEncode(data: Uint8Array): string {\n return _fromByteArray(data)\n .replace(/\\+/g, '-')\n .replace(/\\//g, '_')\n .replace(/=+/g, '');\n}\n\nexport function b64uDecode(str: string): Uint8Array {\n const b64 = str.replace(/-/g, '+').replace(/_/g, '/').padEnd(Math.ceil(str.length / 4) * 4, '=');\n return _toByteArray(b64);\n}\n\nexport function constantTimeEqual(a: Uint8Array, b: Uint8Array): boolean {\n if (a.length !== b.length) return false;\n let result = 0;\n for (let i = 0; i < a.length; i++) {\n result |= a[i] ^ b[i];\n }\n return result === 0;\n}\n\n// ============================================================================\n// THRESHOLD SIGNATURES & GOVERNANCE\n// ============================================================================\n\nexport interface GovernancePolicy {\n policyId: string;\n version: number;\n chainId: string;\n threshold: number;\n signers: Array<{\n publicKeyB64u: string;\n keyId: string;\n weight: number;\n role: 'owner' | 'guardian' | 'delegate' | 'recovery';\n }>;\n operations: Array<{\n action: string;\n requiredThreshold?: number;\n requiredRoles?: string[];\n maxValue?: string;\n timelock?: number;\n }>;\n validFrom: number;\n validUntil: number;\n createdAt: number;\n createdBy: string;\n policySignature: string;\n}\n\nexport interface Attestation {\n signerKeyId: string;\n signerPublicKeyB64u: string;\n operationHash: string;\n operationType: string;\n attestedAt: number;\n expiresAt: number;\n signatureAlg: 'dilithium2';\n signatureB64u: string;\n}\n\nexport interface AggregatedSignature {\n policyId: string;\n policyVersion: number;\n operationHash: string;\n attestations: Attestation[];\n totalWeight: number;\n thresholdMet: boolean;\n verifiedAt: number;\n}\n\n/**\n * Create an attestation for a threshold signature operation.\n */\nexport async function createAttestation(\n operation: { type: string; payload: unknown },\n signerKeys: { keyId: string; publicKeyB64u: string; secretKeyB64u: string },\n expiresInSeconds: number = 3600\n): Promise<Attestation> {\n await initWasm();\n \n // Build deterministic preimage for the operation\n const preimage = await jcsCanonicalize({ type: operation.type, payload: operation.payload });\n const preimageBytes = new TextEncoder().encode(preimage);\n const operationHash = await sha3_384_b64u(preimageBytes);\n const msgB64u = b64uEncode(preimageBytes);\n \n // Sign the preimage\n const sig = await dilithiumSign(msgB64u, signerKeys.secretKeyB64u);\n \n return {\n signerKeyId: signerKeys.keyId,\n signerPublicKeyB64u: signerKeys.publicKeyB64u,\n operationHash,\n operationType: operation.type,\n attestedAt: Date.now(),\n expiresAt: Date.now() + expiresInSeconds * 1000,\n signatureAlg: 'dilithium2',\n signatureB64u: sig.signature_b64u\n };\n}\n\n/**\n * Verify an attestation signature.\n */\nexport async function verifyAttestation(\n attestation: Attestation,\n operation: { type: string; payload: unknown }\n): Promise<{ valid: boolean; error?: string }> {\n await initWasm();\n \n // Rebuild expected operation hash\n const preimage = await jcsCanonicalize({ type: operation.type, payload: operation.payload });\n const preimageBytes = new TextEncoder().encode(preimage);\n const expectedHash = await sha3_384_b64u(preimageBytes);\n \n if (attestation.operationHash !== expectedHash) {\n return { valid: false, error: 'Operation hash mismatch' };\n }\n \n // Check expiry\n if (attestation.expiresAt < Date.now()) {\n return { valid: false, error: 'Attestation expired' };\n }\n \n // Verify signature\n const msgB64u = b64uEncode(preimageBytes);\n const result = await dilithiumVerify(msgB64u, attestation.signatureB64u, attestation.signerPublicKeyB64u);\n \n if (!result.is_valid) {\n return { valid: false, error: 'Invalid signature' };\n }\n \n return { valid: true };\n}\n\n/**\n * Verify that an aggregated signature meets the threshold policy.\n */\nexport async function verifyThreshold(\n aggregated: AggregatedSignature,\n operation: { type: string; payload: unknown },\n policy: GovernancePolicy\n): Promise<{ valid: boolean; errors: string[] }> {\n const errors: string[] = [];\n \n // Check policy match\n if (aggregated.policyId !== policy.policyId) {\n errors.push('Policy ID mismatch');\n }\n \n // Verify each attestation and compute weight\n let validWeight = 0;\n for (const attestation of aggregated.attestations) {\n const signer = policy.signers.find(s => s.publicKeyB64u === attestation.signerPublicKeyB64u);\n if (!signer) {\n errors.push(`Signer ${attestation.signerKeyId} not in policy`);\n continue;\n }\n \n const result = await verifyAttestation(attestation, operation);\n if (!result.valid) {\n errors.push(`Attestation from ${attestation.signerKeyId}: ${result.error}`);\n continue;\n }\n \n validWeight += signer.weight;\n }\n \n // Check threshold\n if (validWeight < policy.threshold) {\n errors.push(`Threshold not met: weight ${validWeight} < required ${policy.threshold}`);\n }\n \n return { valid: errors.length === 0, errors };\n}\n\n// ============================================================================\n// PRE-REGISTRATION COMMITMENT SCHEME\n// ============================================================================\n\nexport interface ProvenanceCommitment {\n type: 'ProvenanceCommitment';\n version: 1;\n commitmentHash: string;\n creatorPublicKey: string;\n timestamp: number;\n signature: string;\n}\n\nexport interface CommitmentReveal {\n commitmentHash: string;\n salt: string;\n assetHash: string;\n}\n\n/**\n * Create a provenance commitment for an asset before public disclosure.\n * This establishes a timestamped claim without revealing the asset content.\n */\nexport async function createProvenanceCommitment(\n assetBytes: Uint8Array,\n keys: { publicKeyB64u: string; secretKeyB64u: string }\n): Promise<{ commitment: ProvenanceCommitment; reveal: CommitmentReveal }> {\n await initWasm();\n \n // Generate random salt\n const salt = crypto.getRandomValues(new Uint8Array(32));\n \n // Compute commitment hash = SHA3-384(asset || salt || publicKey)\n const publicKeyBytes = b64uDecode(keys.publicKeyB64u);\n const preimage = new Uint8Array(assetBytes.length + salt.length + publicKeyBytes.length);\n preimage.set(assetBytes, 0);\n preimage.set(salt, assetBytes.length);\n preimage.set(publicKeyBytes, assetBytes.length + salt.length);\n \n const commitmentHash = await sha3_384_b64u(preimage);\n const assetHash = await sha3_384_b64u(assetBytes);\n \n // Build commitment object (without signature)\n const commitmentData = {\n type: 'ProvenanceCommitment' as const,\n version: 1 as const,\n commitmentHash,\n creatorPublicKey: keys.publicKeyB64u,\n timestamp: Date.now()\n };\n \n // Sign the commitment\n const canonical = await jcsCanonicalize(commitmentData);\n const sig = await dilithiumSign(b64uEncode(new TextEncoder().encode(canonical)), keys.secretKeyB64u);\n \n const commitment: ProvenanceCommitment = {\n ...commitmentData,\n signature: sig.signature_b64u\n };\n \n const reveal: CommitmentReveal = {\n commitmentHash,\n salt: b64uEncode(salt),\n assetHash\n };\n \n return { commitment, reveal };\n}\n\n/**\n * Verify a provenance commitment signature.\n */\nexport async function verifyProvenanceCommitment(\n commitment: ProvenanceCommitment\n): Promise<{ valid: boolean; error?: string }> {\n await initWasm();\n \n // Reconstruct the signed data (without signature field)\n const commitmentData = {\n type: commitment.type,\n version: commitment.version,\n commitmentHash: commitment.commitmentHash,\n creatorPublicKey: commitment.creatorPublicKey,\n timestamp: commitment.timestamp\n };\n \n const canonical = await jcsCanonicalize(commitmentData);\n const msgB64u = b64uEncode(new TextEncoder().encode(canonical));\n \n const result = await dilithiumVerify(msgB64u, commitment.signature, commitment.creatorPublicKey);\n \n if (!result.is_valid) {\n return { valid: false, error: 'Invalid commitment signature' };\n }\n \n return { valid: true };\n}\n\n/**\n * Verify that a revealed asset matches a commitment.\n */\nexport async function verifyCommitmentReveal(\n commitment: ProvenanceCommitment,\n assetBytes: Uint8Array,\n reveal: CommitmentReveal\n): Promise<{ valid: boolean; error?: string }> {\n await initWasm();\n \n // First verify the commitment signature\n const sigResult = await verifyProvenanceCommitment(commitment);\n if (!sigResult.valid) {\n return { valid: false, error: `Commitment signature invalid: ${sigResult.error}` };\n }\n \n // Verify asset hash matches\n const computedAssetHash = await sha3_384_b64u(assetBytes);\n if (computedAssetHash !== reveal.assetHash) {\n return { valid: false, error: 'Asset hash does not match reveal' };\n }\n \n // Reconstruct commitment hash\n const salt = b64uDecode(reveal.salt);\n const publicKeyBytes = b64uDecode(commitment.creatorPublicKey);\n \n const preimage = new Uint8Array(assetBytes.length + salt.length + publicKeyBytes.length);\n preimage.set(assetBytes, 0);\n preimage.set(salt, assetBytes.length);\n preimage.set(publicKeyBytes, assetBytes.length + salt.length);\n \n const computedCommitmentHash = await sha3_384_b64u(preimage);\n \n if (computedCommitmentHash !== commitment.commitmentHash) {\n return { valid: false, error: 'Commitment hash does not match reveal' };\n }\n \n return { valid: true };\n}\n\n// ============================================================================\n// ============================================================================\n// SHA3-384 HASHING (PQC Compliant)\n// ============================================================================\n// All SHA3-384 operations use the WASM module - no external dependencies required\n\n// Import SHA3-384 functions from WASM\nconst wasm_sha3_384_bytes = (wasmPkg as any).sha3_384_hash as ((data: Uint8Array) => string) | undefined;\nconst wasm_sha3_384_string = (wasmPkg as any).sha3_384_hash_string as ((data: string) => string) | undefined;\nconst wasm_sha3_384_bytes_b64u = (wasmPkg as any).sha3_384_hash_b64u as ((data: Uint8Array) => string) | undefined;\nconst wasm_sha3_384_string_b64u = (wasmPkg as any).sha3_384_hash_string_b64u as ((data: string) => string) | undefined;\nconst wasm_sha3_384_truncated = (wasmPkg as any).sha3_384_hash_truncated_32 as ((data: Uint8Array) => string) | undefined;\n\n/**\n * SHA3-384 Hash Result\n */\nexport interface Sha3HashResult {\n /** 96-character lowercase hex string (48 bytes) */\n hex: string;\n /** 64-character base64url string (no padding) */\n b64u: string;\n}\n\n/**\n * Compute SHA3-384 hash of raw bytes.\n * Returns both hex and base64url encodings.\n * \n * @example\n * ```typescript\n * const data = new TextEncoder().encode('hello');\n * const { hex, b64u } = await sha3_384(data);\n * // hex = \"720aea11019ef06440fbf05d87aa24680a2153df3907b2...\" (96 chars)\n * // b64u = \"cgrqEQGe8GRA-_BdOKokaDCAoVPfOQe...\" (64 chars)\n * ```\n */\nexport async function sha3_384(data: Uint8Array): Promise<Sha3HashResult> {\n await initWasm();\n if (!wasm_sha3_384_bytes || !wasm_sha3_384_bytes_b64u) {\n throw new Error('SHA3-384 WASM functions not available - ensure WASM module is initialized');\n }\n return {\n hex: wasm_sha3_384_bytes(data),\n b64u: wasm_sha3_384_bytes_b64u(data),\n };\n}\n\n/**\n * Compute SHA3-384 hash of a UTF-8 string.\n * Returns both hex and base64url encodings.\n * \n * @example\n * ```typescript\n * const { hex, b64u } = await sha3_384_string('hello world');\n * ```\n */\nexport async function sha3_384_string(data: string): Promise<Sha3HashResult> {\n await initWasm();\n if (!wasm_sha3_384_string || !wasm_sha3_384_string_b64u) {\n throw new Error('SHA3-384 WASM functions not available - ensure WASM module is initialized');\n }\n return {\n hex: wasm_sha3_384_string(data),\n b64u: wasm_sha3_384_string_b64u(data),\n };\n}\n\n/**\n * Compute SHA3-384 hash truncated to 32 bytes (for EVM bytes32 compatibility).\n * Uses the first 32 bytes of the full 48-byte hash.\n * \n * @example\n * ```typescript\n * const hex32 = await sha3_384_truncated32(data);\n * // Returns 64-char hex string suitable for Ethereum bytes32\n * ```\n */\nexport async function sha3_384_truncated32(data: Uint8Array): Promise<string> {\n await initWasm();\n if (!wasm_sha3_384_truncated) {\n throw new Error('SHA3-384 truncation WASM function not available');\n }\n return wasm_sha3_384_truncated(data);\n}\n\n/**\n * Compute SHA3-384 hash with base64url output (internal helper, also exported for convenience).\n * This is the 64-character base64url encoding of the 48-byte hash.\n */\nasync function sha3_384_b64u(data: Uint8Array): Promise<string> {\n const result = await sha3_384(data);\n return result.b64u;\n}\n\n// ============================================================================\n// ALGORITHMIC OPTIMIZATIONS (arXiv:2501.02305, arXiv:2504.17033)\n// ============================================================================\n// High-performance data structures for verification operations\n\n// WASM bindings for algorithm functions\nconst wasm_create_nonce_cache = (wasmPkg as any).create_nonce_cache as (capacity: number, ttl_ms: number) => string;\nconst wasm_nonce_cache_info = (wasmPkg as any).nonce_cache_info as () => string;\nconst wasm_sssp_config = (wasmPkg as any).sssp_config as (nodes: number) => string;\nconst wasm_provenance_path_config = (wasmPkg as any).provenance_path_config as (chain_length: number, branches: number) => string;\nconst wasm_elastic_hash_config = (wasmPkg as any).elastic_hash_config as (capacity: number, load_factor: number) => string;\n\n/**\n * Nonce Cache Configuration\n * Uses Elastic Hashing (arXiv:2501.02305) for O(1) amortized lookup\n */\nexport interface NonceCacheConfig {\n type: string;\n capacity: number;\n ttl_ms: number;\n algorithm: string;\n complexity: string;\n}\n\n/**\n * Create a nonce cache configuration for replay attack prevention.\n * Based on Elastic Hashing - O(1) amortized, O(log(1/δ)) worst-case.\n * \n * @param capacity - Maximum number of nonces to track\n * @param ttlMs - Time-to-live in milliseconds before nonces expire\n */\nexport async function createNonceCacheConfig(capacity: number, ttlMs: number): Promise<NonceCacheConfig> {\n await initWasm();\n return JSON.parse(wasm_create_nonce_cache(capacity, ttlMs));\n}\n\n/**\n * Get information about the nonce cache algorithm.\n */\nexport async function getNonceCacheInfo(): Promise<{\n name: string;\n paper: string;\n probe_complexity: string;\n load_factor: number;\n features: string[];\n}> {\n await initWasm();\n return JSON.parse(wasm_nonce_cache_info());\n}\n\n/**\n * SSSP (Single-Source Shortest Path) Configuration\n * Uses Frontier-Reduced algorithm (arXiv:2504.17033)\n */\nexport interface SSSPConfig {\n name: string;\n paper: string;\n complexity: string;\n nodes: number;\n pivots_k: number;\n batch_t: number;\n use_cases: string[];\n}\n\n/**\n * Get optimal SSSP configuration for graph verification.\n * Uses Frontier-Reduced SSSP - O(m × log^(2/3)(n)) complexity.\n * \n * @param nodes - Expected number of nodes in the graph\n */\nexport async function getSSSPConfig(nodes: number): Promise<SSSPConfig> {\n await initWasm();\n return JSON.parse(wasm_sssp_config(nodes));\n}\n\n/**\n * Provenance Path Configuration\n * Optimized parameters for chain of custody verification\n */\nexport interface ProvenancePathConfig {\n algorithm: string;\n chain_length: number;\n branches: number;\n estimated_nodes: number;\n estimated_edges: number;\n pivots_k: number;\n batch_t: number;\n complexity: string;\n verification_mode: string;\n}\n\n/**\n * Get optimized configuration for provenance chain verification.\n * \n * @param chainLength - Number of blocks in the provenance chain\n * @param branches - Average number of branches per block\n */\nexport async function getProvenancePathConfig(chainLength: number, branches: number): Promise<ProvenancePathConfig> {\n await initWasm();\n return JSON.parse(wasm_provenance_path_config(chainLength, branches));\n}\n\n/**\n * Elastic Hash Configuration\n * High-performance hash table for key caching\n */\nexport interface ElasticHashConfig {\n algorithm: string;\n paper: string;\n capacity: number;\n load_factor: number;\n levels: number;\n probe_complexity: {\n amortized: string;\n worst_case: string;\n };\n use_cases: string[];\n}\n\n/**\n * Get elastic hash table configuration for key caching.\n * Optimal for PQC public key caching with O(1) amortized lookups.\n * \n * @param capacity - Maximum number of entries\n * @param loadFactor - Target load factor (0.0 to 1.0, recommend 0.95)\n */\nexport async function getElasticHashConfig(capacity: number, loadFactor: number = 0.95): Promise<ElasticHashConfig> {\n await initWasm();\n return JSON.parse(wasm_elastic_hash_config(capacity, loadFactor));\n}\n\n// ============================================================================\n// CROSS-CHAIN ANCHORING (Roadmap M8)\n// ============================================================================\n// Merkle root submission to Ethereum, Bitcoin, and L2s for timestamping\n\n// WASM bindings for anchoring functions\nconst wasm_anchor_chains_info = (wasmPkg as any).anchor_chains_info as () => string;\nconst wasm_create_accumulator_leaf = (wasmPkg as any).create_accumulator_leaf as (userId: string, chainId: string, blockHash: string, blockIndex: bigint) => string;\nconst wasm_create_accumulator_leaf_with_alg = (wasmPkg as any).create_accumulator_leaf_with_alg as (userId: string, chainId: string, blockHash: string, blockIndex: bigint, hashAlg: string) => string;\nconst wasm_compute_merkle_root = (wasmPkg as any).compute_merkle_root as (leavesJson: string, hashAlg: string) => string;\nconst wasm_generate_evm_anchor_calldata = (wasmPkg as any).generate_evm_anchor_calldata as (rootHex: string, epoch: bigint) => string;\nconst wasm_generate_bitcoin_anchor_payload = (wasmPkg as any).generate_bitcoin_anchor_payload as (rootHex: string, epoch: bigint) => string;\nconst wasm_decode_bitcoin_anchor_payload = (wasmPkg as any).decode_bitcoin_anchor_payload as (payloadHex: string) => string;\nconst wasm_truncate_to_bytes32 = (wasmPkg as any).truncate_to_bytes32 as (hashHex: string) => string;\nconst wasm_anchor_config_info = (wasmPkg as any).anchor_config_info as () => string;\n\n/**\n * Supported blockchain chains for anchoring\n */\nexport interface AnchorChainInfo {\n id: string;\n name: string;\n chain_id?: number;\n type: 'evm' | 'evm_l2' | 'bitcoin';\n contract?: string;\n method?: string;\n payload_size?: number;\n}\n\n/**\n * Get information about supported anchor chains\n */\nexport async function getAnchorChainsInfo(): Promise<{ chains: AnchorChainInfo[] }> {\n await initWasm();\n return JSON.parse(wasm_anchor_chains_info());\n}\n\n/**\n * Accumulator leaf representing a chain's current state\n */\nexport interface AccumulatorLeaf {\n user_id: string;\n chain_id: string;\n block_hash: string;\n block_index: number;\n timestamp: number;\n leaf_hash: string;\n hash_alg?: string;\n}\n\n/**\n * Create a Merkle accumulator leaf for a chain state.\n * This is the fundamental unit for batching chain updates into super-roots.\n * \n * @param userId - User ID (64 hex chars)\n * @param chainId - Chain identifier within user's chains\n * @param blockHash - Hash of the latest block (64 hex chars)\n * @param blockIndex - Block height/index (number or bigint)\n * @param hashAlg - Hash algorithm for leaf hash ('sha256' or 'sha3-384')\n * @throws Error if inputs are invalid\n */\nexport async function createAccumulatorLeaf(\n userId: string,\n chainId: string,\n blockHash: string,\n blockIndex: number | bigint,\n hashAlg: 'sha256' | 'sha3-384' = 'sha3-384'\n): Promise<AccumulatorLeaf> {\n await initWasm();\n \n // Input validation with helpful error messages\n if (typeof userId !== 'string' || userId.length !== 64) {\n throw new Error(`Invalid userId: must be 64 hex characters (got ${typeof userId === 'string' ? userId.length : typeof userId})`);\n }\n if (!/^[0-9a-fA-F]{64}$/.test(userId)) {\n throw new Error('Invalid userId: must contain only hex characters (0-9, a-f, A-F)');\n }\n \n if (typeof chainId !== 'string' || chainId.length === 0) {\n throw new Error('Invalid chainId: must be a non-empty string');\n }\n \n if (typeof blockHash !== 'string' || blockHash.length !== 64) {\n throw new Error(`Invalid blockHash: must be 64 hex characters (got ${typeof blockHash === 'string' ? blockHash.length : typeof blockHash})`);\n }\n if (!/^[0-9a-fA-F]{64}$/.test(blockHash)) {\n throw new Error('Invalid blockHash: must contain only hex characters (0-9, a-f, A-F)');\n }\n \n // Convert blockIndex to bigint (WASM expects bigint for u64)\n let indexBigInt: bigint;\n if (typeof blockIndex === 'bigint') {\n indexBigInt = blockIndex;\n } else if (typeof blockIndex === 'number') {\n if (!Number.isInteger(blockIndex) || blockIndex < 0) {\n throw new Error('Invalid blockIndex: must be a non-negative integer');\n }\n if (!Number.isSafeInteger(blockIndex)) {\n throw new Error('Invalid blockIndex: number exceeds MAX_SAFE_INTEGER; use bigint instead');\n }\n indexBigInt = BigInt(blockIndex);\n } else {\n throw new Error(`Invalid blockIndex: must be a number or bigint (got ${typeof blockIndex})`);\n }\n \n if (indexBigInt < 0n) {\n throw new Error('Invalid blockIndex: must be non-negative');\n }\n \n try {\n const result = typeof wasm_create_accumulator_leaf_with_alg === 'function'\n ? wasm_create_accumulator_leaf_with_alg(userId, chainId, blockHash, indexBigInt, hashAlg)\n : wasm_create_accumulator_leaf(userId, chainId, blockHash, indexBigInt);\n const parsed = JSON.parse(result);\n if (parsed.error) {\n throw new Error(parsed.error);\n }\n return parsed;\n } catch (e) {\n if (e instanceof Error) {\n // Re-throw our validation errors\n if (e.message.startsWith('Invalid ')) {\n throw e;\n }\n // Wrap WASM errors\n throw new Error(`WASM error in createAccumulatorLeaf: ${e.message}`);\n }\n throw new Error(`Unknown error in createAccumulatorLeaf: ${String(e)}`);\n }\n}\n\n/**\n * Merkle root computation result\n */\nexport interface MerkleRootResult {\n root: string;\n leaf_count: number;\n hash_alg: string;\n}\n\n/**\n * Compute Merkle root from an array of leaf hashes.\n * \n * @param leaves - Array of hex hash strings\n * @param hashAlg - Hash algorithm (defaults to 'sha3-384' for PQC compliance)\n */\nexport async function computeMerkleRoot(\n leaves: string[],\n hashAlg: 'sha3-384' = 'sha3-384'\n): Promise<MerkleRootResult> {\n await initWasm();\n return JSON.parse(wasm_compute_merkle_root(JSON.stringify(leaves), hashAlg));\n}\n\n/**\n * EVM anchor calldata for AnchorRegistry contract\n */\nexport interface EvmAnchorCalldata {\n calldata: string;\n root: string;\n epoch: number;\n method: string;\n selector: string;\n}\n\n/**\n * Generate EVM calldata for AnchorRegistry.anchor(bytes32, uint256).\n * Ready to use in an Ethereum transaction.\n * \n * @param rootHex - 32-byte Merkle root (64 hex chars, with or without 0x prefix)\n * @param epoch - Epoch number (number or bigint)\n */\nexport async function generateEvmAnchorCalldata(\n rootHex: string,\n epoch: number | bigint\n): Promise<EvmAnchorCalldata> {\n await initWasm();\n let epochBigInt: bigint;\n if (typeof epoch === 'bigint') {\n epochBigInt = epoch;\n } else {\n if (!Number.isInteger(epoch) || epoch < 0) {\n throw new Error('Invalid epoch: must be a non-negative integer');\n }\n if (!Number.isSafeInteger(epoch)) {\n throw new Error('Invalid epoch: number exceeds MAX_SAFE_INTEGER; use bigint instead');\n }\n epochBigInt = BigInt(epoch);\n }\n return JSON.parse(wasm_generate_evm_anchor_calldata(rootHex, epochBigInt));\n}\n\n/**\n * Bitcoin OP_RETURN anchor payload\n */\nexport interface BitcoinAnchorPayload {\n payload_hex: string;\n payload_size: number;\n magic: string;\n epoch: number;\n root: string;\n}\n\n/**\n * Generate Bitcoin OP_RETURN payload for anchoring.\n * 45 bytes: \"MTARA\" (5) + epoch (8) + root32 (32)\n * \n * @param rootHex - 32-byte Merkle root (64 hex chars)\n * @param epoch - Epoch number (number or bigint)\n */\nexport async function generateBitcoinAnchorPayload(\n rootHex: string,\n epoch: number | bigint\n): Promise<BitcoinAnchorPayload> {\n await initWasm();\n let epochBigInt: bigint;\n if (typeof epoch === 'bigint') {\n epochBigInt = epoch;\n } else {\n if (!Number.isInteger(epoch) || epoch < 0) {\n throw new Error('Invalid epoch: must be a non-negative integer');\n }\n if (!Number.isSafeInteger(epoch)) {\n throw new Error('Invalid epoch: number exceeds MAX_SAFE_INTEGER; use bigint instead');\n }\n epochBigInt = BigInt(epoch);\n }\n return JSON.parse(wasm_generate_bitcoin_anchor_payload(rootHex, epochBigInt));\n}\n\n/**\n * Decoded Bitcoin anchor payload\n */\nexport interface DecodedBitcoinPayload {\n magic: string;\n epoch: number;\n root: string;\n}\n\n/**\n * Decode a Bitcoin OP_RETURN anchor payload.\n * \n * @param payloadHex - Hex-encoded payload bytes\n */\nexport async function decodeBitcoinAnchorPayload(\n payloadHex: string\n): Promise<DecodedBitcoinPayload> {\n await initWasm();\n return JSON.parse(wasm_decode_bitcoin_anchor_payload(payloadHex));\n}\n\n/**\n * Truncation result for SHA3-384 to bytes32\n */\nexport interface TruncationResult {\n original: string;\n original_bytes: number;\n truncated: string;\n truncated_bytes: number;\n}\n\n/**\n * Truncate a hash to 32 bytes for EVM compatibility.\n * Used when anchoring SHA3-384 hashes to Ethereum.\n * \n * @param hashHex - Hash to truncate (with or without 0x prefix)\n */\nexport async function truncateToBytes32(hashHex: string): Promise<TruncationResult> {\n await initWasm();\n return JSON.parse(wasm_truncate_to_bytes32(hashHex));\n}\n\n/**\n * Anchor configuration and estimates\n */\nexport interface AnchorConfigInfo {\n accumulator: {\n max_leaves_per_epoch: number;\n hash_algorithms: string[];\n default_hash: string;\n };\n ethereum: {\n contract: string;\n function: string;\n selector: string;\n estimated_gas: number;\n calldata_size: number;\n };\n bitcoin: {\n method: string;\n magic: string;\n payload_size: number;\n estimated_fee_sats: number;\n };\n recommended_schedule: {\n production: string;\n high_frequency: string;\n };\n}\n\n/**\n * Get anchor configuration and gas/fee estimates.\n */\nexport async function getAnchorConfigInfo(): Promise<AnchorConfigInfo> {\n await initWasm();\n return JSON.parse(wasm_anchor_config_info());\n}\n"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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AAI,CAAC,KAAK,CAAC,oCAAoC,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;AAC/E;AAWA;;;;AAIG;AACI,eAAe,0BAA0B,CAC9C,UAAkB,EAAA;IAElB,MAAM,QAAQ,EAAE;IAChB,OAAO,IAAI,CAAC,KAAK,CAAC,kCAAkC,CAAC,UAAU,CAAC,CAAC;AACnE;AAYA;;;;;AAKG;AACI,eAAe,iBAAiB,CAAC,OAAe,EAAA;IACrD,MAAM,QAAQ,EAAE;IAChB,OAAO,IAAI,CAAC,KAAK,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC;AACtD;AA8BA;;AAEG;AACI,eAAe,mBAAmB,GAAA;IACvC,MAAM,QAAQ,EAAE;AAChB,IAAA,OAAO,IAAI,CAAC,KAAK,CAAC,uBAAuB,EAAE,CAAC;AAC9C;;;;"}
@@ -206,6 +206,49 @@ export declare function verifyCommitmentReveal(commitment: ProvenanceCommitment,
206
206
  valid: boolean;
207
207
  error?: string;
208
208
  }>;
209
+ /**
210
+ * SHA3-384 Hash Result
211
+ */
212
+ export interface Sha3HashResult {
213
+ /** 96-character lowercase hex string (48 bytes) */
214
+ hex: string;
215
+ /** 64-character base64url string (no padding) */
216
+ b64u: string;
217
+ }
218
+ /**
219
+ * Compute SHA3-384 hash of raw bytes.
220
+ * Returns both hex and base64url encodings.
221
+ *
222
+ * @example
223
+ * ```typescript
224
+ * const data = new TextEncoder().encode('hello');
225
+ * const { hex, b64u } = await sha3_384(data);
226
+ * // hex = "720aea11019ef06440fbf05d87aa24680a2153df3907b2..." (96 chars)
227
+ * // b64u = "cgrqEQGe8GRA-_BdOKokaDCAoVPfOQe..." (64 chars)
228
+ * ```
229
+ */
230
+ export declare function sha3_384(data: Uint8Array): Promise<Sha3HashResult>;
231
+ /**
232
+ * Compute SHA3-384 hash of a UTF-8 string.
233
+ * Returns both hex and base64url encodings.
234
+ *
235
+ * @example
236
+ * ```typescript
237
+ * const { hex, b64u } = await sha3_384_string('hello world');
238
+ * ```
239
+ */
240
+ export declare function sha3_384_string(data: string): Promise<Sha3HashResult>;
241
+ /**
242
+ * Compute SHA3-384 hash truncated to 32 bytes (for EVM bytes32 compatibility).
243
+ * Uses the first 32 bytes of the full 48-byte hash.
244
+ *
245
+ * @example
246
+ * ```typescript
247
+ * const hex32 = await sha3_384_truncated32(data);
248
+ * // Returns 64-char hex string suitable for Ethereum bytes32
249
+ * ```
250
+ */
251
+ export declare function sha3_384_truncated32(data: Uint8Array): Promise<string>;
209
252
  /**
210
253
  * Nonce Cache Configuration
211
254
  * Uses Elastic Hashing (arXiv:2501.02305) for O(1) amortized lookup
@@ -355,9 +398,9 @@ export interface MerkleRootResult {
355
398
  * Compute Merkle root from an array of leaf hashes.
356
399
  *
357
400
  * @param leaves - Array of hex hash strings
358
- * @param hashAlg - Hash algorithm ('sha256' or 'sha3-384')
401
+ * @param hashAlg - Hash algorithm (defaults to 'sha3-384' for PQC compliance)
359
402
  */
360
- export declare function computeMerkleRoot(leaves: string[], hashAlg?: 'sha256' | 'sha3-384'): Promise<MerkleRootResult>;
403
+ export declare function computeMerkleRoot(leaves: string[], hashAlg?: 'sha3-384'): Promise<MerkleRootResult>;
361
404
  /**
362
405
  * EVM anchor calldata for AnchorRegistry contract
363
406
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAmBA,MAAM,WAAW,YAAY;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,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AAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAGlF;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE;QACX,oBAAoB,EAAE,MAAM,CAAC;QAC7B,eAAe,EAAE,MAAM,EAAE,CAAC;QAC1B,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,QAAQ,EAAE;QACR,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;QACjB,aAAa,EAAE,MAAM,CAAC;QACtB,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,OAAO,EAAE;QACP,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;QACd,YAAY,EAAE,MAAM,CAAC;QACrB,kBAAkB,EAAE,MAAM,CAAC;KAC5B,CAAC;IACF,oBAAoB,EAAE;QACpB,UAAU,EAAE,MAAM,CAAC;QACnB,cAAc,EAAE,MAAM,CAAC;KACxB,CAAC;CACH;AAED;;GAEG;AACH,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAGrE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maatara/core-pqc",
3
- "version": "0.4.5",
3
+ "version": "0.5.0",
4
4
  "description": "Ma'atara Post-Quantum Cryptography Toolkit for Browser and Node.js",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -29,6 +29,7 @@
29
29
  "pqc",
30
30
  "kyber",
31
31
  "dilithium",
32
+ "sha3",
32
33
  "webassembly",
33
34
  "wasm"
34
35
  ],
@@ -45,6 +46,6 @@
45
46
  "typescript": "^5.9.3"
46
47
  },
47
48
  "dependencies": {
48
- "@maatara/core-pqc-wasm": "^0.4.5"
49
+ "@maatara/core-pqc-wasm": "^0.5.0"
49
50
  }
50
51
  }