{"id":17325492,"url":"https://github.com/matoking/python-ed25519-blake2b","last_synced_at":"2025-04-14T16:56:53.309Z","repository":{"id":57425568,"uuid":"171721714","full_name":"Matoking/python-ed25519-blake2b","owner":"Matoking","description":"Python bindings to the Ed25519 public-key signature system (BLAKE2b fork)","archived":false,"fork":false,"pushed_at":"2024-01-22T18:09:51.000Z","size":1083,"stargazers_count":9,"open_issues_count":2,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-23T19:39:00.099Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Matoking.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":"2019-02-20T17:49:18.000Z","updated_at":"2024-06-19T09:17:09.848Z","dependencies_parsed_at":"2024-06-19T09:17:08.512Z","dependency_job_id":"30aa151b-2224-4515-ac8a-6031c9e72232","html_url":"https://github.com/Matoking/python-ed25519-blake2b","commit_stats":{"total_commits":101,"total_committers":6,"mean_commits":"16.833333333333332","dds":"0.12871287128712872","last_synced_commit":"bbc52046755dff306100b03609ff14b27e490277"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Matoking%2Fpython-ed25519-blake2b","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Matoking%2Fpython-ed25519-blake2b/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Matoking%2Fpython-ed25519-blake2b/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Matoking%2Fpython-ed25519-blake2b/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Matoking","download_url":"https://codeload.github.com/Matoking/python-ed25519-blake2b/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248923665,"owners_count":21183949,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-10-15T14:13:34.161Z","updated_at":"2025-04-14T16:56:53.289Z","avatar_url":"https://github.com/Matoking.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Python Bindings to the Ed25519 Digital Signature System (BLAKE2b fork)\n======================================================================\n\n[![Build Status](https://travis-ci.org/Matoking/python-ed25519-blake2b.png?branch=master)](https://travis-ci.org/Matoking/python-ed25519-blake2b)\n\nThis fork of [python-ed25519](https://github.com/warner/python-ed25519)\nuses BLAKE2b instead of SHA512 as a hash algorithm. This allows the library\nto create and verify signatures used in [NANO](https://nano.org). Some of the\ndocumentation in the repository may be out-of-date and refer to the\noriginal SHA512-based implementation.\n\nThis package provides python bindings to a C implementation of the Ed25519\npublic-key signature system [1][]. The C code is copied from the SUPERCOP\nbenchmark suite [2][], using the portable \"ref\" implementation (not the\nhigh-performance assembly code), and is very similar to the copy in the NaCl\nlibrary [3][]. The C code is in the public domain [4][]. This python binding\nis released under the MIT license (see LICENSE in this distribution).\n\nWith this library, you can quickly (2ms) create signing+verifying keypairs,\nderive a verifying key from a signing key, sign messages, and verify the\nsignatures. The keys and signatures are very short, making them easy to\nhandle and incorporate into other protocols. All known attacks take at least\n2^128 operations, providing the same security level as AES-128, NIST P-256,\nand RSA-3072.\n\n\n## Dependencies\n\nThis library includes a copy of all the C code necessary. You will need\nPython 2.x (2.6 or later) or Python 3.x (3.3 or later) and a C compiler. The\ntests are run automatically against python 2.7, 3.3, 3.4, 3.5, 3.6, 3.7 and pypy\nversions of Python 2 and 3.\n\n\n## Speed and Key Sizes\n\nSigning key seeds are merely 32 bytes of random data, so generating a signing\nkey is trivial. Deriving a public verifying key takes more time, as do the\nactual signing and verifying operations.\n\nOn my 2010-era Mac laptop (2.8GHz Core2Duo), deriving a verifying key takes\n1.9ms, signing takes 1.9ms, and verification takes 6.3ms. The\nhigh-performance assembly code in SUPERCOP (amd64-51-30k and amd64-64-24k) is\nup to 100x faster than the portable reference version, and the python\noverhead appears to be minimal (1-2us), so future releases may run even\nfaster.\n\nEd25519 private signing keys are 32 bytes long (this seed is expanded to 64\nbytes when necessary). The public verifying keys are also 32 bytes long.\nSignatures are 64 bytes long. All operations provide a 128-bit security\nlevel.\n\n\n## Testing\n\nThe Ed25519 web site includes a (spectacularly slow) pure-python\nimplementation for educational purposes. That code includes a set of\nknown-answer-tests. Those tests are included in this distribution, and takes\nabout 17 seconds to execute. The distribution also includes unit tests of the\nobject-oriented SigningKey / VerifyingKey layer. Run test.py to execute these\ntests.\n\n\n## Security\n\nThe Ed25519 algorithm and C implementation are carefully designed to prevent\ntiming attacks. The Python wrapper might not preserve this property. Until it\nhas been audited for this purpose, do not allow attackers to measure how long\nit takes you to generate a keypair or sign a message. Key generation depends\nupon a strong source of random numbers. Do not use it on a system where\nos.urandom() is weak.\n\nUnlike typical DSA/ECDSA algorithms, signing does *not* require a source of\nentropy. Ed25519 signatures are deterministic: using the same key to sign the\nsame data any number of times will result in the same signature each time.\n\n\n## Compilation\n\nTo build and install the library, run the normal setup.py command:\n\n```\npython setup.py build\nsudo python setup.py install\n```\n\nYou can run the (fast) test suite, the (slower) known-answer-tests, and the\nspeed-benchmarks through setup.py commands too:\n\n```\npython setup.py test\npython setup.py test_kat\npython setup.py speed\n```\n\n## Prefixes and Encodings\n\nThe basic keypair/sign/verify operations work on binary bytestrings: signing\nkeys are created with a 32-byte seed or a 64-byte expanded form, verifying\nkeys are serialized as 32-byte binary strings, and signatures are 64-byte\nbinary strings.\n\nAll methods that generate or accept bytestrings take a prefix= argument,\nwhich is simply prepended to the output or stripped from the input. This can\nbe used for a cheap version check: if you use e.g. prefix=\"pubkey0-\" when\nhandling verifying keys, and later update your application to use a different\nkind of key (and update to \"pubkey1-\"), then older receivers will throw a\nclean error when faced with a key format that they cannot handle.\n\nThese methods also accept an encoding= argument, which makes them return an\nASCII string instead of a binary bytestring. This makes it convenient to\ndisplay verifying keys or signatures to cut-and-paste or encode into JSON\nmessages. Be careful when encouraging users to cut-and-paste signing keys,\nsince you might enable them to accidentally reveal those keys: in general, it\nshould require slightly more attention to handle signing keys than verifying\nkeys.\n\nencoding= can be set to one of \"base64\", \"base32\", \"base16\", or \"hex\" (an\nalias for \"base16\"). The strings are stripped of trailing \"=\" markers and\nlowercased (for base32/base16).\n\n\n## Usage\n\nThe first step is to create a signing key and store it. The safest way to\ngenerate a key is with the create_keypair() function, which uses 32 bytes of\nrandom data from os.urandom() (although you can provide an alternative\nentropy source with the entropy= argument):\n\n```python\nimport ed25519_blake2b\nsigning_key, verifying_key = ed25519_blake2b.create_keypair()\nopen(\"my-secret-key\",\"wb\").write(signing_key.to_bytes())\nvkey_hex = verifying_key.to_ascii(encoding=\"hex\")\nprint \"the public key is\", vkey_hex\n```\n\nThe private signing key string produced by to_bytes() is 64 bytes long, and\nincludes a copy of the public key (to avoid the 1.9ms needed to recalculate\nit later). If you want to store less data (and recompute the public key\nlater), you can store just the 32 byte seed instead:\n\n```python\nopen(\"my-secret-seed\",\"wb\").write(signing_key.to_seed())\n```\n\nThe signing key is an instance of the ed25519_blake2b.SigningKey class. To\nreconstruct this instance from a serialized form, the constructor accepts the\noutput of either `.to_bytes()` or `.to_seed()`:\n\n```python\nkeydata = open(\"my-secret-key\",\"rb\").read()\nsigning_key = ed25519_blake2b.SigningKey(keydata)\n \nseed = open(\"my-secret-seed\",\"rb\").read()\nsigning_key2 = ed25519_blake2b.SigningKey(seed)\nassert signing_key == signing_key2\n```\n\nSpecial-purpose applications may want to derive keypairs from existing\nsecrets; any 32-byte uniformly-distributed random string can be provided as a\nseed:\n\n```python\nimport os, hashlib\nmaster = os.urandom(87)\nseed = hashlib.sha256(master).digest()\nsigning_key = ed25519_blake2b.SigningKey(seed)\n```\n\nOnce you have the SigningKey instance, use its .sign() method to sign a\nmessage. The signature is 64 bytes, but can be generated in printable form\nwith the encoding= argument:\n\n```python\nsig = signing_key.sign(b\"hello world\", encoding=\"base64\")\nprint \"sig is:\", sig\n```\n\nOn the verifying side, the receiver first needs to construct a\ned25519_blake2b.VerifyingKey instance from the serialized string, then use its\n.verify() method on the signature and message:\n\n```python\nvkey_hex = b\"1246b84985e1ab5f83f4ec2bdf271114666fd3d9e24d12981a3c861b9ed523c6\"\nverifying_key = ed25519_blake2b.VerifyingKey(vkey_hex, encoding=\"hex\")\ntry:\n  verifying_key.verify(sig, b\"hello world\", encoding=\"base64\")\n  print \"signature is good\"\nexcept ed25519_blake2b.BadSignatureError:\n  print \"signature is bad!\"\n```\n\nIf you happen to have the SigningKey but not the corresponding VerifyingKey,\nyou can derive it with `.get_verifying_key()`. This allows the sending side to\nhold just 32 bytes of data and derive everything else from that:\n\n```python\nkeydata = open(\"my-secret-seed\",\"rb\").read()\nsigning_key = ed25519_blake2b.SigningKey(keydata)\nverifying_key = signing_key.get_verifying_key()\n```\n\nThere is also a basic command-line keygen/sign/verify tool in bin/edsig .\n\n\n## API Summary\n\nThe complete API is summarized here:\n\n```python\nsk,vk = ed25519_blake2b.create_keypair(entropy=os.urandom)\nvk = sk.get_verifying_key()\n \nsignature = sk.sign(message, prefix=, encoding=)\nvk.verify(signature, message, prefix=, encoding=)\n \nseed = sk.to_seed(prefix=)\nsk = SigningKey(seed, prefix=)\nbytes = sk.to_bytes(prefix=)\nsk = SigningKey(bytes, prefix=)\nascii = sk.to_ascii(prefix=, encoding=)  # encodes seed\nsk = SigningKey(ascii, prefix=, encoding=)\n \nbytes = vk.to_bytes(prefix=)\nvk = VerifyingKey(bytes, prefix=)\nascii = vk.to_ascii(prefix=, encoding=)\nvk = VerifyingKey(ascii, prefix=, encoding=)\n```\n\n\n\n\n[1]: http://ed25519.cr.yp.to/\n[2]: http://bench.cr.yp.to/supercop.html\n[3]: http://nacl.cr.yp.to/\n[4]: http://ed25519.cr.yp.to/software.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatoking%2Fpython-ed25519-blake2b","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatoking%2Fpython-ed25519-blake2b","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatoking%2Fpython-ed25519-blake2b/lists"}