Skip to content

Commit

Permalink
Bump blake2 from 0.9.2 to 0.10.4 (#54)
Browse files Browse the repository at this point in the history
* Bump blake2 from 0.9.2 to 0.10.4

Bumps [blake2](https://github.com/RustCrypto/hashes) from 0.9.2 to 0.10.4.
- [Release notes](https://github.com/RustCrypto/hashes/releases)
- [Commits](RustCrypto/hashes@blake2-v0.9.2...blake2-v0.10.4)

---
updated-dependencies:
- dependency-name: blake2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Squashed commit of the following:

commit 6c679f7
Author: Jonas Lindstrøm <jonas-lj@users.noreply.github.com>
Date:   Fri Sep 23 20:43:55 2022 +0200

    Include hash functions (SHA-2, SHA-3, Keccak and SHAKE2) (#63)

commit 4b7a06f
Merge: 49b6cf7 aa215c8
Author: Joy Wang <108701016+joyqvq@users.noreply.github.com>
Date:   Mon Sep 19 16:30:18 2022 -0400

    Merge pull request #52 from MystenLabs/ci1

    Fix publish.yml

commit aa215c8
Author: Joy Wang <108701016+joyqvq@users.noreply.github.com>
Date:   Mon Sep 19 16:17:53 2022 -0400

    remove public-api from workflow

commit 5550248
Author: Joy Wang <108701016+joyqvq@users.noreply.github.com>
Date:   Sun Sep 18 20:03:41 2022 -0400

    ci fix

commit 49b6cf7
Author: benr-ml <112846738+benr-ml@users.noreply.github.com>
Date:   Mon Sep 19 21:09:14 2022 +0300

    update public-api (#59)

commit 8cec139
Author: benr-ml <112846738+benr-ml@users.noreply.github.com>
Date:   Mon Sep 19 19:49:47 2022 +0300

    Add basic HMAC and HKDF functions (#38)

* Update usage of blake2b crate to new version

* Fix fmt

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jonas Lindstrøm <jonas-lj@users.noreply.github.com>
  • Loading branch information
dependabot[bot] and jonas-lj committed Sep 26, 2022
1 parent 74d8e28 commit 2623149
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 51 deletions.
18 changes: 3 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ ark-ec = { version = "0.3.0", features = ["std"], optional = true }
ark-ff = { version = "0.3.0", features = ["std"], optional = true }
ark-serialize = { version = "0.3.0", features = ["std"], optional = true }
ark-std = { version = "0.3.0", features = ["std"], optional = true }
blake2 = "0.9"
blake2 = "0.10"
blst = "0.3.10"
digest = "0.10.5"
once_cell = "1.15.0"
Expand Down
37 changes: 2 additions & 35 deletions src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@
// SPDX-License-Identifier: Apache-2.0

use base64ct::{Base64, Encoding};
use blake2::{
digest::{Update, VariableOutput},
VarBlake2b,
};
use digest::OutputSizeUser;
use generic_array::{ArrayLength, GenericArray};
use serde::{Deserialize, Serialize};
use std::{fmt, marker::PhantomData};
use std::fmt;

/// Represents a hash digest of `DigestLength` bytes.
#[derive(Hash, PartialEq, Eq, Clone, Deserialize, Serialize, Ord, PartialOrd)]
Expand Down Expand Up @@ -112,33 +108,4 @@ pub type Sha3_256 = HashFunctionWrapper<sha3::Sha3_256>;
pub type Keccak256 = HashFunctionWrapper<sha3::Keccak256>;

// BLAKE2
pub struct Blake2b<DigestLength: ArrayLength<u8>> {
variant: blake2::VarBlake2b,
digest_length: PhantomData<DigestLength>,
}

impl<DigestLength: ArrayLength<u8>> OutputSizeUser for Blake2b<DigestLength> {
type OutputSize = DigestLength;
}

impl<DigestLength: ArrayLength<u8> + Sized> HashFunction<DigestLength> for Blake2b<DigestLength> {
fn update(&mut self, data: &[u8]) {
self.variant.update(data)
}

fn finalize(self) -> Digest<DigestLength> {
let mut array = GenericArray::<u8, DigestLength>::default();
self.variant
.finalize_variable(|buffer| array.copy_from_slice(buffer));
Digest(array)
}
}

impl<DigestLength: ArrayLength<u8>> Default for Blake2b<DigestLength> {
fn default() -> Self {
Self {
variant: VarBlake2b::new(DigestLength::USIZE).unwrap(),
digest_length: Default::default(),
}
}
}
pub type Blake2b<DigestLength> = HashFunctionWrapper<blake2::Blake2b<DigestLength>>;

0 comments on commit 2623149

Please sign in to comment.