-
Notifications
You must be signed in to change notification settings - Fork 204
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
bign256: WideFieldElement #920
Comments
@tarcieri hey. Any idea about this? |
Not sure |
Maybe any idea where I can read about this algorithm implementation? |
Perhaps @fjarri can help you, as he wrote it |
@makavity it's not quite clear to me what's happening here. The title refers to Also I can't open the link to STB 34.101.66-2014 from the top message. |
@fjarri so, I can't use same code for implementation of WideFieldElement, right? |
So the problem has nothing to do with |
I am trying to implement wide operations for bign256, because I need to to implement swu algorithm. |
Ah, I see. Both |
@fjarri didn't find a better method, than this: pub fn mul_wide(a: &FieldElement, b: &FieldElement) -> Self {
let a_w = a.0.as_words();
let b_w = b.0.as_words();
let lhs = U512::from_words([a_w[0], a_w[1], a_w[2], a_w[3], 0, 0, 0, 0]);
let rhs = U512::from_words([b_w[0], b_w[1], b_w[2], b_w[3], 0, 0, 0, 0]);
Self(lhs.wrapping_mul(&rhs))
}
fn reduce_impl(&self, _modulus_minus_one: bool) -> FieldElement {
let m = MODULUS.as_words();
let p = U512::from_words([m[0], m[1], m[2], m[3], 0, 0, 0, 0]);
let res = self.0.const_rem(&p).0.to_words();
FieldElement(U256::from_words([res[0], res[1], res[2], res[3]]))
} |
Hello! For implementation of 6.2.3 point 2 of STB 34.101.66-2014 I need to construct FieldElement from 48 bytes.
I took the implementation of wide arithmetic from k256 crate:
wide64.rs
My tests is:
Output is:
In my opinion,
1 (wide reduced canonical)
and1 (canonical)
should be the same, but1 (wide reduced canonical)
is in Montgomery form. Don't know, what am I doing wrong.Can I get help with that?
Thanks!
The text was updated successfully, but these errors were encountered: