{"id":19692558,"url":"https://github.com/sakkarose/ntru","last_synced_at":"2026-06-13T17:05:47.815Z","repository":{"id":165995716,"uuid":"440047923","full_name":"sakkarose/NTRU","owner":"sakkarose","description":"Simple implementation of NTRU because I was bored.","archived":false,"fork":false,"pushed_at":"2024-06-30T03:21:49.000Z","size":95,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-27T11:51:02.750Z","etag":null,"topics":["implementation","kem","ntru","ntruencrypt","post-quantum-cryptography","python","qmake"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sakkarose.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-20T05:01:48.000Z","updated_at":"2024-06-30T03:21:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"cdde4b7c-592f-4a6c-88a3-bdb9f18713c8","html_url":"https://github.com/sakkarose/NTRU","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sakkarose/NTRU","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sakkarose%2FNTRU","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sakkarose%2FNTRU/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sakkarose%2FNTRU/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sakkarose%2FNTRU/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sakkarose","download_url":"https://codeload.github.com/sakkarose/NTRU/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sakkarose%2FNTRU/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34292339,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-13T02:00:06.617Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["implementation","kem","ntru","ntruencrypt","post-quantum-cryptography","python","qmake"],"created_at":"2024-11-11T19:13:45.127Z","updated_at":"2026-06-13T17:05:47.792Z","avatar_url":"https://github.com/sakkarose.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NTRU\n## Introduction\nJust a simple implementation of **NTRU** which is one of the **Round-3 Finalists of Post-Quantum Cryptography** in **Public-key Encryption and Key-establishment Algorithms**. For the same reason, `sympy` is used for polynomial. So for the larger polynomial rings, this might needs more works. `numpy` is also needed for many things to run this. This is just for studying purposes so the code can be unoptimized and outputs will be uncompressed. Do not use this for actual cryptographic uses. \n\nMoreover, the post-quantum security parameters are suggested from **IEEE p1363.1 Standard** [1].\n\nAt the moment, there is only **NTRUEncrypt** (\u0026 **NTRUDecrypt**).\n\n## To-do \u0026 Work-in-progress\n- Working on **NTRUSign**.\n- Resolving this program's poor performance on **kem** \u0026 **ss-kem** algorithm, so it needs to be reworked in order to handle them. \n\n## Installation\n- No installation needed, but you need to have `sympy` and `numpy` in python.\n- After that you can run the program by executing the `main.py` file .\n- Also pypy3 is optional.\n\n## Parameters [2]\n\n- High security\n  - `-S4`  : Optimized for size.\n  - `-C4`  : Optimized for cost.\n  - `-F4`  : Optimized for speed.\n- Moderate security : `-S3`, `-C3`, `-F3`\n- Low security : `-S2`, `-C2`, `-F2`\n- Lowest security : `-S1`, `-C1`, `-F1`\n\n- If you don't pick parameter, it will use the default parameter which is `F4`.\n\n| Parameter Set  | N | p | q | dg  | df | dr  |\n| :---: | :---: | :---: | :---: | :---: | :---: | :---: |\n| **(S1)** ees401ep1  | 401  | 3  | 2048  | 133  | 113  | 113  |\n| **(S2)** ees449ep1  | 449  | 3  | 2048  | 149  | 134  | 134  |\n| **(S3)** ees677ep1  | 677  | 3  | 2048  | 225  | 157  | 157  |\n| **(S4)** ees1087ep2  | 1087  | 3  | 2048  | 362  | 120  | 120  |\n| **(C1)** ees541ep1  | 541  | 3  | 2048  | 180  | 49  | 49  |\n| **(C2)** ees613ep1  | 613  | 3  | 2048  | 204  | 55  | 55  |\n| **(C3)** ees887ep1  | 887  | 3  | 2048  | 295  | 81  | 81  |\n| **(C4)** ees1171ep1  | 1171  | 3  | 2048  | 390  | 106  | 106  |\n| **(F1)** ees659ep1  | 659  | 3  | 2048  | 219  | 38  | 38  |\n| **(F2)** ees761ep1  | 761  | 3  | 2048  | 253  | 42  | 42  |\n| **(F3)** ees1087ep1  | 1087  | 3  | 2048  | 362  | 63  | 63  |\n| **(F4)** ees1499ep1  | 1499  | 3  | 2048  | 499  | 79  | 79  |\n\n## Generating Key\n- To generate keys. We run the `main.py` with parameter `-g`.\n- To change file name of the keys. We add parameter `-k`. (Default is `ntru`).\n### Example\n- To generate public and private keys with high security, optimized for speed and named \"test_key\".\n```\npython3 main.py -F4 -g -k test_key\n```\n- To generate keys with your own parameters.\n```\npython3 main.py -g -N 1499 -p 3 -q 2048 -dg 499 -df 79 -dr 79\n```\n## Encrypting\n- To encrypt a string, use `-estr`, and `-efile` for a file\n- To define the output, you can use `-of` to write it in a file, and `-ot` will print the output to the screen.\n### Example\n- To encrypt a string \"Hello\" with key named \"test_key\" and print the output on the screen.\n```\npython3 main.py -k test_key -estr \"Hello\" -ot\n```\n- To encrypt a file named \"Hi.txt\" with key named \"test_key\" and write it in the file named \"post_hi.bin\"\n```\npython3 main.py -k test_key -efile Hi.txt -of post_hi.bin\n```\n## Decrypting\n- Same for encrypting, we have `-dstr` for a string and `-dfile` for a file.\n- Both `-of` and `-ot`are also working for decrypting too.\n### Example\n- To decrypt a cyphertext of \"Hello\" we did earlier with key named \"test_key\" and print the output on the screen.\n```\npython3 main.py -k test_key -dstr \"12 -16 18 -4 -15 -28 -23 -20 31 31 -13 7 9 21 -2 4 25 -20 -14 -30 13 3 1 -10 -9 27 -20 -13 5 -31 -13 15 3 -22 13 -2 21 -19 -27 20 -31 25 -14 -3 3 -15 -11 18 -22 -1 -31 -3 -7 21 20 19 -25 -11 25 24 32 -21 -14 -10 19 -15 -26 17 -12 -17 8 -5\" -ot\n```\n- To decrypt a file named \"post_hi.bin\" with key named \"test_key\" and write it in the file named \"post_post_hi.bin\"\n```\npython3 main.py -k test_key -dfile Hi.txt -of post_post_hi.bin\n```\n## Notes\n\n## References\n[1](https://ieeexplore.ieee.org/document/4800404) : \"IEEE Standard Specification for Public Key Cryptographic Techniques Based on Hard Problems over Lattices,\" in IEEE Std 1363.1-2008 , vol., no., pp.1-81, 10 March 2009, doi: 10.1109/IEEESTD.2009.4800404.\n\n[2](https://ieeexplore.ieee.org/document/9137237) : T. Kim and M. -K. Lee, \"Efficient and Secure Implementation of NTRUEncrypt Using Signed Sliding Window Method,\" in IEEE Access, vol. 8, pp. 126591-126605, 2020, doi: 10.1109/ACCESS.2020.3008182.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsakkarose%2Fntru","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsakkarose%2Fntru","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsakkarose%2Fntru/lists"}