From d4078388ce9b9b2e609e3d15783ad403835082d5 Mon Sep 17 00:00:00 2001 From: Joe Date: Tue, 23 Jul 2024 15:45:02 -0700 Subject: [PATCH] cleanup --- Cargo.toml | 4 ++-- src/checksum.rs | 10 ---------- src/dkg/error.rs | 5 +---- src/dkg/group_key.rs | 3 +-- src/dkg/round1.rs | 1 - src/lib.rs | 1 - src/multienc.rs | 4 ++-- src/serde.rs | 1 - 8 files changed, 6 insertions(+), 23 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 16b0cc8..91717a9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ ed25519-dalek = { version = "2.1.0", features = ["rand_core"] } rand_chacha = { version = "0.3.1", optional = true } rand_core = "0.6.4" reddsa = { git = "https://github.com/ZcashFoundation/reddsa.git", rev = "311baf8865f6e21527d1f20750d8f2cf5c9e531a", features = ["frost", "frost-rerandomized"] } -siphasher = { version = "1.0.0", optional = true } +siphasher = { version = "1.0.0", features =["serde_no_std"] } x25519-dalek = { version = "2.0.0", features = ["reusable_secrets", "static_secrets"] } [dev-dependencies] @@ -27,5 +27,5 @@ rand = "0.8.5" default = ["dkg"] std = [] -signing = ["dep:blake3", "dep:rand_chacha", "dep:siphasher", "std"] +signing = ["dep:blake3", "dep:rand_chacha", "std"] dkg = [] diff --git a/src/checksum.rs b/src/checksum.rs index 29e1f73..ad43868 100644 --- a/src/checksum.rs +++ b/src/checksum.rs @@ -4,23 +4,13 @@ use core::fmt; -#[cfg(feature = "std")] use siphasher::sip::SipHasher24; -#[cfg(feature = "std")] pub(crate) type ChecksumHasher = SipHasher24; -#[cfg(not(feature = "std"))] -use core::hash::SipHasher; -#[cfg(not(feature = "std"))] -pub(crate) type ChecksumHasher = SipHasher; - - pub(crate) const CHECKSUM_LEN: usize = 8; pub(crate) type Checksum = u64; - - #[derive(Clone, Debug)] pub enum ChecksumError { SigningCommitmentError, diff --git a/src/dkg/error.rs b/src/dkg/error.rs index 6576cf8..c0baf89 100644 --- a/src/dkg/error.rs +++ b/src/dkg/error.rs @@ -4,18 +4,15 @@ use crate::checksum::ChecksumError; use crate::frost; +use crate::io; use core::fmt; use core::fmt::Debug; -use crate::io; - #[cfg(not(feature = "std"))] extern crate alloc; #[cfg(not(feature = "std"))] use alloc::string::String; - - #[derive(Debug)] pub enum Error { InvalidInput(String), diff --git a/src/dkg/group_key.rs b/src/dkg/group_key.rs index 1e63952..4f86b55 100644 --- a/src/dkg/group_key.rs +++ b/src/dkg/group_key.rs @@ -2,19 +2,18 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ +use crate::io; use crate::multienc; use crate::participant::Identity; use crate::participant::Secret; use rand_core::CryptoRng; use rand_core::RngCore; -use crate::io; #[cfg(not(feature = "std"))] extern crate alloc; #[cfg(not(feature = "std"))] use alloc::vec::Vec; - pub const GROUP_SECRET_KEY_LEN: usize = 32; pub type GroupSecretKey = [u8; GROUP_SECRET_KEY_LEN]; diff --git a/src/dkg/round1.rs b/src/dkg/round1.rs index 388a560..c2f09a0 100644 --- a/src/dkg/round1.rs +++ b/src/dkg/round1.rs @@ -16,7 +16,6 @@ use crate::frost::Identifier; use crate::frost::JubjubScalarField; use crate::io; use crate::multienc; -use crate::multienc::read_encrypted_blob; use crate::participant; use crate::participant::Identity; use crate::serde::read_u16; diff --git a/src/lib.rs b/src/lib.rs index 0f32bc6..d71b0cc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -163,4 +163,3 @@ impl io::Write for Vec { Ok(()) } } - diff --git a/src/multienc.rs b/src/multienc.rs index a40c08c..387c9ef 100644 --- a/src/multienc.rs +++ b/src/multienc.rs @@ -23,9 +23,9 @@ use x25519_dalek::ReusableSecret; #[cfg(not(feature = "std"))] extern crate alloc; #[cfg(not(feature = "std"))] -use alloc::vec::Vec; -#[cfg(not(feature = "std"))] use crate::alloc::borrow::ToOwned; +#[cfg(not(feature = "std"))] +use alloc::vec::Vec; pub const HEADER_SIZE: usize = 56; pub const KEY_SIZE: usize = 32; diff --git a/src/serde.rs b/src/serde.rs index 75c15d5..326e312 100644 --- a/src/serde.rs +++ b/src/serde.rs @@ -11,7 +11,6 @@ extern crate alloc; #[cfg(not(feature = "std"))] use alloc::vec::Vec; - #[inline] #[cfg(feature = "dkg")] pub(crate) fn write_u16(mut writer: W, value: u16) -> io::Result<()> {