diff --git a/indy-data-types/Cargo.toml b/indy-data-types/Cargo.toml index 77c2319..2bdb1a0 100644 --- a/indy-data-types/Cargo.toml +++ b/indy-data-types/Cargo.toml @@ -20,7 +20,7 @@ default = ["anoncreds", "merkle_tree"] anoncreds = ["serde_support"] cl = ["anoncreds", "anoncreds-clsignatures", "serde_support"] cl_native = ["anoncreds", "anoncreds-clsignatures/openssl_bn", "serde_support"] -merkle_tree = ["indy-utils/hash", "hex"] +merkle_tree = ["hex", "sha2"] rich_schema = [] serde_support = [ "serde", @@ -37,8 +37,10 @@ once_cell = "1" regex = "1" serde = { version = "1.0", optional = true, features = ["derive"] } serde_json = { version = "1.0", optional = true, features = ["raw_value"] } +sha2 = { version = "0.10", optional = true } zeroize = { version = "1", features = ["zeroize_derive"] } rmp-serde = "1.0" + [dependencies.indy-utils] version = "0.6" path = "../indy-utils" diff --git a/indy-utils/src/hash.rs b/indy-data-types/src/merkle_tree/hash.rs similarity index 97% rename from indy-utils/src/hash.rs rename to indy-data-types/src/merkle_tree/hash.rs index e162a41..3e18e8c 100644 --- a/indy-utils/src/hash.rs +++ b/indy-data-types/src/merkle_tree/hash.rs @@ -1,13 +1,13 @@ pub use sha2::Digest; -use super::ValidationError; +use crate::ValidationError; /// Derive a new hash type #[macro_export] macro_rules! hash_type { ($modname:ident, $digest:path, $doc:expr) => { #[doc=$doc] - #[allow(non_snake_case)] + #[allow(non_snake_case, unused)] pub mod $modname { use once_cell::sync::Lazy; use sha2::Digest; diff --git a/indy-data-types/src/merkle_tree/merkletree.rs b/indy-data-types/src/merkle_tree/merkletree.rs index da89d4b..d6ebc47 100644 --- a/indy-data-types/src/merkle_tree/merkletree.rs +++ b/indy-data-types/src/merkle_tree/merkletree.rs @@ -1,8 +1,7 @@ -use indy_utils::hash::{ +use super::hash::{ TreeHash, SHA256::{digest_empty, DigestType as Hash}, }; - use super::proof::{Lemma, Proof}; use super::tree::{LeavesIntoIterator, LeavesIterator, Tree, TreeLeafData}; use crate::ValidationError; diff --git a/indy-data-types/src/merkle_tree/mod.rs b/indy-data-types/src/merkle_tree/mod.rs index 2126d6f..b2669a1 100644 --- a/indy-data-types/src/merkle_tree/mod.rs +++ b/indy-data-types/src/merkle_tree/mod.rs @@ -1,11 +1,11 @@ -use indy_utils::hash::{TreeHash, SHA256::DigestType as Hash}; - +use self::hash::{TreeHash, SHA256::DigestType as Hash}; use self::tree::{Tree, TreeLeafData}; use crate::ValidationError; pub use self::merkletree::MerkleTree; pub use self::proof::Positioned; +mod hash; mod merkletree; mod proof; mod tree; diff --git a/indy-data-types/src/merkle_tree/proof.rs b/indy-data-types/src/merkle_tree/proof.rs index 84afa3a..f2c38a5 100644 --- a/indy-data-types/src/merkle_tree/proof.rs +++ b/indy-data-types/src/merkle_tree/proof.rs @@ -1,5 +1,4 @@ -use indy_utils::hash::{TreeHash, SHA256::DigestType as Hash}; - +use super::hash::{TreeHash, SHA256::DigestType as Hash}; use super::tree::{Tree, TreeLeafData}; use crate::ValidationError; diff --git a/indy-data-types/src/merkle_tree/tree.rs b/indy-data-types/src/merkle_tree/tree.rs index 551aa7d..2cb46bf 100644 --- a/indy-data-types/src/merkle_tree/tree.rs +++ b/indy-data-types/src/merkle_tree/tree.rs @@ -1,7 +1,6 @@ use std::cmp; -use indy_utils::hash::{TreeHash, SHA256::DigestType as Hash}; - +use super::hash::{TreeHash, SHA256::DigestType as Hash}; use crate::ValidationError; pub type TreeLeafData = Vec; diff --git a/indy-utils/Cargo.toml b/indy-utils/Cargo.toml index 275b31c..6bf2a70 100644 --- a/indy-utils/Cargo.toml +++ b/indy-utils/Cargo.toml @@ -16,9 +16,8 @@ path = "src/lib.rs" crate-type = ["rlib"] [features] -default = ["ed25519", "hash"] +default = ["ed25519"] ed25519 = ["curve25519-dalek", "ed25519-dalek", "rand", "sha2", "x25519-dalek"] -hash = ["sha2"] [dependencies] bs58 = "0.5" diff --git a/indy-utils/src/lib.rs b/indy-utils/src/lib.rs index 8b92c9c..aed6b2b 100644 --- a/indy-utils/src/lib.rs +++ b/indy-utils/src/lib.rs @@ -27,7 +27,3 @@ pub mod did; /// Indy signing keys and verification keys pub mod keys; - -/// Hash algorithms -#[cfg(feature = "hash")] -pub mod hash;