hyugit / EllipticCurve

An elliptic curve library written in Swift 4
MIT License
22 stars 5 forks source link

Litterature reference - secp256k1 InverseCharacteristic (= Point.InverseOrder) #9

Open Sajjon opened 6 years ago

Sajjon commented 6 years ago

Where can I find a literature reference to the values:

    InverseN: (
        high: UInt256(1),
        low: UInt256([0, 1, 0x4551231950b75fc4, 0x402da1732fc9bec0])
    )

Thanks!

hyugit commented 6 years ago

Hi Sajjon,

First off, thank you for your support in my project. This issue is the one I can answer right now.

This is just the inverse of N presented in 512 bit integer.

It is used in Barrett's Fast Division algo in the UInt256 library: here

Huang

Sajjon commented 6 years ago

@hyugit Sorry for my noob question, but by "inverse of N" are you referring to the modular multiplicative inverse?

hyugit commented 6 years ago

@Sajjon sorry, my bad. actually.. this is (2^512)/N, a precomputed "approximation" to the inverse of the divisor, according to my source (2.4.1 Barrett's Algorithm). And this is indeed being used by UInt256 library's Barrett's Algorithm: here