Cashu Protocol
website·Indexed 35 days ago
https://docs.cashu.spaceA free and open-source Chaumian ecash protocol built for Bitcoin. Cashu provides digital bearer tokens and an open protocol for developers to build wallets, mints, and other services. Documentation includes details on NUTs, BDHKE, and implementations such as Nutshell (Python) and mintd (Go).
What's inside Cashu
- Cashu is a free and open-source Chaumian ecash protocol integrated with Bitcoin. It implements digital bearer tokens stored on user devices, functioning similarly to physical cash. The system consists of two primary components: the mint and the ecash wallet. Cashu is designed for privacy, security, and scalability, offering instant and nearly free transactions. Because mints do not store databases of user accounts or activity, the system is resistant to data leaks and censorship.
Understand the Cashu Protocol and NUTs specifications
Cashu is an open ecash protocol built for Bitcoin. Because it is an open protocol, any software that follows the specifications is compatible with the rest of the ecosystem. The protocol specifications are defined in the NUTs (Notation, Usage, and Terminology) documents, which are maintained on GitHub.Choose a Cashu mint implementation
Depending on your language preference and requirements, there are several available implementations of Cashu mints:
- Nutshell: The reference mint implementation, written in Python.
- mintd: A mint implementation written in Rust.
- nutmix: A mint implementation written in Go.
Learn about the Cashu protocol and cryptography
Technical resources for understanding the Cashu protocol include explanations of Chaumian Ecash, blinded signatures, and a proof of liabilities scheme for Ecash Mints. A protocol simulation is also available for interactive learning.Explore highlighted Cashu ecosystem projects
The Cashu ecosystem includes various implementations for payments, privacy, and infrastructure. Key projects include:
- Athenut: A privacy-preserving web search engine powered by Kagi and Cashu.
- BTCNutServer: Integration allowing BTCPay Server to accept Bitcoin payments via Cashu tokens.
- hashpool: An accountless mining pool using ecash for mining shares.
- npubcash-server: A server that uses Cashu mints to receive funds via Lightning addresses.
- Numo: A Bitcoin point-of-sale (POS) app for tap-to-pay merchant payments.
- Orchard: A web application dedicated to Cashu mint management.
- Redeem: A tool to redeem Cashu tokens directly to a Lightning wallet without requiring a Cashu wallet.
- routstr: A marketplace for buying and selling LLM APIs using Cashu ecash tokens.
- TollGate: A system to turn Wi-Fi routers into decentralized ISPs using Bitcoin and ecash.
For a comprehensive and up-to-date list of all projects, refer to the awesome-cashu repository.
Understand the role of Cashu Mints
A mint is a Lightning node operator that acts as a custodian for satoshis on the Lightning network and issues corresponding ecash tokens to users.
Key Constraints:
- Non-Interoperability: Tokens are specific to the mint that issued them. You cannot receive tokens from one mint directly into another.
- Inter-Mint Transfers: To move value between mints, you must use 'Multimint Swap' functionality to swap tokens over the Lightning network.
- Trust: Users should only use mints operated by trusted parties or use small amounts.
Create a payment request in Cashu.me
To create a payment request using the Cashu.me interface:
- Navigate to Settings and enable Payment requests (optionally enable 'Claim automatically').
- Go to Receive -> Ecash.
- Select Request to access the Payment Request functionality.
Accept Cashu ecash using trusted mints with delayed melting
In this setup, you accept Cashu ecash as payment if the token is valid, without converting it to Lightning (LN) sats immediately. To implement this safely:
- Validate the token: Ensure it has the correct amount, the correct unit, and originates from one of your trusted mints.
- Swap the token: Always swap the received token before treating the transaction as complete.
- Specify trusted mints: If using NUT-18 Payment Requests, include the trusted mints in the
mfield. - Manage liquidity: Regularly melt tokens to LN sats based on a balance threshold or a set time interval.
- Account for costs: Factor in swap and melt fees in your pricing or accounting.
Accept Cashu ecash from any mint with immediate melting
In this setup, you accept ecash from any mint provided the token is valid and can be successfully melted to LN sats immediately. Key considerations include:
- Validation: Verify the token has the correct unit and the correct amount, which must be the expected LN amount plus a
fee_reserve. - Payment Confirmation: The transaction is only considered successful once the token has been successfully melted.
- Pricing: The UI price for ecash should be calculated as:
Price (LN) + fee_reserve. - Fee Management: If melts fail, the
fee_reservemay be too low and should be increased. To reduce or eliminate LN fees, open LN channels with your trusted mints.
- Validation: Verify the token has the correct unit and the correct amount, which must be the expected LN amount plus a
Donate to Cashu via Bitcoin or Lightning
Cashu is an open-source project funded by donations to cover operational costs, open-source bounties, and events. Support can be provided through three primary methods: on-chain Bitcoin via BTCPay Server, the Lightning Network, or BIP-352 silent payments.On-chain (BTCPay): https://pay.withbitcoin.org/api/v1/invoices?storeId=RbgfGTkSr2o1hxjpAv11L6tzq2DHbztHX8BLrsN6Hmn¤cy=BTC Lightning: https://donate.cashu.space/Implement token signing and redemption using Blind Diffie-Hellmann Key Exchange (BDHKE)
The Cashu protocol uses the Blind Diffie-Hellmann Key Exchange (BDHKE) to allow a mint (Bob) to sign tokens for a user (Alice) without knowing the token's secret. A token consists of the pair
(x, C), wherexis a secret message andCis the unblinded signature.The BDHKE Process:
- Setup: The mint (Bob) publishes a public key
K = kG(wherekis the private key). - Blinding: Alice picks a secret
x, computesY = hash_to_curve(x), and generates a random blinding factorr. She sendsB_ = Y + rGto Bob. - Signing: Bob computes the blinded key
C_ = kB_and sends it back to Alice. - Unblinding: Alice calculates the unblinded key
C = C_ - rK(which simplifies tokY). - Verification: To redeem the token, the holder sends
(x, C)to Bob. Bob verifies the token by checking ifk * hash_to_curve(x) == C. If valid, Bob addsxto the list of spent secrets to prevent double-spending.
// Conceptual BDHKE flow // 1. Mint Setup const K = k * G; // Public key // 2. User Blinding const Y = hash_to_curve(x); const B_ = Y + (r * G); // Send B_ to mint // 3. Mint Signing const C_ = k * B_; // Send C_ to user // 4. User Unblinding const C = C_ - (r * K); const token = { x, C }; // 5. Mint Verification const isValid = (k * hash_to_curve(x)) === C;- Setup: The mint (Bob) publishes a public key
Restore a Cashu wallet from a seed
Wallet restoration is standardized via NUT-13. To restore funds, you must use a wallet that supports seed restoration.
Important Note: There is no automatic discovery mechanism for mints. You must manually save and connect to the specific mints you wish to restore tokens from. Additionally, seeds only recover tokens created after the seed's generation date.