From 0b2aacb23766f8495e558398710bdf4f4739b8fe Mon Sep 17 00:00:00 2001 From: Raphael Toledo Date: Fri, 13 Dec 2024 12:59:36 +0000 Subject: [PATCH] Src/Moving Hash type to crate::utils --- src/centralized_telescope/algorithm.rs | 7 ++++--- src/centralized_telescope/mod.rs | 2 -- src/centralized_telescope/round.rs | 7 ++++--- src/centralized_telescope/types.rs | 7 ------- src/simple_lottery/algorithm.rs | 7 ++++--- src/simple_lottery/mod.rs | 2 -- src/simple_lottery/types.rs | 7 ------- src/utils/types.rs | 7 +++++++ 8 files changed, 19 insertions(+), 27 deletions(-) delete mode 100644 src/centralized_telescope/types.rs delete mode 100644 src/simple_lottery/types.rs diff --git a/src/centralized_telescope/algorithm.rs b/src/centralized_telescope/algorithm.rs index 499d8e83..65275c37 100644 --- a/src/centralized_telescope/algorithm.rs +++ b/src/centralized_telescope/algorithm.rs @@ -3,9 +3,10 @@ use super::proof::Proof; use super::round::Round; use super::setup::Setup; -use super::types::Hash; -use crate::utils::sample; -use crate::utils::types::Element; +use crate::utils::{ + sample, + types::{Element, Hash}, +}; use blake2::{Blake2s256, Digest}; /// Alba's proving algorithm, based on a depth-first search algorithm. diff --git a/src/centralized_telescope/mod.rs b/src/centralized_telescope/mod.rs index 0529ee58..8166a8cf 100644 --- a/src/centralized_telescope/mod.rs +++ b/src/centralized_telescope/mod.rs @@ -15,8 +15,6 @@ mod round; pub mod setup; -mod types; - mod wrapper; // Re-exports diff --git a/src/centralized_telescope/round.rs b/src/centralized_telescope/round.rs index 4b3a59bc..ac7e4755 100644 --- a/src/centralized_telescope/round.rs +++ b/src/centralized_telescope/round.rs @@ -2,9 +2,10 @@ #![doc = include_str!("../../docs/rustdoc/centralized_telescope/round.md")] -use super::types::Hash; -use crate::utils::sample; -use crate::utils::types::Element; +use crate::utils::{ + sample, + types::{Element, Hash}, +}; use blake2::{Blake2s256, Digest}; /// Round parameters diff --git a/src/centralized_telescope/types.rs b/src/centralized_telescope/types.rs deleted file mode 100644 index 47b1b5f3..00000000 --- a/src/centralized_telescope/types.rs +++ /dev/null @@ -1,7 +0,0 @@ -//! Types specific to centralized_telescope - -/// Digest size for internal hashes -pub(super) const DIGEST_SIZE: usize = 32; - -/// Hash type for internal hashes -pub(super) type Hash = [u8; DIGEST_SIZE]; diff --git a/src/simple_lottery/algorithm.rs b/src/simple_lottery/algorithm.rs index cbe5c95f..ff1d44e2 100644 --- a/src/simple_lottery/algorithm.rs +++ b/src/simple_lottery/algorithm.rs @@ -2,9 +2,10 @@ use super::proof::Proof; use super::setup::Setup; -use super::types::Hash; -use crate::utils::sample; -use crate::utils::types::Element; +use crate::utils::{ + sample, + types::{Element, Hash}, +}; use blake2::{Blake2s256, Digest}; pub(super) fn prove(setup: &Setup, prover_set: &[Element]) -> Option { diff --git a/src/simple_lottery/mod.rs b/src/simple_lottery/mod.rs index 25d1c635..7598d86f 100644 --- a/src/simple_lottery/mod.rs +++ b/src/simple_lottery/mod.rs @@ -9,8 +9,6 @@ pub mod setup; pub mod proof; -mod types; - mod algorithm; mod wrapper; diff --git a/src/simple_lottery/types.rs b/src/simple_lottery/types.rs deleted file mode 100644 index cafcdac7..00000000 --- a/src/simple_lottery/types.rs +++ /dev/null @@ -1,7 +0,0 @@ -//! Types specific to simple lottery - -/// Digest size for internal hashes -pub(super) const DIGEST_SIZE: usize = 32; - -/// Hash type for internal hashes -pub(super) type Hash = [u8; DIGEST_SIZE]; diff --git a/src/utils/types.rs b/src/utils/types.rs index f99ff5cd..c7abde99 100644 --- a/src/utils/types.rs +++ b/src/utils/types.rs @@ -1,3 +1,10 @@ pub(crate) const DATA_LENGTH: usize = 32; +/// Type of dataset's elements to lower bound pub(crate) type Element = [u8; DATA_LENGTH]; + +/// Digest size for internal hashes +pub(crate) const DIGEST_SIZE: usize = 32; + +/// Hash type for internal hashes +pub(crate) type Hash = [u8; DIGEST_SIZE];