-
Notifications
You must be signed in to change notification settings - Fork 233
Open
Description
There are a few changes I would like to bring to hash2curve
, mainly to reduce the amount of code the crate has and make it independent of the elliptic-curve
crate.
Motivations
- Reducing the amount of code is always a plus IMHO - makes the crate more maintainable & approachable.
elliptic-curve
is almost unused as a dependency, but brings a lot of transitive dependencies (see below for comparison).- Some functions use out parameters and I would like to change that where possible (
Expander
andhash_to_field
).
Changes
- Change
GroupDigest
to something like aSuite
trait.
/// A hash to curve suite.
///
/// <https://www.rfc-editor.org/rfc/rfc9380.html#name-suites-for-hashing>
pub trait Suite {
const ID: &'static str;
type Point: MapToCurve;
type SecurityLevel: Unsigned;
type ExpandMsg: ExpandMsg<Self::SecurityLevel>;
fn hash_from_bytes(msg: &[&[u8]], dst: &[&[u8]]) -> Option<Self::Point> {
// ...
}
fn encode_from_bytes(msg: &[&[u8]], dst: &[&[u8]]) -> Option<Self::Point> {
// ...
}
}
- MapToCurve will be bound by
Group
instead ofCurveArithmetic
. - All places that return
elliptic_curve::Result<_>
will returnOption
instead (elliptic_curve::Error
was already as ZST). - Make
hash_to_field
outputArray<F, C>
forF: FromOkm
andC: ArraySize
instead of taking&mut [F]
as out parameter. - Make
ExpandMsg
returnIterator<Item = u8>
instead of anExpander
(This may cause a slight performance regression, will be benchmarked before it is added).
Dependency tree with & without elliptic-curve
With elliptic-curve
hash2curve v0.14.0-rc.0
├── digest v0.11.0-rc.0
│ ├── block-buffer v0.11.0-rc.4
│ │ └── hybrid-array v0.3.1
│ │ ├── typenum v1.18.0
│ │ └── zeroize v1.8.1
│ └── crypto-common v0.2.0-rc.3
│ └── hybrid-array v0.3.1 (*)
├── elliptic-curve v0.14.0-rc.10
│ ├── base16ct v0.2.0
│ ├── crypto-bigint v0.7.0-pre.6
│ │ ├── hybrid-array v0.3.1 (*)
│ │ ├── num-traits v0.2.19
│ │ │ [build-dependencies]
│ │ │ └── autocfg v1.5.0
│ │ ├── rand_core v0.9.3
│ │ ├── subtle v2.6.1
│ │ └── zeroize v1.8.1
│ ├── ff v0.14.0-pre.0
│ │ ├── rand_core v0.9.3
│ │ └── subtle v2.6.1
│ ├── group v0.14.0-pre.0
│ │ ├── ff v0.14.0-pre.0 (*)
│ │ ├── rand_core v0.9.3
│ │ └── subtle v2.6.1
│ ├── hybrid-array v0.3.1 (*)
│ ├── rand_core v0.9.3
│ ├── subtle v2.6.1
│ └── zeroize v1.8.1
├── ff v0.14.0-pre.0 (*)
└── subtle v2.6.1
Without:
hash2curve v0.14.0-rc.0
├── digest v0.11.0-rc.0
│ ├── block-buffer v0.11.0-rc.4
│ │ └── hybrid-array v0.3.1
│ │ └── typenum v1.18.0
│ └── crypto-common v0.2.0-rc.3
│ └── hybrid-array v0.3.1 (*)
├── ff v0.14.0-pre.0
│ ├── rand_core v0.9.3
│ └── subtle v2.6.1
├── group v0.14.0-pre.0
│ ├── ff v0.14.0-pre.0 (*)
│ ├── rand_core v0.9.3
│ └── subtle v2.6.1
└── subtle v2.6.1
Metadata
Metadata
Assignees
Labels
No labels