From 1587b4c24ff381cd7c1c7667992902ea26ce105b Mon Sep 17 00:00:00 2001 From: zz-sol Date: Thu, 26 Mar 2026 08:09:10 -0400 Subject: [PATCH] refactor and merge curve and ed crates (#6) * refactor and merge curve and ed crates * fmt * ci * fmt again * ci * Update bench.rs * fix ubuntu --- Cargo.lock | 460 +------ Cargo.toml | 4 +- curve25519/curve25519-cuda/Cargo.toml | 2 +- curve25519/curve25519-derive/CHANGELOG.md | 8 - curve25519/curve25519-derive/Cargo.toml | 18 - curve25519/curve25519-derive/LICENSE-APACHE | 201 --- curve25519/curve25519-derive/LICENSE-MIT | 23 - curve25519/curve25519-derive/README.md | 191 --- curve25519/curve25519-derive/src/lib.rs | 463 ------- curve25519/curve25519-derive/tests/tests.rs | 152 --- curve25519/ed25519-heea/CHANGELOG.md | 136 -- curve25519/ed25519-heea/Cargo.lock | 1190 ----------------- curve25519/ed25519-heea/Cargo.toml | 79 -- curve25519/ed25519-heea/DEVELOPERS.md | 44 - curve25519/ed25519-heea/LICENSE-APACHE | 203 --- curve25519/ed25519-heea/LICENSE-MIT | 20 - curve25519/ed25519-heea/README.md | 139 -- .../ACKNOWLEDGEMENTS.md | 0 .../CHANGELOG_dalek.md | 0 .../{curve25519 => solana-ed25519}/Cargo.toml | 22 +- .../{curve25519 => solana-ed25519}/LICENSE | 0 .../{curve25519 => solana-ed25519}/Makefile | 0 .../{curve25519 => solana-ed25519}/README.md | 94 +- .../README_dalek.md | 0 .../README_zebra.md | 0 .../benches/bench.rs | 26 +- .../benches/dalek_benchmarks.rs | 13 +- .../{curve25519 => solana-ed25519}/build.rs | 0 .../assets/rustdoc-include-katex-header.html | 0 .../docs/avx2-notes.md | 0 .../docs/ifma-notes.md | 0 .../docs/parallel-formulas.md | 0 .../examples/pkcs8-v1.der | Bin .../examples/pkcs8-v1.pem | 0 .../examples/pkcs8-v2-bad-ver-key.der | Bin .../examples/pkcs8-v2-bad-ver-key.pem | 0 .../examples/pkcs8-v2.der | Bin .../examples/pkcs8-v2.pem | 0 .../examples/pubkey.der | Bin .../examples/pubkey.pem | 0 .../src/backend.rs | 0 .../src/backend/serial.rs | 0 .../src/backend/serial/curve_models.rs | 0 .../src/backend/serial/scalar_mul.rs | 0 .../backend/serial/scalar_mul/pippenger.rs | 0 .../serial/scalar_mul/precomputed_straus.rs | 0 .../src/backend/serial/scalar_mul/straus.rs | 0 .../serial/scalar_mul/variable_base.rs | 0 .../serial/scalar_mul/vartime_double_base.rs | 0 .../serial/scalar_mul/vartime_triple_base.rs | 0 .../src/backend/serial/u64.rs | 0 .../src/backend/serial/u64/constants.rs | 0 .../src/backend/serial/u64/field.rs | 0 .../src/backend/serial/u64/scalar.rs | 0 .../src/backend/vector.rs | 0 .../src/backend/vector/avx2.rs | 0 .../src/backend/vector/avx2/constants.rs | 0 .../src/backend/vector/avx2/edwards.rs | 2 +- .../src/backend/vector/avx2/field.rs | 2 +- .../src/backend/vector/packed_simd.rs | 2 +- .../src/backend/vector/scalar_mul.rs | 0 .../backend/vector/scalar_mul/pippenger.rs | 2 +- .../vector/scalar_mul/precomputed_straus.rs | 2 +- .../src/backend/vector/scalar_mul/straus.rs | 2 +- .../vector/scalar_mul/variable_base.rs | 2 +- .../vector/scalar_mul/vartime_double_base.rs | 2 +- .../vector/scalar_mul/vartime_triple_base.rs | 2 +- .../src/constants.rs | 0 .../src/diagnostics.rs | 0 .../lib.rs => solana-ed25519/src/ed_sigs.rs} | 14 +- .../src/ed_sigs}/batch.rs | 18 +- .../src/ed_sigs}/error.rs | 0 .../src/ed_sigs}/signing_key.rs | 12 +- .../solana-ed25519/src/ed_sigs/tests.rs | 9 + .../src/ed_sigs}/tests/batch.rs | 13 +- .../src/ed_sigs}/tests/decoding.rs | 2 +- .../src/ed_sigs}/tests/encoding.rs | 4 +- .../src/ed_sigs}/tests/heea.rs | 10 +- .../src/ed_sigs}/tests/rfc8032.rs | 2 +- .../src/ed_sigs}/tests/small_order.rs | 10 +- .../src/ed_sigs}/tests/unit_tests.rs | 8 +- .../src/ed_sigs/tests/util.rs} | 6 +- .../src/ed_sigs}/verification_key.rs | 13 +- .../src/edwards.rs | 8 +- .../src/edwards/affine.rs | 0 .../src/field.rs | 0 .../{curve25519 => solana-ed25519}/src/lib.rs | 6 + .../src/lizard.rs | 0 .../src/lizard/README.md | 0 .../src/lizard/jacobi_quartic.rs | 0 .../src/lizard/lizard_constants.rs | 0 .../src/lizard/lizard_ristretto.rs | 0 .../src/lizard/u64_constants.rs | 0 .../src/macros.rs | 0 .../src/montgomery.rs | 0 .../src/ristretto.rs | 19 +- .../src/ristretto/elligator.rs | 0 .../src/scalar.rs | 4 +- .../src/scalar/heea.rs | 2 +- .../src/short_weierstrass.rs | 0 .../src/traits.rs | 0 .../src/window.rs | 0 .../tests/build_tests.sh | 0 .../vendor/ristretto.sage | 0 104 files changed, 249 insertions(+), 3417 deletions(-) delete mode 100644 curve25519/curve25519-derive/CHANGELOG.md delete mode 100644 curve25519/curve25519-derive/Cargo.toml delete mode 100644 curve25519/curve25519-derive/LICENSE-APACHE delete mode 100644 curve25519/curve25519-derive/LICENSE-MIT delete mode 100644 curve25519/curve25519-derive/README.md delete mode 100644 curve25519/curve25519-derive/src/lib.rs delete mode 100644 curve25519/curve25519-derive/tests/tests.rs delete mode 100644 curve25519/ed25519-heea/CHANGELOG.md delete mode 100644 curve25519/ed25519-heea/Cargo.lock delete mode 100644 curve25519/ed25519-heea/Cargo.toml delete mode 100644 curve25519/ed25519-heea/DEVELOPERS.md delete mode 100644 curve25519/ed25519-heea/LICENSE-APACHE delete mode 100644 curve25519/ed25519-heea/LICENSE-MIT delete mode 100644 curve25519/ed25519-heea/README.md rename curve25519/{curve25519 => solana-ed25519}/ACKNOWLEDGEMENTS.md (100%) rename curve25519/{curve25519 => solana-ed25519}/CHANGELOG_dalek.md (100%) rename curve25519/{curve25519 => solana-ed25519}/Cargo.toml (82%) rename curve25519/{curve25519 => solana-ed25519}/LICENSE (100%) rename curve25519/{curve25519 => solana-ed25519}/Makefile (100%) rename curve25519/{curve25519 => solana-ed25519}/README.md (58%) rename curve25519/{curve25519 => solana-ed25519}/README_dalek.md (100%) rename curve25519/{ed25519-heea => solana-ed25519}/README_zebra.md (100%) rename curve25519/{ed25519-heea => solana-ed25519}/benches/bench.rs (81%) rename curve25519/{curve25519 => solana-ed25519}/benches/dalek_benchmarks.rs (97%) rename curve25519/{curve25519 => solana-ed25519}/build.rs (100%) rename curve25519/{curve25519 => solana-ed25519}/docs/assets/rustdoc-include-katex-header.html (100%) rename curve25519/{curve25519 => solana-ed25519}/docs/avx2-notes.md (100%) rename curve25519/{curve25519 => solana-ed25519}/docs/ifma-notes.md (100%) rename curve25519/{curve25519 => solana-ed25519}/docs/parallel-formulas.md (100%) rename curve25519/{ed25519-heea/tests => solana-ed25519}/examples/pkcs8-v1.der (100%) rename curve25519/{ed25519-heea/tests => solana-ed25519}/examples/pkcs8-v1.pem (100%) rename curve25519/{ed25519-heea/tests => solana-ed25519}/examples/pkcs8-v2-bad-ver-key.der (100%) rename curve25519/{ed25519-heea/tests => solana-ed25519}/examples/pkcs8-v2-bad-ver-key.pem (100%) rename curve25519/{ed25519-heea/tests => solana-ed25519}/examples/pkcs8-v2.der (100%) rename curve25519/{ed25519-heea/tests => solana-ed25519}/examples/pkcs8-v2.pem (100%) rename curve25519/{ed25519-heea/tests => solana-ed25519}/examples/pubkey.der (100%) rename curve25519/{ed25519-heea/tests => solana-ed25519}/examples/pubkey.pem (100%) rename curve25519/{curve25519 => solana-ed25519}/src/backend.rs (100%) rename curve25519/{curve25519 => solana-ed25519}/src/backend/serial.rs (100%) rename curve25519/{curve25519 => solana-ed25519}/src/backend/serial/curve_models.rs (100%) rename curve25519/{curve25519 => solana-ed25519}/src/backend/serial/scalar_mul.rs (100%) rename curve25519/{curve25519 => solana-ed25519}/src/backend/serial/scalar_mul/pippenger.rs (100%) rename curve25519/{curve25519 => solana-ed25519}/src/backend/serial/scalar_mul/precomputed_straus.rs (100%) rename curve25519/{curve25519 => solana-ed25519}/src/backend/serial/scalar_mul/straus.rs (100%) rename curve25519/{curve25519 => solana-ed25519}/src/backend/serial/scalar_mul/variable_base.rs (100%) rename curve25519/{curve25519 => solana-ed25519}/src/backend/serial/scalar_mul/vartime_double_base.rs (100%) rename curve25519/{curve25519 => solana-ed25519}/src/backend/serial/scalar_mul/vartime_triple_base.rs (100%) rename curve25519/{curve25519 => solana-ed25519}/src/backend/serial/u64.rs (100%) rename curve25519/{curve25519 => solana-ed25519}/src/backend/serial/u64/constants.rs (100%) rename curve25519/{curve25519 => solana-ed25519}/src/backend/serial/u64/field.rs (100%) rename curve25519/{curve25519 => solana-ed25519}/src/backend/serial/u64/scalar.rs (100%) rename curve25519/{curve25519 => solana-ed25519}/src/backend/vector.rs (100%) rename curve25519/{curve25519 => solana-ed25519}/src/backend/vector/avx2.rs (100%) rename curve25519/{curve25519 => solana-ed25519}/src/backend/vector/avx2/constants.rs (100%) rename curve25519/{curve25519 => solana-ed25519}/src/backend/vector/avx2/edwards.rs (99%) rename curve25519/{curve25519 => solana-ed25519}/src/backend/vector/avx2/field.rs (99%) rename curve25519/{curve25519 => solana-ed25519}/src/backend/vector/packed_simd.rs (99%) rename curve25519/{curve25519 => solana-ed25519}/src/backend/vector/scalar_mul.rs (100%) rename curve25519/{curve25519 => solana-ed25519}/src/backend/vector/scalar_mul/pippenger.rs (98%) rename curve25519/{curve25519 => solana-ed25519}/src/backend/vector/scalar_mul/precomputed_straus.rs (98%) rename curve25519/{curve25519 => solana-ed25519}/src/backend/vector/scalar_mul/straus.rs (98%) rename curve25519/{curve25519 => solana-ed25519}/src/backend/vector/scalar_mul/variable_base.rs (95%) rename curve25519/{curve25519 => solana-ed25519}/src/backend/vector/scalar_mul/vartime_double_base.rs (97%) rename curve25519/{curve25519 => solana-ed25519}/src/backend/vector/scalar_mul/vartime_triple_base.rs (98%) rename curve25519/{curve25519 => solana-ed25519}/src/constants.rs (100%) rename curve25519/{curve25519 => solana-ed25519}/src/diagnostics.rs (100%) rename curve25519/{ed25519-heea/src/lib.rs => solana-ed25519/src/ed_sigs.rs} (50%) rename curve25519/{ed25519-heea/src => solana-ed25519/src/ed_sigs}/batch.rs (94%) rename curve25519/{ed25519-heea/src => solana-ed25519/src/ed_sigs}/error.rs (100%) rename curve25519/{ed25519-heea/src => solana-ed25519/src/ed_sigs}/signing_key.rs (97%) create mode 100644 curve25519/solana-ed25519/src/ed_sigs/tests.rs rename curve25519/{ed25519-heea => solana-ed25519/src/ed_sigs}/tests/batch.rs (81%) rename curve25519/{ed25519-heea => solana-ed25519/src/ed_sigs}/tests/decoding.rs (99%) rename curve25519/{ed25519-heea => solana-ed25519/src/ed_sigs}/tests/encoding.rs (99%) rename curve25519/{ed25519-heea => solana-ed25519/src/ed_sigs}/tests/heea.rs (90%) rename curve25519/{ed25519-heea => solana-ed25519/src/ed_sigs}/tests/rfc8032.rs (99%) rename curve25519/{ed25519-heea => solana-ed25519/src/ed_sigs}/tests/small_order.rs (95%) rename curve25519/{ed25519-heea => solana-ed25519/src/ed_sigs}/tests/unit_tests.rs (85%) rename curve25519/{ed25519-heea/tests/util/mod.rs => solana-ed25519/src/ed_sigs/tests/util.rs} (98%) rename curve25519/{ed25519-heea/src => solana-ed25519/src/ed_sigs}/verification_key.rs (98%) rename curve25519/{curve25519 => solana-ed25519}/src/edwards.rs (99%) rename curve25519/{curve25519 => solana-ed25519}/src/edwards/affine.rs (100%) rename curve25519/{curve25519 => solana-ed25519}/src/field.rs (100%) rename curve25519/{curve25519 => solana-ed25519}/src/lib.rs (93%) rename curve25519/{curve25519 => solana-ed25519}/src/lizard.rs (100%) rename curve25519/{curve25519 => solana-ed25519}/src/lizard/README.md (100%) rename curve25519/{curve25519 => solana-ed25519}/src/lizard/jacobi_quartic.rs (100%) rename curve25519/{curve25519 => solana-ed25519}/src/lizard/lizard_constants.rs (100%) rename curve25519/{curve25519 => solana-ed25519}/src/lizard/lizard_ristretto.rs (100%) rename curve25519/{curve25519 => solana-ed25519}/src/lizard/u64_constants.rs (100%) rename curve25519/{curve25519 => solana-ed25519}/src/macros.rs (100%) rename curve25519/{curve25519 => solana-ed25519}/src/montgomery.rs (100%) rename curve25519/{curve25519 => solana-ed25519}/src/ristretto.rs (99%) rename curve25519/{curve25519 => solana-ed25519}/src/ristretto/elligator.rs (100%) rename curve25519/{curve25519 => solana-ed25519}/src/scalar.rs (99%) rename curve25519/{curve25519 => solana-ed25519}/src/scalar/heea.rs (99%) rename curve25519/{curve25519 => solana-ed25519}/src/short_weierstrass.rs (100%) rename curve25519/{curve25519 => solana-ed25519}/src/traits.rs (100%) rename curve25519/{curve25519 => solana-ed25519}/src/window.rs (100%) rename curve25519/{curve25519 => solana-ed25519}/tests/build_tests.sh (100%) rename curve25519/{curve25519 => solana-ed25519}/vendor/ristretto.sage (100%) diff --git a/Cargo.lock b/Cargo.lock index 6da0a13..a6cac25 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13,21 +13,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "addr2line" -version = "0.25.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5d307320b3181d6d7954e663bd7c774a838b8220fe0593c86d9fb09f498b4b" -dependencies = [ - "gimli", -] - -[[package]] -name = "adler2" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" - [[package]] name = "aho-corasick" version = "1.1.4" @@ -67,21 +52,6 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" -[[package]] -name = "backtrace" -version = "0.3.76" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb531853791a215d7c62a30daf0dde835f381ab5de4589cfe7c649d2cbe92bd6" -dependencies = [ - "addr2line", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", - "windows-link", -] - [[package]] name = "base64ct" version = "1.8.3" @@ -130,15 +100,6 @@ dependencies = [ "wyz", ] -[[package]] -name = "block-buffer" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" -dependencies = [ - "generic-array", -] - [[package]] name = "block-buffer" version = "0.12.0" @@ -154,12 +115,6 @@ version = "3.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - [[package]] name = "cast" version = "0.3.0" @@ -245,33 +200,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9" -[[package]] -name = "color-eyre" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5920befb47832a6d61ee3a3a846565cfa39b331331e68a3b1d1116630f2f26d" -dependencies = [ - "backtrace", - "color-spantrace", - "eyre", - "indenter", - "once_cell", - "owo-colors", - "tracing-error", -] - -[[package]] -name = "color-spantrace" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8b88ea9df13354b55bc7234ebcce36e6ef896aca2e42a15de9e10edce01b427" -dependencies = [ - "once_cell", - "owo-colors", - "tracing-core", - "tracing-error", -] - [[package]] name = "const-oid" version = "0.9.6" @@ -306,9 +234,9 @@ dependencies = [ "cast", "ciborium", "clap", - "criterion-plot 0.5.0", + "criterion-plot", "is-terminal", - "itertools 0.10.5", + "itertools", "num-traits", "once_cell", "oorandom", @@ -322,29 +250,6 @@ dependencies = [ "walkdir", ] -[[package]] -name = "criterion" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1c047a62b0cc3e145fa84415a3191f628e980b194c2755aa12300a4e6cbd928" -dependencies = [ - "anes", - "cast", - "ciborium", - "clap", - "criterion-plot 0.6.0", - "itertools 0.13.0", - "num-traits", - "oorandom", - "plotters", - "rayon", - "regex", - "serde", - "serde_json", - "tinytemplate", - "walkdir", -] - [[package]] name = "criterion-plot" version = "0.5.0" @@ -352,17 +257,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" dependencies = [ "cast", - "itertools 0.10.5", -] - -[[package]] -name = "criterion-plot" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b1bcc0dc7dfae599d84ad0b1a55f80cde8af3725da8313b528da95ef783e338" -dependencies = [ - "cast", - "itertools 0.13.0", + "itertools", ] [[package]] @@ -406,16 +301,14 @@ dependencies = [ ] [[package]] -name = "curve25519-dalek" -version = "3.2.0" +name = "curve25519-dalek-derive" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ - "byteorder", - "digest 0.9.0", - "rand_core 0.5.1", - "subtle", - "zeroize", + "proc-macro2", + "quote", + "syn 2.0.117", ] [[package]] @@ -429,22 +322,13 @@ dependencies = [ "zeroize", ] -[[package]] -name = "digest" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" -dependencies = [ - "generic-array", -] - [[package]] name = "digest" version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4850db49bf08e663084f7fb5c87d202ef91a3907271aff24a94eb97ff039153c" dependencies = [ - "block-buffer 0.12.0", + "block-buffer", "crypto-common", ] @@ -455,47 +339,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" dependencies = [ "pkcs8", - "serde", "signature", ] -[[package]] -name = "ed25519-heea" -version = "0.1.0" -dependencies = [ - "bincode", - "color-eyre", - "criterion 0.7.0", - "der", - "ed25519", - "ed25519-zebra", - "hashbrown 0.16.1", - "hex", - "once_cell", - "pkcs8", - "rand 0.8.5", - "rand_core 0.6.4", - "serde", - "sha2 0.11.0-rc.5", - "solana-curve25519", - "subtle", - "zeroize", -] - -[[package]] -name = "ed25519-zebra" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c85a1fff1b329c96789427b09d4d5949b2d2f717851fd1e65a18878bee19d1ff" -dependencies = [ - "curve25519-dalek", - "hex", - "rand_core 0.5.1", - "serde", - "sha2 0.9.9", - "thiserror", -] - [[package]] name = "either" version = "1.15.0" @@ -518,16 +364,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "eyre" -version = "0.6.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cd915d99f24784cdc19fd37ef22b97e3ff0ae756c7e492e9fbfe897d61e2aec" -dependencies = [ - "indenter", - "once_cell", -] - [[package]] name = "fastrand" version = "2.3.0" @@ -552,39 +388,12 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" -[[package]] -name = "foldhash" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" - [[package]] name = "funty" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" -[[package]] -name = "generic-array" -version = "0.14.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bb6743198531e02858aeaea5398fcc883e71851fcbcb5a2f773e2fb6cb1edf2" -dependencies = [ - "typenum", - "version_check", -] - -[[package]] -name = "getrandom" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" -dependencies = [ - "cfg-if", - "libc", - "wasi 0.9.0+wasi-snapshot-preview1", -] - [[package]] name = "getrandom" version = "0.2.17" @@ -593,7 +402,7 @@ checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" dependencies = [ "cfg-if", "libc", - "wasi 0.11.1+wasi-snapshot-preview1", + "wasi", ] [[package]] @@ -622,12 +431,6 @@ dependencies = [ "wasip3", ] -[[package]] -name = "gimli" -version = "0.32.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e629b9b98ef3dd8afe6ca2bd0f89306cec16d43d907889945bc5d6687f2f13c7" - [[package]] name = "half" version = "2.7.1" @@ -645,7 +448,9 @@ version = "0.15.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" dependencies = [ - "foldhash 0.1.5", + "allocator-api2", + "equivalent", + "foldhash", ] [[package]] @@ -653,11 +458,6 @@ name = "hashbrown" version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" -dependencies = [ - "allocator-api2", - "equivalent", - "foldhash 0.2.0", -] [[package]] name = "heck" @@ -701,12 +501,6 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" -[[package]] -name = "indenter" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "964de6e86d545b246d84badc0fef527924ace5134f30641c203ef52ba83f58d5" - [[package]] name = "indexmap" version = "2.13.0" @@ -739,15 +533,6 @@ dependencies = [ "either", ] -[[package]] -name = "itertools" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" -dependencies = [ - "either", -] - [[package]] name = "itoa" version = "1.0.18" @@ -764,12 +549,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "lazy_static" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" - [[package]] name = "leb128fmt" version = "0.1.0" @@ -806,15 +585,6 @@ version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" -[[package]] -name = "miniz_oxide" -version = "0.8.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" -dependencies = [ - "adler2", -] - [[package]] name = "num-bigint" version = "0.3.3" @@ -844,15 +614,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "object" -version = "0.37.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff76201f031d8863c38aa7f905eca4f53abbfa15f609db4277d44cd8938f33fe" -dependencies = [ - "memchr", -] - [[package]] name = "once_cell" version = "1.21.4" @@ -865,18 +626,6 @@ version = "11.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e" -[[package]] -name = "opaque-debug" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" - -[[package]] -name = "owo-colors" -version = "4.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d211803b9b6b570f68772237e415a029d5a50c65d382910b879fb19d3271f94d" - [[package]] name = "pem-rfc7468" version = "0.7.0" @@ -886,12 +635,6 @@ dependencies = [ "base64ct", ] -[[package]] -name = "pin-project-lite" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" - [[package]] name = "pkcs8" version = "0.10.2" @@ -1062,15 +805,6 @@ dependencies = [ "rand_core 0.9.5", ] -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom 0.1.16", -] - [[package]] name = "rand_core" version = "0.6.4" @@ -1153,12 +887,6 @@ version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a" -[[package]] -name = "rustc-demangle" -version = "0.1.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b50b8869d9fc858ce7266cce0194bd74df58b9d0e3f6df3a9fc8eb470d95c09d" - [[package]] name = "rustc_version" version = "0.4.1" @@ -1308,19 +1036,6 @@ dependencies = [ "zmij", ] -[[package]] -name = "sha2" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" -dependencies = [ - "block-buffer 0.9.0", - "cfg-if", - "cpufeatures 0.2.17", - "digest 0.9.0", - "opaque-debug", -] - [[package]] name = "sha2" version = "0.11.0-rc.5" @@ -1329,16 +1044,7 @@ checksum = "7c5f3b1e2dc8aad28310d8410bd4d7e180eca65fca176c52ab00d364475d0024" dependencies = [ "cfg-if", "cpufeatures 0.2.17", - "digest 0.11.2", -] - -[[package]] -name = "sharded-slab" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" -dependencies = [ - "lazy_static", + "digest", ] [[package]] @@ -1352,20 +1058,36 @@ name = "signature" version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" + +[[package]] +name = "solana-curve25519-cuda" +version = "0.1.0" dependencies = [ + "cc", + "criterion", + "rand 0.8.5", + "rand_chacha 0.3.1", "rand_core 0.6.4", + "rayon", + "solana-ed25519", + "which", ] [[package]] -name = "solana-curve25519" +name = "solana-ed25519" version = "0.1.0" dependencies = [ "bincode", "cfg-if", "cpufeatures 0.2.17", - "criterion 0.5.1", - "digest 0.11.2", + "criterion", + "curve25519-dalek-derive", + "der", + "digest", + "ed25519", + "hashbrown 0.15.5", "hex", + "pkcs8", "proptest", "rand 0.10.0", "rand_core 0.10.0", @@ -1373,35 +1095,11 @@ dependencies = [ "rustcrypto-ff", "rustcrypto-group", "serde", - "sha2 0.11.0-rc.5", - "solana-curve25519-derive", + "sha2", "subtle", "zeroize", ] -[[package]] -name = "solana-curve25519-cuda" -version = "0.1.0" -dependencies = [ - "cc", - "criterion 0.5.1", - "rand 0.8.5", - "rand_chacha 0.3.1", - "rand_core 0.6.4", - "rayon", - "solana-curve25519", - "which", -] - -[[package]] -name = "solana-curve25519-derive" -version = "0.1.0" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.117", -] - [[package]] name = "spki" version = "0.7.3" @@ -1459,35 +1157,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "thiserror" -version = "1.0.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.117", -] - -[[package]] -name = "thread_local" -version = "1.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f60246a4944f24f6e018aa17cdeffb7818b76356965d03b07d6a9886e8962185" -dependencies = [ - "cfg-if", -] - [[package]] name = "tinytemplate" version = "1.2.1" @@ -1498,47 +1167,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "tracing" -version = "0.1.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" -dependencies = [ - "pin-project-lite", - "tracing-core", -] - -[[package]] -name = "tracing-core" -version = "0.1.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" -dependencies = [ - "once_cell", - "valuable", -] - -[[package]] -name = "tracing-error" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b1581020d7a273442f5b45074a6a57d5757ad0a47dac0e9f0bd57b81936f3db" -dependencies = [ - "tracing", - "tracing-subscriber", -] - -[[package]] -name = "tracing-subscriber" -version = "0.3.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7f578e5945fb242538965c2d0b04418d38ec25c79d160cd279bf0731c8d319" -dependencies = [ - "sharded-slab", - "thread_local", - "tracing-core", -] - [[package]] name = "typenum" version = "1.19.0" @@ -1563,18 +1191,6 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" -[[package]] -name = "valuable" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" - -[[package]] -name = "version_check" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" - [[package]] name = "wait-timeout" version = "0.2.1" @@ -1594,12 +1210,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - [[package]] name = "wasi" version = "0.11.1+wasi-snapshot-preview1" diff --git a/Cargo.toml b/Cargo.toml index 5a605a4..79f9e59 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,9 +1,7 @@ [workspace] members = [ "curve25519/curve25519-cuda", - "curve25519/curve25519", - "curve25519/curve25519-derive", - "curve25519/ed25519-heea", + "curve25519/solana-ed25519", ] resolver = "2" diff --git a/curve25519/curve25519-cuda/Cargo.toml b/curve25519/curve25519-cuda/Cargo.toml index 69ab68e..84cc50a 100644 --- a/curve25519/curve25519-cuda/Cargo.toml +++ b/curve25519/curve25519-cuda/Cargo.toml @@ -7,7 +7,7 @@ authors = ["Anza Cryptography Team"] [dependencies] # Keep the dependency key as "curve25519" so that all existing `use curve25519::…` # references in source files remain valid; the actual package is curve25519-sol. -curve25519 = { path = "../curve25519", package = "solana-curve25519" } +curve25519 = { path = "../solana-ed25519", package = "solana-ed25519" } rand = "0.8" rand_chacha = "0.3" rand_core = "0.6" diff --git a/curve25519/curve25519-derive/CHANGELOG.md b/curve25519/curve25519-derive/CHANGELOG.md deleted file mode 100644 index 8a0915b..0000000 --- a/curve25519/curve25519-derive/CHANGELOG.md +++ /dev/null @@ -1,8 +0,0 @@ -# Changelog - -Entries are listed in reverse chronological order per undeprecated -major series. - -### 0.1.1 - -* Copied over license files from [original](https://github.com/koute/unsafe_target_feature/tree/389ae00d34cf0ff589cb8d9b38a85ae1b05ebfdc) repo diff --git a/curve25519/curve25519-derive/Cargo.toml b/curve25519/curve25519-derive/Cargo.toml deleted file mode 100644 index 4c322a3..0000000 --- a/curve25519/curve25519-derive/Cargo.toml +++ /dev/null @@ -1,18 +0,0 @@ -[package] -name = "solana-curve25519-derive" -version = "0.1.0" -edition = "2021" - -authors = ["Anza Cryptography Team"] -license = "MIT OR Apache-2.0" -readme = "README.md" -description = "Proc-macro helpers for solana-curve25519 (forked from curve25519-derive)" - -[lib] -name = "curve25519_derive" -proc-macro = true - -[dependencies] -proc-macro2 = "1.0.66" -quote = "1.0.31" -syn = { version = "2.0.27", features = ["full"] } diff --git a/curve25519/curve25519-derive/LICENSE-APACHE b/curve25519/curve25519-derive/LICENSE-APACHE deleted file mode 100644 index 16fe87b..0000000 --- a/curve25519/curve25519-derive/LICENSE-APACHE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - -2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - -Copyright [yyyy] [name of copyright owner] - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/curve25519/curve25519-derive/LICENSE-MIT b/curve25519/curve25519-derive/LICENSE-MIT deleted file mode 100644 index 31aa793..0000000 --- a/curve25519/curve25519-derive/LICENSE-MIT +++ /dev/null @@ -1,23 +0,0 @@ -Permission is hereby granted, free of charge, to any -person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the -Software without restriction, including without -limitation the rights to use, copy, modify, merge, -publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice -shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF -ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT -SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR -IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. diff --git a/curve25519/curve25519-derive/README.md b/curve25519/curve25519-derive/README.md deleted file mode 100644 index e3986b9..0000000 --- a/curve25519/curve25519-derive/README.md +++ /dev/null @@ -1,191 +0,0 @@ -# A more convenient `#[target_feature]` replacement - -To get good performance out of SIMD everything on the SIMD codepath must be inlined. -With how SIMD is currently implemented in Rust one of two things have to be true for -a function using SIMD to be inlinable: (and this includes the SIMD intrinsics themselves) - - a) The whole program has to be compiled with the relevant `-C target-cpu` or `-C target-feature` flags. - - b) SIMD support must be automatically detected at runtime, and every function on the SIMD codepath must be marked with `#[target_feature]`. - -Both have their downsides. Setting the `target-cpu` or `target-features` makes the resulting binary -incompatible with older CPUs, while using `#[target_feature]` is incredibly inconvenient. - -This crate is meant to make `#[target_feature]` less painful to use. - -## Problems with `#[target_feature]` - -When we're not compiling with the relevant `target-cpu`/`target-feature` flags everything on -the SIMD codepath must be marked with the `#[target_feature]` attribute. This is not a problem -when all of your SIMD code is neatly encapsulated inside of a single function, but once you start -to build out more elaborate abstractions it starts to become painful to use. - - * It can only be used on `unsafe` functions, so everything on your SIMD codepath now has to be `unsafe`. - - In theory this is nice - these functions require the relevant SIMD instructions to be present at runtime, - so calling them without checking is obviously unsafe! But in practice this is rarely what you want. When - you build an abstraction over SIMD code you usually want to assume that *internally* within your module - all of the necessary SIMD instructions are available, and you only want to check this at the boundaries - when you're first entering your module. You do *not* want to infect everything *inside* of the module with - `unsafe` since you've already checked this invariant at the module's API boundary. - - * It cannot be used on non-`unsafe` trait methods. - - If you're implementing a trait, say for example `std::ops::Add`, then you cannot mark the method `unsafe` - unless the original trait also has it marked as `unsafe`, and usually it doesn't. - - * It makes it impossible to abstract over a given SIMD instruction set using a trait. - - For example, let's assume you want to abstract over which SIMD instructions you use using a trait in the following way: - - ```rust - trait Backend { - unsafe fn sum(input: &[u32]) -> u32; - } - - struct AVX; - # #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] - impl Backend for AVX { - #[target_feature(enable = "avx")] - unsafe fn sum(xs: &[u32]) -> u32 { - // ... - todo!(); - } - } - - struct AVX2; - # #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] - impl Backend for AVX2 { - #[target_feature(enable = "avx2")] - unsafe fn sum(xs: &[u32]) -> u32 { - // ... - todo!(); - } - } - - // And now you want a have function which calls into that trait: - unsafe fn do_calculations(xs: &[u32]) -> u32 where B: Backend { - let value = B::sum(xs); - // ...do some more calculations here... - value - } - ``` - - We have a problem here. This has to be marked with `#[target_feature]`, and that has to specify the concrete - feature flag for a given SIMD instruction set, but this function is generic so we can't do that! - -## How does this crate make it better? - -### You can now mark safe functions with `#[target_feature]` - -This crate exposes an `#[unsafe_target_feature]` macro which works just like `#[target_feature]` except -it moves the `unsafe` from the function prototype into the macro name, and can be used on safe functions. - -```rust -# #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] -#[target_feature(enable = "avx2")] -unsafe fn func() {} -``` - -```rust -use curve25519_derive::unsafe_target_feature; - -// No `unsafe` on the function itself! -# #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] -#[unsafe_target_feature("avx2")] -fn func() {} -``` - -It can also be used to mark functions inside of impls: - -```rust,compile_fail -struct S; - -impl core::ops::Add for S { - type Output = S; - // ERROR: method `add` has an incompatible type for trait - #[target_feature(enable = "avx2")] - unsafe fn add(self, rhs: S) -> S { - S - } -} -``` - -```rust -use curve25519_derive::unsafe_target_feature; - -struct S; - -# #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] -#[unsafe_target_feature("avx2")] -impl core::ops::Add for S { - type Output = S; - // No `unsafe` on the function itself! - fn add(self, rhs: S) -> S { - S - } -} - -``` - -### You can generate specialized copies of a module for each target feature - -```rust -use curve25519_derive::unsafe_target_feature_specialize; - -# #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] -#[unsafe_target_feature_specialize("sse2", "avx2", conditional("avx512ifma", nightly))] -mod simd { - #[for_target_feature("sse2")] - pub const CONSTANT: u32 = 1; - - #[for_target_feature("avx2")] - pub const CONSTANT: u32 = 2; - - #[for_target_feature("avx512ifma")] - pub const CONSTANT: u32 = 3; - - pub fn func() { /* ... */ } -} - -# #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] -fn entry_point() { - #[cfg(nightly)] - if std::is_x86_feature_detected!("avx512ifma") { - return simd_avx512ifma::func(); - } - - if std::is_x86_feature_detected!("avx2") { - return simd_avx2::func(); - } - - if std::is_x86_feature_detected!("sse2") { - return simd_sse2::func(); - } - - unimplemented!(); -} -``` - -## How to use `#[unsafe_target_feature]`? - - - Can be used on `fn`s, `impl`s and `mod`s. - - When used on a function will only apply to that function; it won't apply to any nested functions, traits, mods, etc. - - When used on an `impl` will only apply to all of the functions directly defined inside of that `impl`. - - When used on a `mod` will only apply to all of the `fn`s and `impl`s directly defined inside of that `mod`. - - Cannot be used on methods which use `self` or `Self`; instead use it on the `impl` in which the method is defined. - -## License - -Licensed under either of - - * Apache License, Version 2.0, [LICENSE-APACHE](LICENSE-APACHE) - * MIT license ([LICENSE-MIT](LICENSE-MIT)) - -at your option. - -### Contribution - -Unless you explicitly state otherwise, any contribution intentionally submitted -for inclusion in the work by you, as defined in the Apache-2.0 license, shall be -dual licensed as above, without any additional terms or conditions. diff --git a/curve25519/curve25519-derive/src/lib.rs b/curve25519/curve25519-derive/src/lib.rs deleted file mode 100644 index 1fecd91..0000000 --- a/curve25519/curve25519-derive/src/lib.rs +++ /dev/null @@ -1,463 +0,0 @@ -#![doc = include_str!("../README.md")] - -use proc_macro::TokenStream; -use proc_macro2::TokenStream as TokenStream2; -use syn::spanned::Spanned; - -macro_rules! unsupported_if_some { - ($value:expr) => { - if let Some(value) = $value { - return syn::Error::new(value.span(), "unsupported by #[unsafe_target_feature(...)]") - .into_compile_error() - .into(); - } - }; -} - -macro_rules! unsupported { - ($value: expr) => { - return syn::Error::new( - $value.span(), - "unsupported by #[unsafe_target_feature(...)]", - ) - .into_compile_error() - .into() - }; -} - -mod kw { - syn::custom_keyword!(conditional); -} - -enum SpecializeArg { - LitStr(syn::LitStr), - Conditional(Conditional), -} - -impl SpecializeArg { - fn lit(&self) -> &syn::LitStr { - match self { - SpecializeArg::LitStr(lit) => lit, - SpecializeArg::Conditional(conditional) => &conditional.lit, - } - } - - fn condition(&self) -> Option<&TokenStream2> { - match self { - SpecializeArg::LitStr(..) => None, - SpecializeArg::Conditional(conditional) => Some(&conditional.attr), - } - } -} - -struct Conditional { - lit: syn::LitStr, - attr: TokenStream2, -} - -impl syn::parse::Parse for Conditional { - fn parse(input: syn::parse::ParseStream) -> syn::Result { - let lit = input.parse()?; - input.parse::()?; - let attr = input.parse()?; - - Ok(Conditional { lit, attr }) - } -} - -impl syn::parse::Parse for SpecializeArg { - fn parse(input: syn::parse::ParseStream) -> syn::Result { - let lookahead = input.lookahead1(); - if lookahead.peek(kw::conditional) { - input.parse::()?; - - let content; - syn::parenthesized!(content in input); - - let conditional = content.parse()?; - Ok(SpecializeArg::Conditional(conditional)) - } else { - Ok(SpecializeArg::LitStr(input.parse()?)) - } - } -} - -struct SpecializeArgs(syn::punctuated::Punctuated); - -impl syn::parse::Parse for SpecializeArgs { - fn parse(input: syn::parse::ParseStream) -> syn::Result { - Ok(Self(syn::punctuated::Punctuated::parse_terminated(input)?)) - } -} - -#[proc_macro_attribute] -pub fn unsafe_target_feature(attributes: TokenStream, input: TokenStream) -> TokenStream { - let attributes = syn::parse_macro_input!(attributes as syn::LitStr); - let item = syn::parse_macro_input!(input as syn::Item); - process_item(&attributes, item, true) -} - -#[proc_macro_attribute] -pub fn unsafe_target_feature_specialize( - attributes: TokenStream, - input: TokenStream, -) -> TokenStream { - let attributes = syn::parse_macro_input!(attributes as SpecializeArgs); - let item_mod = syn::parse_macro_input!(input as syn::ItemMod); - - let mut out = Vec::new(); - for attributes in attributes.0 { - let features: Vec<_> = attributes - .lit() - .value() - .split(',') - .map(|feature| feature.replace(' ', "")) - .collect(); - let name = format!("{}_{}", item_mod.ident, features.join("_")); - let ident = syn::Ident::new(&name, item_mod.ident.span()); - let mut attrs = item_mod.attrs.clone(); - if let Some(condition) = attributes.condition() { - attrs.push(syn::Attribute { - pound_token: Default::default(), - style: syn::AttrStyle::Outer, - bracket_token: Default::default(), - meta: syn::Meta::List(syn::MetaList { - path: syn::Ident::new("cfg", attributes.lit().span()).into(), - delimiter: syn::MacroDelimiter::Paren(Default::default()), - tokens: condition.clone(), - }), - }); - } - - let item_mod = process_mod( - attributes.lit(), - syn::ItemMod { - attrs, - ident, - ..item_mod.clone() - }, - Some(features), - ); - - out.push(item_mod); - } - - quote::quote! { - #(#out)* - } - .into() -} - -fn process_item(attributes: &syn::LitStr, item: syn::Item, strict: bool) -> TokenStream { - match item { - syn::Item::Fn(function) => process_function(attributes, function, None), - syn::Item::Impl(item_impl) => process_impl(attributes, item_impl), - syn::Item::Mod(item_mod) => process_mod(attributes, item_mod, None).into(), - item => { - if strict { - unsupported!(item) - } else { - quote::quote! { #item }.into() - } - } - } -} - -fn process_mod( - attributes: &syn::LitStr, - mut item_mod: syn::ItemMod, - spec_features: Option>, -) -> TokenStream2 { - if let Some((_, ref mut content)) = item_mod.content { - 'next_item: for item in content { - if let Some(ref spec_features) = spec_features { - match item { - syn::Item::Const(syn::ItemConst { ref mut attrs, .. }) - | syn::Item::Enum(syn::ItemEnum { ref mut attrs, .. }) - | syn::Item::ExternCrate(syn::ItemExternCrate { ref mut attrs, .. }) - | syn::Item::Fn(syn::ItemFn { ref mut attrs, .. }) - | syn::Item::ForeignMod(syn::ItemForeignMod { ref mut attrs, .. }) - | syn::Item::Impl(syn::ItemImpl { ref mut attrs, .. }) - | syn::Item::Macro(syn::ItemMacro { ref mut attrs, .. }) - | syn::Item::Mod(syn::ItemMod { ref mut attrs, .. }) - | syn::Item::Static(syn::ItemStatic { ref mut attrs, .. }) - | syn::Item::Struct(syn::ItemStruct { ref mut attrs, .. }) - | syn::Item::Trait(syn::ItemTrait { ref mut attrs, .. }) - | syn::Item::TraitAlias(syn::ItemTraitAlias { ref mut attrs, .. }) - | syn::Item::Type(syn::ItemType { ref mut attrs, .. }) - | syn::Item::Union(syn::ItemUnion { ref mut attrs, .. }) - | syn::Item::Use(syn::ItemUse { ref mut attrs, .. }) => { - let mut index = 0; - while index < attrs.len() { - let attr = &attrs[index]; - if matches!(attr.style, syn::AttrStyle::Outer) { - match attr.meta { - syn::Meta::List(ref list) - if is_path_eq(&list.path, "for_target_feature") => - { - let feature: syn::LitStr = match list.parse_args() { - Ok(feature) => feature, - Err(error) => { - return error.into_compile_error(); - } - }; - - let feature = feature.value(); - if !spec_features.contains(&feature) { - *item = syn::Item::Verbatim(Default::default()); - continue 'next_item; - } - - attrs.remove(index); - continue; - } - _ => {} - } - } - - index += 1; - continue; - } - } - _ => { - unsupported!(item_mod); - } - } - } - - *item = syn::Item::Verbatim( - process_item( - attributes, - std::mem::replace(item, syn::Item::Verbatim(Default::default())), - false, - ) - .into(), - ); - } - } - - quote::quote! { - #item_mod - } -} - -fn process_impl(attributes: &syn::LitStr, mut item_impl: syn::ItemImpl) -> TokenStream { - unsupported_if_some!(item_impl.defaultness); - unsupported_if_some!(item_impl.unsafety); - - let mut items = Vec::new(); - for item in item_impl.items.drain(..) { - match item { - syn::ImplItem::Fn(function) => { - unsupported_if_some!(function.defaultness); - let function = syn::ItemFn { - attrs: function.attrs, - vis: function.vis, - sig: function.sig, - block: Box::new(function.block), - }; - let output_item = process_function( - attributes, - function, - Some((item_impl.generics.clone(), item_impl.self_ty.clone())), - ); - items.push(syn::ImplItem::Verbatim(output_item.into())); - } - item => items.push(item), - } - } - - item_impl.items = items; - quote::quote! { - #item_impl - } - .into() -} - -fn is_path_eq(path: &syn::Path, ident: &str) -> bool { - let segments: Vec<_> = ident.split("::").collect(); - path.segments.len() == segments.len() - && path - .segments - .iter() - .zip(segments.iter()) - .all(|(segment, expected)| segment.ident == expected && segment.arguments.is_none()) -} - -fn process_function( - attributes: &syn::LitStr, - function: syn::ItemFn, - outer: Option<(syn::Generics, Box)>, -) -> TokenStream { - if function.sig.unsafety.is_some() { - return quote::quote! { - #[target_feature(enable = #attributes)] - #function - } - .into(); - } - - unsupported_if_some!(function.sig.constness); - unsupported_if_some!(function.sig.asyncness); - unsupported_if_some!(function.sig.abi); - unsupported_if_some!(function.sig.variadic); - - let function_visibility = function.vis; - let function_name = function.sig.ident; - let function_return = function.sig.output; - let function_inner_name = - syn::Ident::new(&format!("_impl_{}", function_name), function_name.span()); - let function_args = function.sig.inputs; - let function_body = function.block; - let mut function_call_args = Vec::new(); - let mut function_args_outer = Vec::new(); - let mut function_args_inner = Vec::new(); - for (index, arg) in function_args.iter().enumerate() { - match arg { - syn::FnArg::Receiver(receiver) => { - unsupported_if_some!(receiver.attrs.first()); - unsupported_if_some!(receiver.colon_token); - - if outer.is_none() { - return syn::Error::new(receiver.span(), "unsupported by #[unsafe_target_feature(...)]; put the attribute on the outer `impl`").into_compile_error().into(); - } - - function_args_inner.push(syn::FnArg::Receiver(receiver.clone())); - function_args_outer.push(syn::FnArg::Receiver(receiver.clone())); - function_call_args.push(syn::Ident::new("self", receiver.self_token.span())); - } - syn::FnArg::Typed(ty) => { - unsupported_if_some!(ty.attrs.first()); - - match &*ty.pat { - syn::Pat::Ident(pat_ident) => { - unsupported_if_some!(pat_ident.attrs.first()); - - function_args_inner.push(arg.clone()); - function_args_outer.push(syn::FnArg::Typed(syn::PatType { - attrs: Vec::new(), - pat: Box::new(syn::Pat::Ident(syn::PatIdent { - attrs: Vec::new(), - by_ref: None, - mutability: None, - ident: pat_ident.ident.clone(), - subpat: None, - })), - colon_token: ty.colon_token, - ty: ty.ty.clone(), - })); - function_call_args.push(pat_ident.ident.clone()); - } - syn::Pat::Wild(pat_wild) => { - unsupported_if_some!(pat_wild.attrs.first()); - - let ident = syn::Ident::new( - &format!("__arg_{}__", index), - pat_wild.underscore_token.span(), - ); - function_args_inner.push(arg.clone()); - function_args_outer.push(syn::FnArg::Typed(syn::PatType { - attrs: Vec::new(), - pat: Box::new(syn::Pat::Ident(syn::PatIdent { - attrs: Vec::new(), - by_ref: None, - mutability: None, - ident: ident.clone(), - subpat: None, - })), - colon_token: ty.colon_token, - ty: ty.ty.clone(), - })); - function_call_args.push(ident); - } - _ => unsupported!(arg), - } - } - } - } - - let mut maybe_inline = quote::quote! {}; - let mut maybe_outer_attributes = Vec::new(); - let mut maybe_cfg = quote::quote! {}; - for attribute in function.attrs { - match &attribute.meta { - syn::Meta::Path(path) if is_path_eq(path, "inline") => { - maybe_inline = quote::quote! { #[inline] }; - } - syn::Meta::Path(path) if is_path_eq(path, "test") => { - maybe_outer_attributes.push(attribute); - maybe_cfg = quote::quote! { #[cfg(target_feature = #attributes)] }; - } - syn::Meta::List(syn::MetaList { path, tokens, .. }) - if is_path_eq(path, "inline") && tokens.to_string() == "always" => - { - maybe_inline = quote::quote! { #[inline] }; - } - syn::Meta::NameValue(syn::MetaNameValue { path, .. }) if is_path_eq(path, "doc") => { - maybe_outer_attributes.push(attribute); - } - syn::Meta::List(syn::MetaList { path, .. }) - if is_path_eq(path, "cfg") - || is_path_eq(path, "allow") - || is_path_eq(path, "deny") => - { - maybe_outer_attributes.push(attribute); - } - syn::Meta::Path(path) if is_path_eq(path, "rustfmt::skip") => { - maybe_outer_attributes.push(attribute); - } - _ => unsupported!(attribute), - } - } - - let (fn_impl_generics, fn_ty_generics, fn_where_clause) = - function.sig.generics.split_for_impl(); - let fn_call_generics = fn_ty_generics.as_turbofish(); - - if let Some((generics, self_ty)) = outer { - let (outer_impl_generics, outer_ty_generics, outer_where_clause) = - generics.split_for_impl(); - let trait_ident = - syn::Ident::new(&format!("__Impl_{}__", function_name), function_name.span()); - let item_trait = quote::quote! { - #[allow(non_camel_case_types)] - trait #trait_ident #outer_impl_generics #outer_where_clause { - unsafe fn #function_inner_name #fn_impl_generics (#(#function_args_outer),*) #function_return #fn_where_clause; - } - }; - - let item_trait_impl = quote::quote! { - impl #outer_impl_generics #trait_ident #outer_ty_generics for #self_ty #outer_where_clause { - #[target_feature(enable = #attributes)] - #maybe_inline - unsafe fn #function_inner_name #fn_impl_generics (#(#function_args_inner),*) #function_return #fn_where_clause #function_body - } - }; - - quote::quote! { - #[inline(always)] - #(#maybe_outer_attributes)* - #function_visibility fn #function_name #fn_impl_generics (#(#function_args_outer),*) #function_return #fn_where_clause { - #item_trait - #item_trait_impl - unsafe { - ::#function_inner_name #fn_call_generics (#(#function_call_args),*) - } - } - }.into() - } else { - quote::quote! { - #[inline(always)] - #maybe_cfg - #(#maybe_outer_attributes)* - #function_visibility fn #function_name #fn_impl_generics (#(#function_args_outer),*) #function_return #fn_where_clause { - #[target_feature(enable = #attributes)] - #maybe_inline - unsafe fn #function_inner_name #fn_impl_generics (#(#function_args_inner),*) #function_return #fn_where_clause #function_body - unsafe { - #function_inner_name #fn_call_generics (#(#function_call_args),*) - } - } - }.into() - } -} diff --git a/curve25519/curve25519-derive/tests/tests.rs b/curve25519/curve25519-derive/tests/tests.rs deleted file mode 100644 index 530f516..0000000 --- a/curve25519/curve25519-derive/tests/tests.rs +++ /dev/null @@ -1,152 +0,0 @@ -#![cfg(any(target_arch = "x86", target_arch = "x86_64"))] -#![allow(dead_code)] -#![allow(unused_imports)] - -use curve25519_derive::{unsafe_target_feature, unsafe_target_feature_specialize}; - -#[unsafe_target_feature("sse2")] -/// A doc comment. -fn function(a: u32, b: u32) -> u32 { - a - b -} - -#[unsafe_target_feature("sse2")] -fn function_with_const_arg(b: u32) -> u32 { - N - b -} - -#[unsafe_target_feature("sse2")] -fn function_with_where_clause(a: T, b: T) -> T::Output -where - T: Copy + core::ops::Sub, -{ - a - b -} - -#[unsafe_target_feature("sse2")] -#[rustfmt::skip] -fn function_with_rustfmt_skip() {} - -struct Struct { - a: u32, -} - -#[unsafe_target_feature("sse2")] -impl Struct { - #[allow(unused_mut)] - fn member_function(&self, mut b: u32) -> u32 { - self.a - b - } - - fn member_function_with_const_arg(self) -> u32 { - self.a - N - } -} - -struct StructWithGenerics -where - T: Copy + core::ops::Sub, -{ - a: T, -} - -#[unsafe_target_feature("sse2")] -impl StructWithGenerics -where - T: Copy + core::ops::Sub, -{ - #[inline] - fn member_function(&self, b: T) -> T::Output { - self.a - b - } -} - -struct StructWithGenericsNoWhere { - a: T, -} - -#[unsafe_target_feature("sse2")] -impl StructWithGenericsNoWhere { - #[inline(always)] - fn member_function(&self, b: T) -> T::Output { - self.a - b - } -} - -#[unsafe_target_feature("sse2")] -#[allow(dead_code)] -impl<'a> From<&'a Struct> for () { - fn from(_: &'a Struct) -> Self {} -} - -#[unsafe_target_feature("sse2")] -mod inner { - fn inner_function(a: u32, b: u32) -> u32 { - a - b - } -} - -#[unsafe_target_feature_specialize("sse2", "avx2")] -mod inner_spec { - #[for_target_feature("sse2")] - const CONST: u32 = 1; - - #[for_target_feature("avx2")] - const CONST: u32 = 2; - - pub fn spec_function(a: u32, b: u32) -> u32 { - a - b - CONST - } - - #[for_target_feature("sse2")] - const IS_AVX2: bool = false; - - #[for_target_feature("avx2")] - const IS_AVX2: bool = true; - - #[test] - fn test_specialized() { - #[allow(clippy::assertions_on_constants)] - { - assert!(!IS_AVX2); - } - } - - #[cfg(test)] - mod tests { - #[test] - fn test_specialized_inner() { - #[allow(clippy::assertions_on_constants)] - { - assert!(!super::IS_AVX2); - } - } - } -} - -#[unsafe_target_feature("sse2")] -#[test] -fn test_sse2_only() {} - -// it turns out that for compilation to succeed, the feature needs be supported by rustc. For this -// test actually verify what happens when the target_feature is not enabled, this needs to be a -// pretty esoteric feature. Looking at the table of supported avx512 features at -// https://en.wikipedia.org/wiki/AVX-512#CPUs_with_AVX-512 it seems avx512vp2intersect is one of the -// most unusual ones that has rustc knows about -#[unsafe_target_feature("avx512vp2intersect")] -#[test] -fn test_unset_target_feature() { - compile_error!("When an unknown target_feature is set on a test, unsafe_target_feature is expected remove the function"); -} - -#[test] -fn test_function() { - assert_eq!(function(10, 3), 7); - assert_eq!(function_with_where_clause(10, 3), 7); - assert_eq!(function_with_const_arg::<10>(3), 7); - assert_eq!(Struct { a: 10 }.member_function(3), 7); - assert_eq!(StructWithGenerics { a: 10 }.member_function(3), 7); - assert_eq!(StructWithGenericsNoWhere { a: 10 }.member_function(3), 7); - assert_eq!(inner_spec_sse2::spec_function(10, 3), 6); - assert_eq!(inner_spec_avx2::spec_function(10, 3), 5); -} diff --git a/curve25519/ed25519-heea/CHANGELOG.md b/curve25519/ed25519-heea/CHANGELOG.md deleted file mode 100644 index 1d392be..0000000 --- a/curve25519/ed25519-heea/CHANGELOG.md +++ /dev/null @@ -1,136 +0,0 @@ -# CHANGELOG - -Entries are listed in reverse chronological order. - -# 4.2.0 - -* Bump MSRV from 1.65 to 1.85. -* Bump `hashbrown` from 0.15 to 0.16. - -# 4.1.0 - -* Implement `PartialEq` and `Eq` in `SigningKey` and `VerificationKey` (#102) -* Add `alloc` feature by @nazar-pc in (#161, #174) -* Add helper methods by @conradoplg in (#179) - -Note: to use Rust older than `1.85`, you will need to downgrade the `base64ct` -crate: - -``` -cargo update base64ct --precise 1.6.0 -``` - -# 4.0.3 - -* Update `curve25519` to `4.1.0` - -# 4.0.2 - -* Update `curve25519` to `4.0.0` - -# 4.0.1 - -* Fix no-std build with serde activated (#87) -* Update `curve25519` to `4.0.0-rc.3` - -# 4.0.0 - -* `Signature` is now an alias for `ed25519::Signature` - * `impl From for [u8; 64]` no longer exists; use `to_bytes()` instead. -* `signature::{Signer, Verifier} is now implemented for `SigningKey` and `VerificationKey`. -* Updates `sha2` version to `0.10` and `curve25519` version to `4.0.0-rc.2`. -* Add DER & PEM support for SigningKeySeed and VerificationKeyBytes (RFC 8410) #46 https://github.com/ZcashFoundation/ed25519-zebra/pull/46 - * This is under the non-default `pem` and `pkcs8` features - -MSRV increased to `1.65.0`. - -# 3.1.0 - -* Add no_std support by @pvdrz in https://github.com/ZcashFoundation/ed25519-zebra/pull/57 - -# 3.0.0 - -* Fix typo by @rex4539 in https://github.com/ZcashFoundation/ed25519-zebra/pull/32 -* Add Zeroize impl for SigningKey by @kim in https://github.com/ZcashFoundation/ed25519-zebra/pull/34 -* Add JNI code for ed25519-zebra by @droark in https://github.com/ZcashFoundation/ed25519-zebra/pull/37 -* Update rand_core to 0.6 and rand to 0.8 by @dconnolly in https://github.com/ZcashFoundation/ed25519-zebra/pull/44 -* dependencies: update zeroize to 1.2 by @FintanH in https://github.com/ZcashFoundation/ed25519-zebra/pull/52 - -# 2.2.0 - -* Add `PartialOrd`, `Ord` implementations for `VerificationKeyBytes`. While - the derived ordering is not cryptographically meaningful, deriving these - traits is useful because it allows, e.g., using `VerificationKeyBytes` as the - key to a `BTreeMap` (contributed by @cloudhead). - -# 2.1.2 - -* Updates `sha2` version to `0.9` and `curve25519` version to `3`. - -# 2.1.1 - -* Add a missing multiplication by the cofactor in batch verification and test - that individual and batch verification agree. This corrects an omission that - should have been included in `2.0.0`. - -# 2.1.0 - -* Implements `Clone + Debug` for `batch::Item` and provides - `batch::Item::verify_single` to perform fallback verification in case - of batch failure. - -# 2.0.0 - -* Implements ZIP 215, so that batched and individual verification - agree on whether signatures are valid. - -# 1.0.0 - -* Adds `impl TryFrom<&[u8]>` for all types. - -# 1.0.0-pre.0 - -* Add a note about versioning to handle ZIP 215. - -# 0.4.1 - -* Change `docs.rs` configuration in `Cargo.toml` to not refer to the removed - `batch` feature so that the docs render correctly on `docs.rs`. - -# 0.4.0 - -* The sync batch verification api is changed to remove a dependence on the - message lifetime that made it difficult to use in async contexts. - -# 0.3.0 - -* Change terminology from secret and public keys to signing and verification - keys. -* Remove async batch verification in favor of a sync api; the async approach is - to be developed in another crate. - -# 0.2.3 - -* The previous implementation exactly matched the behavior of `libsodium` - `1.0.15` with the `ED25519_COMPAT` configuration, but this configuration - wasn't used by `zcashd`. This commit changes the validation rules to exactly - match without `ED25519_COMPAT`, and highlights the remaining inconsistencies - with the Zcash specification that were not addressed in the previous spec - fix. - -# 0.2.2 - -* Adds `impl AsRef<[u8]> for PublicKey`. -* Adds `impl AsRef<[u8]> for SecretKey`. - -# 0.2.1 - -* Adds `impl AsRef<[u8]> for PublicKeyBytes`. - -# 0.2.0 - -* Adds experimental futures-based batch verification API, gated by the `batch` feature. - -# 0.1.0 - -Initial release, attempting to match the actual `zcashd` behavior. diff --git a/curve25519/ed25519-heea/Cargo.lock b/curve25519/ed25519-heea/Cargo.lock deleted file mode 100644 index 9960aa1..0000000 --- a/curve25519/ed25519-heea/Cargo.lock +++ /dev/null @@ -1,1190 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 4 - -[[package]] -name = "addr2line" -version = "0.25.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5d307320b3181d6d7954e663bd7c774a838b8220fe0593c86d9fb09f498b4b" -dependencies = [ - "gimli", -] - -[[package]] -name = "adler2" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" - -[[package]] -name = "aho-corasick" -version = "1.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" -dependencies = [ - "memchr", -] - -[[package]] -name = "allocator-api2" -version = "0.2.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" - -[[package]] -name = "anes" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" - -[[package]] -name = "anstyle" -version = "1.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78" - -[[package]] -name = "autocfg" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" - -[[package]] -name = "backtrace" -version = "0.3.76" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb531853791a215d7c62a30daf0dde835f381ab5de4589cfe7c649d2cbe92bd6" -dependencies = [ - "addr2line", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", - "windows-link", -] - -[[package]] -name = "base64ct" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55248b47b0caf0546f7988906588779981c43bb1bc9d0c44087278f80cdb44ba" - -[[package]] -name = "bincode" -version = "1.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" -dependencies = [ - "serde", -] - -[[package]] -name = "block-buffer" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" -dependencies = [ - "generic-array", -] - -[[package]] -name = "block-buffer" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96eb4cdd6cf1b31d671e9efe75c5d1ec614776856cefbe109ca373554a6d514f" -dependencies = [ - "hybrid-array", -] - -[[package]] -name = "bumpalo" -version = "3.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" - -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - -[[package]] -name = "cast" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" - -[[package]] -name = "cfg-if" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" - -[[package]] -name = "ciborium" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e" -dependencies = [ - "ciborium-io", - "ciborium-ll", - "serde", -] - -[[package]] -name = "ciborium-io" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757" - -[[package]] -name = "ciborium-ll" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9" -dependencies = [ - "ciborium-io", - "half", -] - -[[package]] -name = "clap" -version = "4.5.53" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9e340e012a1bf4935f5282ed1436d1489548e8f72308207ea5df0e23d2d03f8" -dependencies = [ - "clap_builder", -] - -[[package]] -name = "clap_builder" -version = "4.5.53" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d76b5d13eaa18c901fd2f7fca939fefe3a0727a953561fefdf3b2922b8569d00" -dependencies = [ - "anstyle", - "clap_lex", -] - -[[package]] -name = "clap_lex" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" - -[[package]] -name = "color-eyre" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5920befb47832a6d61ee3a3a846565cfa39b331331e68a3b1d1116630f2f26d" -dependencies = [ - "backtrace", - "color-spantrace", - "eyre", - "indenter", - "once_cell", - "owo-colors", - "tracing-error", -] - -[[package]] -name = "color-spantrace" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8b88ea9df13354b55bc7234ebcce36e6ef896aca2e42a15de9e10edce01b427" -dependencies = [ - "once_cell", - "owo-colors", - "tracing-core", - "tracing-error", -] - -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - -[[package]] -name = "cpufeatures" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" -dependencies = [ - "libc", -] - -[[package]] -name = "criterion" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1c047a62b0cc3e145fa84415a3191f628e980b194c2755aa12300a4e6cbd928" -dependencies = [ - "anes", - "cast", - "ciborium", - "clap", - "criterion-plot", - "itertools", - "num-traits", - "oorandom", - "plotters", - "rayon", - "regex", - "serde", - "serde_json", - "tinytemplate", - "walkdir", -] - -[[package]] -name = "criterion-plot" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b1bcc0dc7dfae599d84ad0b1a55f80cde8af3725da8313b528da95ef783e338" -dependencies = [ - "cast", - "itertools", -] - -[[package]] -name = "crossbeam-deque" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" -dependencies = [ - "crossbeam-epoch", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.9.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" -dependencies = [ - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" - -[[package]] -name = "crunchy" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" - -[[package]] -name = "crypto-common" -version = "0.2.0-rc.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "919bd05924682a5480aec713596b9e2aabed3a0a6022fab6847f85a99e5f190a" -dependencies = [ - "hybrid-array", -] - -[[package]] -name = "curve25519" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" -dependencies = [ - "byteorder", - "digest 0.9.0", - "rand_core 0.5.1", - "subtle", - "zeroize", -] - -[[package]] -name = "curve25519" -version = "5.0.0-pre.2" -source = "git+https://github.com/zz-sol/curve25519.git?branch=zz%2Fimpl_ches25#9db800b4d9ababbcf7522b74d2b0955cc0ee9bb9" -dependencies = [ - "cfg-if", - "cpufeatures", - "curve25519-derive", - "digest 0.11.0-rc.4", - "ethnum", - "fiat-crypto", - "rustc_version", - "subtle", - "zeroize", -] - -[[package]] -name = "curve25519-derive" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "der" -version = "0.7.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" -dependencies = [ - "const-oid", - "pem-rfc7468", - "zeroize", -] - -[[package]] -name = "digest" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" -dependencies = [ - "generic-array", -] - -[[package]] -name = "digest" -version = "0.11.0-rc.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea390c940e465846d64775e55e3115d5dc934acb953de6f6e6360bc232fe2bf7" -dependencies = [ - "block-buffer 0.11.0", - "crypto-common", -] - -[[package]] -name = "ed25519" -version = "2.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" -dependencies = [ - "pkcs8", - "serde", - "signature", -] - -[[package]] -name = "ed25519-zebra" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c85a1fff1b329c96789427b09d4d5949b2d2f717851fd1e65a18878bee19d1ff" -dependencies = [ - "curve25519 3.2.0", - "hex", - "rand_core 0.5.1", - "serde", - "sha2 0.9.9", - "thiserror", -] - -[[package]] -name = "ed25519-zebra" -version = "4.2.0" -dependencies = [ - "bincode", - "color-eyre", - "criterion", - "curve25519 5.0.0-pre.2", - "der", - "ed25519", - "ed25519-zebra 1.0.1", - "hashbrown", - "hex", - "once_cell", - "pkcs8", - "rand", - "rand_core 0.6.4", - "serde", - "sha2 0.11.0-rc.3", - "subtle", - "zeroize", -] - -[[package]] -name = "either" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" - -[[package]] -name = "equivalent" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" - -[[package]] -name = "ethnum" -version = "1.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca81e6b4777c89fd810c25a4be2b1bd93ea034fbe58e6a75216a34c6b82c539b" - -[[package]] -name = "eyre" -version = "0.6.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cd915d99f24784cdc19fd37ef22b97e3ff0ae756c7e492e9fbfe897d61e2aec" -dependencies = [ - "indenter", - "once_cell", -] - -[[package]] -name = "fiat-crypto" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64cd1e32ddd350061ae6edb1b082d7c54915b5c672c389143b9a63403a109f24" - -[[package]] -name = "foldhash" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" - -[[package]] -name = "generic-array" -version = "0.14.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" -dependencies = [ - "typenum", - "version_check", -] - -[[package]] -name = "getrandom" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" -dependencies = [ - "cfg-if", - "libc", - "wasi 0.9.0+wasi-snapshot-preview1", -] - -[[package]] -name = "getrandom" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" -dependencies = [ - "cfg-if", - "libc", - "wasi 0.11.1+wasi-snapshot-preview1", -] - -[[package]] -name = "gimli" -version = "0.32.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e629b9b98ef3dd8afe6ca2bd0f89306cec16d43d907889945bc5d6687f2f13c7" - -[[package]] -name = "half" -version = "2.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b" -dependencies = [ - "cfg-if", - "crunchy", - "zerocopy", -] - -[[package]] -name = "hashbrown" -version = "0.16.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" -dependencies = [ - "allocator-api2", - "equivalent", - "foldhash", -] - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "hybrid-array" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f471e0a81b2f90ffc0cb2f951ae04da57de8baa46fa99112b062a5173a5088d0" -dependencies = [ - "typenum", -] - -[[package]] -name = "indenter" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "964de6e86d545b246d84badc0fef527924ace5134f30641c203ef52ba83f58d5" - -[[package]] -name = "itertools" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" -dependencies = [ - "either", -] - -[[package]] -name = "itoa" -version = "1.0.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" - -[[package]] -name = "js-sys" -version = "0.3.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "464a3709c7f55f1f721e5389aa6ea4e3bc6aba669353300af094b29ffbdde1d8" -dependencies = [ - "once_cell", - "wasm-bindgen", -] - -[[package]] -name = "lazy_static" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" - -[[package]] -name = "libc" -version = "0.2.178" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37c93d8daa9d8a012fd8ab92f088405fb202ea0b6ab73ee2482ae66af4f42091" - -[[package]] -name = "memchr" -version = "2.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" - -[[package]] -name = "miniz_oxide" -version = "0.8.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" -dependencies = [ - "adler2", -] - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", -] - -[[package]] -name = "object" -version = "0.37.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff76201f031d8863c38aa7f905eca4f53abbfa15f609db4277d44cd8938f33fe" -dependencies = [ - "memchr", -] - -[[package]] -name = "once_cell" -version = "1.21.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" - -[[package]] -name = "oorandom" -version = "11.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e" - -[[package]] -name = "opaque-debug" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" - -[[package]] -name = "owo-colors" -version = "4.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c6901729fa79e91a0913333229e9ca5dc725089d1c363b2f4b4760709dc4a52" - -[[package]] -name = "pem-rfc7468" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" -dependencies = [ - "base64ct", -] - -[[package]] -name = "pin-project-lite" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" - -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - -[[package]] -name = "plotters" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aeb6f403d7a4911efb1e33402027fc44f29b5bf6def3effcc22d7bb75f2b747" -dependencies = [ - "num-traits", - "plotters-backend", - "plotters-svg", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "plotters-backend" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df42e13c12958a16b3f7f4386b9ab1f3e7933914ecea48da7139435263a4172a" - -[[package]] -name = "plotters-svg" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51bae2ac328883f7acdfea3d66a7c35751187f870bc81f94563733a154d7a670" -dependencies = [ - "plotters-backend", -] - -[[package]] -name = "ppv-lite86" -version = "0.2.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" -dependencies = [ - "zerocopy", -] - -[[package]] -name = "proc-macro2" -version = "1.0.103" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core 0.6.4", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core 0.6.4", -] - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom 0.1.16", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom 0.2.16", -] - -[[package]] -name = "rayon" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368f01d005bf8fd9b1206fb6fa653e6c4a81ceb1466406b81792d87c5677a58f" -dependencies = [ - "either", - "rayon-core", -] - -[[package]] -name = "rayon-core" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91" -dependencies = [ - "crossbeam-deque", - "crossbeam-utils", -] - -[[package]] -name = "regex" -version = "1.12.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" - -[[package]] -name = "rustc-demangle" -version = "0.1.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56f7d92ca342cea22a06f2121d944b4fd82af56988c270852495420f961d4ace" - -[[package]] -name = "rustc_version" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" -dependencies = [ - "semver", -] - -[[package]] -name = "rustversion" -version = "1.0.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" - -[[package]] -name = "ryu" -version = "1.0.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" - -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "semver" -version = "1.0.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" - -[[package]] -name = "serde" -version = "1.0.228" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" -dependencies = [ - "serde_core", - "serde_derive", -] - -[[package]] -name = "serde_core" -version = "1.0.228" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.228" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_json" -version = "1.0.145" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c" -dependencies = [ - "itoa", - "memchr", - "ryu", - "serde", - "serde_core", -] - -[[package]] -name = "sha2" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" -dependencies = [ - "block-buffer 0.9.0", - "cfg-if", - "cpufeatures", - "digest 0.9.0", - "opaque-debug", -] - -[[package]] -name = "sha2" -version = "0.11.0-rc.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19d43dc0354d88b791216bb5c1bfbb60c0814460cc653ae0ebd71f286d0bd927" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest 0.11.0-rc.4", -] - -[[package]] -name = "sharded-slab" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "rand_core 0.6.4", -] - -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", -] - -[[package]] -name = "subtle" -version = "2.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" - -[[package]] -name = "syn" -version = "2.0.111" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "390cc9a294ab71bdb1aa2e99d13be9c753cd2d7bd6560c77118597410c4d2e87" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "thiserror" -version = "1.0.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "thread_local" -version = "1.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f60246a4944f24f6e018aa17cdeffb7818b76356965d03b07d6a9886e8962185" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "tinytemplate" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" -dependencies = [ - "serde", - "serde_json", -] - -[[package]] -name = "tracing" -version = "0.1.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d15d90a0b5c19378952d479dc858407149d7bb45a14de0142f6c534b16fc647" -dependencies = [ - "pin-project-lite", - "tracing-core", -] - -[[package]] -name = "tracing-core" -version = "0.1.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a04e24fab5c89c6a36eb8558c9656f30d81de51dfa4d3b45f26b21d61fa0a6c" -dependencies = [ - "once_cell", - "valuable", -] - -[[package]] -name = "tracing-error" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b1581020d7a273442f5b45074a6a57d5757ad0a47dac0e9f0bd57b81936f3db" -dependencies = [ - "tracing", - "tracing-subscriber", -] - -[[package]] -name = "tracing-subscriber" -version = "0.3.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f30143827ddab0d256fd843b7a66d164e9f271cfa0dde49142c5ca0ca291f1e" -dependencies = [ - "sharded-slab", - "thread_local", - "tracing-core", -] - -[[package]] -name = "typenum" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" - -[[package]] -name = "unicode-ident" -version = "1.0.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" - -[[package]] -name = "valuable" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" - -[[package]] -name = "version_check" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" - -[[package]] -name = "walkdir" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" -dependencies = [ - "same-file", - "winapi-util", -] - -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - -[[package]] -name = "wasi" -version = "0.11.1+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" - -[[package]] -name = "wasm-bindgen" -version = "0.2.106" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d759f433fa64a2d763d1340820e46e111a7a5ab75f993d1852d70b03dbb80fd" -dependencies = [ - "cfg-if", - "once_cell", - "rustversion", - "wasm-bindgen-macro", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.106" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48cb0d2638f8baedbc542ed444afc0644a29166f1595371af4fecf8ce1e7eeb3" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.106" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cefb59d5cd5f92d9dcf80e4683949f15ca4b511f4ac0a6e14d4e1ac60c6ecd40" -dependencies = [ - "bumpalo", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.106" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbc538057e648b67f72a982e708d485b2efa771e1ac05fec311f9f63e5800db4" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "web-sys" -version = "0.3.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b32828d774c412041098d182a8b38b16ea816958e07cf40eec2bc080ae137ac" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "winapi-util" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" -dependencies = [ - "windows-sys", -] - -[[package]] -name = "windows-link" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" - -[[package]] -name = "windows-sys" -version = "0.61.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" -dependencies = [ - "windows-link", -] - -[[package]] -name = "zerocopy" -version = "0.8.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd74ec98b9250adb3ca554bdde269adf631549f51d8a8f8f0a10b50f1cb298c3" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.8.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8a8d209fdf45cf5138cbb5a506f6b52522a25afccc534d1475dad8e31105c6a" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "zeroize" -version = "1.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" -dependencies = [ - "zeroize_derive", -] - -[[package]] -name = "zeroize_derive" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] diff --git a/curve25519/ed25519-heea/Cargo.toml b/curve25519/ed25519-heea/Cargo.toml deleted file mode 100644 index 176e376..0000000 --- a/curve25519/ed25519-heea/Cargo.toml +++ /dev/null @@ -1,79 +0,0 @@ -[package] -name = "ed25519-heea" -version = "0.1.0" -rust-version = "1.85.0" -authors = [ - "Henry de Valence ", - "Zcash Foundation ", - "Anza Cryptography Team", -] -license = "MIT OR Apache-2.0" -edition = "2024" -description = "ZIP-215-compliant Ed25519 with HEEA-accelerated verification (forked from ed25519-zebra)" -resolver = "2" -include = [ - "/src", - "/README.md", - "/CHANGELOG.md", - "/LICENSE-APACHE", - "/LICENSE-MIT", - "/tests", - "/benches", -] - -[package.metadata.docs.rs] -features = ["nightly"] - -[dependencies] -# Keep the dependency key as "curve25519" so that all existing `use curve25519::…` -# references in source files remain valid; the actual package is curve25519-sol. -curve25519 = { path = "../curve25519", package = "solana-curve25519", default-features = false, features = ["digest", "zeroize", "precomputed-tables"] } -der = { version = "0.7.9", optional = true } -ed25519 = { version = "2.2.3", default-features = false } -hashbrown = { version = "0.16", optional = true } -pkcs8 = { version = "0.10.1", optional = true, features = ["pem"] } -rand_core = "0.6" -serde = { version = "1", default-features = false, optional = true, features = ["derive"] } -sha2 = { version = "0.11.0-rc.3", default-features = false } -subtle = { version = "2.6.1", default-features = false } -zeroize = { version = "1.8", default-features = false, features = ["derive"] } - -[dev-dependencies] -rand = "0.8" -bincode = "1" -criterion = "0.7" -ed25519-zebra-legacy = { package = "ed25519-zebra", version = "1" } -color-eyre = "0.6" -hex = { version = "0.4.3", default-features = false, features = ["alloc"] } -once_cell = "1.21" - -[features] -nightly = [] -default = ["serde", "std"] -alloc = [ - "curve25519/alloc", - "ed25519/alloc", - "hashbrown", - "pkcs8?/alloc", - "zeroize/alloc", -] -pem = ["pkcs8", "dep:der", "ed25519/pem"] -pkcs8 = ["dep:pkcs8", "ed25519/pkcs8", "alloc"] -serde = ["dep:serde", "ed25519/serde"] -std = ["alloc", "ed25519/std", "subtle/std"] - -[[test]] -name = "rfc8032" - -[[test]] -name = "unit_tests" - -[[test]] -name = "batch" - -[[test]] -name = "heea" - -[[bench]] -name = "bench" -harness = false diff --git a/curve25519/ed25519-heea/DEVELOPERS.md b/curve25519/ed25519-heea/DEVELOPERS.md deleted file mode 100644 index 7a3c1e4..0000000 --- a/curve25519/ed25519-heea/DEVELOPERS.md +++ /dev/null @@ -1,44 +0,0 @@ -## Release Checklist - -- Run `cargo semver-checks` to see if a major version bump is required -- Bump version in Cargo.toml - - If major version was bumped, update README.md -- Update CHANGELOG.md -- Ensure the MSRV in Cargo.toml (`rust-version` key) is equal to the MSRV being - tested (main.yml) -- Update locked dependencies: `cargo update`. Run `cargo test --all-features` - to check if anything breaks. If that happens, see next section. -- Test if it's publishable: `cargo publish --dry-run` -- Open a PR with the version bump and changelog update, wait for review and merge -- Tag a new release in GitHub: https://github.com/ZcashFoundation/ed25519-zebra/releases/new - - Create a tag with the version (e.g. `4.0.3`) - - Name: e.g. `ed25519-zebra 4.0.3` - - Paste the changelog for the version -- Publish: `cargo publish` - -## If something breaks - -If testing broke after running `cargo update`, first determine if it's a -test-only dependency or not. Run `cargo build --all-features`. If that works, -then it's probably a test-only dependency, and you can avoid updating that -specific dependency (leave a old version in the lockfile). Otherwise investigate -why it caused build to fail. - -If the "test on nightly" test failed, then either there is some bug in the code -or some dependency update caused it to fail. Investigate and if it's the latter, -you can either downgrade in the lockfile or try to workaround it. - -If the "build with no_std" test failed, then some change was introduced that -depended on the std-library. You will probably need to fix this by changing -to some no_std dependency, or gating the code so it only compiles when -`std` is enabled. - -If one of the dependencies bumped its MSRV, we might require a MSRV bump too: - -- Double check if the dependency is not a test-only dependency. (The MSRV - test in CI only builds the library but does not test it, to prevent - a test-only dependency MSRV bump from breaking it.) -- If it's not a test-only dependency, check if the main consumers of the - library are OK with a MSRV bump. I usually ask ECC devs. -- If it's OK, bump it in Cargo.toml and main.yml. -- If not, you will need to find some workaround. diff --git a/curve25519/ed25519-heea/LICENSE-APACHE b/curve25519/ed25519-heea/LICENSE-APACHE deleted file mode 100644 index bdb0982..0000000 --- a/curve25519/ed25519-heea/LICENSE-APACHE +++ /dev/null @@ -1,203 +0,0 @@ -Copyright (c) 2020 Zcash Foundation - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - -2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - -Copyright [yyyy] [name of copyright owner] - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/curve25519/ed25519-heea/LICENSE-MIT b/curve25519/ed25519-heea/LICENSE-MIT deleted file mode 100644 index 416b525..0000000 --- a/curve25519/ed25519-heea/LICENSE-MIT +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2020 Zcash Foundation - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - diff --git a/curve25519/ed25519-heea/README.md b/curve25519/ed25519-heea/README.md deleted file mode 100644 index 21ac1e1..0000000 --- a/curve25519/ed25519-heea/README.md +++ /dev/null @@ -1,139 +0,0 @@ -# ed25519-heea - -**ZIP-215-compliant Ed25519 signatures with HEEA-accelerated verification, forked from -[ed25519-zebra].** - -> For the original ed25519-zebra documentation see [README_zebra.md](README_zebra.md). - -This crate is part of the [curve25519-sol](../README.md) workspace. - ---- - -## Changes from ed25519-zebra - -### `verify_heea`: fast-path signature verification - -A new method `VerificationKey::verify_heea` has been added alongside the existing `verify`. -Both methods accept the same arguments and produce identical results — `verify_heea` is a -**drop-in accelerated replacement** for `verify`. - -The HEEA method (from the TCHES 2025 paper _"Accelerating EdDSA Signature Verification with -Faster Scalar Size Halving"_) transforms the standard 2-point MSM: - -```text -[8][s]B = [8]R + [8][h]A (standard) -``` - -into a 4-point MSM over half-size (~128-bit) scalars: - -```text -τs_lo·B + τs_hi·(2¹²⁸·B) = τ·R + ρ·A (HEEA) -``` - -where `ρ ≡ ±τ·h (mod ℓ)` and `τs = τs_hi·2¹²⁸ + τs_lo`. All four scalars are ≤128 bits, -and the two basepoints (`B` and `2¹²⁸B`) use precomputed lookup tables, giving approximately -**~15% faster** verification compared to the standard path. - -### Dependencies - -`ed25519-zebra` was updated to depend on this fork's `curve25519` crate instead of -`curve25519-dalek`, in order to access `HEEADecomposition` and `vartime_triple_scalar_mul_basepoint`. - ---- - -## ZIP 215 - -ZIP-215-compliant Ed25519 validation rules are fully preserved from ed25519-zebra: - -- Non-canonical point encodings are accepted for `A` and `R`. -- `s` must be a canonical integer less than the group order `ℓ`. -- The cofactor-cleared equation `[8][s]B = [8]R + [8][h]A` is used (not the RFC 8032 variant). - -See [README_zebra.md](README_zebra.md) and [ZIP 215] for full details. - ---- - -## Usage - -```toml -[dependencies] -ed25519-heea = { git = "https://github.com/zz-sol/ed25519-sol", package = "ed25519-heea" } -``` - -### Example - -```rust,no_run -use core::convert::TryFrom; -use rand::thread_rng; -use ed25519_heea::{SigningKey, VerificationKey}; - -let msg = b"curve25519-sol"; - -// Generate key and sign -let sk = SigningKey::new(thread_rng()); -let sig = sk.sign(msg); -let vk = VerificationKey::from(&sk); - -// Standard ZIP-215 verification (from ed25519-zebra) -vk.verify(&sig, msg).expect("valid signature"); - -// HEEA-accelerated verification (same result, ~15% faster) -vk.verify_heea(&sig, msg).expect("valid signature"); -``` - -### Batch verification - -Batch verification is unchanged from ed25519-zebra and uses a randomised linear combination to -check multiple signatures in one pass: - -```rust,ignore -#[cfg(feature = "alloc")] -{ - use ed25519_heea::batch; - - let mut verifier = batch::Verifier::new(); - for (vk_bytes, sig, msg) in items { - verifier.queue((vk_bytes, sig, msg)); - } - verifier.verify(thread_rng()).expect("all valid"); -} -``` - ---- - -## Features - -| Feature | Default? | Description | -|---|:---:|---| -| `std` | ✓ | Enables `std`; without it the crate is `no_std` + `alloc`. | -| `alloc` | ✓ | Enables batch verification. | -| `serde` | | Serialization for key and signature types. | -| `pkcs8` | | PKCS#8 DER encoding/decoding for `VerificationKey`. | - ---- - -## MSRV - -Rust **1.85.0** (Edition 2024). - ---- - -## References - -- [TCHES 2025 paper] – _Accelerating EdDSA Signature Verification with Faster Scalar Size Halving_ -- [ed25519-zebra] – upstream library (Zcash Foundation) -- [ZIP 215] – Ed25519 validation rules for Zcash -- [Original ed25519-zebra README](README_zebra.md) - -## License - -Licensed under either of - -- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE)) -- MIT license ([LICENSE-MIT](LICENSE-MIT)) - -at your option. - -[TCHES 2025 paper]: https://tches.iacr.org/index.php/TCHES/article/view/11971 -[ed25519-zebra]: https://github.com/ZcashFoundation/ed25519-zebra -[ZIP 215]: https://zips.z.cash/zip-0215 diff --git a/curve25519/curve25519/ACKNOWLEDGEMENTS.md b/curve25519/solana-ed25519/ACKNOWLEDGEMENTS.md similarity index 100% rename from curve25519/curve25519/ACKNOWLEDGEMENTS.md rename to curve25519/solana-ed25519/ACKNOWLEDGEMENTS.md diff --git a/curve25519/curve25519/CHANGELOG_dalek.md b/curve25519/solana-ed25519/CHANGELOG_dalek.md similarity index 100% rename from curve25519/curve25519/CHANGELOG_dalek.md rename to curve25519/solana-ed25519/CHANGELOG_dalek.md diff --git a/curve25519/curve25519/Cargo.toml b/curve25519/solana-ed25519/Cargo.toml similarity index 82% rename from curve25519/curve25519/Cargo.toml rename to curve25519/solana-ed25519/Cargo.toml index ce99893..7ec4505 100644 --- a/curve25519/curve25519/Cargo.toml +++ b/curve25519/solana-ed25519/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "solana-curve25519" +name = "solana-ed25519" version = "0.1.0" edition = "2024" rust-version = "1.85.0" @@ -30,7 +30,6 @@ rustdoc-args = [ all-features = true [dev-dependencies] -sha2 = { version = "0.11.0-rc.3", default-features = false } bincode = "1" criterion = { version = "0.5", features = ["html_reports"] } hex = "0.4.2" @@ -43,39 +42,46 @@ rustc_version = "0.4.0" [[bench]] name = "dalek_benchmarks" harness = false -required-features = ["alloc", "rand_core"] +required-features = ["alloc"] [dependencies] cfg-if = "1" +ed25519 = { version = "2.2.3", default-features = false } ff = { version = "=0.14.0-pre.0", package = "rustcrypto-ff", default-features = false, optional = true } group = { version = "=0.14.0-pre.0", package = "rustcrypto-group", default-features = false, optional = true } rand_core = { version = "0.10.0-rc-3", default-features = false, optional = true } digest = { version = "0.11.0-rc.4", default-features = false, optional = true, features = [ "block-api", ] } +hashbrown = { version = "0.15" } +der = { version = "0.7.9", optional = true } +pkcs8 = { version = "0.10.1", optional = true, features = ["pem"] } +sha2 = { version = "0.11.0-rc.3", default-features = false } subtle = { version = "2.6.0", default-features = false, features = [ "const-generics", ] } serde = { version = "1.0", default-features = false, optional = true, features = [ "derive", ] } -zeroize = { version = "1", default-features = false, optional = true } +zeroize = { version = "1", default-features = false, optional = true, features = ["derive"] } -# Keep the dependency key as "curve25519-derive" so existing #[curve25519_derive::…] -# attributes in source files remain valid; the actual package is curve25519-derive-sol. [target.'cfg(target_arch = "x86_64")'.dependencies] cpufeatures = "0.2.17" -curve25519-derive = { path = "../curve25519-derive", package = "solana-curve25519-derive" } +curve25519-dalek-derive = "0.1.1" [features] -default = ["alloc", "precomputed-tables", "zeroize"] +default = ["alloc", "precomputed-tables", "zeroize", "rand_core", "digest"] alloc = ["zeroize?/alloc"] precomputed-tables = [] legacy_compatibility = [] +rand_core = ["dep:rand_core"] +std = ["alloc"] group = ["dep:group", "rand_core"] group-bits = ["group", "ff/bits"] digest = ["dep:digest"] lizard = ["digest"] +pkcs8 = ["dep:pkcs8", "ed25519/pkcs8", "alloc"] +pem = ["pkcs8", "dep:der", "ed25519/pem"] [lints.rust.unexpected_cfgs] level = "warn" diff --git a/curve25519/curve25519/LICENSE b/curve25519/solana-ed25519/LICENSE similarity index 100% rename from curve25519/curve25519/LICENSE rename to curve25519/solana-ed25519/LICENSE diff --git a/curve25519/curve25519/Makefile b/curve25519/solana-ed25519/Makefile similarity index 100% rename from curve25519/curve25519/Makefile rename to curve25519/solana-ed25519/Makefile diff --git a/curve25519/curve25519/README.md b/curve25519/solana-ed25519/README.md similarity index 58% rename from curve25519/curve25519/README.md rename to curve25519/solana-ed25519/README.md index a66a34c..ec14d13 100644 --- a/curve25519/curve25519/README.md +++ b/curve25519/solana-ed25519/README.md @@ -48,12 +48,86 @@ have been removed. --- +## Ed25519 Signatures (`ed_sigs`) + +This crate includes a **ZIP-215-compliant Ed25519 signature implementation** in the +`ed_sigs` module, forked from [ed25519-zebra] and extended with HEEA-accelerated +verification. + +> For the original ed25519-zebra documentation see [README_zebra.md](README_zebra.md). + +### `verify_heea`: fast-path signature verification + +A new method `VerificationKey::verify_heea` sits alongside the existing `verify`. +Both accept the same arguments and produce identical results — `verify_heea` is a +**drop-in accelerated replacement** for `verify`. + +The HEEA method (TCHES 2025) transforms the standard 2-point MSM: + +```text +[8][s]B = [8]R + [8][h]A (standard) +``` + +into a 4-point MSM over half-size (~128-bit) scalars: + +```text +τs_lo·B + τs_hi·(2¹²⁸·B) = τ·R + ρ·A (HEEA) +``` + +where `ρ ≡ ±τ·h (mod ℓ)` and `τs = τs_hi·2¹²⁸ + τs_lo`. All four scalars are ≤128 bits +and the two basepoints (`B` and `2¹²⁸B`) use precomputed lookup tables, giving approximately +**~15% faster** verification compared to the standard path. + +### ZIP 215 + +ZIP-215-compliant Ed25519 validation rules are fully preserved from ed25519-zebra: + +- Non-canonical point encodings are accepted for `A` and `R`. +- `s` must be a canonical integer less than the group order `ℓ`. +- The cofactor-cleared equation `[8][s]B = [8]R + [8][h]A` is used (not the RFC 8032 variant). + +See [ZIP 215] for full details. + +--- + ## Use ```toml curve25519-sol = { git = "https://github.com/zz-sol/ed25519-sol" } ``` +### Ed25519 signing and verification + +```rust,no_run +use core::convert::TryFrom; +use curve25519::ed_sigs::{SigningKey, VerificationKey}; + +let msg = b"curve25519-sol"; + +// Generate key and sign +let sk = SigningKey::new(rand::rng()); +let sig = sk.sign(msg); +let vk = VerificationKey::from(&sk); + +// Standard ZIP-215 verification (from ed25519-zebra) +vk.verify(&sig, msg).expect("valid signature"); + +// HEEA-accelerated verification (same result, ~15% faster) +vk.verify_heea(&sig, msg).expect("valid signature"); +``` + +### Batch verification + +```rust,ignore +use curve25519::ed_sigs::batch; + +let mut verifier = batch::Verifier::new(); +for (vk_bytes, sig, msg) in items { + verifier.queue((vk_bytes, sig, msg)); +} +verifier.verify(rand::rng()).expect("all valid"); +``` + ### HEEA decomposition example ```rust,ignore @@ -73,16 +147,17 @@ let (rho, tau, flip_h) = h.heea_decompose(); ## Feature Flags -The feature flags are inherited from upstream with no additions: - | Feature | Default? | Description | |---|:---:|---| -| `alloc` | ✓ | Multiscalar multiplication, batch inversion, batch compress. | +| `alloc` | ✓ | Multiscalar multiplication, batch inversion, batch compress, batch Ed25519 verification. | | `zeroize` | ✓ | `Zeroize` for all scalar and point types. | | `precomputed-tables` | ✓ | Precomputed basepoint tables (~400 KB, ~4× faster basepoint mul). | -| `rand_core` | | `Scalar::random`, `RistrettoPoint::random`. | -| `digest` | | Hash-to-curve and `Scalar::from_hash`. | -| `serde` | | Serialization for all point and scalar types. | +| `rand_core` | ✓ | `Scalar::random`, `RistrettoPoint::random`, `SigningKey::new`. | +| `digest` | ✓ | Hash-to-curve, `Scalar::from_hash`, and Ed25519 hashing. | +| `std` | | Enables `std::error::Error` impl on `ed_sigs::Error`. | +| `serde` | | Serialization for all point, scalar, and key types. | +| `pkcs8` | | PKCS#8 DER encoding/decoding for Ed25519 keys. | +| `pem` | | PEM encoding/decoding for Ed25519 keys (requires `pkcs8`). | | `legacy_compatibility` | | `Scalar::from_bits` (broken arithmetic, use only if required). | | `group` | | `group` and `ff` crate trait impls. | | `group-bits` | | `ff::PrimeFieldBits` for `Scalar`. | @@ -135,10 +210,15 @@ Rust **1.85.0** (Edition 2024). ## References - [TCHES 2025 paper] – _Accelerating EdDSA Signature Verification with Faster Scalar Size Halving_ -- [curve25519-dalek] – upstream library (isis lovecruft, Henry de Valence) +- [curve25519-dalek] – upstream curve25519 library (isis lovecruft, Henry de Valence) +- [ed25519-zebra] – upstream Ed25519 library (Zcash Foundation) +- [ZIP 215] – Ed25519 validation rules for Zcash - [Original curve25519-dalek README](README_dalek.md) +- [Original ed25519-zebra README](README_zebra.md) [TCHES 2025 paper]: https://tches.iacr.org/index.php/TCHES/article/view/11971 [curve25519-dalek]: https://github.com/dalek-cryptography/curve25519-dalek +[ed25519-zebra]: https://github.com/ZcashFoundation/ed25519-zebra +[ZIP 215]: https://zips.z.cash/zip-0215 [SPPARK]: https://github.com/supranational/sppark [subtle]: https://docs.rs/subtle diff --git a/curve25519/curve25519/README_dalek.md b/curve25519/solana-ed25519/README_dalek.md similarity index 100% rename from curve25519/curve25519/README_dalek.md rename to curve25519/solana-ed25519/README_dalek.md diff --git a/curve25519/ed25519-heea/README_zebra.md b/curve25519/solana-ed25519/README_zebra.md similarity index 100% rename from curve25519/ed25519-heea/README_zebra.md rename to curve25519/solana-ed25519/README_zebra.md diff --git a/curve25519/ed25519-heea/benches/bench.rs b/curve25519/solana-ed25519/benches/bench.rs similarity index 81% rename from curve25519/ed25519-heea/benches/bench.rs rename to curve25519/solana-ed25519/benches/bench.rs index 5fb3dc8..640e476 100644 --- a/curve25519/ed25519-heea/benches/bench.rs +++ b/curve25519/solana-ed25519/benches/bench.rs @@ -1,12 +1,10 @@ use criterion::{BenchmarkId, Criterion, Throughput, criterion_group, criterion_main}; -use core::convert::TryFrom; -use ed25519_heea::*; -use rand::thread_rng; +use curve25519::ed_sigs::*; fn sigs_with_distinct_pubkeys() -> impl Iterator { std::iter::repeat_with(|| { - let sk = SigningKey::new(thread_rng()); + let sk = SigningKey::new(rand::rng()); let pk_bytes = VerificationKeyBytes::from(&sk); let sig = sk.sign(b""); (pk_bytes, sig) @@ -14,7 +12,7 @@ fn sigs_with_distinct_pubkeys() -> impl Iterator impl Iterator { - let sk = SigningKey::new(thread_rng()); + let sk = SigningKey::new(rand::rng()); let pk_bytes = VerificationKeyBytes::from(&sk); std::iter::repeat_with(move || { let sig = sk.sign(b""); @@ -30,11 +28,11 @@ fn bench_batch_verify(c: &mut Criterion) { group.bench_with_input( BenchmarkId::new("Unbatched verification", n), &sigs, - |b, sigs| { + |b, sigs: &Vec<(VerificationKeyBytes, Signature)>| { b.iter(|| { for (vk_bytes, sig) in sigs.iter() { - let _ = - VerificationKey::try_from(*vk_bytes).and_then(|vk| vk.verify(sig, b"")); + let _ = VerificationKey::try_from(*vk_bytes) + .and_then(|vk: VerificationKey| vk.verify(sig, b"")); } }) }, @@ -43,13 +41,13 @@ fn bench_batch_verify(c: &mut Criterion) { group.bench_with_input( BenchmarkId::new("Signatures with Distinct Pubkeys", n), &sigs, - |b, sigs| { + |b, sigs: &Vec<(VerificationKeyBytes, Signature)>| { b.iter(|| { let mut batch = batch::Verifier::new(); for (vk_bytes, sig) in sigs.iter().cloned() { batch.queue((vk_bytes, sig, b"")); } - batch.verify(thread_rng()) + batch.verify(rand::rng()) }) }, ); @@ -59,13 +57,13 @@ fn bench_batch_verify(c: &mut Criterion) { group.bench_with_input( BenchmarkId::new("Signatures with the Same Pubkey", n), &sigs, - |b, sigs| { + |b, sigs: &Vec<(VerificationKeyBytes, Signature)>| { b.iter(|| { let mut batch = batch::Verifier::new(); for (vk_bytes, sig) in sigs.iter().cloned() { batch.queue((vk_bytes, sig, b"")); } - batch.verify(thread_rng()) + batch.verify(rand::rng()) }) }, ); @@ -77,7 +75,7 @@ fn bench_single_verify(c: &mut Criterion) { let mut group = c.benchmark_group("Single Verification"); group.bench_function("ed25519", |b| { - let sk = SigningKey::new(thread_rng()); + let sk = SigningKey::new(rand::rng()); let vk = VerificationKey::from(&sk); let sig = sk.sign(b""); b.iter(|| { @@ -86,7 +84,7 @@ fn bench_single_verify(c: &mut Criterion) { }); group.bench_function("ed25519_hEEA", |b| { - let sk = SigningKey::new(thread_rng()); + let sk = SigningKey::new(rand::rng()); let vk = VerificationKey::from(&sk); let sig = sk.sign(b""); b.iter(|| { diff --git a/curve25519/curve25519/benches/dalek_benchmarks.rs b/curve25519/solana-ed25519/benches/dalek_benchmarks.rs similarity index 97% rename from curve25519/curve25519/benches/dalek_benchmarks.rs rename to curve25519/solana-ed25519/benches/dalek_benchmarks.rs index 6cdd7a2..5f22662 100644 --- a/curve25519/curve25519/benches/dalek_benchmarks.rs +++ b/curve25519/solana-ed25519/benches/dalek_benchmarks.rs @@ -1,6 +1,7 @@ #![allow(non_snake_case)] -use rand::{RngCore, TryRngCore, rng, rngs::SysRng}; +use rand::rng; +use rand_core::Rng as RngCore; use criterion::{ BatchSize, BenchmarkGroup, BenchmarkId, Criterion, criterion_main, measurement::Measurement, @@ -31,10 +32,10 @@ mod edwards_benches { BenchmarkId::new("Batch EdwardsPoint compression", batch_size), &batch_size, |b, &size| { - let mut rng = SysRng.unwrap_err(); + let mut rng = rng(); let points: Vec = (0..size).map(|_| EdwardsPoint::random(&mut rng)).collect(); - b.iter(|| EdwardsPoint::compress_batch_alloc(&points)); + b.iter(|| EdwardsPoint::compress_batch(&points)); }, ); } @@ -301,9 +302,9 @@ mod ristretto_benches { BenchmarkId::new("Batch Ristretto double-and-encode", *batch_size), &batch_size, |b, &&size| { - let mut rng = SysRng; + let mut rng = rng(); let points: Vec = (0..size) - .map(|_| RistrettoPoint::try_from_rng(&mut rng).unwrap()) + .map(|_| RistrettoPoint::random(&mut rng)) .collect(); b.iter(|| RistrettoPoint::double_and_compress_batch(&points)); }, @@ -388,7 +389,7 @@ mod scalar_benches { BenchmarkId::new("Batch scalar inversion", *batch_size), &batch_size, |b, &&size| { - let mut rng = SysRng.unwrap_err(); + let mut rng = rng(); let scalars: Vec = (0..size).map(|_| Scalar::random(&mut rng)).collect(); b.iter(|| { diff --git a/curve25519/curve25519/build.rs b/curve25519/solana-ed25519/build.rs similarity index 100% rename from curve25519/curve25519/build.rs rename to curve25519/solana-ed25519/build.rs diff --git a/curve25519/curve25519/docs/assets/rustdoc-include-katex-header.html b/curve25519/solana-ed25519/docs/assets/rustdoc-include-katex-header.html similarity index 100% rename from curve25519/curve25519/docs/assets/rustdoc-include-katex-header.html rename to curve25519/solana-ed25519/docs/assets/rustdoc-include-katex-header.html diff --git a/curve25519/curve25519/docs/avx2-notes.md b/curve25519/solana-ed25519/docs/avx2-notes.md similarity index 100% rename from curve25519/curve25519/docs/avx2-notes.md rename to curve25519/solana-ed25519/docs/avx2-notes.md diff --git a/curve25519/curve25519/docs/ifma-notes.md b/curve25519/solana-ed25519/docs/ifma-notes.md similarity index 100% rename from curve25519/curve25519/docs/ifma-notes.md rename to curve25519/solana-ed25519/docs/ifma-notes.md diff --git a/curve25519/curve25519/docs/parallel-formulas.md b/curve25519/solana-ed25519/docs/parallel-formulas.md similarity index 100% rename from curve25519/curve25519/docs/parallel-formulas.md rename to curve25519/solana-ed25519/docs/parallel-formulas.md diff --git a/curve25519/ed25519-heea/tests/examples/pkcs8-v1.der b/curve25519/solana-ed25519/examples/pkcs8-v1.der similarity index 100% rename from curve25519/ed25519-heea/tests/examples/pkcs8-v1.der rename to curve25519/solana-ed25519/examples/pkcs8-v1.der diff --git a/curve25519/ed25519-heea/tests/examples/pkcs8-v1.pem b/curve25519/solana-ed25519/examples/pkcs8-v1.pem similarity index 100% rename from curve25519/ed25519-heea/tests/examples/pkcs8-v1.pem rename to curve25519/solana-ed25519/examples/pkcs8-v1.pem diff --git a/curve25519/ed25519-heea/tests/examples/pkcs8-v2-bad-ver-key.der b/curve25519/solana-ed25519/examples/pkcs8-v2-bad-ver-key.der similarity index 100% rename from curve25519/ed25519-heea/tests/examples/pkcs8-v2-bad-ver-key.der rename to curve25519/solana-ed25519/examples/pkcs8-v2-bad-ver-key.der diff --git a/curve25519/ed25519-heea/tests/examples/pkcs8-v2-bad-ver-key.pem b/curve25519/solana-ed25519/examples/pkcs8-v2-bad-ver-key.pem similarity index 100% rename from curve25519/ed25519-heea/tests/examples/pkcs8-v2-bad-ver-key.pem rename to curve25519/solana-ed25519/examples/pkcs8-v2-bad-ver-key.pem diff --git a/curve25519/ed25519-heea/tests/examples/pkcs8-v2.der b/curve25519/solana-ed25519/examples/pkcs8-v2.der similarity index 100% rename from curve25519/ed25519-heea/tests/examples/pkcs8-v2.der rename to curve25519/solana-ed25519/examples/pkcs8-v2.der diff --git a/curve25519/ed25519-heea/tests/examples/pkcs8-v2.pem b/curve25519/solana-ed25519/examples/pkcs8-v2.pem similarity index 100% rename from curve25519/ed25519-heea/tests/examples/pkcs8-v2.pem rename to curve25519/solana-ed25519/examples/pkcs8-v2.pem diff --git a/curve25519/ed25519-heea/tests/examples/pubkey.der b/curve25519/solana-ed25519/examples/pubkey.der similarity index 100% rename from curve25519/ed25519-heea/tests/examples/pubkey.der rename to curve25519/solana-ed25519/examples/pubkey.der diff --git a/curve25519/ed25519-heea/tests/examples/pubkey.pem b/curve25519/solana-ed25519/examples/pubkey.pem similarity index 100% rename from curve25519/ed25519-heea/tests/examples/pubkey.pem rename to curve25519/solana-ed25519/examples/pubkey.pem diff --git a/curve25519/curve25519/src/backend.rs b/curve25519/solana-ed25519/src/backend.rs similarity index 100% rename from curve25519/curve25519/src/backend.rs rename to curve25519/solana-ed25519/src/backend.rs diff --git a/curve25519/curve25519/src/backend/serial.rs b/curve25519/solana-ed25519/src/backend/serial.rs similarity index 100% rename from curve25519/curve25519/src/backend/serial.rs rename to curve25519/solana-ed25519/src/backend/serial.rs diff --git a/curve25519/curve25519/src/backend/serial/curve_models.rs b/curve25519/solana-ed25519/src/backend/serial/curve_models.rs similarity index 100% rename from curve25519/curve25519/src/backend/serial/curve_models.rs rename to curve25519/solana-ed25519/src/backend/serial/curve_models.rs diff --git a/curve25519/curve25519/src/backend/serial/scalar_mul.rs b/curve25519/solana-ed25519/src/backend/serial/scalar_mul.rs similarity index 100% rename from curve25519/curve25519/src/backend/serial/scalar_mul.rs rename to curve25519/solana-ed25519/src/backend/serial/scalar_mul.rs diff --git a/curve25519/curve25519/src/backend/serial/scalar_mul/pippenger.rs b/curve25519/solana-ed25519/src/backend/serial/scalar_mul/pippenger.rs similarity index 100% rename from curve25519/curve25519/src/backend/serial/scalar_mul/pippenger.rs rename to curve25519/solana-ed25519/src/backend/serial/scalar_mul/pippenger.rs diff --git a/curve25519/curve25519/src/backend/serial/scalar_mul/precomputed_straus.rs b/curve25519/solana-ed25519/src/backend/serial/scalar_mul/precomputed_straus.rs similarity index 100% rename from curve25519/curve25519/src/backend/serial/scalar_mul/precomputed_straus.rs rename to curve25519/solana-ed25519/src/backend/serial/scalar_mul/precomputed_straus.rs diff --git a/curve25519/curve25519/src/backend/serial/scalar_mul/straus.rs b/curve25519/solana-ed25519/src/backend/serial/scalar_mul/straus.rs similarity index 100% rename from curve25519/curve25519/src/backend/serial/scalar_mul/straus.rs rename to curve25519/solana-ed25519/src/backend/serial/scalar_mul/straus.rs diff --git a/curve25519/curve25519/src/backend/serial/scalar_mul/variable_base.rs b/curve25519/solana-ed25519/src/backend/serial/scalar_mul/variable_base.rs similarity index 100% rename from curve25519/curve25519/src/backend/serial/scalar_mul/variable_base.rs rename to curve25519/solana-ed25519/src/backend/serial/scalar_mul/variable_base.rs diff --git a/curve25519/curve25519/src/backend/serial/scalar_mul/vartime_double_base.rs b/curve25519/solana-ed25519/src/backend/serial/scalar_mul/vartime_double_base.rs similarity index 100% rename from curve25519/curve25519/src/backend/serial/scalar_mul/vartime_double_base.rs rename to curve25519/solana-ed25519/src/backend/serial/scalar_mul/vartime_double_base.rs diff --git a/curve25519/curve25519/src/backend/serial/scalar_mul/vartime_triple_base.rs b/curve25519/solana-ed25519/src/backend/serial/scalar_mul/vartime_triple_base.rs similarity index 100% rename from curve25519/curve25519/src/backend/serial/scalar_mul/vartime_triple_base.rs rename to curve25519/solana-ed25519/src/backend/serial/scalar_mul/vartime_triple_base.rs diff --git a/curve25519/curve25519/src/backend/serial/u64.rs b/curve25519/solana-ed25519/src/backend/serial/u64.rs similarity index 100% rename from curve25519/curve25519/src/backend/serial/u64.rs rename to curve25519/solana-ed25519/src/backend/serial/u64.rs diff --git a/curve25519/curve25519/src/backend/serial/u64/constants.rs b/curve25519/solana-ed25519/src/backend/serial/u64/constants.rs similarity index 100% rename from curve25519/curve25519/src/backend/serial/u64/constants.rs rename to curve25519/solana-ed25519/src/backend/serial/u64/constants.rs diff --git a/curve25519/curve25519/src/backend/serial/u64/field.rs b/curve25519/solana-ed25519/src/backend/serial/u64/field.rs similarity index 100% rename from curve25519/curve25519/src/backend/serial/u64/field.rs rename to curve25519/solana-ed25519/src/backend/serial/u64/field.rs diff --git a/curve25519/curve25519/src/backend/serial/u64/scalar.rs b/curve25519/solana-ed25519/src/backend/serial/u64/scalar.rs similarity index 100% rename from curve25519/curve25519/src/backend/serial/u64/scalar.rs rename to curve25519/solana-ed25519/src/backend/serial/u64/scalar.rs diff --git a/curve25519/curve25519/src/backend/vector.rs b/curve25519/solana-ed25519/src/backend/vector.rs similarity index 100% rename from curve25519/curve25519/src/backend/vector.rs rename to curve25519/solana-ed25519/src/backend/vector.rs diff --git a/curve25519/curve25519/src/backend/vector/avx2.rs b/curve25519/solana-ed25519/src/backend/vector/avx2.rs similarity index 100% rename from curve25519/curve25519/src/backend/vector/avx2.rs rename to curve25519/solana-ed25519/src/backend/vector/avx2.rs diff --git a/curve25519/curve25519/src/backend/vector/avx2/constants.rs b/curve25519/solana-ed25519/src/backend/vector/avx2/constants.rs similarity index 100% rename from curve25519/curve25519/src/backend/vector/avx2/constants.rs rename to curve25519/solana-ed25519/src/backend/vector/avx2/constants.rs diff --git a/curve25519/curve25519/src/backend/vector/avx2/edwards.rs b/curve25519/solana-ed25519/src/backend/vector/avx2/edwards.rs similarity index 99% rename from curve25519/curve25519/src/backend/vector/avx2/edwards.rs rename to curve25519/solana-ed25519/src/backend/vector/avx2/edwards.rs index eef91da..a7e2c68 100644 --- a/curve25519/curve25519/src/backend/vector/avx2/edwards.rs +++ b/curve25519/solana-ed25519/src/backend/vector/avx2/edwards.rs @@ -40,7 +40,7 @@ use core::ops::{Add, Neg, Sub}; use subtle::Choice; use subtle::ConditionallySelectable; -use curve25519_derive::unsafe_target_feature; +use curve25519_dalek_derive::unsafe_target_feature; use crate::edwards; use crate::window::{LookupTable, NafLookupTable5}; diff --git a/curve25519/curve25519/src/backend/vector/avx2/field.rs b/curve25519/solana-ed25519/src/backend/vector/avx2/field.rs similarity index 99% rename from curve25519/curve25519/src/backend/vector/avx2/field.rs rename to curve25519/solana-ed25519/src/backend/vector/avx2/field.rs index 4383c55..a276def 100644 --- a/curve25519/curve25519/src/backend/vector/avx2/field.rs +++ b/curve25519/solana-ed25519/src/backend/vector/avx2/field.rs @@ -53,7 +53,7 @@ use crate::backend::vector::avx2::constants::{ P_TIMES_2_HI, P_TIMES_2_LO, P_TIMES_16_HI, P_TIMES_16_LO, }; -use curve25519_derive::unsafe_target_feature; +use curve25519_dalek_derive::unsafe_target_feature; /// Unpack 32-bit lanes into 64-bit lanes: /// ```ascii,no_run diff --git a/curve25519/curve25519/src/backend/vector/packed_simd.rs b/curve25519/solana-ed25519/src/backend/vector/packed_simd.rs similarity index 99% rename from curve25519/curve25519/src/backend/vector/packed_simd.rs rename to curve25519/solana-ed25519/src/backend/vector/packed_simd.rs index d568c4a..0e1c134 100644 --- a/curve25519/curve25519/src/backend/vector/packed_simd.rs +++ b/curve25519/solana-ed25519/src/backend/vector/packed_simd.rs @@ -16,7 +16,7 @@ //! by the callers of this code. use core::ops::{Add, AddAssign, BitAnd, BitAndAssign, BitXor, BitXorAssign, Sub}; -use curve25519_derive::unsafe_target_feature; +use curve25519_dalek_derive::unsafe_target_feature; macro_rules! impl_shared { ( diff --git a/curve25519/curve25519/src/backend/vector/scalar_mul.rs b/curve25519/solana-ed25519/src/backend/vector/scalar_mul.rs similarity index 100% rename from curve25519/curve25519/src/backend/vector/scalar_mul.rs rename to curve25519/solana-ed25519/src/backend/vector/scalar_mul.rs diff --git a/curve25519/curve25519/src/backend/vector/scalar_mul/pippenger.rs b/curve25519/solana-ed25519/src/backend/vector/scalar_mul/pippenger.rs similarity index 98% rename from curve25519/curve25519/src/backend/vector/scalar_mul/pippenger.rs rename to curve25519/solana-ed25519/src/backend/vector/scalar_mul/pippenger.rs index 3f3a96c..1b5335b 100644 --- a/curve25519/curve25519/src/backend/vector/scalar_mul/pippenger.rs +++ b/curve25519/solana-ed25519/src/backend/vector/scalar_mul/pippenger.rs @@ -9,7 +9,7 @@ #![allow(non_snake_case)] -#[curve25519_derive::unsafe_target_feature_specialize("avx2")] +#[curve25519_dalek_derive::unsafe_target_feature_specialize("avx2")] pub mod spec { use alloc::vec::Vec; diff --git a/curve25519/curve25519/src/backend/vector/scalar_mul/precomputed_straus.rs b/curve25519/solana-ed25519/src/backend/vector/scalar_mul/precomputed_straus.rs similarity index 98% rename from curve25519/curve25519/src/backend/vector/scalar_mul/precomputed_straus.rs rename to curve25519/solana-ed25519/src/backend/vector/scalar_mul/precomputed_straus.rs index 0b04703..43bbd99 100644 --- a/curve25519/curve25519/src/backend/vector/scalar_mul/precomputed_straus.rs +++ b/curve25519/solana-ed25519/src/backend/vector/scalar_mul/precomputed_straus.rs @@ -11,7 +11,7 @@ #![allow(non_snake_case)] -#[curve25519_derive::unsafe_target_feature_specialize("avx2")] +#[curve25519_dalek_derive::unsafe_target_feature_specialize("avx2")] pub mod spec { use alloc::vec::Vec; diff --git a/curve25519/curve25519/src/backend/vector/scalar_mul/straus.rs b/curve25519/solana-ed25519/src/backend/vector/scalar_mul/straus.rs similarity index 98% rename from curve25519/curve25519/src/backend/vector/scalar_mul/straus.rs rename to curve25519/solana-ed25519/src/backend/vector/scalar_mul/straus.rs index 0b68770..b7b8efc 100644 --- a/curve25519/curve25519/src/backend/vector/scalar_mul/straus.rs +++ b/curve25519/solana-ed25519/src/backend/vector/scalar_mul/straus.rs @@ -11,7 +11,7 @@ #![allow(non_snake_case)] -#[curve25519_derive::unsafe_target_feature_specialize("avx2")] +#[curve25519_dalek_derive::unsafe_target_feature_specialize("avx2")] pub mod spec { use alloc::vec::Vec; diff --git a/curve25519/curve25519/src/backend/vector/scalar_mul/variable_base.rs b/curve25519/solana-ed25519/src/backend/vector/scalar_mul/variable_base.rs similarity index 95% rename from curve25519/curve25519/src/backend/vector/scalar_mul/variable_base.rs rename to curve25519/solana-ed25519/src/backend/vector/scalar_mul/variable_base.rs index ef0ace1..10a7e44 100644 --- a/curve25519/curve25519/src/backend/vector/scalar_mul/variable_base.rs +++ b/curve25519/solana-ed25519/src/backend/vector/scalar_mul/variable_base.rs @@ -1,6 +1,6 @@ #![allow(non_snake_case)] -#[curve25519_derive::unsafe_target_feature_specialize("avx2")] +#[curve25519_dalek_derive::unsafe_target_feature_specialize("avx2")] pub mod spec { #[for_target_feature("avx2")] diff --git a/curve25519/curve25519/src/backend/vector/scalar_mul/vartime_double_base.rs b/curve25519/solana-ed25519/src/backend/vector/scalar_mul/vartime_double_base.rs similarity index 97% rename from curve25519/curve25519/src/backend/vector/scalar_mul/vartime_double_base.rs rename to curve25519/solana-ed25519/src/backend/vector/scalar_mul/vartime_double_base.rs index 70bd39e..89df5f0 100644 --- a/curve25519/curve25519/src/backend/vector/scalar_mul/vartime_double_base.rs +++ b/curve25519/solana-ed25519/src/backend/vector/scalar_mul/vartime_double_base.rs @@ -11,7 +11,7 @@ #![allow(non_snake_case)] -#[curve25519_derive::unsafe_target_feature_specialize("avx2")] +#[curve25519_dalek_derive::unsafe_target_feature_specialize("avx2")] pub mod spec { use core::cmp::Ordering; diff --git a/curve25519/curve25519/src/backend/vector/scalar_mul/vartime_triple_base.rs b/curve25519/solana-ed25519/src/backend/vector/scalar_mul/vartime_triple_base.rs similarity index 98% rename from curve25519/curve25519/src/backend/vector/scalar_mul/vartime_triple_base.rs rename to curve25519/solana-ed25519/src/backend/vector/scalar_mul/vartime_triple_base.rs index 219153a..4508051 100644 --- a/curve25519/curve25519/src/backend/vector/scalar_mul/vartime_triple_base.rs +++ b/curve25519/solana-ed25519/src/backend/vector/scalar_mul/vartime_triple_base.rs @@ -7,7 +7,7 @@ #![allow(non_snake_case)] -#[curve25519_derive::unsafe_target_feature_specialize("avx2")] +#[curve25519_dalek_derive::unsafe_target_feature_specialize("avx2")] pub mod spec { use core::cmp::Ordering; diff --git a/curve25519/curve25519/src/constants.rs b/curve25519/solana-ed25519/src/constants.rs similarity index 100% rename from curve25519/curve25519/src/constants.rs rename to curve25519/solana-ed25519/src/constants.rs diff --git a/curve25519/curve25519/src/diagnostics.rs b/curve25519/solana-ed25519/src/diagnostics.rs similarity index 100% rename from curve25519/curve25519/src/diagnostics.rs rename to curve25519/solana-ed25519/src/diagnostics.rs diff --git a/curve25519/ed25519-heea/src/lib.rs b/curve25519/solana-ed25519/src/ed_sigs.rs similarity index 50% rename from curve25519/ed25519-heea/src/lib.rs rename to curve25519/solana-ed25519/src/ed_sigs.rs index f4c312e..e7fd3b6 100644 --- a/curve25519/ed25519-heea/src/lib.rs +++ b/curve25519/solana-ed25519/src/ed_sigs.rs @@ -1,11 +1,7 @@ -#![deny(missing_docs)] -#![doc = include_str!("../README.md")] -#![cfg_attr(not(feature = "std"), no_std)] +//! Ed25519 signing and verification (ZIP-215 / HEEA-accelerated). -//! Docs require the `nightly` feature until RFC 1990 lands. - -#[cfg(feature = "alloc")] -extern crate alloc; +#[cfg(test)] +mod tests; #[cfg(feature = "alloc")] pub mod batch; @@ -14,8 +10,8 @@ mod signing_key; mod verification_key; // Allows importing traits used by `Signature`. -pub use ed25519; -pub use ed25519::Signature; +pub use ::ed25519; +pub use ::ed25519::Signature; pub use error::Error; pub use signing_key::SigningKey; pub use verification_key::{VerificationKey, VerificationKeyBytes}; diff --git a/curve25519/ed25519-heea/src/batch.rs b/curve25519/solana-ed25519/src/ed_sigs/batch.rs similarity index 94% rename from curve25519/ed25519-heea/src/batch.rs rename to curve25519/solana-ed25519/src/ed_sigs/batch.rs index fd73d4e..d808712 100644 --- a/curve25519/ed25519-heea/src/batch.rs +++ b/curve25519/solana-ed25519/src/ed_sigs/batch.rs @@ -34,16 +34,16 @@ //! //! # Example //! ``` -//! # use ed25519_heea::*; +//! # use curve25519::ed_sigs::*; //! let mut batch = batch::Verifier::new(); //! for _ in 0..32 { -//! let sk = SigningKey::new(rand::thread_rng()); +//! let sk = SigningKey::new(rand::rng()); //! let vk_bytes = VerificationKeyBytes::from(&sk); //! let msg = b"BatchVerifyTest"; //! let sig = sk.sign(&msg[..]); //! batch.queue((vk_bytes, sig, &msg[..])); //! } -//! assert!(batch.verify(rand::thread_rng()).is_ok()); +//! assert!(batch.verify(rand::rng()).is_ok()); //! ``` //! //! [ZIP215]: https://zips.z.cash/zip-0215 @@ -51,20 +51,20 @@ use alloc::vec::Vec; use core::convert::TryFrom; -use curve25519::{ +use crate::{ edwards::{CompressedEdwardsY, EdwardsPoint}, scalar::Scalar, traits::{IsIdentity, VartimeMultiscalarMul}, }; use hashbrown::HashMap; -use rand_core::{CryptoRng, RngCore}; +use rand_core::{CryptoRng, Rng}; use sha2::{Sha512, digest::Update}; -use crate::{Error, VerificationKey, VerificationKeyBytes}; +use super::{Error, VerificationKey, VerificationKeyBytes}; use ed25519::Signature; // Shim to generate a u128 without importing `rand`. -fn gen_u128(mut rng: R) -> u128 { +fn gen_u128(mut rng: R) -> u128 { let mut bytes = [0u8; 16]; rng.fill_bytes(&mut bytes[..]); u128::from_le_bytes(bytes) @@ -142,7 +142,7 @@ impl Verifier { /// Perform batch verification, returning `Ok(())` if all signatures were /// valid and `Err` otherwise. #[allow(non_snake_case)] - pub fn verify(self, mut rng: R) -> Result<(), Error> { + pub fn verify(self, mut rng: R) -> Result<(), Error> { // The batch verification equation is // // 8*[-sum(z_i * s_i)]B + 8*sum([z_i]R_i) + 8*sum([z_i * k_i]A_i) = 0. @@ -199,8 +199,8 @@ impl Verifier { A_coeffs.push(A_coeff); } + use crate::constants::ED25519_BASEPOINT_POINT as B; use core::iter::once; - use curve25519::constants::ED25519_BASEPOINT_POINT as B; let check = EdwardsPoint::vartime_multiscalar_mul( once(&B_coeff).chain(A_coeffs.iter()).chain(R_coeffs.iter()), once(&B).chain(As.iter()).chain(Rs.iter()), diff --git a/curve25519/ed25519-heea/src/error.rs b/curve25519/solana-ed25519/src/ed_sigs/error.rs similarity index 100% rename from curve25519/ed25519-heea/src/error.rs rename to curve25519/solana-ed25519/src/ed_sigs/error.rs diff --git a/curve25519/ed25519-heea/src/signing_key.rs b/curve25519/solana-ed25519/src/ed_sigs/signing_key.rs similarity index 97% rename from curve25519/ed25519-heea/src/signing_key.rs rename to curve25519/solana-ed25519/src/ed_sigs/signing_key.rs index d3a8d34..563b887 100644 --- a/curve25519/ed25519-heea/src/signing_key.rs +++ b/curve25519/solana-ed25519/src/ed_sigs/signing_key.rs @@ -6,14 +6,14 @@ const ALGORITHM_ID: AlgorithmIdentifierRef = AlgorithmIdentifierRef { parameters: None, }; -use crate::Error; +use super::Error; +use crate::{constants, scalar::Scalar}; #[cfg(all(feature = "pem", feature = "pkcs8"))] use alloc::string::String; use core::convert::TryFrom; #[cfg(feature = "pkcs8")] use core::convert::TryInto; -use curve25519::{constants, scalar::Scalar}; -use rand_core::{CryptoRng, RngCore}; +use rand_core::{CryptoRng, Rng}; use sha2::{Digest, Sha512, digest::Update}; use subtle::ConstantTimeEq; use zeroize::Zeroize; @@ -40,7 +40,7 @@ use zeroize::Zeroizing; #[cfg(all(feature = "pem", feature = "pkcs8"))] use pkcs8::der::pem::PemLabel; -use crate::{VerificationKey, VerificationKeyBytes}; +use super::{VerificationKey, VerificationKeyBytes}; /// The length of a ed25519 `SecretKey`, in bytes. pub const SECRET_KEY_LENGTH: usize = 32; @@ -68,7 +68,7 @@ pub struct SigningKey { } impl core::fmt::Debug for SigningKey { - fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result { + fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { fmt.debug_struct("SigningKey") .field("vk", &self.vk) .finish() @@ -317,7 +317,7 @@ impl SigningKey { } /// Generate a new signing key. - pub fn new(mut rng: R) -> SigningKey { + pub fn new(mut rng: R) -> SigningKey { let mut bytes = [0u8; 32]; rng.fill_bytes(&mut bytes[..]); bytes.into() diff --git a/curve25519/solana-ed25519/src/ed_sigs/tests.rs b/curve25519/solana-ed25519/src/ed_sigs/tests.rs new file mode 100644 index 0000000..f289766 --- /dev/null +++ b/curve25519/solana-ed25519/src/ed_sigs/tests.rs @@ -0,0 +1,9 @@ +pub mod util; + +mod batch; +mod decoding; +mod encoding; +mod heea; +mod rfc8032; +mod small_order; +mod unit_tests; diff --git a/curve25519/ed25519-heea/tests/batch.rs b/curve25519/solana-ed25519/src/ed_sigs/tests/batch.rs similarity index 81% rename from curve25519/ed25519-heea/tests/batch.rs rename to curve25519/solana-ed25519/src/ed_sigs/tests/batch.rs index eb06840..5974138 100644 --- a/curve25519/ed25519-heea/tests/batch.rs +++ b/curve25519/solana-ed25519/src/ed_sigs/tests/batch.rs @@ -1,20 +1,19 @@ #![cfg(feature = "alloc")] -use rand::thread_rng; - -use ed25519_heea::*; +use crate::ed_sigs::*; +use alloc::vec::Vec; #[test] fn batch_verify() { let mut batch = batch::Verifier::new(); for _ in 0..32 { - let sk = SigningKey::new(thread_rng()); + let sk = SigningKey::new(rand::rng()); let pk_bytes = VerificationKeyBytes::from(&sk); let msg = b"BatchVerifyTest"; let sig = sk.sign(&msg[..]); batch.queue((pk_bytes, sig, msg)); } - assert!(batch.verify(thread_rng()).is_ok()); + assert!(batch.verify(rand::rng()).is_ok()); } #[test] @@ -23,7 +22,7 @@ fn batch_verify_with_one_bad_sig() { let mut batch = batch::Verifier::new(); let mut items = Vec::new(); for i in 0..32 { - let sk = SigningKey::new(thread_rng()); + let sk = SigningKey::new(rand::rng()); let pk_bytes = VerificationKeyBytes::from(&sk); let msg = b"BatchVerifyTest"; let sig = if i != bad_index { @@ -35,7 +34,7 @@ fn batch_verify_with_one_bad_sig() { items.push(item.clone()); batch.queue(item); } - assert!(batch.verify(thread_rng()).is_err()); + assert!(batch.verify(rand::rng()).is_err()); for (i, item) in items.drain(..).enumerate() { if i != bad_index { assert!(item.verify_single().is_ok()); diff --git a/curve25519/ed25519-heea/tests/decoding.rs b/curve25519/solana-ed25519/src/ed_sigs/tests/decoding.rs similarity index 99% rename from curve25519/ed25519-heea/tests/decoding.rs rename to curve25519/solana-ed25519/src/ed_sigs/tests/decoding.rs index acf23c3..e6d59df 100644 --- a/curve25519/ed25519-heea/tests/decoding.rs +++ b/curve25519/solana-ed25519/src/ed_sigs/tests/decoding.rs @@ -1,5 +1,5 @@ #[cfg(any(feature = "pem", feature = "pkcs8"))] -use ed25519_heea::*; +use crate::ed_sigs::*; #[cfg(feature = "pkcs8")] use pkcs8::{DecodePrivateKey, DecodePublicKey}; diff --git a/curve25519/ed25519-heea/tests/encoding.rs b/curve25519/solana-ed25519/src/ed_sigs/tests/encoding.rs similarity index 99% rename from curve25519/ed25519-heea/tests/encoding.rs rename to curve25519/solana-ed25519/src/ed_sigs/tests/encoding.rs index b1acb4a..ba93817 100644 --- a/curve25519/ed25519-heea/tests/encoding.rs +++ b/curve25519/solana-ed25519/src/ed_sigs/tests/encoding.rs @@ -1,7 +1,7 @@ +#[cfg(any(feature = "pem", feature = "pkcs8"))] +use crate::ed_sigs::*; #[cfg(feature = "pem")] use der::pem::LineEnding; -#[cfg(any(feature = "pem", feature = "pkcs8"))] -use ed25519_heea::*; #[cfg(feature = "pkcs8")] pub use pkcs8::{ EncodePrivateKey, EncodePublicKey, ObjectIdentifier, PrivateKeyInfo, diff --git a/curve25519/ed25519-heea/tests/heea.rs b/curve25519/solana-ed25519/src/ed_sigs/tests/heea.rs similarity index 90% rename from curve25519/ed25519-heea/tests/heea.rs rename to curve25519/solana-ed25519/src/ed_sigs/tests/heea.rs index e87e8f9..36fedac 100644 --- a/curve25519/ed25519-heea/tests/heea.rs +++ b/curve25519/solana-ed25519/src/ed_sigs/tests/heea.rs @@ -1,11 +1,9 @@ -use ed25519_heea::SigningKey; -use ed25519_heea::VerificationKey; - -use rand::thread_rng; +use crate::ed_sigs::SigningKey; +use crate::ed_sigs::VerificationKey; #[test] fn test_verify_heea_invalid_signature() { - let mut rng = thread_rng(); + let mut rng = rand::rng(); let signing_key = SigningKey::new(&mut rng); let verification_key = VerificationKey::from(&signing_key); @@ -31,7 +29,7 @@ fn test_verify_heea_invalid_signature() { #[test] fn test_verify_heea_multiple_signatures() { - let mut rng = thread_rng(); + let mut rng = rand::rng(); for i in 0..100 { let signing_key = SigningKey::new(&mut rng); diff --git a/curve25519/ed25519-heea/tests/rfc8032.rs b/curve25519/solana-ed25519/src/ed_sigs/tests/rfc8032.rs similarity index 99% rename from curve25519/ed25519-heea/tests/rfc8032.rs rename to curve25519/solana-ed25519/src/ed_sigs/tests/rfc8032.rs index d96a61b..d943131 100644 --- a/curve25519/ed25519-heea/tests/rfc8032.rs +++ b/curve25519/solana-ed25519/src/ed_sigs/tests/rfc8032.rs @@ -5,8 +5,8 @@ //! in consensus.rs. #![cfg(feature = "serde")] +use crate::ed_sigs::*; use ed25519::Signature; -use ed25519_heea::*; fn rfc8032_test_case(sk_bytes: Vec, pk_bytes: Vec, sig_bytes: Vec, msg: Vec) { let sk: SigningKey = bincode::deserialize(&sk_bytes).expect("sk should deserialize"); diff --git a/curve25519/ed25519-heea/tests/small_order.rs b/curve25519/solana-ed25519/src/ed_sigs/tests/small_order.rs similarity index 95% rename from curve25519/ed25519-heea/tests/small_order.rs rename to curve25519/solana-ed25519/src/ed_sigs/tests/small_order.rs index ed2c56f..e053720 100644 --- a/curve25519/ed25519-heea/tests/small_order.rs +++ b/curve25519/solana-ed25519/src/ed_sigs/tests/small_order.rs @@ -1,14 +1,14 @@ #![cfg(feature = "std")] -use color_eyre::Report; -use curve25519::{ +use crate::{ constants::EIGHT_TORSION, digest::Update, edwards::CompressedEdwardsY, scalar::Scalar, traits::IsIdentity, }; +use color_eyre::Report; use once_cell::sync::Lazy; use sha2::Sha512; -mod util; +use super::util; use util::TestCase; #[allow(non_snake_case)] @@ -86,9 +86,9 @@ fn conformance() -> Result<(), Report> { #[cfg(feature = "alloc")] #[test] fn individual_matches_batch_verification() -> Result<(), Report> { + use crate::ed_sigs::{VerificationKey, VerificationKeyBytes, batch}; use core::convert::TryFrom; use ed25519::Signature; - use ed25519_heea::{VerificationKey, VerificationKeyBytes, batch}; for case in SMALL_ORDER_SIGS.iter() { let msg = b"Zcash"; @@ -98,7 +98,7 @@ fn individual_matches_batch_verification() -> Result<(), Report> { VerificationKey::try_from(vkb).and_then(|vk| vk.verify(&sig, msg)); let mut bv = batch::Verifier::new(); bv.queue((vkb, sig, msg)); - let batch_verification = bv.verify(rand::thread_rng()); + let batch_verification = bv.verify(rand::rng()); assert_eq!(individual_verification.is_ok(), batch_verification.is_ok()); } Ok(()) diff --git a/curve25519/ed25519-heea/tests/unit_tests.rs b/curve25519/solana-ed25519/src/ed_sigs/tests/unit_tests.rs similarity index 85% rename from curve25519/ed25519-heea/tests/unit_tests.rs rename to curve25519/solana-ed25519/src/ed_sigs/tests/unit_tests.rs index d1e8d7a..612ac49 100644 --- a/curve25519/ed25519-heea/tests/unit_tests.rs +++ b/curve25519/solana-ed25519/src/ed_sigs/tests/unit_tests.rs @@ -2,13 +2,11 @@ use core::convert::TryFrom; -use rand::thread_rng; - -use ed25519_heea::{Signature, SigningKey, VerificationKey, VerificationKeyBytes}; +use crate::ed_sigs::{Signature, SigningKey, VerificationKey, VerificationKeyBytes}; #[test] fn parsing() { - let sk = SigningKey::new(thread_rng()); + let sk = SigningKey::new(rand::rng()); let pk = VerificationKey::from(&sk); let pkb = VerificationKeyBytes::from(&sk); let sig = sk.sign(b"test"); @@ -39,7 +37,7 @@ fn parsing() { #[test] fn sign_and_verify() { - let sk = SigningKey::new(thread_rng()); + let sk = SigningKey::new(rand::rng()); let pk = VerificationKey::from(&sk); let msg = b"ed25519-zebra test message"; diff --git a/curve25519/ed25519-heea/tests/util/mod.rs b/curve25519/solana-ed25519/src/ed_sigs/tests/util.rs similarity index 98% rename from curve25519/ed25519-heea/tests/util/mod.rs rename to curve25519/solana-ed25519/src/ed_sigs/tests/util.rs index 29842a9..76ef743 100644 --- a/curve25519/ed25519-heea/tests/util/mod.rs +++ b/curve25519/solana-ed25519/src/ed_sigs/tests/util.rs @@ -2,9 +2,9 @@ #![allow(dead_code)] #![cfg(feature = "std")] +use crate::ed_sigs as ed25519_heea_zip215; +use crate::edwards::{CompressedEdwardsY, EdwardsPoint}; use color_eyre::{Report, eyre::eyre}; -use curve25519::edwards::{CompressedEdwardsY, EdwardsPoint}; -use ed25519_heea as ed25519_heea_zip215; use core::convert::TryFrom; @@ -170,7 +170,7 @@ fn print_non_canonical_points() { } pub fn order(point: EdwardsPoint) -> &'static str { - use curve25519::traits::IsIdentity; + use crate::traits::IsIdentity; if point.is_small_order() { let point2 = point + point; let point4 = point2 + point2; diff --git a/curve25519/ed25519-heea/src/verification_key.rs b/curve25519/solana-ed25519/src/ed_sigs/verification_key.rs similarity index 98% rename from curve25519/ed25519-heea/src/verification_key.rs rename to curve25519/solana-ed25519/src/ed_sigs/verification_key.rs index 9b37e21..421c46c 100644 --- a/curve25519/ed25519-heea/src/verification_key.rs +++ b/curve25519/solana-ed25519/src/ed_sigs/verification_key.rs @@ -12,12 +12,12 @@ // Halving" (TCHES 2025) for the algorithm. // - `verify` and all ZIP-215 consensus logic are unchanged from ed25519-zebra. -use core::convert::{TryFrom, TryInto}; -use curve25519::{ +use crate::{ edwards::{CompressedEdwardsY, EdwardsPoint}, scalar::Scalar, traits::{HEEADecomposition, IsIdentity}, }; +use core::convert::{TryFrom, TryInto}; use sha2::{Sha512, digest::Update}; use zeroize::DefaultIsZeroes; @@ -32,7 +32,7 @@ use pkcs8::spki::{ #[cfg(feature = "pkcs8")] use pkcs8::{Document, ObjectIdentifier}; -use crate::Error; +use super::Error; /// The length of an ed25519 `VerificationKey`, in bytes. pub const VERIFICATION_KEY_LENGTH: usize = 32; @@ -48,10 +48,9 @@ pub const VERIFICATION_KEY_LENGTH: usize = 32; /// following idiom: /// ``` /// use core::convert::TryFrom; -/// # use rand::thread_rng; -/// # use ed25519_heea::*; +/// # use curve25519::ed_sigs::*; /// # let msg = b"Zcash"; -/// # let sk = SigningKey::new(thread_rng()); +/// # let sk = SigningKey::new(rand::rng()); /// # let sig = sk.sign(msg); /// # let vk_bytes = VerificationKeyBytes::from(&sk); /// VerificationKey::try_from(vk_bytes) @@ -62,7 +61,7 @@ pub const VERIFICATION_KEY_LENGTH: usize = 32; pub struct VerificationKeyBytes(pub(crate) [u8; VERIFICATION_KEY_LENGTH]); impl core::fmt::Debug for VerificationKeyBytes { - fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result { + fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { fmt.debug_tuple("VerificationKeyBytes") .field(&self.0) .finish() diff --git a/curve25519/curve25519/src/edwards.rs b/curve25519/solana-ed25519/src/edwards.rs similarity index 99% rename from curve25519/curve25519/src/edwards.rs rename to curve25519/solana-ed25519/src/edwards.rs index ec490f4..c28c935 100644 --- a/curve25519/curve25519/src/edwards.rs +++ b/curve25519/solana-ed25519/src/edwards.rs @@ -113,12 +113,12 @@ use digest::{ #[cfg(feature = "group")] use { group::{GroupEncoding, cofactor::CofactorGroup, prime::PrimeGroup}, - rand_core::TryRngCore, + rand_core::TryRng, subtle::CtOption, }; #[cfg(feature = "rand_core")] -use rand_core::RngCore; +use rand_core::Rng as RngCore; use subtle::Choice; use subtle::ConditionallyNegatable; @@ -1481,7 +1481,7 @@ impl Debug for EdwardsPoint { impl group::Group for EdwardsPoint { type Scalar = Scalar; - fn try_from_rng(rng: &mut R) -> Result { + fn try_from_rng(rng: &mut R) -> Result { let mut repr = CompressedEdwardsY([0u8; 32]); loop { rng.try_fill_bytes(&mut repr.0)?; @@ -1733,7 +1733,7 @@ impl Zeroize for SubgroupPoint { impl group::Group for SubgroupPoint { type Scalar = Scalar; - fn try_from_rng(rng: &mut R) -> Result { + fn try_from_rng(rng: &mut R) -> Result { use group::ff::Field; // This will almost never loop, but `Group::random` is documented as returning a diff --git a/curve25519/curve25519/src/edwards/affine.rs b/curve25519/solana-ed25519/src/edwards/affine.rs similarity index 100% rename from curve25519/curve25519/src/edwards/affine.rs rename to curve25519/solana-ed25519/src/edwards/affine.rs diff --git a/curve25519/curve25519/src/field.rs b/curve25519/solana-ed25519/src/field.rs similarity index 100% rename from curve25519/curve25519/src/field.rs rename to curve25519/solana-ed25519/src/field.rs diff --git a/curve25519/curve25519/src/lib.rs b/curve25519/solana-ed25519/src/lib.rs similarity index 93% rename from curve25519/curve25519/src/lib.rs rename to curve25519/solana-ed25519/src/lib.rs index 2091fb4..f1d0590 100644 --- a/curve25519/curve25519/src/lib.rs +++ b/curve25519/solana-ed25519/src/lib.rs @@ -78,6 +78,12 @@ pub mod constants; // External (and internal) traits. pub mod traits; +//------------------------------------------------------------------------ +// ed25519 public modules +//------------------------------------------------------------------------ + +pub mod ed_sigs; + //------------------------------------------------------------------------ // curve25519 internal modules //------------------------------------------------------------------------ diff --git a/curve25519/curve25519/src/lizard.rs b/curve25519/solana-ed25519/src/lizard.rs similarity index 100% rename from curve25519/curve25519/src/lizard.rs rename to curve25519/solana-ed25519/src/lizard.rs diff --git a/curve25519/curve25519/src/lizard/README.md b/curve25519/solana-ed25519/src/lizard/README.md similarity index 100% rename from curve25519/curve25519/src/lizard/README.md rename to curve25519/solana-ed25519/src/lizard/README.md diff --git a/curve25519/curve25519/src/lizard/jacobi_quartic.rs b/curve25519/solana-ed25519/src/lizard/jacobi_quartic.rs similarity index 100% rename from curve25519/curve25519/src/lizard/jacobi_quartic.rs rename to curve25519/solana-ed25519/src/lizard/jacobi_quartic.rs diff --git a/curve25519/curve25519/src/lizard/lizard_constants.rs b/curve25519/solana-ed25519/src/lizard/lizard_constants.rs similarity index 100% rename from curve25519/curve25519/src/lizard/lizard_constants.rs rename to curve25519/solana-ed25519/src/lizard/lizard_constants.rs diff --git a/curve25519/curve25519/src/lizard/lizard_ristretto.rs b/curve25519/solana-ed25519/src/lizard/lizard_ristretto.rs similarity index 100% rename from curve25519/curve25519/src/lizard/lizard_ristretto.rs rename to curve25519/solana-ed25519/src/lizard/lizard_ristretto.rs diff --git a/curve25519/curve25519/src/lizard/u64_constants.rs b/curve25519/solana-ed25519/src/lizard/u64_constants.rs similarity index 100% rename from curve25519/curve25519/src/lizard/u64_constants.rs rename to curve25519/solana-ed25519/src/lizard/u64_constants.rs diff --git a/curve25519/curve25519/src/macros.rs b/curve25519/solana-ed25519/src/macros.rs similarity index 100% rename from curve25519/curve25519/src/macros.rs rename to curve25519/solana-ed25519/src/macros.rs diff --git a/curve25519/curve25519/src/montgomery.rs b/curve25519/solana-ed25519/src/montgomery.rs similarity index 100% rename from curve25519/curve25519/src/montgomery.rs rename to curve25519/solana-ed25519/src/montgomery.rs diff --git a/curve25519/curve25519/src/ristretto.rs b/curve25519/solana-ed25519/src/ristretto.rs similarity index 99% rename from curve25519/curve25519/src/ristretto.rs rename to curve25519/solana-ed25519/src/ristretto.rs index 7672440..fa1ba16 100644 --- a/curve25519/curve25519/src/ristretto.rs +++ b/curve25519/solana-ed25519/src/ristretto.rs @@ -180,7 +180,7 @@ use crate::field::FieldElement; #[cfg(feature = "group")] use { group::{GroupEncoding, cofactor::CofactorGroup, prime::PrimeGroup}, - rand_core::TryRngCore, + rand_core::TryRng, subtle::CtOption, }; @@ -543,12 +543,11 @@ impl RistrettoPoint { #[cfg_attr(feature = "rand_core", doc = "```")] #[cfg_attr(not(feature = "rand_core"), doc = "```ignore")] /// # use curve25519::ristretto::RistrettoPoint; - /// use rand::{rngs::SysRng, TryRngCore}; /// /// # // Need fn main() here in comment so the doctest compiles /// # // See https://doc.rust-lang.org/book/documentation.html#documentation-as-tests /// # fn main() { - /// let mut rng = SysRng.unwrap_err(); + /// let mut rng = rand::rng(); /// /// let points: Vec = /// (0..32).map(|_| RistrettoPoint::random(&mut rng)).collect(); @@ -1179,7 +1178,7 @@ impl Debug for RistrettoPoint { impl group::Group for RistrettoPoint { type Scalar = Scalar; - fn try_from_rng(rng: &mut R) -> Result { + fn try_from_rng(rng: &mut R) -> Result { // NOTE: this is duplicated due to different `rng` bounds let mut uniform_bytes = [0u8; 64]; rng.try_fill_bytes(&mut uniform_bytes)?; @@ -1277,8 +1276,8 @@ mod test { use crate::edwards::CompressedEdwardsY; #[cfg(feature = "group")] use proptest::prelude::*; - #[cfg(feature = "rand_core")] - use rand::{TryRngCore, rngs::SysRng}; + #[cfg(all(feature = "rand_core", feature = "group"))] + use rand::rngs::SysRng; #[test] #[cfg(feature = "serde")] @@ -1477,7 +1476,7 @@ mod test { #[cfg(feature = "rand_core")] #[test] fn four_torsion_random() { - let mut rng = SysRng.unwrap_err(); + let mut rng = rand::rng(); let P = RistrettoPoint::mul_base(&Scalar::random(&mut rng)); let P_coset = P.coset4(); for point in P_coset { @@ -1488,11 +1487,13 @@ mod test { #[cfg(feature = "rand_core")] #[test] fn random_roundtrip() { - let mut rng = SysRng.unwrap_err(); + let mut rng = rand::rng(); for _ in 0..100 { let P = RistrettoPoint::mul_base(&Scalar::random(&mut rng)); let compressed_P = P.compress(); - let Q = compressed_P.decompress().unwrap(); + let Q = compressed_P + .decompress() + .expect("compression round-trip should decompress"); assert_eq!(P, Q); } } diff --git a/curve25519/curve25519/src/ristretto/elligator.rs b/curve25519/solana-ed25519/src/ristretto/elligator.rs similarity index 100% rename from curve25519/curve25519/src/ristretto/elligator.rs rename to curve25519/solana-ed25519/src/ristretto/elligator.rs diff --git a/curve25519/curve25519/src/scalar.rs b/curve25519/solana-ed25519/src/scalar.rs similarity index 99% rename from curve25519/curve25519/src/scalar.rs rename to curve25519/solana-ed25519/src/scalar.rs index c0c373a..50f6561 100644 --- a/curve25519/curve25519/src/scalar.rs +++ b/curve25519/solana-ed25519/src/scalar.rs @@ -126,7 +126,7 @@ use group::ff::{Field, FromUniformBytes, PrimeField}; use group::ff::{FieldBits, PrimeFieldBits}; #[cfg(feature = "group")] -use rand_core::TryRngCore; +use rand_core::TryRng; #[cfg(feature = "rand_core")] use rand_core::CryptoRng; @@ -1263,7 +1263,7 @@ impl Field for Scalar { const ZERO: Self = Self::ZERO; const ONE: Self = Self::ONE; - fn try_from_rng(rng: &mut R) -> Result { + fn try_from_rng(rng: &mut R) -> Result { // NOTE: this is duplicated due to different `rng` bounds let mut scalar_bytes = [0u8; 64]; rng.try_fill_bytes(&mut scalar_bytes)?; diff --git a/curve25519/curve25519/src/scalar/heea.rs b/curve25519/solana-ed25519/src/scalar/heea.rs similarity index 99% rename from curve25519/curve25519/src/scalar/heea.rs rename to curve25519/solana-ed25519/src/scalar/heea.rs index 2f39a2d..d40c416 100644 --- a/curve25519/curve25519/src/scalar/heea.rs +++ b/curve25519/solana-ed25519/src/scalar/heea.rs @@ -423,7 +423,7 @@ mod tests { use crate::{Scalar, digest::Update, traits::HEEADecomposition}; #[cfg(feature = "rand_core")] - use rand::RngCore; + use rand_core::Rng; #[test] #[cfg(all(feature = "rand_core", feature = "digest"))] diff --git a/curve25519/curve25519/src/short_weierstrass.rs b/curve25519/solana-ed25519/src/short_weierstrass.rs similarity index 100% rename from curve25519/curve25519/src/short_weierstrass.rs rename to curve25519/solana-ed25519/src/short_weierstrass.rs diff --git a/curve25519/curve25519/src/traits.rs b/curve25519/solana-ed25519/src/traits.rs similarity index 100% rename from curve25519/curve25519/src/traits.rs rename to curve25519/solana-ed25519/src/traits.rs diff --git a/curve25519/curve25519/src/window.rs b/curve25519/solana-ed25519/src/window.rs similarity index 100% rename from curve25519/curve25519/src/window.rs rename to curve25519/solana-ed25519/src/window.rs diff --git a/curve25519/curve25519/tests/build_tests.sh b/curve25519/solana-ed25519/tests/build_tests.sh similarity index 100% rename from curve25519/curve25519/tests/build_tests.sh rename to curve25519/solana-ed25519/tests/build_tests.sh diff --git a/curve25519/curve25519/vendor/ristretto.sage b/curve25519/solana-ed25519/vendor/ristretto.sage similarity index 100% rename from curve25519/curve25519/vendor/ristretto.sage rename to curve25519/solana-ed25519/vendor/ristretto.sage