Skip to content

Document this library #35

Open
Open
@TomAFrench

Description

@TomAFrench

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...

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    👀 To Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions