{ "info": { "author": "Scott Wyman Neagle, Svetlin Nakov", "author_email": "", "bugtrack_url": null, "classifiers": [], "description": "# PyNewHope\n\nPyNewHope is an **experimental** (an unstable) Python implementation of the **NewHope quantum-safe key-exchange** cryptographic scheme proposed by Alkim, Ducas, Poppelmann, and Schwabe: https://eprint.iacr.org/2015/1092\n\nNewHope uses lattice-based cryptography, more precisely Ring-LWE (ring-learning-with-errors), which is designed to be quantum-resistant.\n\nThis Python implementation is based on, and duplicates much of the functionality of, the reference C implementation available in the `liboqs` repository: https://github.com/open-quantum-safe/liboqs/tree/master/src/kex_rlwe_newhope\n\nThis implementation is designed to be used natively in Python applications, without the need for wrappers or other means of incorporating the C implementation into production software. A testing harness is available in `test_newhope.py`, and documentation is provided as code comments. The code should be readable and usable.\n\n**For educational purposes only!** Avoid using this code in real-world projects.\n\nThis work was submitted as a master's capstone advanced lab to the computer science department at the Courant Institute of Mathematical Sciences at New York University. It should be considered open source, free to use and modify.\n\nPython 3.6 must be installed for this implementation to work, as it relies on `hashlib.shake_128()`, which is only available in version 3.6 and later.\n\nInstructions for installing from PyPI:\n--------------------------------------\n\nThis library is available in the PyPI repository (packaged by [Svetlin Nakov](https://github.com/nakov)). To install it, use this:\n\n```\npip install pynewhope\n```\n\nSample usage:\n-------------\n\n```py\nfrom pynewhope import newhope\n\n# Step 1: Alice generates random keys and her public msg to Bob\nalicePrivKey, aliceMsg = newhope.keygen()\nprint(\"Alice sends to Bob her public message:\", aliceMsg)\n\n# Step 2: Bob receives the msg from Alice and responds to Alice with a msg\nbobSharedKey, bobMsg = newhope.sharedB(aliceMsg)\nprint(\"\\nBob sends to Alice his public message:\", bobMsg)\nprint(\"\\nBob's shared key:\", bobSharedKey)\n\n# Step 3: Alice receives the msg from Bob and generates her shared secret\naliceSharedKey = newhope.sharedA(bobMsg, alicePrivKey)\nprint(\"\\nAlice's shared key:\", aliceSharedKey)\n\nif aliceSharedKey == bobSharedKey:\n print(\"\\nSuccessful key exchange! Keys match.\")\nelse:\n print(\"\\nError! Keys do not match.\")\n```\n\nSample output:\n--------------\n\n```\nAlice sends to Bob her public message: ([1328, 8117, 8737, 6265, 8128, 12924, 3390, 12041, 4568, 7602, 2673, 7517, 2410, 1291, 2125, 2789, 11486, 1568, 12043, 9209, 6681, 9858, 5936, ..., 1021, 2113, 8424, 8501, 3442, 4238, 9503, 4625, 11250, 11609], b\"\\r\\x8c\\x89\\xd0\\xa0\\x06gc8\\xd2%:\\xb0Z'\\x9c\\x8cs\\xf9\\xf8\\xe7\\x9f\\x84T\\xb73\\x85w\\xcc\\xe5\\xb5\\xe1\")\n\nBob sends to Alice his public message: ([2, 0, 3, 1, 0, 3, 0, 3, 0, 1, 0, 1, 0, 0, 1, 1, 1, 3, 0, 2, 0, 2, 2, 1, 1, 3, 2, 3, 3, 3, 3, 1, 3, 1, 0, 1, 2, 0, 1, 1, 3, 3, 2, 1, 1, 2, 0, 3, 3, 2, 1, 1, 1, 0, 2, 3, 1, ..., 3, 3, 2, 2, 0, 1], [9328, 8906, 2517, 6830, 4517, 2142, 8296, 938, 3333, 10585, 12196, 11496, 3726, 12462, 10271, 4871, 4499, 2899, 11284, 8994, 4732, 7381, 2950, 8675, 4349, 2534, 2161, ..., 6591, 6369, 8664, 5182, 10856, 4314, 7919, 3651, 2352, 4103, 6035, 3990])\n\nBob's shared key: [92, 122, 75, 33, 239, 164, 84, 241, 245, 204, 106, 197, 142, 230, 28, 189, 54, 112, 190, 124, 176, 66, 129, 69, 108, 66, 110, 42, 115, 70, 17, 107]\n\nAlice's shared key: [92, 122, 75, 33, 239, 164, 84, 241, 245, 204, 106, 197, 142, 230, 28, 189, 54, 112, 190, 124, 176, 66, 129, 69, 108, 66, 110, 42, 115, 70, 17, 107]\n\nSuccessful key exchange! Keys match.\n```\n\nAs it is visible from the output, the Alice's public message consists of a sequence of polynomial coefficients + a random seed (sequence of bytes). Bob's public message consists of two sequences of polynomial coefficients. The obtained from Alice and Bob shared key consists also of a sequence of polynomial coefficients.\n\nInstructions for cloning and testing PyNewHope on Mac/Linux:\n------------------------------------------------------------\n\nOnce you have Python 3.6 and Git installed, open a terminal and enter the following commands:\n```\ngit clone https://github.com/nakov/PyNewHope\n\ncd PyNewHope\n\npython3.6 test_newhope.py\n```\n\nInstructions for cloning and testing PyNewHope on Windows:\n----------------------------------------------------------\n\nFirst make sure you have Python 3.6 installed.\n\nDownload PyNewHope as a zip file from https://github.com/nakov/PyNewHope using the \"Clone or download\" button.\n\nUnzip PyNewHope into a directory in your Python PATH.\n\nOpen a Python shell and enter the following commands:\n```\nimport test_newhope\n\ntest_newhope\n```\n\nContributors:\n-------------\n - Originally created by Scott Wyman Neagle (2017) - https://github.com/scottwn/\n - Based on the Open Quantum Safe project (2016) - https://github.com/open-quantum-safe/liboqs/\n - Modified by Svetlin Nakov and uploaded to PyPI (2018) - https://github.com/nakov\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "http://www.nakov.com", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/nakov/PyNewHope", "keywords": "NewHope,PQC,post-quantum-cryptography,key-exchange,cryptography", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "PyNewHope", "package_url": "https://pypi.org/project/PyNewHope/", "platform": "", "project_url": "https://pypi.org/project/PyNewHope/", "project_urls": { "Download": "http://www.nakov.com", "Homepage": "https://github.com/nakov/PyNewHope" }, "release_url": "https://pypi.org/project/PyNewHope/0.33/", "requires_dist": null, "requires_python": "", "summary": "An experimental implementation of the NewHope post-quantum key exchange algorithm", "version": "0.33" }, "last_serial": 4536277, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "6bc1f999d473e953ebe701f8ffe14bf8", "sha256": "f41a4af35a4b1d5f72b4746e72ad9a1fad45af54f766eb39468b7a3c3b5593d0" }, "downloads": -1, "filename": "PyNewHope-0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "6bc1f999d473e953ebe701f8ffe14bf8", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 15695, "upload_time": "2018-11-27T22:15:04", "url": "https://files.pythonhosted.org/packages/2d/3a/e43b938d9f6024ab48215a3813ed23d4de60a373ce31d9e4fea13d1af109/PyNewHope-0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "070b126314f4b4a8202eaac8edc0cb5d", "sha256": "ad60b4b478668ece36b429309a500b40b6d96be13f4353db721ffba8d2075478" }, "downloads": -1, "filename": "PyNewHope-0.1.tar.gz", "has_sig": false, "md5_digest": "070b126314f4b4a8202eaac8edc0cb5d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14973, "upload_time": "2018-11-27T22:15:06", "url": "https://files.pythonhosted.org/packages/44/a8/61f689defcaec7a10aef265a3e544070a01f4391230f1e5435f172617608/PyNewHope-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "7568b84431bdaa9bc474ea79862fccd7", "sha256": "56adae15fc84a2f0570e31278e440d463497ba676fbba016dc46f1582046642c" }, "downloads": -1, "filename": "PyNewHope-0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "7568b84431bdaa9bc474ea79862fccd7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 16005, "upload_time": "2018-11-27T23:11:58", "url": "https://files.pythonhosted.org/packages/74/6e/3b0523de764047fd3b28316d4d4408806f48779f0c823a5ff01c1cc02d35/PyNewHope-0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "39e25eac20bee7f8b50f6d74439961eb", "sha256": "08228c3abd0a608e7d16ca01bac3699129d29c4b396a9f1476b2f18f0afe3bc2" }, "downloads": -1, "filename": "PyNewHope-0.2.tar.gz", "has_sig": false, "md5_digest": "39e25eac20bee7f8b50f6d74439961eb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15345, "upload_time": "2018-11-27T23:10:49", "url": "https://files.pythonhosted.org/packages/3c/6a/8b0b58bcb72dfe3906eb0b5206d3293b5ce8e2ec16d627537ade85b8ac10/PyNewHope-0.2.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "a2c97553a6b9a551d714d2829cd66eb7", "sha256": "5b0d0621df81c44c2d9b9cce934dd39b37e7faf0eaf42126e1b4be149ab16370" }, "downloads": -1, "filename": "PyNewHope-0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "a2c97553a6b9a551d714d2829cd66eb7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 15978, "upload_time": "2018-11-27T23:18:37", "url": "https://files.pythonhosted.org/packages/05/5b/a55f300e82686f703e2004fdf1f4782910325bd6942c131819dc8956df3d/PyNewHope-0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "eea980feef23fda64fc0e230a1c36038", "sha256": "eefb8b70760329d51b7948ed80e511a390dca3a4ba54268d596bab4788f9b692" }, "downloads": -1, "filename": "PyNewHope-0.3.tar.gz", "has_sig": false, "md5_digest": "eea980feef23fda64fc0e230a1c36038", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15319, "upload_time": "2018-11-27T23:18:38", "url": "https://files.pythonhosted.org/packages/79/29/03a91a02325dc0b496dd40ad64cbcd2090a81076dc1f92defe1aebe5f6f0/PyNewHope-0.3.tar.gz" } ], "0.31": [ { "comment_text": "", "digests": { "md5": "5e06cced96c2cb416205f42841cac2c9", "sha256": "f688d4bef38b0ed9e13b0cd0cfcf1195ac6dd982b6fb4d5c02483f1eccfba460" }, "downloads": -1, "filename": "PyNewHope-0.31-py3-none-any.whl", "has_sig": false, "md5_digest": "5e06cced96c2cb416205f42841cac2c9", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 16012, "upload_time": "2018-11-27T23:22:43", "url": "https://files.pythonhosted.org/packages/36/51/a23cbbea9a926129178aacb29240b9594aa3749b37642e2d3c29c65c8010/PyNewHope-0.31-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6b0759ed848eff5b4df9f69d22966220", "sha256": "e091ef7a9b81a0564199569efb3d1e850bfb04d762fc4c966ce827158da5943d" }, "downloads": -1, "filename": "PyNewHope-0.31.tar.gz", "has_sig": false, "md5_digest": "6b0759ed848eff5b4df9f69d22966220", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15367, "upload_time": "2018-11-27T23:22:45", "url": "https://files.pythonhosted.org/packages/85/c4/9868a9807091c4adb377b8d99f46029adc2860813cefbcec963a3b7f5ad5/PyNewHope-0.31.tar.gz" } ], "0.32": [ { "comment_text": "", "digests": { "md5": "1657a5b91bda2c82f2a4d4ca160f10d7", "sha256": "aeac50d70a5fbde02a97368e9a627618ef874017293dae97e60135bb1a6e0f18" }, "downloads": -1, "filename": "PyNewHope-0.32-py3-none-any.whl", "has_sig": false, "md5_digest": "1657a5b91bda2c82f2a4d4ca160f10d7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 16019, "upload_time": "2018-11-27T23:26:50", "url": "https://files.pythonhosted.org/packages/f7/74/190f54ea9f8d6ef2f644c50a7a25c95db4021bbf6478eca2329a5d4f344d/PyNewHope-0.32-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "03bdafee3013b87018b512c4002d21ac", "sha256": "c032e8880ef0a0db3405653cc29fa59426730c9a2de4b2454c5623618761b7e6" }, "downloads": -1, "filename": "PyNewHope-0.32.tar.gz", "has_sig": false, "md5_digest": "03bdafee3013b87018b512c4002d21ac", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15413, "upload_time": "2018-11-27T23:26:51", "url": "https://files.pythonhosted.org/packages/ec/51/9c24a4c54e6d39604675c77601541094fd05f6c7d644b277dde935d09eb0/PyNewHope-0.32.tar.gz" } ], "0.33": [ { "comment_text": "", "digests": { "md5": "98b6b3a25c4c556380a6e655c6abef7b", "sha256": "3aeffae418a931390fed1086179697e539c6ad18c2092219014d3185a01612f3" }, "downloads": -1, "filename": "PyNewHope-0.33-py3-none-any.whl", "has_sig": false, "md5_digest": "98b6b3a25c4c556380a6e655c6abef7b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 16007, "upload_time": "2018-11-27T23:29:00", "url": "https://files.pythonhosted.org/packages/ef/04/59a6398d16a6b1c6686b9436737724f72877dcde4519bceeaf37263c4c5d/PyNewHope-0.33-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "08bb0170874fa7a732a3c5a3331a6431", "sha256": "26b9db3159c6a36b81cfed8a24097fcda4348f8a78b2e0480f1e7aa3d6814d23" }, "downloads": -1, "filename": "PyNewHope-0.33.tar.gz", "has_sig": false, "md5_digest": "08bb0170874fa7a732a3c5a3331a6431", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15384, "upload_time": "2018-11-27T23:29:02", "url": "https://files.pythonhosted.org/packages/25/eb/8ae97f399aa95ad882aaa421efacfa0f31737d4b1be594f443cb121a9786/PyNewHope-0.33.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "98b6b3a25c4c556380a6e655c6abef7b", "sha256": "3aeffae418a931390fed1086179697e539c6ad18c2092219014d3185a01612f3" }, "downloads": -1, "filename": "PyNewHope-0.33-py3-none-any.whl", "has_sig": false, "md5_digest": "98b6b3a25c4c556380a6e655c6abef7b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 16007, "upload_time": "2018-11-27T23:29:00", "url": "https://files.pythonhosted.org/packages/ef/04/59a6398d16a6b1c6686b9436737724f72877dcde4519bceeaf37263c4c5d/PyNewHope-0.33-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "08bb0170874fa7a732a3c5a3331a6431", "sha256": "26b9db3159c6a36b81cfed8a24097fcda4348f8a78b2e0480f1e7aa3d6814d23" }, "downloads": -1, "filename": "PyNewHope-0.33.tar.gz", "has_sig": false, "md5_digest": "08bb0170874fa7a732a3c5a3331a6431", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15384, "upload_time": "2018-11-27T23:29:02", "url": "https://files.pythonhosted.org/packages/25/eb/8ae97f399aa95ad882aaa421efacfa0f31737d4b1be594f443cb121a9786/PyNewHope-0.33.tar.gz" } ] }