# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

0x0800000000000010ffffffffffffffffb781126dcae7b2321e66a241adc64d2f - 1

p = 0x0800000000000011000000000000000000000000000000000000000000000001

l = 0x0800000000000010ffffffffffffffffb781126dcae7b2321e66a241adc64d2f


def embedding_degree(p, l):
    pp = 1
    for i in range(1, 10**7):
        pp *= p
        pp %= l
        if pp == 1:
            return i
        if i % 10**6 == 0:
            print(i, pp)
    for n in range(100, 2, -1):
        if pow(p, (l-1)//n, l) == 1:
            print("(l-1/)", n)
            return (l-1)//n
    return "Good!"


(l-1)/100

pow(p,(l-1)//2962142, l)

embedding_degree(p, l)

# BN(2, 254)
embedding_degree(
    16798108731015832284940804142231733909889187121439069848933715426072753864723,
    16798108731015832284940804142231733909759579603404752749028378864165570215949)

# Curve25519
embedding_degree(
    57896044618658097711785492504343953926634992332820282019728792003956564819949,
    7237005577332262213973186563042994240857116359379907606001950938285454250989
)



StarcoderdataJupyterScriptsDedupFiltered