Skip to content

Commit

Permalink
Remove blake2b hashing which was moved to builtin-actors (filecoin-pr…
Browse files Browse the repository at this point in the history
  • Loading branch information
geoff-vball authored Aug 29, 2022
1 parent 7a9fad1 commit d19230e
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 25 deletions.
16 changes: 0 additions & 16 deletions ipld/encoding/src/cbor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
use std::ops::Deref;
use std::rc::Rc;

use cid::{multihash, Cid};
use serde::{Deserialize, Serialize};

use super::errors::Error;
Expand All @@ -23,21 +22,6 @@ pub trait Cbor: ser::Serialize + de::DeserializeOwned {
fn unmarshal_cbor(bz: &[u8]) -> Result<Self, Error> {
from_slice(bz)
}

/// Returns the content identifier of the raw block of data
/// Default is Blake2b256 hash
fn cid(&self) -> Result<Cid, Error> {
use multihash::MultihashDigest;
const DIGEST_SIZE: u32 = 32; // TODO get from the multihash?
let data = &self.marshal_cbor()?;
let hash = multihash::Code::Blake2b256.digest(data);
debug_assert_eq!(
u32::from(hash.size()),
DIGEST_SIZE,
"expected 32byte digest"
);
Ok(Cid::new_v1(DAG_CBOR, hash))
}
}

impl<T> Cbor for Vec<T> where T: Cbor {}
Expand Down
4 changes: 2 additions & 2 deletions shared/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ data-encoding-macro = "0.1.12"
lazy_static = "1.4.0"
log = "0.4.8"
cid = { version = "0.8.5", default-features = false, features = ["serde-codec", "std"] }
multihash = { version = "0.16.3", default-features = false, features = ["blake2b", "multihash-impl", "sha2", "sha3", "ripemd"] }
multihash = { version = "0.16.3", default-features = false, features = ["multihash-impl", "sha2", "sha3", "ripemd"] }
unsigned-varint = "0.7.1"
anyhow = "1.0.51"
fvm_ipld_blockstore = { version = "0.1", path = "../ipld/blockstore" }
Expand All @@ -42,7 +42,7 @@ byteorder = "1.4.3"
rand = "0.8"
rand_chacha = "0.3"
serde_json = "1.0.56"
multihash = { version = "0.16.3", default-features = false, features = ["blake2b", "multihash-impl", "sha2", "sha3", "ripemd"] }
multihash = { version = "0.16.3", default-features = false, features = ["multihash-impl", "sha2", "sha3", "ripemd"] }

[features]
default = []
Expand Down
7 changes: 0 additions & 7 deletions shared/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,6 @@ pub struct Message {
impl Cbor for Message {}

impl Message {
/// Helper function to convert the message into signing bytes.
/// This function returns the message `Cid` bytes.
pub fn to_signing_bytes(&self) -> Vec<u8> {
// Safe to unwrap here, unsigned message cannot fail to serialize.
self.cid().unwrap().to_bytes()
}

/// Does some basic checks on the Message to see if the fields are valid.
pub fn check(self: &Message) -> anyhow::Result<()> {
if self.gas_limit == 0 {
Expand Down

0 comments on commit d19230e

Please sign in to comment.