Skip to content

Commit

Permalink
move hash module to merkle tree implementation
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Whitehead <[email protected]>
  • Loading branch information
andrewwhitehead committed Aug 2, 2023
1 parent 16b0ca4 commit 1443693
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 17 deletions.
4 changes: 3 additions & 1 deletion indy-data-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
3 changes: 1 addition & 2 deletions indy-data-types/src/merkle_tree/merkletree.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 2 additions & 2 deletions indy-data-types/src/merkle_tree/mod.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
3 changes: 1 addition & 2 deletions indy-data-types/src/merkle_tree/proof.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
3 changes: 1 addition & 2 deletions indy-data-types/src/merkle_tree/tree.rs
Original file line number Diff line number Diff line change
@@ -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<u8>;
Expand Down
3 changes: 1 addition & 2 deletions indy-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 0 additions & 4 deletions indy-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,3 @@ pub mod did;

/// Indy signing keys and verification keys
pub mod keys;

/// Hash algorithms
#[cfg(feature = "hash")]
pub mod hash;

0 comments on commit 1443693

Please sign in to comment.