Manual
Note
The mts CLI operates on a CSMT instance. MPF does not currently
have a dedicated CLI.
Demos
Basic Operations
Insert, query, delete keys and get root hash:
Proof Operations
Generate and verify self-contained inclusion proofs:
CLI Usage
The MTS package includes a command-line interface (CLI) tool for interacting with the CSMT tree. The CLI provides commands for adding/removing elements, generating proofs, and verifying membership.
CLI works in interactive mode by default. You can also pass commands directly as stdin as we are doing in this manual.
List of commands
| Command | Description | Arguments | Return value |
|---|---|---|---|
i |
Insert a key-value pair | key, value | |
d |
Delete a key | key | |
q |
Query inclusion proof for a key | key | base64 encoding of the proof |
r |
Get the current root of the CSMT | base64 encoding of the root | |
v |
Verify inclusion proof | proof | Valid or Invalid |
w |
Query value for a key | key | value |
c |
Comment (no operation) |
Basic operations
Setup
Setup the environment variable CSMT_DB_PATH to point to a directory where the CSMT will store its data. For example:
export CSMT_DB_PATH=tmp/demo
rm -rf $CSMT_DB_PATH
Insertion
mts <<$
i key1 value1
q key1
$
AQDjun1C8tTl1kdY1oon8sAQWL86/UMiJyZFswQ9Sf49XQAA
The output is the inclusion proof for key1. It will not change depending on the value associated with the key.
Now the database contains the value for key1, and you can query its inclusion proof at any time.
Verification
mts <<$
v AQDjun1C8tTl1kdY1oon8sAQWL86/UMiJyZFswQ9Sf49XQAA
$
Valid
The proof is self-contained and includes the value hash, so verification doesn't need the value as a separate argument.
Querying
Currently you cannot inspect the keys, but you can ask for the values:
mts <<< 'w key1'
value1
Deletion
You can delete keys as well:
mts <<< 'd key1'
DeletedKey
Now if you try to query for the inclusion proof of key1 again:
mts <<< 'q key1'
NoProofFound
Or if you try to get the value for key1:
mts <<< 'w key1'
KeyNotFound
Getting the root
You can get the current root of the CSMT tree with the r command:
mts <<< 'r'
TreeEmpty
If you insert some keys first:
mts <<$
i key1 value1
r
i key2 value2
r
d key2
r
d key1
r
$
AddedKey
NrJMih3czFriydMUwvFKFK6VYKZYVjKpKGe1WC4e+VU=
AddedKey
jyW/0W96OAsUNpbd+SgA0B/ZjM8zGBOd3xR5Y1iOJOs=
DeletedKey
NrJMih3czFriydMUwvFKFK6VYKZYVjKpKGe1WC4e+VU=
TreeEmpty