laudiacay / barustenberg

barretenburg in rust (here we go)
Apache License 2.0
97 stars 10 forks source link

TODO: Convert `twist_coeff_b` from the `Fq2` params to arkworks Fp #58

Closed PatStiles closed 1 year ago

PatStiles commented 1 year ago

To finish #57 we need to convert the constant twist_coeff_b from barrentenburg into a Fp . This will involve building barrentenburg and printing out the byte representation of the constant, writing a script to convert the value, and adding it as a hardcoded constant with the ['MontConfig'] macro.

Autoparallel commented 1 year ago

Is this a matter of just changing the representation of the curves? Can you explain a bit more? Just trying to catch up.

laudiacay commented 1 year ago

no- we're not sure what representation these are in

    static constexpr fq twist_coeff_b_0{
        0x3bf938e377b802a8UL, 0x020b1b273633535dUL, 0x26b7edf049755260UL, 0x2514c6324384a86dUL
    };
    static constexpr fq twist_coeff_b_1{
        0x38e7ecccd1dcff67UL, 0x65f0b37d93ce0d3eUL, 0xd749d0dd22ac00aaUL, 0x0141b9ce4a688d4dUL
    };

neither is zac

MontConfig constructs itself using a string decimal-repr int. i have thus far been unable to figure out how to turn params that should be the same from the repr above to the corresponding ones in the montconfigs. so @PatStiles is going to figure it out and get them copied over.

PatStiles commented 1 year ago

Reference for wnaf encoding: https://hackmd.io/@aztec-network/rJ3VZcyZ9

shuklaayush commented 1 year ago

They're in montgomery form (i.e. $x * R\mod q$) where R is defined here https://github.com/privacy-scaling-explorations/halo2curves/blob/main/src/bn256/fq.rs#L60-L66

If we want to use raw values, then we can just use these https://github.com/privacy-scaling-explorations/halo2curves/blob/main/src/bn256/curve.rs#L70-L81