added a problem, but someone has to get my program running on a server
This commit is contained in:
parent
3371d7bc1b
commit
0a31b38383
4 changed files with 42 additions and 0 deletions
3
paillier-service/description.md
Normal file
3
paillier-service/description.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
My friend made some sort of encryption service using the Paillier Cryptosystem. Can you get him to encrypt the string `easyctf{3ncrypt_m3!}` for me?
|
||||||
|
|
||||||
|
Access his encryption serice at `memes.com:1234` <- fix this later
|
17
paillier-service/encrypt.py
Normal file
17
paillier-service/encrypt.py
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#easyctf{3ncrypt_m3!}
|
||||||
|
p = 8144194198641127053467521063088973929365485175581336279930490759203400725623086153929294542350943040473375790841894343662879542882143670576484983482676929
|
||||||
|
q = 9349990237178389195581522619084514015305492951423232071317276234453300521753669715890246992825146527366147991960266180184131002960074501683578205688324193
|
||||||
|
n = p*q
|
||||||
|
l = (p-1)*(q-1)
|
||||||
|
g = n+1
|
||||||
|
mu = 50461441817124067084598541006218828107720370909059246792962232658242869571003990015294541684702084151173329882441771747115542549562899610400402036968340066285127945127930744036805832623326255171902722383305695091973581469008587730106329093915495096858331002656658189454919392650001488548518482449865519307486
|
||||||
|
m = int(raw_input('Enter a message to encrypt: '))
|
||||||
|
r = int(raw_input('Enter r (int): '))
|
||||||
|
if m > 100000000000000000 or m < 0:
|
||||||
|
print('Bad m. We only take m from 0 to 100000000000000000.')
|
||||||
|
exit()
|
||||||
|
if r > 100000000000000000 or r < 0:
|
||||||
|
print('Bad r. We only take r from 0 to 100000000000000000.')
|
||||||
|
exit()
|
||||||
|
c = (pow(g,m,n**2)*pow(r,n,n**2))%(n**2)
|
||||||
|
print 'c: '+str(c)
|
14
paillier-service/grader.py
Normal file
14
paillier-service/grader.py
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
def grade(autogen, answer):
|
||||||
|
try:
|
||||||
|
answer = int(answer)
|
||||||
|
p = 8144194198641127053467521063088973929365485175581336279930490759203400725623086153929294542350943040473375790841894343662879542882143670576484983482676929
|
||||||
|
q = 9349990237178389195581522619084514015305492951423232071317276234453300521753669715890246992825146527366147991960266180184131002960074501683578205688324193
|
||||||
|
n = p*q
|
||||||
|
l = (p-1)*(q-1)
|
||||||
|
g = n+1
|
||||||
|
mu = 50461441817124067084598541006218828107720370909059246792962232658242869571003990015294541684702084151173329882441771747115542549562899610400402036968340066285127945127930744036805832623326255171902722383305695091973581469008587730106329093915495096858331002656658189454919392650001488548518482449865519307486
|
||||||
|
if ((pow(answer,l,n**2)-1)//n * mu)%n == 578781299356711768839252397261103878073419506045:
|
||||||
|
return True, "Correct!"
|
||||||
|
return False, "Nope, try again."
|
||||||
|
except:
|
||||||
|
return False, "Nope, try again."
|
8
paillier-service/problem.yml
Normal file
8
paillier-service/problem.yml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
title: Paillier Service
|
||||||
|
author: neptunia
|
||||||
|
hint: https://en.wikipedia.org/wiki/Paillier_cryptosystem
|
||||||
|
category: Cryptography
|
||||||
|
autogen: false
|
||||||
|
programming: false
|
||||||
|
value: 400
|
||||||
|
|
Loading…
Reference in a new issue