Created
November 8, 2012 23:13
-
-
Save ferhatelmas/4042522 to your computer and use it in GitHub Desktop.
sage drill
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
K = 214805 | |
P = Primes() | |
p, q = P.next(K^8+1), P.next(K^8+K^4+K+1) | |
x = crt(1, 2, p, q) | |
print x |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
K = 214805 | |
P = Primes() | |
p = 10^200 + K * 10^10 + 1 | |
while(p not in P): | |
p += 10^20 | |
print p |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
K = 214805 | |
m = K^20 | |
P = Primes() | |
p = m + 1 | |
while(not(p in P and p+2 in P)): | |
p = P.next(p) | |
print p |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://www.sagemath.org/doc/constructions/polynomials.html | |
K = 214805 | |
gf = GF(2**128, 'x') | |
R = PolynomialRing(gf, 'x') | |
x = R.gen() | |
S = R.quotient(gf.modulus(), 'a') | |
a = S.gen() | |
sum, pow = 0, 1 | |
for i in (a^K).list(): | |
if i == 1: | |
sum += pow | |
pow *= 2 | |
print sum |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
K = 214805 | |
p = 2^192 - 2^64 - 1 | |
seed = K^8 + K^5 + K + 1 | |
b = p - 1 | |
a = Mod(seed * b^2, p).nth_root(3) | |
x = 1 | |
while(Mod((x^3 + a * x + b)^((p-1)/2), p) != 1): | |
x += 1 | |
y = Mod(x^3 + a*x + b, p).nth_root(2) | |
if(Mod(y, 2) == 1): | |
y = Mod(-y, p) | |
xP, yP, xQ, yQ = x, y, 0, Mod(b**0.5, p) | |
for _ in range(10): | |
L = (yQ - yP)/(xQ - xP) | |
xR = L^2 - xP - xQ | |
yR = L * (xP - xR) - yP | |
xQ = xR | |
yQ = yR | |
# print Mod(xR^3 + a*xR + b, p) == yR^2 | |
print "(%d, %d)" % (xR, yR) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment