-
Notifications
You must be signed in to change notification settings - Fork 219
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
feat(base_layer/core): add domain hashing wrapper for consensus encoding #4381
feat(base_layer/core): add domain hashing wrapper for consensus encoding #4381
Conversation
This looks nice. I think one of the issues with the failing integration tests is the hash calculation in
from what I could pick up. I was busy chasing some other failures after ^^ have been corrected before I closed #4373. |
Sorry, finger trouble closing this |
@hansieodendaal lol no problem :) Oh right, I'll need to update cucumber tests. Thanks |
0aada87
to
b14bf72
Compare
Cucumber metadata signature is still broken, it seems to be the encrypted value is incorrect in the transactionBuilder. Going to leave that for another PR. |
b14bf72
to
20661f6
Compare
20661f6
to
455d572
Compare
* development: test(comms/core): fix broken DNS resolution test (tari-project#4385)
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.
LGTM. See comment.
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> { | ||
self.digest.update(buf); | ||
/// This private struct wraps a Digest and implements the Write trait to satisfy the consensus encoding trait.. | ||
#[derive(Clone)] |
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.
Couldn't we provide a blanket Write
impl on the underlying DomainHasher
?
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.
In this case we can't because the API for Write
is meant to allow "chunked" writes (network sockets, files etc) and the DomainSeparatedHasher
does not allow this.
c = a||b
H.chain(a).chain(b) != H.chain(c)
This is the main reason why I chose to make the write interface internal to the hasher, because we know that ConseususEncoding writes each element in its entirety and our internal Write implementation never tells the caller to wait to write.
Description
DomainSeparatedConsensusHasher
ConsensusHashWriter
toConsensusHasher
Write
implementation fromConsensusHasher
TransactionHashDomain
hash domainMotivation and Context
Creates an ergonomic and 0-alloc hasher for consensus encoded values.
Usage:
How Has This Been Tested?
New unit test, existing tests use hashing