Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hashes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description = "Hash functions used by the rust-dash eccosystem"
categories = ["algorithms"]
keywords = [ "crypto", "dash", "hash", "digest" ]
readme = "README.md"
edition = "2024"
edition = "2021"
exclude = ["tests", "contrib"]

[features]
Expand Down
4 changes: 2 additions & 2 deletions hashes/benches/hashes.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use criterion::{BenchmarkId, Criterion, Throughput, black_box, criterion_group, criterion_main};
use dashcore_hashes::{Hash, HashEngine, hmac, siphash24};
use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
use dashcore_hashes::{hash160, ripemd160, sha1, sha256, sha256d, sha512, sha512_256};
use dashcore_hashes::{hmac, siphash24, Hash, HashEngine};

fn bench_sha256(c: &mut Criterion) {
let mut group = c.benchmark_group("sha256");
Expand Down
8 changes: 4 additions & 4 deletions hashes/src/hash160.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use core::ops::Index;
use core::slice::SliceIndex;
use core::str;

use crate::{Error, ripemd160, sha256};
use crate::{ripemd160, sha256, Error};

crate::internal_macros::hash_type! {
160,
Expand All @@ -51,7 +51,7 @@ mod tests {
#[test]
#[cfg(feature = "alloc")]
fn test() {
use crate::{Hash, HashEngine, hash160};
use crate::{hash160, Hash, HashEngine};

#[derive(Clone)]
#[cfg(feature = "alloc")]
Expand Down Expand Up @@ -105,9 +105,9 @@ mod tests {
#[cfg(feature = "serde")]
#[test]
fn ripemd_serde() {
use serde_test::{Configure, Token, assert_tokens};
use serde_test::{assert_tokens, Configure, Token};

use crate::{Hash, hash160};
use crate::{hash160, Hash};

#[rustfmt::skip]
static HASH_BYTES: [u8; 20] = [
Expand Down
2 changes: 1 addition & 1 deletion hashes/src/hash_x11.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use core2::io;

#[cfg(all(feature = "alloc", not(feature = "std")))]
use crate::alloc::vec::Vec;
use crate::{Error, HashEngine as _, hex};
use crate::{hex, Error, HashEngine as _};

crate::internal_macros::hash_type! {
256,
Expand Down
6 changes: 3 additions & 3 deletions hashes/src/hmac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ mod tests {
#[test]
#[cfg(feature = "alloc")]
fn test() {
use crate::{Hash, HashEngine, Hmac, HmacEngine, sha256};
use crate::{sha256, Hash, HashEngine, Hmac, HmacEngine};

#[derive(Clone)]
struct Test {
Expand Down Expand Up @@ -372,9 +372,9 @@ mod tests {
#[cfg(feature = "serde")]
#[test]
fn hmac_sha512_serde() {
use serde_test::{Configure, Token, assert_tokens};
use serde_test::{assert_tokens, Configure, Token};

use crate::{Hash, Hmac, sha512};
use crate::{sha512, Hash, Hmac};

#[rustfmt::skip]
static HASH_BYTES: [u8; 64] = [
Expand Down
4 changes: 2 additions & 2 deletions hashes/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use std::io;
#[cfg(not(feature = "std"))]
use core2::io;

use crate::{HashEngine, hmac, ripemd160, sha1, sha256, sha512, siphash24};
use crate::{hmac, ripemd160, sha1, sha256, sha512, siphash24, HashEngine};

impl io::Write for sha1::HashEngine {
fn flush(&mut self) -> io::Result<()> {
Expand Down Expand Up @@ -94,7 +94,7 @@ impl<T: crate::Hash> io::Write for hmac::HmacEngine<T> {
#[cfg(test)]
mod tests {
use super::io::Write;
use crate::{Hash, hash160, hmac, ripemd160, sha1, sha256, sha256d, sha512, siphash24};
use crate::{hash160, hmac, ripemd160, sha1, sha256, sha256d, sha512, siphash24, Hash};

macro_rules! write_test {
($mod:ident, $exp_empty:expr, $exp_256:expr, $exp_64k:expr,) => {
Expand Down
2 changes: 1 addition & 1 deletion hashes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ pub trait Hash:

#[cfg(test)]
mod tests {
use crate::{Hash, sha256d};
use crate::{sha256d, Hash};

hash_newtype! {
/// A test newtype
Expand Down
6 changes: 3 additions & 3 deletions hashes/src/ripemd160.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ mod tests {
fn test() {
use std::convert::TryFrom;

use crate::{Hash, HashEngine, ripemd160};
use crate::{ripemd160, Hash, HashEngine};

#[derive(Clone)]
struct Test {
Expand Down Expand Up @@ -502,9 +502,9 @@ mod tests {
#[cfg(feature = "serde")]
#[test]
fn ripemd_serde() {
use serde_test::{Configure, Token, assert_tokens};
use serde_test::{assert_tokens, Configure, Token};

use crate::{Hash, ripemd160};
use crate::{ripemd160, Hash};

#[rustfmt::skip]
static HASH_BYTES: [u8; 20] = [
Expand Down
2 changes: 1 addition & 1 deletion hashes/src/serde_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub mod serde_details {

use crate::Error;
struct HexVisitor<ValueT>(PhantomData<ValueT>);
use serde::{Deserializer, Serializer, de};
use serde::{de, Deserializer, Serializer};

impl<'de, ValueT> de::Visitor<'de> for HexVisitor<ValueT>
where
Expand Down
6 changes: 3 additions & 3 deletions hashes/src/sha1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ mod tests {
#[test]
#[cfg(feature = "alloc")]
fn test() {
use crate::{Hash, HashEngine, sha1};
use crate::{sha1, Hash, HashEngine};

#[derive(Clone)]
struct Test {
Expand Down Expand Up @@ -214,9 +214,9 @@ mod tests {
#[cfg(feature = "serde")]
#[test]
fn sha1_serde() {
use serde_test::{Configure, Token, assert_tokens};
use serde_test::{assert_tokens, Configure, Token};

use crate::{Hash, sha1};
use crate::{sha1, Hash};

#[rustfmt::skip]
static HASH_BYTES: [u8; 20] = [
Expand Down
6 changes: 3 additions & 3 deletions hashes/src/sha256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use core::ops::Index;
use core::slice::SliceIndex;
use core::{cmp, str};

use crate::{Error, HashEngine as _, hex, sha256d};
use crate::{hex, sha256d, Error, HashEngine as _};

crate::internal_macros::hash_type! {
256,
Expand Down Expand Up @@ -517,7 +517,7 @@ impl HashEngine {

#[cfg(test)]
mod tests {
use crate::{Hash, HashEngine, sha256};
use crate::{sha256, Hash, HashEngine};

#[test]
#[cfg(feature = "alloc")]
Expand Down Expand Up @@ -694,7 +694,7 @@ mod tests {
#[cfg(feature = "serde")]
#[test]
fn sha256_serde() {
use serde_test::{Configure, Token, assert_tokens};
use serde_test::{assert_tokens, Configure, Token};

#[rustfmt::skip]
static HASH_BYTES: [u8; 32] = [
Expand Down
8 changes: 4 additions & 4 deletions hashes/src/sha256d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use core::ops::Index;
use core::slice::SliceIndex;
use core::str;

use crate::{Error, sha256};
use crate::{sha256, Error};

crate::internal_macros::hash_type! {
256,
Expand All @@ -46,7 +46,7 @@ mod tests {
#[test]
#[cfg(feature = "alloc")]
fn test() {
use crate::{Hash, HashEngine, sha256, sha256d};
use crate::{sha256, sha256d, Hash, HashEngine};

#[derive(Clone)]
struct Test {
Expand Down Expand Up @@ -97,9 +97,9 @@ mod tests {
#[cfg(feature = "serde")]
#[test]
fn sha256_serde() {
use serde_test::{Configure, Token, assert_tokens};
use serde_test::{assert_tokens, Configure, Token};

use crate::{Hash, sha256d};
use crate::{sha256d, Hash};

#[rustfmt::skip]
static HASH_BYTES: [u8; 32] = [
Expand Down
2 changes: 1 addition & 1 deletion hashes/src/sha256t.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use core::ops::Index;
use core::slice::SliceIndex;
use core::{cmp, str};

use crate::{Error, sha256};
use crate::{sha256, Error};

type HashEngine = sha256::HashEngine;

Expand Down
6 changes: 3 additions & 3 deletions hashes/src/sha512.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ mod tests {
#[test]
#[cfg(feature = "alloc")]
fn test() {
use crate::{Hash, HashEngine, sha512};
use crate::{sha512, Hash, HashEngine};

#[derive(Clone)]
struct Test {
Expand Down Expand Up @@ -350,9 +350,9 @@ mod tests {
#[cfg(feature = "serde")]
#[test]
fn sha512_serde() {
use serde_test::{Configure, Token, assert_tokens};
use serde_test::{assert_tokens, Configure, Token};

use crate::{Hash, sha512};
use crate::{sha512, Hash};

#[rustfmt::skip]
static HASH_BYTES: [u8; 64] = [
Expand Down
4 changes: 2 additions & 2 deletions hashes/src/sha512_256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use core::slice::SliceIndex;
use core::str;

use crate::sha512::BLOCK_SIZE;
use crate::{Error, sha512};
use crate::{sha512, Error};

/// Engine to compute SHA512/256 hash function.
///
Expand Down Expand Up @@ -90,7 +90,7 @@ mod tests {
#[test]
#[cfg(feature = "alloc")]
fn test() {
use crate::{Hash, HashEngine, sha512_256};
use crate::{sha512_256, Hash, HashEngine};

#[derive(Clone)]
struct Test {
Expand Down
4 changes: 3 additions & 1 deletion hashes/src/siphash24.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ fn from_engine(e: HashEngine) -> Hash {
}

macro_rules! compress {
($state:expr) => {{ compress!($state.v0, $state.v1, $state.v2, $state.v3) }};
($state:expr) => {{
compress!($state.v0, $state.v1, $state.v2, $state.v3)
}};
($v0:expr, $v1:expr, $v2:expr, $v3:expr) => {{
$v0 = $v0.wrapping_add($v1);
$v1 = $v1.rotate_left(13);
Expand Down
6 changes: 3 additions & 3 deletions hashes/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -583,9 +583,9 @@ macro_rules! hash_newtype_known_attrs {

#[cfg(feature = "schemars")]
pub mod json_hex_string {
use schemars::JsonSchema;
use schemars::r#gen::SchemaGenerator;
use schemars::gen::SchemaGenerator;
use schemars::schema::{Schema, SchemaObject};
use schemars::JsonSchema;
macro_rules! define_custom_hex {
($name:ident, $len:expr) => {
pub fn $name(generator: &mut SchemaGenerator) -> Schema {
Expand All @@ -607,7 +607,7 @@ pub mod json_hex_string {

#[cfg(test)]
mod test {
use crate::{Hash, sha256};
use crate::{sha256, Hash};

#[test]
fn hash_as_ref_array() {
Expand Down
Loading