FiloSottile / edwards25519

filippo.io/edwards25519 — A safer, faster, and more powerful low-level edwards25519 Go implementation.
https://filippo.io/edwards25519
BSD 3-Clause "New" or "Revised" License
139 stars 30 forks source link

edwards25519: add (*Point) EqualCofactor #5

Closed lukechampine closed 3 years ago

lukechampine commented 3 years ago

This is needed for ed25519consensus. Implementation is directly ported from there. (src)

I don't know how to write tests for this, sorry :/

FiloSottile commented 3 years ago

This doesn't need to be in the library, and I tried to leave cofactor issues out of scope.

Instead, you can implement it as

// [8](u - v) == 0
p := (&Point{}).Sub(u, v)       // p = u - v
p.Double(p).Double(p).Double(p) // p = [8]p
p.Equal(NewIdentityPoint())     // p == 0