forest_cid/mh_code.rs
1// Copyright 2020 ChainSafe Systems
2// SPDX-License-Identifier: Apache-2.0, MIT
3
4use multihash::{derive::Multihash, U32};
5
6/// Multihash code for Poseidon BLS replica commitments.
7pub const POSEIDON_BLS12_381_A1_FC1: u64 = 0xb401;
8
9/// Multihash code for Sha2 256 trunc254 padded used in data commitments.
10pub const SHA2_256_TRUNC254_PADDED: u64 = 0x1012;
11
12/// Multihash generation codes for the Filecoin protocol. This is not an exhausting list of
13/// codes used, just the ones used to generate multihashes.
14#[derive(Clone, Copy, Debug, Eq, Multihash, PartialEq)]
15#[mh(alloc_size = U32)]
16pub enum Code {
17 /// BLAKE2b-256 (32-byte hash size)
18 #[mh(code = 0xb220, hasher = multihash::Blake2b256, digest = multihash::Blake2bDigest<U32>)]
19 Blake2b256,
20
21 /// Identity multihash (max 32 bytes)
22 #[mh(code = 0x00, hasher = multihash::IdentityHasher::<U32>, digest = multihash::IdentityDigest<U32>)]
23 Identity,
24}