Skip to content
Liesware edited this page Jan 29, 2019 · 4 revisions

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 ???

import socket
import json
import os,binascii
import time

def sending(message):
	ip = '127.0.0.1'
	port = 6613
	BUFFER_SIZE = 65536
	s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
	s.connect((ip, port))
	s.send(message)
	data = s.recv(BUFFER_SIZE)
	s.close()
	return data

ntru_gen=json.loads('{ "version": 1 , "algorithm":"NTRU", "parameter": "EES1499EP1", "operation":"gen"}')

data_js_n=sending(json.dumps(ntru_gen))
answ=json.loads(data_js_n)
print "Recived gen NTRU: \n" + (json.dumps(answ)) +"\n"
json_enc=json.loads('{ "version": 1 , "algorithm":"NTRU", "type":"string","parameter": "EES1499EP1","pubkey": "" ,"operation":"enc", "plaintext":""}')
json_enc["pubkey"]=answ["pubkey"]
json_enc["plaintext"]="Hello wolrd!"
data_js_n=sending(json.dumps(json_enc))
answ_1=json.loads(data_js_n)
print "Recived enc NTRU: \n" + (json.dumps(answ_1)) +"\n\n\n"
json_dec=json.loads('{ "version": 1 , "algorithm":"NTRU", "type":"string","parameter": "EES1499EP1","privkey": "" ,"operation":"dec", "plaintext":""}')
json_dec["privkey"]=answ["privkey"]
json_dec["pubkey"]=answ["pubkey"]
json_dec["plaintext"]=answ_1["result"]
data_js_n=sending(json.dumps(json_dec))
answ_2=json.loads(data_js_n)
print "Recived dec NTRU: \n" + (json.dumps(answ_2)) +"\n"

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

{ "version": 1 , "algorithm":"NTRU", "parameter": "ntru flavor", "operation":"gen"}

Json to enc

{ "version": 1 , "algorithm":"NTRU", "type":"string","parameter": "ntru flavor",
"pubkey": "your ntru hex pubkey" ,"operation":"enc", "plaintext":"your string","hex":BOOL}

Json to dec

{ "version": 1 , "algorithm":"NTRU", "type":"string","parameter": "ntru flavor",
"privkey": "your ntru hex privkey","pubkey":"your ntru hex pubkey" ,"operation":"dec", 
"plaintext":"your enc hex string"}
You can’t perform that action at this time.