-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Address some Client SCA issues #145
Conversation
Currently WIP while the document is discussed and finalized. |
b2913a6
to
853385a
Compare
7c93998
to
7bf9a31
Compare
9d4113a
to
4052f36
Compare
896c503
to
28bb7de
Compare
9f8b88e
to
e37dedd
Compare
66bb45b
to
9b0abbe
Compare
e37dedd
to
af4da2d
Compare
for out_ev in mix_result.output_events: | ||
merkle_tree.set_entry( | ||
out_ev.commitment_address, out_ev.commitment) | ||
new_merkle_root = mix_result.new_merkle_root |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Storing the entire Merkle Tree will be very expensive for the clients (2^{depth + 1} - 1 nodes to store, so if depth is set to 32, the storage requirements for the client will be very important). Instead of storing the full MK tree, the client is only interested in storing the nodes required to generate Merkle authentication paths for the commitments the client user "owns" (i.e.knows the opening for).
This may lead to various SCAs on the client itself, but won't be exploitable at the networking level which is what this PR seems to address
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: this does not need to be addressed on this PR, but is something to be aware of, and document for further iterations on the client.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Noted for future work and documentation.
af4da2d
to
5fb2d1d
Compare
1b9f697
to
4be1c1b
Compare
5fb2d1d
to
5335eb7
Compare
pyClient/commands/constants.py
Outdated
@@ -20,3 +20,5 @@ | |||
|
|||
WALLET_DIR_DEFAULT = "./notes" | |||
WALLET_USERNAME = "zeth" | |||
|
|||
MERKLE_TREE_FILE_DEFAULT = "./merkle_tree" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's be consistent with the naming of the constants:
In the same file you have:
INSTANCEFILE_DEFAULT = "zeth-instance.json"
, ADDRESSFILE_DEFAULT = "zeth-address.json"
(FILE
is concatenated directly without _
), and now you declare MERKLE_TREE_FILE_DEFAULT = "./merkle_tree"
, with a _FILE
.
Let's stick to _FILE
everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, let's use file extensions in order to inform on how the data is stored and should be read (.dat
can be used for generic data files)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Chaged to _FILE_
everywhere, and used .dat
for merkle tree data.
mixer_desc = load_mixer_description_from_ctx(ctx) | ||
zeth_instance = mixer_desc.mixer.instantiate(web3) | ||
null = bytes(32) | ||
merkle_tree = open_merkle_tree(ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
open_merkle_tree
should receive a Context
, so let's switch to Context
instead of Any
in the signature of the ls_commit
function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used Context
everywhere.
pyClient/commands/zeth_ls_notes.py
Outdated
@pass_context | ||
def ls_notes(ctx: Any) -> None: | ||
def ls_notes(ctx: Any, balance: bool, spent: bool) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, Any
should be Context
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(fixed)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @dtebbs. I like the changes you have made to display the balance and the spent notes!
pyClient/test/test_merkle_tree.py
Outdated
from unittest import TestCase | ||
|
||
MERKLE_TREE_TEST_DIR = "_merkle_tests" | ||
MERKLE_TREE_TEST_SIZE = 16 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's rename this constant to be clearer. I imagine that by "size" you mean the nb of leaves, so what about MERKLE_TREE_TEST_LEAVES
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed the constant.
Address some Client SCA issues
Related to #144