{"_id":"@xrplf/mpt-crypto","_rev":"2-5d54ecd6c97fb20e7db5081b3cc3bdb6","name":"@xrplf/mpt-crypto","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@xrplf/mpt-crypto","version":"0.1.0","keywords":["ripple","xrp","xrp ledger","xrpl","mpt","confidential"],"license":"ISC","_id":"@xrplf/mpt-crypto@0.1.0","maintainers":[{"name":"bmollin","email":"brett@xrpl.foundation"},{"name":"transia","email":"dangell@transia.co"},{"name":"shichengripple001","email":"cshi@ripple.com"},{"name":"vjkhannaripple","email":"vraviraj@ripple.com"},{"name":"ripplex-automation","email":"ripplegithub@ripple.com"}],"homepage":"https://github.com/XRPLF/xrpl.js/tree/main/packages/mpt-crypto#readme","bugs":{"url":"https://github.com/XRPLF/xrpl.js/issues"},"dist":{"shasum":"3134b93d9cabbd5614a7802826b2bdeb4a6ffc59","tarball":"https://registry.npmjs.org/@xrplf/mpt-crypto/-/mpt-crypto-0.1.0.tgz","fileCount":70,"integrity":"sha512-RlpuUqvx0aigBfBXEHkifTIBNEFSVxvfTxuqiwv5q/tJiAwH7R8gjfXF5CnIdIMgPzI1bT6Rr2WjC208QV3aPg==","signatures":[{"sig":"MEQCIFCEkwkoTCaYyyZ5CONF1CyJEWu86gh14/jZ2fOyLuCHAiAoul3oSkzGhARAWY/7cV/+aWi1VnWHzysa4x786Lb4ig==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":2488520},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">= 18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/esm/index.js","browser":"./dist/esm/index.js","default":"./dist/index.js","require":"./dist/index.js"},"./wasm":{"import":"./wasm/mpt_crypto.mjs","browser":"./wasm/mpt_crypto.mjs","default":"./wasm/mpt_crypto.js","require":"./wasm/mpt_crypto.js"}},"gitHead":"5a283fff6d8e401c16a348caa9890d3e90aeaca7","scripts":{"lint":"eslint . --max-warnings 0","test":"jest --passWithNoTests --verbose false --silent=false ./test/*.test.ts","build":"tsc --build tsconfig.build.json && tsc -p tsconfig.esm.json && node scripts/finalize-esm.js","clean":"rm -rf ./dist ./coverage tsconfig.build.tsbuildinfo","fetch:wasm":"bash scripts/fetch-wasm.sh"},"_npmUser":{"name":"ripplex-automation","email":"ripplegithub@ripple.com"},"prettier":"@xrplf/prettier-config","repository":{"url":"git+ssh://git@github.com/XRPLF/xrpl.js.git","type":"git"},"_npmVersion":"10.9.3","description":"Confidential MPT (XLS-0096) cryptographic primitives for the XRP Ledger, compiled to WebAssembly","directories":{},"_nodeVersion":"22.18.0","publishConfig":{"access":"public","provenance":true},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/mpt-crypto_0.1.0_1786893981317_0.5922638578887676","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@xrplf/mpt-crypto","version":"0.1.1","description":"Confidential MPT (XLS-0096) cryptographic primitives for the XRP Ledger, compiled to WebAssembly","main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","browser":"./dist/esm/index.js","import":"./dist/esm/index.js","require":"./dist/index.js","default":"./dist/index.js"},"./wasm":{"browser":"./wasm/mpt_crypto.web.mjs","import":"./wasm/mpt_crypto.mjs","require":"./wasm/mpt_crypto.js","default":"./wasm/mpt_crypto.js"}},"license":"ISC","keywords":["ripple","xrp","xrp ledger","xrpl","mpt","confidential"],"repository":{"type":"git","url":"git+ssh://git@github.com/XRPLF/xrpl.js.git"},"bugs":{"url":"https://github.com/XRPLF/xrpl.js/issues"},"homepage":"https://github.com/XRPLF/xrpl.js/tree/main/packages/mpt-crypto#readme","publishConfig":{"access":"public","provenance":true},"scripts":{"build":"tsc --build tsconfig.build.json && tsc -p tsconfig.esm.json && node scripts/finalize-esm.js","fetch:wasm":"bash scripts/fetch-wasm.sh","test":"jest --passWithNoTests --verbose false --silent=false ./test/*.test.ts","lint":"eslint . --max-warnings 0","clean":"rm -rf ./dist ./coverage tsconfig.build.tsbuildinfo"},"prettier":"@xrplf/prettier-config","engines":{"node":">= 18"},"_id":"@xrplf/mpt-crypto@0.1.1","_integrity":"sha512-Wv9wbk60DRGWvI+B9DITwfWygCWDfEjv8yWxiLJyDf/G8UPkfhVlUKIflF9nMaBFMygPRkXrpO1jNqTj6/vJow==","_resolved":"/home/runner/work/xrpl.js/xrpl.js/dist/xrplf-mpt-crypto-0.1.1.tgz","_from":"file:xrplf-mpt-crypto-0.1.1.tgz","_nodeVersion":"20.20.2","_npmVersion":"11.6.0","dist":{"integrity":"sha512-Wv9wbk60DRGWvI+B9DITwfWygCWDfEjv8yWxiLJyDf/G8UPkfhVlUKIflF9nMaBFMygPRkXrpO1jNqTj6/vJow==","shasum":"f0416ca9a064a11cd777d29f76c6e9c021699c2a","tarball":"https://registry.npmjs.org/@xrplf/mpt-crypto/-/mpt-crypto-0.1.1.tgz","fileCount":70,"unpackedSize":2489818,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@xrplf%2fmpt-crypto@0.1.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCVWHkjieehiZ6G8MzmYgGk5hbNrU2vM9Ggq/kdf3evuwIhAOANSOyhIOq6wVNYuJZOIMXyXm+jFlhCFm3bF41U23SF"}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:237eb872-0292-4e72-bdfe-f08145490d3b"}},"directories":{},"maintainers":[{"name":"bmollin","email":"brett@xrpl.foundation"},{"name":"transia","email":"dangell@transia.co"},{"name":"shichengripple001","email":"cshi@ripple.com"},{"name":"vjkhannaripple","email":"vraviraj@ripple.com"},{"name":"ripplex-automation","email":"ripplegithub@ripple.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/mpt-crypto_0.1.1_1787598011769_0.5252630951065276"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-16T15:26:21.191Z","modified":"2026-08-24T19:00:12.336Z","0.1.0":"2026-08-16T15:26:21.497Z","0.1.1":"2026-08-24T19:00:11.994Z"},"bugs":{"url":"https://github.com/XRPLF/xrpl.js/issues"},"license":"ISC","homepage":"https://github.com/XRPLF/xrpl.js/tree/main/packages/mpt-crypto#readme","keywords":["ripple","xrp","xrp ledger","xrpl","mpt","confidential"],"repository":{"type":"git","url":"git+ssh://git@github.com/XRPLF/xrpl.js.git"},"description":"Confidential MPT (XLS-0096) cryptographic primitives for the XRP Ledger, compiled to WebAssembly","maintainers":[{"name":"bmollin","email":"brett@xrpl.foundation"},{"name":"transia","email":"dangell@transia.co"},{"name":"shichengripple001","email":"cshi@ripple.com"},{"name":"vjkhannaripple","email":"vraviraj@ripple.com"},{"name":"ripplex-automation","email":"ripplegithub@ripple.com"}],"readme":"# @xrplf/mpt-crypto\n\nCryptographic primitives for **Confidential MPT (XLS-0096)** on the XRP Ledger,\nexposed as a small **hex-in / hex-out** TypeScript API over a vendored\nWebAssembly build of the reference C crypto library.\n\nThis package ships as a dependency of `xrpl`, but it is **lazily loaded**: the\n[`xrpl/confidential`](../xrpl/src/confidential) builders reach it through a\ndynamic import, so bundlers code-split its ~2 MB WASM into a separate chunk and\napps that never assemble a Confidential MPT transaction never load it. You\ntypically interact with those builders rather than calling this package directly.\n\n## What it provides\n\nConfidential MPT replaces a public MPT balance with **EC-ElGamal ciphertexts**\non-ledger and uses **zero-knowledge proofs** so validators can verify transfers\n(no overdraft, amounts conserved) without seeing the amounts. This package\nexposes the building blocks:\n\n- **Encryption** — `encryptAmount`, `decryptAmount` (EC-ElGamal over secp256k1).\n- **Commitments** — `getPedersenCommitment`, `generateBlindingFactor`.\n- **Context hashes** — `getConvertContextHash`, `getConvertBackContextHash`,\n  `getSendContextHash`, `getClawbackContextHash`. Each binds a proof to a\n  specific transaction (account, issuance, sequence, …).\n- **Proofs** — `getConvertProof`, `getConvertBackProof`,\n  `getConfidentialSendProof`, `getClawbackProof`.\n- **Constants** — the fixed byte sizes (`PUBKEY_SIZE`, `ELGAMAL_TOTAL_SIZE`, the\n  per-transaction proof sizes, …) and the `bytesToHex` / `hexToBytes` helpers.\n\n## Conventions\n\n- Every byte argument and return value is an **uppercase, even-length hex\n  string** with no `0x` prefix (matching the rest of `xrpl.js`).\n- Integer amounts are **`bigint`**, to losslessly carry the full `uint64_t`\n  range.\n- Keys are a **secp256k1 keypair** (32-byte private key, 33-byte compressed\n  public key) — the same curve as a secp256k1 signing key, but a distinct key\n  used only for encryption. Generate one with `ripple-keypairs`\n  (`deriveKeypair(generateSeed({ algorithm: 'ecdsa-secp256k1' }))`).\n- The WASM module is loaded once and cached on first use, so depending on this\n  package costs nothing until a confidential operation is actually invoked.\n\n## Usage\n\n```ts\nimport {\n  encryptAmount,\n  decryptAmount,\n  generateBlindingFactor,\n} from '@xrplf/mpt-crypto'\n\nconst blinding = await generateBlindingFactor()\nconst ciphertext = await encryptAmount(1000n, publicKey, blinding)\n// `rangeHigh` bounds the discrete-log search; decryption recovers any amount in\n// [0, rangeHigh]. Pass the tightest correct bound you know (e.g. the issuance's\n// outstanding confidential amount) — cost scales with it.\nconst amount = await decryptAmount(ciphertext, privateKey, 10_000n) // 1000n\n```\n\n## The vendored WASM\n\n`wasm/mpt_crypto.{js,mjs,wasm}` is an Emscripten build of the reference\n`mpt-crypto` C library ([`XRPLF/mpt-crypto`](https://github.com/XRPLF/mpt-crypto)),\nthe same library `rippled` links. A single `.wasm` is wrapped by three glues built\nfrom it — `mpt_crypto.js` (CommonJS, for Node / `require`), `mpt_crypto.mjs` (ES\nmodule, for Node / `import`), and `mpt_crypto.web.mjs` (ES module with no `node:`\nimports, for bundlers / browsers) — so the module loads in every environment.\n\nThe exact `mpt-crypto` release these are built from is pinned in\n[`MPT_CRYPTO_VERSION`](./MPT_CRYPTO_VERSION). The npm release pipeline downloads\nthat release's WASM bundle and vendors it into `wasm/` before publishing (via\n[`scripts/fetch-wasm.sh`](./scripts/fetch-wasm.sh)), so the published package\nalways carries the exact WASM for the pinned tag — never fetched at the\nconsumer's install time.\n\n**The pinned version must stay in lockstep with the `mpt-crypto` version that\n`rippled` pins** — a mismatch produces valid-looking transactions that `rippled`\nrejects with `tecBAD_PROOF`. To update:\n\n1. Find the version `rippled` pins in its `conanfile.py` (e.g. `mpt-crypto/1.0.2`).\n2. Set that tag in [`MPT_CRYPTO_VERSION`](./MPT_CRYPTO_VERSION).\n3. Run `npm run fetch:wasm` to vendor the matching WASM locally (the release\n   pipeline does the same automatically).\n\n`fetch-wasm.sh` verifies the bundle's `SHA256SUMS` manifest when the release\nships one; integrity of the published npm package is further covered by the npm\npackage hash.\n","readmeFilename":"README.md"}