MPT-Crypto is a specialized C library implementing the cryptographic building blocks for
Confidential Multi-Purpose Tokens (MPT) on the XRP Ledger. It provides implementations of homomorphic encryption, aggregated range proofs, and specialized zero-knowledge proofs.
The library is built on top of libsecp256k1 for elliptic curve arithmetic and OpenSSL for hashing and randomness.
- Additive Homomorphic Encryption: Enables the ledger to aggregate encrypted balances (e.g.,
Enc(A) + Enc(B) = Enc(A+B)) without decryption. - Canonical Zero: Deterministic encryption of zero balances to prevent ledger state bloat and ensure consistency.
-
Aggregated Proofs: Supports proving that
$m$ values are within the range$[0, 2^{64})$ in a single proof with logarithmic size$\mathcal{O}(\log n)$ . - Inner Product Argument (IPA): Implements the standard Bulletproofs IPA for succinct verification.
- Fiat-Shamir: Secure non-interactive challenge generation with strict domain separation.
- Compact AND-Composed Sigma Proofs: Proves ciphertext equality, Pedersen commitment linkage, and balance ownership under a single Fiat-Shamir challenge. Three variants cover the standard send, convert-back, and clawback transaction types.
- Proof of Knowledge (PoK): Proves ownership of the secret key during account registration to prevent rogue key attacks.
Before building, ensure you have the following installed:
- CMake (version 3.10 or higher)
- C Compiler (GCC, Clang, or AppleClang)
On macOS with Homebrew:
brew install cmakeOn Ubuntu/Debian:
sudo apt-get install cmake build-essentialSet up Conan using rippled's BUILD.md.
Dependency revisions are pinned via a Conan lockfile (conan.lock) at the repository root; Conan picks it up implicitly on conan install. To regenerate after editing conanfile.py, run ./conan/lockfile/regenerate.sh from the repo root. The pattern mirrors rippled's conan/lockfile/.
Run following commands to build the library
-
Create build directory:
mkdir build && cd build
-
Buld dependencies:
conan install .. --build=missing -o "&:tests=True" -
Run CMake:
cmake .. \ -DCMAKE_BUILD_TYPE=Release \ -G Ninja \ -DCMAKE_TOOLCHAIN_FILE:FILEPATH=build/generators/conan_toolchain.cmake
-
Build the library and tests:
ninja
After building, run the test suite using CTest from the build directory:
ctest --output-on-failureOr run individual tests directly:
./tests/test_elgamal
./tests/test_bulletproof_agg
./tests/test_commitmentsThe following tests should pass:
test_bulletproof_agg- Aggregated Bulletproof range proofstest_commitments- Pedersen commitmentstest_compact_clawback- Compact sigma proof for clawbacktest_compact_convertback- Compact sigma proof for convert-backtest_compact_standard- Compact sigma proof for standard sendtest_elgamal- ElGamal encryption/decryptiontest_elgamal_verify- ElGamal verificationtest_ipa- Inner Product Argument (IPA) Core Logictest_mpt_utility- End-to-end utility layer (send, convert, convert-back, clawback)test_pok_sk- Proof of knowledge of secret key
Two public documents cover the design choices and integration details:
-
XLS-0096 Standard Specification: XRPL Standards – XLS-0096 The specification covers the protocol design and how it integrates with the XRPL ledger.
-
Research Paper: ePrint 2026/602 The paper provides a deeper dive into the cryptographic design choices and security analysis.
-
Compact Sigma Proof Specification:
paper/cmpt-compact-sigma.pdfFormal specification and security analysis of the compact AND-composed sigma proof for standard EC-ElGamal transfers.