Skip to content

Instantly share code, notes, and snippets.

@ibaaj
Created October 22, 2016 18:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ibaaj/0f8a7b25b543d5474b447a601f6884f3 to your computer and use it in GitHub Desktop.
Save ibaaj/0f8a7b25b543d5474b447a601f6884f3 to your computer and use it in GitHub Desktop.
coppersmith_padding.gp
default(realprecision,9000);
setrand(1);
p=nextprime(random(2^15));
q=nextprime(random(2^15));
N=p*q;
print("N=p*q="N);
P = random(N); \\ le padding
print("padding="P)
e = 3; \\ expo public
print("expo="e)
X = floor(N^(1/3)); \\ N^(1/e - epsilon)
print("X="X)
x0 = random(X); \\ le message inconnu
print("X0="x0)
C = lift( (Mod(x0,N) + P)^e ); \\ le chiffré
print("C="C)
print("coppersmith........")
print(zncoppersmith((P + x)^3 - C, N, X))
print(" = X0 ")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment