-
Notifications
You must be signed in to change notification settings - Fork 229
ExpandMsg improvements
#1862
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
ExpandMsg improvements
#1862
Conversation
7b221e2 to
9df328e
Compare
9df328e to
5c1b97f
Compare
|
Cc @mikelodder7. |
This PR implements `CollisionResistance` for all XOFs. I started with those to add support for `ExpandMsgXof` in `elliptic-curve` and will do follow-up PRs for at least SHA2 and SHA3 fixed output hashes. Companion PR: RustCrypto/traits#1862. See RustCrypto/traits#1816 for previous discussions.
5c1b97f to
fac0af9
Compare
|
Looks good to me. I was just preparing a PR to address #1146 which would remove the |
|
This LGTM. I like the approach to remove the |
Feel free to do your thing, I'm happy to rebase. |
fac0af9 to
d11b3be
Compare
This PR implements `CollisionResistance` for all XOFs. I started with those to add support for `ExpandMsgXof` in `elliptic-curve` and will do follow-up PRs for at least SHA2 and SHA3 fixed output hashes. Companion PR: RustCrypto/traits#1862. See RustCrypto/traits#1816 for previous discussions.
Changes to
ExpandMsgMove generic parameter
KfromExpandMsgimplementers totrait ExpandMsgitself. This was necessary to be able to enforce the correctKinstead of letting users insert an arbitrary one. E.g.GroupDigest::hash_from_bytes()can nowwhere X: ExpandMsg<Self::K>instead of users callinghash_from_bytes::<ExpandMsgXmd<Sha256, U0>>().However, this made calling
ExpandMsgimplementers directly more difficult. E.g. instead ofExpandMsgXmd::<Sha256, U32>::expand_msg(...)users now have to write<ExpandMsgXmd<Sha256> as ExpandMsg<U32>>::expand_message(). If we want to address this, I propose addingRawExpandMsgXmd.Add
CollisionResistancerequirement toExpandMsgXof.Move the lifetime on
ExpandMsgto the associatedtype Expander<'dst>.Fix
dstnot actually being checked to be empty, but instead checked for number of slices.Move
GroupDigestsProjectivePoint: CofactorGroupbound to super trait bounds. This makes it less "poisoning" so downstream users don't have to writewhere ProjectivePoint: CofactorGroupevery time they useGroupDigest.Move
GroupDigest::hash_to_scalar()sScalar: FromOkmbounds toGroupDigest. I believe this was a historical leftover whenFromOkmwasn't implemented forScalars yet.Improved some documentation around hash2curve and updated all mentions of the draft to RFC9380.
Rename parameter names
msgsanddststo singularmsganddst. This is to avoid confusion: even though the type is&[&[u8]], it doesn't represent multiple messages or DSTs, but single concated ones.Remove non-functioning examples. While I don't think the examples are necessary, I'm happy to re-add them if desired, but I would have to add
GroupDigestto theDevcurve.Changes to VOPRF
While I was at it, I also adjusted a couple of things around
VoprfParameters(but I'm happy to split this into its own PR):const IDfrom&strto&[u8].type Hashfrom requiringDigesttoDefault + FixedOutput + Update.Related: RustCrypto/hashes#694.
Companion PR: RustCrypto/elliptic-curves#1203.