{"id":13629321,"url":"https://github.com/orlp/ed25519","last_synced_at":"2025-04-05T00:10:30.926Z","repository":{"id":6312929,"uuid":"7547840","full_name":"orlp/ed25519","owner":"orlp","description":"Portable C implementation of Ed25519, a high-speed high-security public-key signature system.","archived":false,"fork":false,"pushed_at":"2022-10-02T23:06:28.000Z","size":704,"stargazers_count":491,"open_issues_count":11,"forks_count":157,"subscribers_count":36,"default_branch":"master","last_synced_at":"2024-10-14T03:05:11.011Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"RBSChange/modules.task","license":"zlib","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/orlp.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-01-10T20:13:57.000Z","updated_at":"2024-10-04T13:21:48.000Z","dependencies_parsed_at":"2022-08-06T19:15:27.724Z","dependency_job_id":null,"html_url":"https://github.com/orlp/ed25519","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orlp%2Fed25519","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orlp%2Fed25519/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orlp%2Fed25519/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orlp%2Fed25519/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/orlp","download_url":"https://codeload.github.com/orlp/ed25519/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247266565,"owners_count":20910836,"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-08-01T22:01:07.365Z","updated_at":"2025-04-05T00:10:30.904Z","avatar_url":"https://github.com/orlp.png","language":"C","readme":"Ed25519\n=======\n\nThis is a portable implementation of [Ed25519](http://ed25519.cr.yp.to/) based\non the SUPERCOP \"ref10\" implementation. Additionally there is key exchanging\nand scalar addition included to further aid building a PKI using Ed25519. All\ncode is licensed under the permissive zlib license.\n\nAll code is pure ANSI C without any dependencies, except for the random seed\ngeneration which uses standard OS cryptography APIs (`CryptGenRandom` on\nWindows, `/dev/urandom` on nix). If you wish to be entirely portable define\n`ED25519_NO_SEED`. This disables the `ed25519_create_seed` function, so if your\napplication requires key generation you must supply your own seeding function\n(which is simply a 256 bit (32 byte) cryptographic random number generator).\n\n\nPerformance\n-----------\n\nOn a Windows machine with an Intel Pentium B970 @ 2.3GHz I got the following\nspeeds (running on only one a single core):\n\n    Seed generation: 64us (15625 per second)\n    Key generation: 88us (11364 per second)\n    Message signing (short message): 87us (11494 per second)\n    Message verifying (short message): 228us (4386 per second)\n    Scalar addition: 100us (10000 per second)\n    Key exchange: 220us (4545 per second)\n\nThe speeds on other machines may vary. Sign/verify times will be higher with\nlonger messages. The implementation significantly benefits from 64 bit\narchitectures, if possible compile as 64 bit.\n\n\nUsage\n-----\n\nSimply add all .c and .h files in the `src/` folder to your project and include\n`ed25519.h` in any file you want to use the API. If you prefer to use a shared\nlibrary, only copy `ed25519.h` and define `ED25519_DLL` before importing. A\nwindows DLL is pre-built.\n\nThere are no defined types for seeds, private keys, public keys, shared secrets\nor signatures. Instead simple `unsigned char` buffers are used with the\nfollowing sizes:\n\n```c\nunsigned char seed[32];\nunsigned char signature[64];\nunsigned char public_key[32];\nunsigned char private_key[64];\nunsigned char scalar[32];\nunsigned char shared_secret[32];\n```\n\n**Note:** this library stores private keys in a different format than some other\nlibraries, notably `libsodium`. They tend to store the concatenation of the `seed`\nand `public_key` as their private key representation. If you wish to be compatible\nwith these libraries you must keep the seed around.\n\nAPI\n---\n\n```c\nint ed25519_create_seed(unsigned char *seed);\n```\n\nCreates a 32 byte random seed in `seed` for key generation. `seed` must be a\nwritable 32 byte buffer. Returns 0 on success, and nonzero on failure.\n\n```c\nvoid ed25519_create_keypair(unsigned char *public_key, unsigned char *private_key,\n                            const unsigned char *seed);\n```\n\nCreates a new key pair from the given seed. `public_key` must be a writable 32\nbyte buffer, `private_key` must be a writable 64 byte buffer and `seed` must be\na 32 byte buffer.\n\n```c\nvoid ed25519_sign(unsigned char *signature,\n                  const unsigned char *message, size_t message_len,\n                  const unsigned char *public_key, const unsigned char *private_key);\n```\n\nCreates a signature of the given message with the given key pair. `signature`\nmust be a writable 64 byte buffer. `message` must have at least `message_len`\nbytes to be read. \n\n```c\nint ed25519_verify(const unsigned char *signature,\n                   const unsigned char *message, size_t message_len,\n                   const unsigned char *public_key);\n```\n\nVerifies the signature on the given message using `public_key`. `signature`\nmust be a readable 64 byte buffer. `message` must have at least `message_len`\nbytes to be read. Returns 1 if the signature matches, 0 otherwise.\n\n```c\nvoid ed25519_add_scalar(unsigned char *public_key, unsigned char *private_key,\n                        const unsigned char *scalar);\n```\n\nAdds `scalar` to the given key pair where scalar is a 32 byte buffer (possibly\ngenerated with `ed25519_create_seed`), generating a new key pair. You can\ncalculate the public key sum without knowing the private key and vice versa by\npassing in `NULL` for the key you don't know. This is useful for enforcing\nrandomness on a key pair by a third party while only knowing the public key,\namong other things.  Warning: the last bit of the scalar is ignored - if\ncomparing scalars make sure to clear it with `scalar[31] \u0026= 127`.\n\n\n```c\nvoid ed25519_key_exchange(unsigned char *shared_secret,\n                          const unsigned char *public_key, const unsigned char *private_key);\n```\n\nPerforms a key exchange on the given public key and private key, producing a\nshared secret. It is recommended to hash the shared secret before using it.\n`shared_secret` must be a 32 byte writable buffer where the shared secret will\nbe stored.\n\nExample\n-------\n\n```c\nunsigned char seed[32], public_key[32], private_key[64], signature[64];\nunsigned char other_public_key[32], other_private_key[64], shared_secret[32];\nconst unsigned char message[] = \"TEST MESSAGE\";\n\n/* create a random seed, and a key pair out of that seed */\nif (ed25519_create_seed(seed)) {\n    printf(\"error while generating seed\\n\");\n    exit(1);\n}\n\ned25519_create_keypair(public_key, private_key, seed);\n\n/* create signature on the message with the key pair */\ned25519_sign(signature, message, strlen(message), public_key, private_key);\n\n/* verify the signature */\nif (ed25519_verify(signature, message, strlen(message), public_key)) {\n    printf(\"valid signature\\n\");\n} else {\n    printf(\"invalid signature\\n\");\n}\n\n/* create a dummy keypair to use for a key exchange, normally you'd only have\nthe public key and receive it through some communication channel */\nif (ed25519_create_seed(seed)) {\n    printf(\"error while generating seed\\n\");\n    exit(1);\n}\n\ned25519_create_keypair(other_public_key, other_private_key, seed);\n\n/* do a key exchange with other_public_key */\ned25519_key_exchange(shared_secret, other_public_key, private_key);\n\n/* \n    the magic here is that ed25519_key_exchange(shared_secret, public_key,\n    other_private_key); would result in the same shared_secret\n*/\n\n```\n\nLicense\n-------\nAll code is released under the zlib license. See license.txt for details.\n","funding_links":[],"categories":["C","Maths"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forlp%2Fed25519","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Forlp%2Fed25519","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forlp%2Fed25519/lists"}