noir-lang / docs

19 stars 22 forks source link

Document usage of elliptic curve primitives #82

Closed Savio-Sou closed 1 year ago

Savio-Sou commented 1 year ago

Corresponding PR: https://github.com/noir-lang/noir/pull/964

To be documented under the Noir Standard Library section.

The inlined comments in the PR might be helpful to facilitate understanding, but if it's too technical we can simply document it as "it exists!" for now.

Last doc issue for v0.3.2.

critesjosh commented 1 year ago

hi, @ax0, I am looking into documenting your contribution and have a few questions.

What new features does the merging of this PR unlock? Do you have any examples/references of how these new primitives are used in Noir?

ax0 commented 1 year ago

Hi @critesjosh. To answer your questions:

What new features does the merging of this PR unlock?

This PR provides data structures and methods on them that allow you to carry out computations involving elliptic curves over the (mathematical) field corresponding to Field. For the field currently at our disposal, applications would involve a curve embedded in BN254, e.g. the Baby Jubjub curve.

In slightly more detail:

Do you have any examples/references of how these new primitives are used in Noir?

The ec_baby_jubjub test illustrates all of the above primitives on various forms of the Baby Jubjub curve. A couple of more interesting examples in Noir would be:

fn bjj_pub_key(priv_key: Field) -> Point {

let bjj = Curve::new(168700, 168696, G::new(995203441582195749578291179787384436505546430278305826713579947235728471134,5472060717959818805561601436314318772137091100104008585924551046643952123905));

let base_pt = Point::new(5299619240641551281634865583518297030282874472190772894086521144482721001553, 16950150798460657717958625567821834550301663161624707787222815936182638968203);

bjj.mul(priv_key,base_pt)

}



This would come in handy in a Merkle proof.

- **EdDSA signature verification**: This is a matter of combining these primitives with a suitable hash function. See noir-lang/noir#1136 for the case of Baby Jubjub and the Poseidon hash function.

Hope that helps!
critesjosh commented 1 year ago

added via this pr (https://github.com/noir-lang/docs/pull/89)