diff --git a/crypto/dkg/Cargo.toml b/crypto/dkg/Cargo.toml index d5abfa15..cf3af60c 100644 --- a/crypto/dkg/Cargo.toml +++ b/crypto/dkg/Cargo.toml @@ -36,13 +36,26 @@ multiexp = { path = "../multiexp", version = "0.4", default-features = false } schnorr = { package = "schnorr-signatures", path = "../schnorr", version = "^0.5.1", default-features = false } dleq = { path = "../dleq", version = "^0.4.1", default-features = false } +# eVRF DKG dependencies +subtle = { version = "2", default-features = false, features = ["std"], optional = true } +generic-array = { version = "1", default-features = false, features = ["alloc"], optional = true } +rand_chacha = { version = "0.3", default-features = false, features = ["std"], optional = true } +blake2 = { version = "0.10", default-features = false, features = ["std"], optional = true } generalized-bulletproofs = { path = "../evrf/generalized-bulletproofs", default-features = false, optional = true } ec-divisors = { path = "../evrf/divisors", default-features = false, optional = true } -evrf = { path = "../evrf", default-features = false, optional = true } +generalized-bulletproofs-circuit-abstraction = { path = "./circuit-abstraction", optional = true } +generalized-bulletproofs-ec-gadgets = { path = "./ec-gadgets", optional = true } [dev-dependencies] rand_core = { version = "0.6", default-features = false, features = ["getrandom"] } ciphersuite = { path = "../ciphersuite", default-features = false, features = ["ristretto"] } +generalized-bulletproofs = { path = "./generalized-bulletproofs", features = ["tests"] } +ec-divisors = { path = "./divisors", features = ["pasta"] } +pasta_curves = "0.5" + +[dependencies] +generalized-bulletproofs-circuit-abstraction = { path = "./circuit-abstraction" } +generalized-bulletproofs-ec-gadgets = { path = "./ec-gadgets" } [features] std = [ @@ -66,6 +79,6 @@ std = [ "dleq/serialize" ] borsh = ["dep:borsh"] -evrf = ["std", "dep:ec-divisors", "dep:generalized-bulletproofs", "dep:evrf"] +evrf = ["std", "dep:subtle", "dep:generic-array", "dep:rand_chacha", "dep:blake2", "dep:ec-divisors", "dep:generalized-bulletproofs", "dep:evrf"] tests = ["rand_core/getrandom"] default = ["std"] diff --git a/crypto/dkg/src/evrf.rs b/crypto/dkg/src/evrf/mod.rs similarity index 100% rename from crypto/dkg/src/evrf.rs rename to crypto/dkg/src/evrf/mod.rs diff --git a/crypto/evrf/src/lib.rs b/crypto/dkg/src/evrf/proof.rs similarity index 100% rename from crypto/evrf/src/lib.rs rename to crypto/dkg/src/evrf/proof.rs diff --git a/crypto/evrf/src/tests.rs b/crypto/dkg/src/tests/evrf/proof.rs similarity index 100% rename from crypto/evrf/src/tests.rs rename to crypto/dkg/src/tests/evrf/proof.rs diff --git a/crypto/evrf/Cargo.toml b/crypto/evrf/Cargo.toml deleted file mode 100644 index 88e914a3..00000000 --- a/crypto/evrf/Cargo.toml +++ /dev/null @@ -1,35 +0,0 @@ -[package] -name = "evrf" -version = "0.1.0" -description = "Implementation of an eVRF premised on Generalized Bulletproofs" -license = "MIT" -repository = "https://github.com/serai-dex/serai/tree/develop/crypto/evrf" -authors = ["Luke Parker "] -keywords = ["ciphersuite", "ff", "group"] -edition = "2021" - -[package.metadata.docs.rs] -all-features = true -rustdoc-args = ["--cfg", "docsrs"] - -[dependencies] -subtle = { version = "2", default-features = false, features = ["std"] } -zeroize = { version = "^1.5", default-features = false, features = ["zeroize_derive"] } - -rand_core = { version = "0.6", default-features = false, features = ["std"] } -rand_chacha = { version = "0.3", default-features = false, features = ["std"] } - -generic-array = { version = "1", default-features = false, features = ["alloc"] } - -blake2 = { version = "0.10", default-features = false, features = ["std"] } -ciphersuite = { path = "../ciphersuite", version = "0.4", default-features = false, features = ["std"] } - -ec-divisors = { path = "./divisors" } -generalized-bulletproofs = { path = "./generalized-bulletproofs" } -generalized-bulletproofs-circuit-abstraction = { path = "./circuit-abstraction" } -generalized-bulletproofs-ec-gadgets = { path = "./ec-gadgets" } - -[dev-dependencies] -generalized-bulletproofs = { path = "./generalized-bulletproofs", features = ["tests"] } -ec-divisors = { path = "./divisors", features = ["pasta"] } -pasta_curves = "0.5" diff --git a/crypto/evrf/LICENSE b/crypto/evrf/LICENSE deleted file mode 100644 index 659881f1..00000000 --- a/crypto/evrf/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2024 Luke Parker - -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/crypto/evrf/README.md b/crypto/evrf/README.md deleted file mode 100644 index a03320e9..00000000 --- a/crypto/evrf/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# eVRF - -An implementation of an [eVRF](https://eprint.iacr.org/2024/397.pdf) premised on -[Generalized Bulletproofs](https://repo.getmonero.org/monero-project/ccs-proposals/uploads/a9baa50c38c6312efc0fea5c6a188bb9/gbp.pdf). diff --git a/crypto/evrf/embedwards25519/src/point.rs b/crypto/evrf/embedwards25519/src/point.rs index 2cbeff31..b762ff5d 100644 --- a/crypto/evrf/embedwards25519/src/point.rs +++ b/crypto/evrf/embedwards25519/src/point.rs @@ -18,7 +18,10 @@ use crate::{backend::u8_from_bool, Scalar, FieldElement}; #[allow(non_snake_case)] fn B() -> FieldElement { - FieldElement::from_repr(hex_literal::hex!("5f07603a853f20370b682036210d463e64903a23ea669d07ca26cfc13f594209")).unwrap() + FieldElement::from_repr(hex_literal::hex!( + "5f07603a853f20370b682036210d463e64903a23ea669d07ca26cfc13f594209" + )) + .unwrap() } fn recover_y(x: FieldElement) -> CtOption { @@ -196,13 +199,13 @@ impl Group for Point { } fn generator() -> Self { Point { - x: FieldElement::from_repr( - hex_literal::hex!("0100000000000000000000000000000000000000000000000000000000000000") - ) + x: FieldElement::from_repr(hex_literal::hex!( + "0100000000000000000000000000000000000000000000000000000000000000" + )) .unwrap(), - y: FieldElement::from_repr( - hex_literal::hex!("2e4118080a484a3dfbafe2199a0e36b7193581d676c0dadfa376b0265616020c") - ) + y: FieldElement::from_repr(hex_literal::hex!( + "2e4118080a484a3dfbafe2199a0e36b7193581d676c0dadfa376b0265616020c" + )) .unwrap(), z: FieldElement::ONE, } @@ -336,11 +339,11 @@ impl GroupEncoding for Point { let point = y.map(|y| Point { x, y, z: FieldElement::ONE }); let not_negative_zero = !(is_identity & sign); - // Only return the point if it isn't -0 and the sign byte wasn't malleated + // Only return the point if it isn't -0 CtOption::conditional_select( &CtOption::new(Point::identity(), 0.into()), &point, - not_negative_zero & ((bytes[0] & 1).ct_eq(&bytes[0])), + not_negative_zero, ) }) }