Skip to content

Commit

Permalink
initial commit for ctnt talk
Browse files Browse the repository at this point in the history
  • Loading branch information
jet08013 committed May 22, 2018
0 parents commit 7764247
Show file tree
Hide file tree
Showing 3 changed files with 595 additions and 0 deletions.
246 changes: 246 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
## Core latex/pdflatex auxiliary files:
*.aux
*.lof
*.log
*.lot
*.fls
*.out
*.toc
*.fmt
*.fot
*.cb
*.cb2
.*.lb

## Intermediate documents:
*.dvi
*.xdv
*-converted-to.*
# these rules might exclude image files for figures etc.
# *.ps
# *.eps
# *.pdf

## Generated if empty string is given at "Please type another file name for output:"
.pdf

## Bibliography auxiliary files (bibtex/biblatex/biber):
*.bbl
*.bcf
*.blg
*-blx.aux
*-blx.bib
*.run.xml

## Build tool auxiliary files:
*.fdb_latexmk
*.synctex
*.synctex(busy)
*.synctex.gz
*.synctex.gz(busy)
*.pdfsync

## Build tool directories for auxiliary files
# latexrun
latex.out/

## Auxiliary and intermediate files from other packages:
# algorithms
*.alg
*.loa

# achemso
acs-*.bib

# amsthm
*.thm

# beamer
*.nav
*.pre
*.snm
*.vrb

# changes
*.soc

# cprotect
*.cpt

# elsarticle (documentclass of Elsevier journals)
*.spl

# endnotes
*.ent

# fixme
*.lox

# feynmf/feynmp
*.mf
*.mp
*.t[1-9]
*.t[1-9][0-9]
*.tfm

#(r)(e)ledmac/(r)(e)ledpar
*.end
*.?end
*.[1-9]
*.[1-9][0-9]
*.[1-9][0-9][0-9]
*.[1-9]R
*.[1-9][0-9]R
*.[1-9][0-9][0-9]R
*.eledsec[1-9]
*.eledsec[1-9]R
*.eledsec[1-9][0-9]
*.eledsec[1-9][0-9]R
*.eledsec[1-9][0-9][0-9]
*.eledsec[1-9][0-9][0-9]R

# glossaries
*.acn
*.acr
*.glg
*.glo
*.gls
*.glsdefs

# gnuplottex
*-gnuplottex-*

# gregoriotex
*.gaux
*.gtex

# htlatex
*.4ct
*.4tc
*.idv
*.lg
*.trc
*.xref

# hyperref
*.brf

# knitr
*-concordance.tex
# TODO Comment the next line if you want to keep your tikz graphics files
*.tikz
*-tikzDictionary

# listings
*.lol

# makeidx
*.idx
*.ilg
*.ind
*.ist

# minitoc
*.maf
*.mlf
*.mlt
*.mtc[0-9]*
*.slf[0-9]*
*.slt[0-9]*
*.stc[0-9]*

# minted
_minted*
*.pyg

# morewrites
*.mw

# nomencl
*.nlg
*.nlo
*.nls

# pax
*.pax

# pdfpcnotes
*.pdfpc

# sagetex
*.sagetex.sage
*.sagetex.py
*.sagetex.scmd

# scrwfile
*.wrt

# sympy
*.sout
*.sympy
sympy-plots-for-*.tex/

# pdfcomment
*.upa
*.upb

# pythontex
*.pytxcode
pythontex-files-*/

# thmtools
*.loe

# TikZ & PGF
*.dpth
*.md5
*.auxlock

# todonotes
*.tdo

# easy-todo
*.lod

# xmpincl
*.xmpi

# xindy
*.xdy

# xypic precompiled matrices
*.xyc

# endfloat
*.ttt
*.fff

# Latexian
TSWLatexianTemp*

## Editors:
# WinEdt
*.bak
*.sav

# Texpad
.texpadtmp

# Kile
*.backup

# KBibTeX
*~[0-9]*

# auto folder when using emacs and auctex
./auto/*
*.el

# expex forward references with \gathertags
*-tags.tex

# standalone packages
*.sta

# generated if using elsarticle.cls
*.spl
112 changes: 112 additions & 0 deletions ECM.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# %load ec3.py
from math import factorial, gcd, log
import numpy as np
P=np.zeros(1000)
P[0]=1
P[1]=1
for i in range(2,100):
if P[i]==0:
j=2
while i*j<100:
P[i*j]=1
j=j+1
Primes1000=[i for i,x in enumerate(P) if x==0 ]


def mexp(a,x,N):
m,s=1,a
while x>0:
if x % 2 ==1:
m=((m*s) % N)
s=((s*s) % N)
x=x//2
return m

def euclid(u,v):
if v==0:
raise ArithmeticError('Division by Zero')
x0,x1=u,v
a0,a1=1,0
b0,b1=0,1
while x1!=0:
q=x0//x1
x2=x0-q*x1
a2=a0-q*a1
b2=b0-q*b1
x0,a0,b0=x1,a1,b1
x1,a1,b1=x2,a2,b2
if x0<0:
return -x0,-a0,-b0
else:
return x0,a0,b0

def mod_inv(u,N):
d,a,b=euclid(u,N)
if d==1:
return a
else:
raise ArithmeticError('Common factor is '+str(d))

def two_p(x,y,a,b,N):
Lu=(3*x**2+a) % N
# print(Lu)
Lb=mod_inv(2*y,N)
# print(Lb)
L=Lu*Lb % N
x_two=(L*L-2*x) % N
y_two=(L*(x-x_two)-y) %N
return x_two,y_two

def sum_p(x1,y1,x2,y2,a,b,N):
Lu=(y2-y1) % N
Lb=mod_inv(x2-x1,N)
L=(Lu*Lb) % N
x_sum=(L*L-x1-x2) %N
y_sum=(L*(x1-x_sum)-y1) %N
return x_sum,y_sum

def exp_p(x,y,a,b,m,N):
sx,sy=x,y
first=True
while m>0:
if m%2==1:
if first:
xm,ym=sx,sy
first=False
else:
xm,ym=sum_p(xm,ym,sx,sy,a,b,N)
sx,sy=two_p(sx,sy,a,b,N)
m=m//2
return xm,ym

#def mexp(a,x,N):
# m,s=1,a
# while x>0:
# if x % 2 ==1:
# m=((m*s) % N)
# s=((s*s) % N)
# x=x//2
# return m

def ecm_trial(N,arange=50,krange=30):
for a in range(-arange,arange):
xm,ym=0,1
print(a)
for k in range(2,krange):
try:
xm,ym=exp_p(xm,ym,a,1,k,N)
except ArithmeticError:
print('try the following: a=',a,' and k=',k)
break



#N=149185656432189838133
#ecm_trial(N,arange=20,krange=10000)
N=2**128+1
#ecm_trial(N,arange=100,krange=10000)
xm,ym=exp_p(0,1,-91,1,factorial(7883),N)




Loading

0 comments on commit 7764247

Please sign in to comment.