-
Notifications
You must be signed in to change notification settings - Fork 104
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
Hashing to a field element #45
Comments
It's probably better to leave that up to something like merlin, no? |
The The immediate use case I have in mind for this feature request is FROST, and the possibility of having a generic implementation that works across |
An alternative API that would probably also suffice for these cases would be something like |
In schnorrkel, I've had a witness delinearization trick for multi-signatures similar to FROST since early January 2020 (and discussed the approach with folks like Neven before that). It's a handy trick. I'll caution the "round optimized" part FROST still looks dangerous though. Anyways, you want either (a) merlin-like construction or else (2) a hash plus |
If we were to add an API for this, I think it would be |
In hindsight, I think this is a much thornier topic than I had originally considered when I opened the issue. To take a step back, my original motivations were ECDSA, and the approach used by ECDSA is both one of many possible approaches and biased as it doesn't use a "wide" reduction. The Anyway, I'll leave this issue open at your discretion, as what should be done about a generalized trait for this purpose seems tricky at best. |
If we're going to hash to a field element, I would suggest we bring in |
Semi-related: there's @mikelodder7's |
We're now MSRV 1.51 for |
@str4d there are some hacks you can do to try to bridge the const generics and use typenum::{U256, U384, U512};
use generic_array::{GenericArray, ArrayLength};
pub struct MyStruct<const N: usize>;
pub trait HashSize {
type Size: ArrayLength<u8>;
}
impl HashSize for MyStruct<256> {
type Size = U256;
}
impl HashSize for MyStruct<384> {
type Size = U384;
}
impl HashSize for MyStruct<512> {
type Size = U512;
}
pub type Hash256 = GenericArray<u8, <MyStruct<256> as HashSize>::Size>; |
The
elliptic-curve
crate presently has aFromDigest
trait which it uses for hashing to a scalar:https://docs.rs/elliptic-curve/0.6.2/elliptic_curve/trait.FromDigest.html
I think it might make sense to move that trait into this crate (possibly gated on a
digest
cargo feature) so it can be used for implementing protocols generically which require hash-to-scalar.The text was updated successfully, but these errors were encountered: