Example #1
0
    Brief: Example file
"""

#-- Import --#
import EC
#- End Import -#

if __name__ == '__main__':
    # Instanciating M-511 curve object
    nM511 = 2**508 + 10724754759635747624044531514068121842070756627434833028965540808827675062043
    CM511 = EC.EllipticCurve("M-511", nM511, 2**511 - 187, [530438, 1, 0])

    # Instantiating generator for the group of points of M-511 curve
    GM511 = EC.Point(
        CM511, 0x5,
        0x2fbdc0ad8530803d28fdbad354bb488d32399ac1cf8f6e01ee3f96389b90c809422b9429e8a43dbf49308ac4455940abe9f1dbca542093a895e30a64af056fa5
    )

    # Instanciating infinite point (zero element for +)
    Z = EC.Point(CM511)
    print(Z + GM511 == GM511)

    # Testing efficiency of multiplication by large integers
    n = 654656845357984954675767598651271325802657127103756757421371765121076751076571757257965331197796511321646517
    P = n * GM511
    Q = P - GM511
    print(Q == (n - 1) * GM511)

    # Multiplying by order results in the infinity point (zero element for +)
    print(nM511 * GM511 == Z)
    print(nM511 * P == Z)
Example #2
0
    Brief: Some Montgomery and Weierstrass Elliptic Curves parameters
"""

#-- Import --#
import EC
#- End Import -#

# ------------------------------------------------------- #
# Montgomery curves : y^2 = x^3 + a.x^2 + b.x + c (mod p) #
# ------------------------------------------------------- #
""" M-511 curve : 2013 Aranha–Barreto–Pereira–Ricardini (formerly named Curve511187) """
nM511 = 2**508 + 10724754759635747624044531514068121842070756627434833028965540808827675062043
CM511 = EC.EllipticCurve("M-511", nM511, 2**511 - 187, [530438, 1, 0])
GM511 = EC.Point(
    CM511, 0x5,
    0x2fbdc0ad8530803d28fdbad354bb488d32399ac1cf8f6e01ee3f96389b90c809422b9429e8a43dbf49308ac4455940abe9f1dbca542093a895e30a64af056fa5
)
""" Curve383187 : 2013 Aranha–Barreto–Pereira–Ricardini; authors subsequently recommended switching to M-383 """
n383187 = 2**380 + 356080847217269887368687156533236720299699248977882517025
C383187 = EC.EllipticCurve("Curve 383187", n383187, 2**383 - 187,
                           [229969, 1, 0])
G383187 = EC.Point(
    C383187, 0x5,
    0x1eebe07dc1871896732b12d5504a32370471965c7a11f2c89865f855ab3cbd7c224e3620c31af3370788457dd5ce46df
)
""" M-383 : 2013 Aranha–Barreto–Pereira–Ricardini """
nM383 = 2**380 + 166236275931373516105219794935542153308039234455761613271
CM383 = EC.EllipticCurve("M-383", nM383, 2**383 - 187, [2065150, 1, 0])
GM383 = EC.Point(
    CM383, 0xc,
    0x1ec7ed04aaf834af310e304b2da0f328e7c165f0e8988abd3992861290f617aa1f1b2e7d0b6e332e969991b62555e77e