{ "info": { "author": "", "author_email": "", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: BSD License", "Programming Language :: Python :: 3", "Programming Language :: Rust" ], "description": "# ed25519-dalek (NEM implementation)\nFast and efficient Rust implementation of ed25519 key generation, signing, and\nverification in Rust.\n\n# Documentation\n\nDocumentation is available [here](https://docs.rs/ed25519-dalek).\n\n# Benchmarks\n\nOn an Intel Skylake i9-7900X running at 3.30 GHz, without TurboBoost, this code achieves\nthe following performance benchmarks:\n\n \u2203!isis\u24b6mistakenot:(master *=)~/code/rust/ed25519-dalek \u2234 cargo bench\n Compiling ed25519-dalek v0.7.0 (file:///home/isis/code/rust/ed25519-dalek)\n Finished release [optimized] target(s) in 3.11s\n Running target/release/deps/ed25519_benchmarks-721332beed423bce\n\n Ed25519 signing time: [15.617 us 15.630 us 15.647 us]\n Ed25519 signature verification time: [45.930 us 45.968 us 46.011 us]\n Ed25519 keypair generation time: [15.440 us 15.465 us 15.492 us]\n\nBy enabling the avx2 backend (on machines with compatible microarchitectures),\nthe performance for signature verification is greatly improved:\n\n \u2203!isis\u24b6mistakenot:(master *=)~/code/rust/ed25519-dalek \u2234 export RUSTFLAGS=-Ctarget_cpu=native\n \u2203!isis\u24b6mistakenot:(master *=)~/code/rust/ed25519-dalek \u2234 cargo bench --features=avx2_backend\n Compiling ed25519-dalek v0.7.0 (file:///home/isis/code/rust/ed25519-dalek)\n Finished release [optimized] target(s) in 4.28s\n Running target/release/deps/ed25519_benchmarks-e4866664de39c84d\n Ed25519 signing time: [15.923 us 15.945 us 15.967 us]\n Ed25519 signature verification time: [33.382 us 33.411 us 33.445 us]\n Ed25519 keypair generation time: [15.246 us 15.260 us 15.275 us]\n\nIn comparison, the equivalent package in Golang performs as follows:\n\n \u2203!isis\u24b6mistakenot:(master *=)~/code/go/src/github.com/agl/ed25519 \u2234 go test -bench .\n BenchmarkKeyGeneration 30000 47007 ns/op\n BenchmarkSigning 30000 48820 ns/op\n BenchmarkVerification 10000 119701 ns/op\n ok github.com/agl/ed25519 5.775s\n\nMaking key generation and signing a rough average of 2x faster, and\nverification 2.5-3x faster depending on the availability of avx2. Of course, this\nis just my machine, and these results\u2014nowhere near rigorous\u2014should be taken\nwith a handful of salt.\n\nTranslating to a rough cycle count: we multiply by a factor of 3.3 to convert\nnanoseconds to cycles per second on a 3300 Mhz CPU, that's 110256 cycles for\nverification and 52618 for signing, which is competitive with hand-optimised\nassembly implementations.\n\nAdditionally, if you're using a CSPRNG from the `rand` crate, the `nightly`\nfeature will enable `u128`/`i128` features there, resulting in potentially\nfaster performance.\n\nIf your protocol or application is able to batch signatures for verification,\nthe `verify_batch()` function has greatly improved performance. On the\naforementioned Intel Skylake i9-7900X, verifying a batch of 96 signatures takes\n1.7673ms. That's 18.4094us, or roughly 60750 cycles, per signature verification,\nmore than double the speed of batch verification given in the original paper\n(this is likely not a fair comparison as that was a Nehalem machine).\nThe numbers after the `/` in the test name refer to the size of the batch:\n\n \u2203!isis\u24b6mistakenot:(master *=)~/code/rust/ed25519-dalek \u2234 export RUSTFLAGS=-Ctarget_cpu=native\n \u2203!isis\u24b6mistakenot:(master *=)~/code/rust/ed25519-dalek \u2234 cargo bench --features=avx2_backend batch\n Compiling ed25519-dalek v0.8.0 (file:///home/isis/code/rust/ed25519-dalek)\n Finished release [optimized] target(s) in 34.16s\n Running target/release/deps/ed25519_benchmarks-cf0daf7d68fc71b6\n Ed25519 batch signature verification/4 time: [105.20 us 106.04 us 106.99 us]\n Ed25519 batch signature verification/8 time: [178.66 us 179.01 us 179.39 us]\n Ed25519 batch signature verification/16 time: [325.65 us 326.67 us 327.90 us]\n Ed25519 batch signature verification/32 time: [617.96 us 620.74 us 624.12 us]\n Ed25519 batch signature verification/64 time: [1.1862 ms 1.1900 ms 1.1943 ms]\n Ed25519 batch signature verification/96 time: [1.7611 ms 1.7673 ms 1.7742 ms]\n Ed25519 batch signature verification/128 time: [2.3320 ms 2.3376 ms 2.3446 ms]\n Ed25519 batch signature verification/256 time: [5.0124 ms 5.0290 ms 5.0491 ms]\n\nAs you can see, there's an optimal batch size for each machine, so you'll likely\nwant to your the benchmarks on your target CPU to discover the best size. For\nthis machine, around 100 signatures per batch is the optimum:\n\n![](https://github.com/dalek-cryptography/ed25519-dalek/blob/master/res/batch-violin-benchmark.svg)\n\nAdditionally, thanks to Rust, this implementation has both type and memory\nsafety. It's also easily readable by a much larger set of people than those who\ncan read qhasm, making it more readily and more easily auditable. We're of\nthe opinion that, ultimately, these features\u2014combined with speed\u2014are more\nvaluable than simply cycle counts alone.\n\n### A Note on Signature Malleability\n\nThe signatures produced by this library are malleable, as discussed in\n[the original paper](https://ed25519.cr.yp.to/ed25519-20110926.pdf):\n\n![](https://github.com/dalek-cryptography/ed25519-dalek/blob/master/res/ed25519-malleability.png)\n\nWe could eliminate the malleability property by multiplying by the curve\ncofactor, however, this would cause our implementation to *not* match the\nbehaviour of every other implementation in existence. As of this writing,\n[RFC 8032](https://tools.ietf.org/html/rfc8032), \"Edwards-Curve Digital\nSignature Algorithm (EdDSA),\" advises that the stronger check should be done.\nWhile we agree that the stronger check should be done, it is our opinion that\none shouldn't get to change the definition of \"ed25519 verification\" a decade\nafter the fact, breaking compatibility with every other implementation.\n\nIn short, if malleable signatures are bad for your protocol, don't use them.\nConsider using a curve25519-based Verifiable Random Function (VRF), such as\n[Trevor Perrin's VXEdDSA](https://www.whispersystems.org/docs/specifications/xeddsa/),\ninstead. We\n[plan](https://github.com/dalek-cryptography/curve25519-dalek/issues/9) to\neventually support VXEdDSA in curve25519-dalek.\n\n# Installation\n\nTo install, add the following to your project's `Cargo.toml`:\n\n```toml\n[dependencies]\ned25519-dalek = {git = \"https://github.com/namuyan/ed25519-dalek\"}\n```\n\nThen, in your library or executable source, add:\n\n```rust\nextern crate ed25519_dalek;\n```\n\nTo use for python:\n\n```bash\npip3 install --user nem_ed25519_rust\n```\n\n```python\nimport nem_ed25519_rust\n \n# keypair generation\nsec, pub = nem_ed25519_rust.generate_keypair()\nprint(\"sk\", sec.hex())\nprint(\"pk\", pub.hex())\n \n# message signature\nmsg = b\"hello world, rust-python combination\"\nsig = nem_ed25519_rust.sign(msg, sec)\nprint(\"sig\", sig.hex())\nnem_ed25519_rust.verify(msg, sig, pub)\n \n# message encryption\nsec_other, pub_other = nem_ed25519_rust.generate_keypair()\nenc = nem_ed25519_rust.encrypt(sec, pub_other, msg)\nprint(\"enc\", enc.hex())\ndec = nem_ed25519_rust.decrypt(sec_other, pub, enc).unwrap()\nprint(\"dec\", dec)\n```\n\n# Features\n\nTo cause your application to build `ed25519-dalek` with the nightly feature\nenabled by default, instead do:\n\n```toml\n[dependencies]\ned25519-dalek = {git = \"https://github.com/namuyan/ed25519-dalek\", features = [\"nightly\"]}\n```\n\nTo cause your application to instead build with the nightly feature enabled\nwhen someone builds with `cargo build --features=\"nightly\"` add the following\nto the `Cargo.toml`:\n\n```toml\n[features]\nnightly = [\"ed25519-dalek/nightly\"]\n```\n\nTo enable [serde](https://serde.rs) support, build `ed25519-dalek` with:\n\n```toml\n[dependencies]\ned25519-dalek = {git = \"https://github.com/namuyan/ed25519-dalek\", features = [\"serde\"]}\n```\n\nBy default, `ed25519-dalek` builds against `curve25519-dalek`'s `u64_backend`\nfeature, which uses Rust's `i128` feature to achieve roughly double the speed as\nthe `u32_backend` feature. When targetting 32-bit systems, however, you'll\nlikely want to compile with\n `cargo build --no-default-features --features=\"u32_backend\"`.\nIf you're building for a machine with avx2 instructions, there's also the\nexperimental `avx2_backend`. To use it, compile with\n`RUSTFLAGS=\"-C target_cpu=native\" cargo build --no-default-features --features=\"avx2_backend\"`", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/namuyan/ed25519-dalek", "keywords": "", "license": "BSD-3", "maintainer": "", "maintainer_email": "", "name": "nem-ed25519-rust", "package_url": "https://pypi.org/project/nem-ed25519-rust/", "platform": "", "project_url": "https://pypi.org/project/nem-ed25519-rust/", "project_urls": { "Homepage": "https://github.com/namuyan/ed25519-dalek" }, "release_url": "https://pypi.org/project/nem-ed25519-rust/1.0.0rc4/", "requires_dist": null, "requires_python": "", "summary": "", "version": "1.0.0rc4" }, "last_serial": 5006272, "releases": { "1.0.0rc2": [ { "comment_text": "", "digests": { "md5": "453bcc5273993d1071ae76b8d5a3924f", "sha256": "39349efe771641c1e3eff22e03a3cc0ea6807f3c74e82fc8c7e35e3b571e77a3" }, "downloads": -1, "filename": "nem-ed25519-rust-1.0.0rc2.tar.gz", "has_sig": false, "md5_digest": "453bcc5273993d1071ae76b8d5a3924f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 25726, "upload_time": "2019-03-22T03:56:46", "url": "https://files.pythonhosted.org/packages/6e/80/b8e93a7847aa2198e80b2d0496753e2457a5ce97c8cfbe4504c3ff5223cd/nem-ed25519-rust-1.0.0rc2.tar.gz" } ], "1.0.0rc4": [ { "comment_text": "", "digests": { "md5": "d50a454fec178ce27c37a03267359887", "sha256": "e5b564845d93c5a5e9fde04e4890b549e542576c2253837db424da680588b66a" }, "downloads": -1, "filename": "nem_ed25519_rust-1.0.0rc4-cp36-cp36m-win_amd64.whl", "has_sig": false, "md5_digest": "d50a454fec178ce27c37a03267359887", "packagetype": "bdist_wheel", "python_version": "cp36", "requires_python": null, "size": 211069, "upload_time": "2019-03-30T07:12:27", "url": "https://files.pythonhosted.org/packages/b1/08/76e4547c2acd363dbe4c6a83aaf7c3e766d7f614878aeffa6e5956e70970/nem_ed25519_rust-1.0.0rc4-cp36-cp36m-win_amd64.whl" }, { "comment_text": "", "digests": { "md5": "49943a7374df90dd2d791d01b4eef272", "sha256": "a7598f0fb5aa8b1d6c4a1d7b2fe624aaef02c4a02c76dc1254953534411caadb" }, "downloads": -1, "filename": "nem-ed25519-rust-1.0.0rc4.tar.gz", "has_sig": false, "md5_digest": "49943a7374df90dd2d791d01b4eef272", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 26020, "upload_time": "2019-03-23T14:53:39", "url": "https://files.pythonhosted.org/packages/43/fc/5d1b68c234931bbed60797f7295f2d47367a90db07346af63e4d514d7b31/nem-ed25519-rust-1.0.0rc4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d50a454fec178ce27c37a03267359887", "sha256": "e5b564845d93c5a5e9fde04e4890b549e542576c2253837db424da680588b66a" }, "downloads": -1, "filename": "nem_ed25519_rust-1.0.0rc4-cp36-cp36m-win_amd64.whl", "has_sig": false, "md5_digest": "d50a454fec178ce27c37a03267359887", "packagetype": "bdist_wheel", "python_version": "cp36", "requires_python": null, "size": 211069, "upload_time": "2019-03-30T07:12:27", "url": "https://files.pythonhosted.org/packages/b1/08/76e4547c2acd363dbe4c6a83aaf7c3e766d7f614878aeffa6e5956e70970/nem_ed25519_rust-1.0.0rc4-cp36-cp36m-win_amd64.whl" }, { "comment_text": "", "digests": { "md5": "49943a7374df90dd2d791d01b4eef272", "sha256": "a7598f0fb5aa8b1d6c4a1d7b2fe624aaef02c4a02c76dc1254953534411caadb" }, "downloads": -1, "filename": "nem-ed25519-rust-1.0.0rc4.tar.gz", "has_sig": false, "md5_digest": "49943a7374df90dd2d791d01b4eef272", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 26020, "upload_time": "2019-03-23T14:53:39", "url": "https://files.pythonhosted.org/packages/43/fc/5d1b68c234931bbed60797f7295f2d47367a90db07346af63e4d514d7b31/nem-ed25519-rust-1.0.0rc4.tar.gz" } ] }