-
Notifications
You must be signed in to change notification settings - Fork 139
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
add functions to support nova repo #44
add functions to support nova repo #44
Conversation
chaosma
commented
May 21, 2023
- add hash_to_curve function
- add from_slice function
- fix minor issue of ysign in from_bytes
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.
Overall LGTM, but I know nothing about the hash to curve algorithms, I'll leave the core part for other reviewers to review.
impl [< $name Compressed >] { | ||
pub fn from_slice(slice: &[u8]) -> Result<Self, &'static str> { | ||
if slice.len() != [< $name _COMPRESSED_SIZE >] { | ||
return Err("Slice length not match"); | ||
} | ||
let mut c = [0u8; [< $name _COMPRESSED_SIZE >]]; | ||
c.copy_from_slice(slice); | ||
Ok(Self(c)) | ||
} | ||
} | ||
|
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.
What's the usecase for this function? I feel one can do this already by compressed.as_mut().copy_from_slice(slice)
, and copy_from_slice
will panic if the length is uneuqal.
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.
In nova, the Group trait requires to define decompressed method to convert [u8;32] to G1Compressed. I didn't find there is a public method that allow me to do this conversion, so I added from_slice
. What is compressed
defined in this code?
use ff::{FromUniformBytes, PrimeField}; | ||
use static_assertions::const_assert; | ||
|
||
// TODO: use simplified swu algorithm |
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.
So to use simplified swu method, we need to find the isogeny parameters right? Is there a deterministic script to do that? (this one might be it https://github.com/cfrg/draft-irtf-cfrg-hash-to-curve/blob/main/poc/iso_values.sage?)
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.
Yes, we need first convert A=0 case to A*B != 0 curve before using simplified swu. en... Let me take a look at this code.
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 have a complete script to find Z and the SWU isogenies here as well: https://github.com/mratsim/constantine/blob/d996ccd/sage/derive_hash_to_curve.sage#L145-L275
is this PR overriden by #47? |