Coherence
Search…
NTRU
In order to understand hex and type parameters read Hash

NTRU

Description: Post-quantum public-key cryptosystem
Problem: The shortest vector problem in a lattice
Uses: Encryption
    It only supports "type":"string"

How to ???

1
import requests
2
import json
3
import os,binascii
4
5
def sending(message):
6
url = 'http://127.0.0.1:6613/'
7
response = requests.post(url, data=message)
8
print response.content
9
return response.content
10
11
ntru_gen=json.loads('{ "version": 1 , "algorithm":"NTRU", "parameter": "EES1499EP1", "operation":"gen"}')
12
13
data_js_n=sending(json.dumps(ntru_gen))
14
answ=json.loads(data_js_n)
15
print "Recived gen NTRU: \n" + (json.dumps(answ)) +"\n"
16
json_enc=json.loads('{ "version": 1 , "algorithm":"NTRU", "type":"string","parameter": "EES1499EP1","pubkey": "" ,"operation":"enc", "plaintext":""}')
17
json_enc["pubkey"]=answ["pubkey"]
18
json_enc["plaintext"]="Hello wolrd!"
19
data_js_n=sending(json.dumps(json_enc))
20
answ_1=json.loads(data_js_n)
21
print "Recived enc NTRU: \n" + (json.dumps(answ_1)) +"\n\n\n"
22
json_dec=json.loads('{ "version": 1 , "algorithm":"NTRU", "type":"string","parameter": "EES1499EP1","privkey": "" ,"operation":"dec", "plaintext":""}')
23
json_dec["privkey"]=answ["privkey"]
24
json_dec["pubkey"]=answ["pubkey"]
25
json_dec["plaintext"]=answ_1["result"]
26
data_js_n=sending(json.dumps(json_dec))
27
answ_2=json.loads(data_js_n)
28
print "Recived dec NTRU: \n" + (json.dumps(answ_2)) +"\n"
Copied!
In this example we generate a NTRU key (EES1499EP1), we enc and dec "Hello world!" string.
On "parameter" can be one of{"EES449EP1", "EES613EP1","EES761EP1","EES677EP1", "EES887EP1","EES1087EP1","EES1087EP2","EES1171EP1","EES1499EP1"}
Json to gen
1
{ "version": 1 , "algorithm":"NTRU", "parameter": "ntru flavor", "operation":"gen"}
Copied!
Json to enc
1
{ "version": 1 , "algorithm":"NTRU", "type":"string","parameter": "ntru flavor",
2
"pubkey": "your ntru hex pubkey" ,"operation":"enc", "plaintext":"your string","hex":BOOL}
Copied!
Json to dec
1
{ "version": 1 , "algorithm":"NTRU", "type":"string","parameter": "ntru flavor",
2
"privkey": "your ntru hex privkey","pubkey":"your ntru hex pubkey" ,"operation":"dec",
3
"plaintext":"your enc hex string"}
Copied!
Copy link