-
Notifications
You must be signed in to change notification settings - Fork 110
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
Remove dependency on rust-crypto #137
Conversation
35c8596
to
261f3ea
Compare
idk, |
3d0a050
to
e1460d5
Compare
But in favour of this dependency switching, I had to change merkle trees API, and proofs generated by previous curv still are not compatible with latest curv. But I think it's fine. |
pub fn create_tree(leaves: Vec<Point<E>>) -> Self { | ||
let hashes = leaves | ||
.iter() | ||
.map(|leaf| H::new().chain_point(leaf).finalize()) |
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.
just want to note, that before we hashed only the first 32 bytes of the point and now we hash the full point (which is better)
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.
Ah you're right. That was strange.
let index = (0u32..) | ||
.zip(&self.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.
I think enumerate()
is more idiomatic
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.
although from codegen standpoint(https://godbolt.org/z/3YKPqE6e6) this is better, and there's probably no way that there are more than 2^32 leaves here (although maybe assert that in create_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.
enumerate
yields usize
that then needs to be converted to u32
via cast expression n as u32
, or conversion trait u32::try_from(n).unwrap()
. I find zipping more pretty among all these options
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.
Yeah, I think there's no way number of leaves can overflow u32
e1460d5
to
8aa1e3f
Compare
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
8aa1e3f
to
db33102
Compare
Removes deprecated dependency on
rust-crypto
. The only thing is changed in the library is merkle tree support.merkle-sha3 v0.1
→merkle v1
(
merkle-sha3
is abandoned)merkle
crate depends onring
. Dependency onring
might be not desirable, so I made it optional. See featuremerkle-tree
.keccak256
→sha256
ring
has no support ofkeccak256
. This change means that any proofs generated by earlier versions ofcurv
are not compatible with the latestcurv
.