Uh oh!
There was an error while loading. Please reload this page.
Improve API for hash2curve functions - #876
Conversation
I came up with three solutions how to remove the
I'm leaning towards the second solution, it seems to be the friendliest one for the user. |
Uh oh!
There was an error while loading. Please reload this page.
d24d2ac to
681f375Compare681f375 to
3ff40abComparetarcieri
commented
Jan 8, 2022
This seems like an improvement to me but with the caveat I haven't carefully read the spec |
daxpedda
commented
Jan 8, 2022
https://www.ietf.org/archive/id/draft-irtf-cfrg-voprf-08.html#section-3.3.1.1-1 |
I implemented the second solution, as explained above, for removing the |
daxpedda
commented
Jan 10, 2022
I just realized, one solution could be to remove the whole |
613cdc2 to
898cc71Compare898cc71 to
ab64ed3Comparedaxpedda
commented
Jan 10, 2022
I decided to revert this, there is no real advantage and the current |
Uh oh!
There was an error while loading. Please reload this page.
tarcieri
commented
Jan 10, 2022
I'm a bit unclear what lifetime relationship the (Of course, I don't understand the impetus for the original |
The issue arises when you want to implement a spec that requires different To be more specific, VOPRF requires a different implVoprfParametersforNistP256{constID:u16 = 0x0003;typeHash = sha2::Sha256;}// https://www.ietf.org/archive/id/draft-irtf-cfrg-voprf-08.html#appendix-A-6fnderive_key_pair<G:VoprfParameters,H:Digest>(seed:&[u8]) -> ... {// contextString = "VOPRF08-" || I2OSP(modeBase, 1) || I2OSP(suite.ID, 2)let context_string = concat!("VOPRF-08",0,G::ID);// skS = GG.HashToScalar(seed, DST = "HashToScalar-" || contextString)let sk_s = NistP256::hash_to_scalar::<ExpandMsgXmd<H>>(seed, context_string)?;
...}This will fail, because As for the EDIT: I attempted, but it wasn't possible. I hope this clears up any questions. Please hit me up if there is anything unclear. |
daxpedda
commented
Jan 10, 2022
If the lifetime is a big issue, I could go back to the solution of removing the |
tarcieri
commented
Jan 10, 2022
Yeah, that's not going to work without a heap allocation. The alternative IMO would be to have an
But that should only require a lifetime on |
daxpedda
commented
Jan 10, 2022
I thought so too, but couldn't make it work sadly. Feel free to try. |
Aah I see, you need the lifetime for the associated |
tarcieri
commented
Jan 11, 2022
@mikelodder7 any thoughts on this? |
mikelodder7
commented
Jan 11, 2022
The lifetime is solely for the dst. I put it as static so I wouldn’t have to copy the dst to a GenericArray of a fixed size less than 255. If we can somehow manage the lifetime without static then great but it pollutes all interfaces when ExpandMsgXof doesn’t even need it. If we had a heap then you could just convert to Vec and be done. |
mikelodder7
commented
Jan 11, 2022
It seems we’re “crossing the streams” with voprf and hash2curve with multiple args but I guess it’s probably okay for now |
data/msgs by using&[&[u8]], á laHkdf::expand_multi_info().hash_to_scalar, got an implementation for P-256 already working with test vectors.'staticrequirement fordst.Maybe we don't want
hash_to_scalaronGroupDigest, because it also pulls in arithmetic for no real reason.The goal here is to make this usable for voprf. VOPRF sometimes builds complex
msgs that are impossible to concat without allocation, this is why the multi-message API was necessary. I would even prefer just to take anIterator<Item = &[u8]>.The
'staticrequirement doesn't work for VOPRF because it needs to build thedstfrom multiple parts that are party derived from associated types from traits, this can't be used in const to build a&'static [u8]in Rust right now.CC @tarcieri@mikelodder7