Skip to content
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

Zeroize txs bench #2932

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
Draft

Zeroize txs bench #2932

wants to merge 13 commits into from

Conversation

cbeck88
Copy link
Contributor

@cbeck88 cbeck88 commented Dec 7, 2022

Add a benchmark for zeroizing a max-size Tx

(Actually, this clones and then drops a max-size Tx, with the ZeroizeOnDrop commit)

cbeck88 and others added 12 commits December 6, 2022 16:43
Also makes transaction builder able to generate the tx summary unblinding data.

This fills out the functionality of MCIP 52.

---

The `TxSummaryUnblindingData`, together with the `TxSummary`, can be used
to verify what is happening in the transaction according to the `TxSummary`.

The `TxSummaryVerifier` takes the extended message digest, and the `TxSummary`
and `TxSummaryUnblindingData` in a streaming fashion. Then it produces the verified
`TxSummaryReport` which lists which entities observe which balance changes as a result
of the transaction, as well as the fee and tombstone block of the transaction.

This process also produces the digest which Ring MLSAG are supposed to sign.

Some tests are added which confirm that this checking and verification is working,
and that serialization is working.

---

This PR has a small impact on the `UnsignedTx` object and associated protouf,
but it is not very difficult for downstream to adapt to that.
This is an experimental change to improve hygeine of memory in
the consensus enclave (but also in the clients)

This makes a bunch of objects derive `Zeroize` in transaction-core,
and makes the `Tx` object zeroize itself on drop.

For examples of why this is a good change, consider that, in the
`mc-connection` ThickClient crate, after we serialize a Tx to protobuf
and encrypt it for the enclave, we zeroize the plaintext. However,
before this change, we do not zeroize the `Tx` object (since it
would not have been possible), so another copy of the data that
we zeroized continues to exist in memory. After this change, the
`Tx` will zeroize itself automatically as well.

The main reason not to do this would be if it hurts the performance
of the consensus nodes, but I consider this unlikely, because,
the untrusted side never actually sees `Tx` objects so SCP should
not be meaningfully impacted by this, only the transaction validation
handles the decrypted `Tx`. And the elliptic curve operations done
to validate a Tx should be many orders of magnitude more expensive
than a zeroizing operation. So I expect no measurable performance
difference as a result of this change.

See github issue #2717
@cbeck88
Copy link
Contributor Author

cbeck88 commented Dec 7, 2022

Locally my results are:

     Running tests/verifier.rs (target/docker/release/deps/verifier-359faa154ba90447)

running 5 tests
test test_max_size_tx_payload_sizes ... ignored
test test_max_size_tx_summary_verification ... ignored
test test_min_size_tx_payload_sizes ... ignored
test test_min_size_tx_summary_verification ... ignored
test bench_max_size_zeroize ... bench:     242,078 ns/iter (+/- 323)

test result: ok. 0 passed; 0 failed; 4 ignored; 1 measured; 0 filtered out; finished in 0.73s

@cbeck88
Copy link
Contributor Author

cbeck88 commented Dec 8, 2022

     Running tests/verifier.rs (target/docker/release/deps/verifier-359faa154ba90447)

running 6 tests
test test_max_size_tx_payload_sizes ... ignored
test test_max_size_tx_summary_verification ... ignored
test test_min_size_tx_payload_sizes ... ignored
test test_min_size_tx_summary_verification ... ignored
test bench_max_size_clone_and_zeroize ... bench:     242,380 ns/iter (+/- 177)
test bench_max_size_clone_no_zeroize  ... bench:     106,048 ns/iter (+/- 3,480)

test result: ok. 0 passed; 0 failed; 4 ignored; 2 measured; 0 filtered out; finished in 6.44s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Needs Review
Development

Successfully merging this pull request may close these issues.

1 participant