-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
There's zero in the way of proper documentation here. Trivial example but what's the difference between these two functions? They're just variants 1 and 2...
noir_bigcurve/src/scalar_field.nr
Lines 23 to 69 in c36268d
| unconstrained fn get_wnaf_slices<let N: u32>(x: Field) -> ([u8; N], bool) { | |
| let mut result: [u8; N] = [0; N]; | |
| let mut nibbles = x.to_le_radix::<N>(16); | |
| let skew: bool = nibbles[0] & 1 == 0; | |
| nibbles[0] = nibbles[0] as u8 + (skew as u8); | |
| result[N - 1] = (nibbles[0] + 15) / 2; | |
| for i in 1..N { | |
| let mut nibble: u8 = nibbles[i]; | |
| result[N - 1 - i] = (nibble + 15) / 2; | |
| if (nibble & 1 == 0) { | |
| result[N - 1 - i] += 1; | |
| result[N - i] -= 8; | |
| } | |
| } | |
| (result, skew) | |
| } | |
| unconstrained fn get_wnaf_slices2<let N: u32, BigNum>(x: BigNum) -> ([u8; N], bool) | |
| where | |
| BigNum: BigNumTrait, | |
| { | |
| let mut result: [u8; N] = [0; N]; | |
| let mut nibbles: [[u8; 30]; (N / 30) + 1] = [[0; 30]; (N / 30) + 1]; | |
| let x: [Field] = x.get_limbs_slice(); | |
| for i in 0..x.len() { | |
| nibbles[i] = x[i].to_le_radix::<30>(16); | |
| } | |
| let skew: bool = nibbles[0][0] & 1 == 0; | |
| nibbles[0][0] = nibbles[0][0] as u8 + (skew as u8); | |
| result[N - 1] = (nibbles[0][0] + 15) / 2; | |
| for i in 1..N { | |
| let major_index = i / 30; | |
| let minor_index = i % 30; | |
| let mut nibble: u8 = nibbles[major_index][minor_index]; | |
| result[N - 1 - i] = (nibble + 15) / 2; | |
| if (nibble & 1 == 0) { | |
| result[N - 1 - i] += 1; | |
| result[N - i] -= 8; | |
| } | |
| } | |
| (result, skew) | |
| } |
We have CurveJ and BigCurve, what's the difference between these from a consumer's point of view, etc.
We should have proper doc comments on the implementation of this library to make it clearer for maintainers and users what's going on in this library.
Metadata
Metadata
Assignees
Labels
No labels