{"id":13531382,"url":"https://github.com/dalek-cryptography/x25519-dalek","last_synced_at":"2025-06-10T17:39:43.527Z","repository":{"id":25220967,"uuid":"103325555","full_name":"dalek-cryptography/x25519-dalek","owner":"dalek-cryptography","description":"X25519 elliptic curve Diffie-Hellman key exchange in pure-Rust, using curve25519-dalek.","archived":false,"fork":false,"pushed_at":"2023-09-01T19:33:25.000Z","size":285,"stargazers_count":338,"open_issues_count":9,"forks_count":135,"subscribers_count":18,"default_branch":"main","last_synced_at":"2025-05-02T15:02:44.567Z","etag":null,"topics":["cryptography","curve25519","elliptic-curve-diffie-hellman","keyexchange","rust"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dalek-cryptography.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","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":"2017-09-12T22:14:24.000Z","updated_at":"2025-04-14T17:49:17.000Z","dependencies_parsed_at":"2024-11-02T18:31:30.028Z","dependency_job_id":"47a3775a-1feb-4ce1-aa32-4e1797c9aaff","html_url":"https://github.com/dalek-cryptography/x25519-dalek","commit_stats":{"total_commits":158,"total_committers":22,"mean_commits":7.181818181818182,"dds":0.6962025316455696,"last_synced_commit":"25fa593df20b098fcca04c89d88fc61fed8e413c"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dalek-cryptography%2Fx25519-dalek","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dalek-cryptography%2Fx25519-dalek/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dalek-cryptography%2Fx25519-dalek/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dalek-cryptography%2Fx25519-dalek/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dalek-cryptography","download_url":"https://codeload.github.com/dalek-cryptography/x25519-dalek/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dalek-cryptography%2Fx25519-dalek/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259118838,"owners_count":22808065,"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":["cryptography","curve25519","elliptic-curve-diffie-hellman","keyexchange","rust"],"created_at":"2024-08-01T07:01:02.516Z","updated_at":"2025-06-10T17:39:43.494Z","avatar_url":"https://github.com/dalek-cryptography.png","language":"Rust","funding_links":[],"categories":["Libraries","Rust","库 Libraries","Cryptography"],"sub_categories":["Cryptography","密码学 Cryptography","Asymmetric Cryptography"],"readme":"# ARCHIVED\n\nThis repo has been [moved](https://github.com/dalek-cryptography/curve25519-dalek). Please direct all issues and pull requests to the new repo.\n\nThis repo will remain here in a read-only state for historical purposes.\n\n---\n\n# x25519-dalek  [![](https://img.shields.io/crates/v/x25519-dalek.svg)](https://crates.io/crates/x25519-dalek) [![](https://docs.rs/x25519-dalek/badge.svg)](https://docs.rs/x25519-dalek) [![](https://travis-ci.org/dalek-cryptography/x25519-dalek.svg?branch=master)](https://travis-ci.org/dalek-cryptography/x25519-dalek)\n\nA pure-Rust implementation of x25519 elliptic curve Diffie-Hellman key exchange,\nwith curve operations provided by\n[curve25519-dalek](https://github.com/dalek-cryptography/curve25519-dalek).\n\nThis crate provides two levels of API: a bare byte-oriented `x25519`\nfunction which matches the function specified in [RFC7748][rfc7748], as\nwell as a higher-level Rust API for static and ephemeral Diffie-Hellman.\n\n## Examples\n\n\u003ca href=\"https://shop.bubblesort.io\"\u003e\n\u003cimg\n  style=\"float: right; width: auto; height: 300px;\"\n  src=\"https://raw.githubusercontent.com/dalek-cryptography/x25519-dalek/master/res/bubblesort-zines-secret-messages-cover.jpeg\"/\u003e\n\u003c/a\u003e\n\nAlice and Bob are two adorable kittens who have lost their mittens, and they\nwish to be able to send secret messages to each other to coordinate finding\nthem, otherwise—if their caretaker cat finds out—they will surely be called\nnaughty kittens and be given no pie!\n\nBut the two kittens are quite clever.  Even though their paws are still too big\nand the rest of them is 90% fuzziness, these clever kittens have been studying\nup on modern public key cryptography and have learned a nifty trick called\n*elliptic curve Diffie-Hellman key exchange*.  With the right incantations, the\nkittens will be able to secretly organise to find their mittens, and then spend\nthe rest of the afternoon nomming some yummy pie!\n\nFirst, Alice uses `EphemeralSecret::random()` and then\n`PublicKey::from()` to produce her secret and public keys:\n\n```ignore\nuse x25519_dalek::{EphemeralSecret, PublicKey};\n\nlet alice_secret = EphemeralSecret::random();\nlet alice_public = PublicKey::from(\u0026alice_secret);\n```\n\nBob does the same:\n\n```ignore\n# use x25519_dalek::{EphemeralSecret, PublicKey};\nlet bob_secret = EphemeralSecret::random();\nlet bob_public = PublicKey::from(\u0026bob_secret);\n```\n\nAlice meows across the room, telling `alice_public` to Bob, and Bob\nloudly meows `bob_public` back to Alice.  Alice now computes her\nshared secret with Bob by doing:\n\n```rust\n# use rand_core::OsRng;\n# use x25519_dalek::{EphemeralSecret, PublicKey};\n# let alice_secret = EphemeralSecret::new(OsRng);\n# let alice_public = PublicKey::from(\u0026alice_secret);\n# let bob_secret = EphemeralSecret::new(OsRng);\n# let bob_public = PublicKey::from(\u0026bob_secret);\nlet alice_shared_secret = alice_secret.diffie_hellman(\u0026bob_public);\n```\n\nSimilarly, Bob computes a shared secret by doing:\n\n```rust\n# use rand_core::OsRng;\n# use x25519_dalek::{EphemeralSecret, PublicKey};\n# let alice_secret = EphemeralSecret::new(OsRng);\n# let alice_public = PublicKey::from(\u0026alice_secret);\n# let bob_secret = EphemeralSecret::new(OsRng);\n# let bob_public = PublicKey::from(\u0026bob_secret);\nlet bob_shared_secret = bob_secret.diffie_hellman(\u0026alice_public);\n```\n\nThese secrets are the same:\n\n```rust\n# use rand_core::OsRng;\n# use x25519_dalek::{EphemeralSecret, PublicKey};\n# let alice_secret = EphemeralSecret::new(OsRng);\n# let alice_public = PublicKey::from(\u0026alice_secret);\n# let bob_secret = EphemeralSecret::new(OsRng);\n# let bob_public = PublicKey::from(\u0026bob_secret);\n# let alice_shared_secret = alice_secret.diffie_hellman(\u0026bob_public);\n# let bob_shared_secret = bob_secret.diffie_hellman(\u0026alice_public);\nassert_eq!(alice_shared_secret.as_bytes(), bob_shared_secret.as_bytes());\n```\n\nVoilà!  Alice and Bob can now use their shared secret to encrypt their\nmeows, for example, by using it to generate a key and nonce for an\nauthenticated-encryption cipher.\n\nThis example used the ephemeral DH API, which ensures that secret keys\ncannot be reused; Alice and Bob could instead use the static DH API\nand load a long-term secret key.\n\n# Installation\n\nTo install, add the following to your project's `Cargo.toml`:\n\n```toml\n[dependencies]\nx25519-dalek = \"2.0.0-rc.3\"\n```\n\n# MSRV\n\nCurrent MSRV is 1.60.\n\n# Documentation\n\nDocumentation is available [here](https://docs.rs/x25519-dalek).\n\n# Performance and backend selection\n\nPerformance is a secondary goal behind correctness, safety, and clarity, but we aim to be competitive with other implementations. To this end, we allow users to choose their _backend_, i.e., the underlying implementation of elliptic curve and scalar arithmetic. Different backends have different use cases. For example, if you demand formally verified code, you want to use the `fiat` backend (as it was generated from [Fiat Crypto][fiat]).\n\nFurther instructions and details regarding backends can be found in the [curve25519-dalek docs](https://github.com/dalek-cryptography/curve25519-dalek#backends).\n\n# Note\n\nThis code matches the [RFC7748][rfc7748] test vectors.\nThe elliptic curve\noperations are provided by `curve25519-dalek`, which makes a best-effort\nattempt to prevent software side-channels.\n\n\"Secret Messages\" cover image and [zine](https://shop.bubblesort.io/products/secret-messages-zine)\ncopyright © Amy Wibowo ([@sailorhg](https://twitter.com/sailorhg))\n\n[rfc7748]: https://tools.ietf.org/html/rfc7748\n\n# See also\n\n- [crypto_box]: pure Rust public-key authenticated encryption compatible with\n  the NaCl family of encryption libraries (libsodium, TweetNaCl) which uses\n  `x25519-dalek` for key agreement\n\n[fiat]: https://github.com/mit-plv/fiat-crypto\n[crypto_box]: https://github.com/RustCrypto/nacl-compat/tree/master/crypto_box\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdalek-cryptography%2Fx25519-dalek","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdalek-cryptography%2Fx25519-dalek","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdalek-cryptography%2Fx25519-dalek/lists"}