> For the complete documentation index, see [llms.txt](https://coherence.3vidence.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://coherence.3vidence.com/ntru.md).

# NTRU

In order to understand *hex* and *type* parameters read [Hash](https://github.com/liesware/coherence/wiki/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 ???

```python
import requests
import json
import os,binascii

def sending(message):
    url = 'http://127.0.0.1:6613/'
    response = requests.post(url, data=message)
    print response.content
    return response.content

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 o&#x66;*{"EES449EP1", "EES613EP1","EES761EP1","EES677EP1", "EES887EP1","EES1087EP1","EES1087EP2","EES1171EP1","EES1499EP1"}*

Json to gen

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

Json to enc

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

Json to dec

```javascript
{ "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"}
```
