https://github.com/oxarbitrage/zcash-memo-protocol
A specification for ZIP-231
https://github.com/oxarbitrage/zcash-memo-protocol
Last synced: 6 months ago
JSON representation
A specification for ZIP-231
- Host: GitHub
- URL: https://github.com/oxarbitrage/zcash-memo-protocol
- Owner: oxarbitrage
- License: apache-2.0
- Created: 2025-03-12T19:46:20.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-22T18:46:59.000Z (over 1 year ago)
- Last Synced: 2025-07-11T04:39:34.122Z (about 1 year ago)
- Language: TLA
- Size: 132 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# NU7 Memo Bundles Specification
This repository contains a TLA⁺ specification that models a simplified version of the memo bundles functionality for NU7, as proposed in ZIP‑231. The specification illustrates how memo encryption, decryption, and pruning are performed in Orchard-style transactions.
## Overview
The specification consists of three primary processes:
- User Process:
Encrypts a memo by splitting it into fixed-size chunks, padding and encrypting each chunk with a derived encryption key, and then building a transaction that carries:
- The encrypted memo bundle (`v_memo_chunks`)
- Associated metadata including the memo key and a salt (used for key derivation)
- Node Process:
Validates transactions from the transaction pool, then progressively prunes the memo bundle. Pruning is implemented in a loop where, in each iteration, a memo chunk is replaced with a pruned digest. Once all chunks are pruned, the transaction is updated:
- `f_all_pruned` is set to TRUE,
- The `salt_or_hash` is updated with new random data representing an overall digest.
- The `pruned` field is set to a bitfield where each bit is 1.
- Scanner Process:
Scans the blockchain for transactions intended for a specific user, decrypts the memo bundle using the stored memo key and salt (or overall hash), and verifies that the decrypted memo is either the original message (if unpruned) or a partially pruned message.
**Note:**
The cryptographic functions (e.g., EncryptionKey, EncryptMemo, DecryptMemo) are abstracted for modeling purposes and do not capture the full complexity of the actual protocol.
## Files
**[protocol.tla](protocol.tla)**
Contains the main PlusCal specification for the protocol, including the User, Node, and Scanner processes.
A [pdf document](protocol.pdf) is also available.
**[operators.tla](operators.tla)**
Contains helper operators for:
- Random hash generation and basic arithmetic operations,
- Sequence splitting, padding, and manipulation,
- Cryptographic abstractions for key derivation, memo encryption, decryption, and high-level memo processing.
A [pdf document](Operators.pdf) is also available.
## How to Run
- Clone the Repository:
```
git clone https://github.com/oxarbitrage/zcash-memo-protocol.git
cd zcash-memo-protocol
```
- Get the Toolbox and run TLC:
```
wget https://github.com/tlaplus/tlaplus/releases/latest/download/tla2tools.jar
java -cp tla2tools.jar tlc2.TLC -config protocol.cfg protocol.tla
```
Alternatively, you can use the TLA+ Toolbox IDE to open the `protocol.tla` file and run the model checker from there or the [vscode extension](https://marketplace.visualstudio.com/items?itemName=alygin.vscode-tlaplus).
## Properties
- `DecrypedEqOrig`:
- `DecrypedEqPruned1`:
- `DecrypedEqPruned2`:
- `DecrypedEqAllPruned`: