bee-crypto 0.3.0

Cryptographic primitives of the IOTA protocol
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// Copyright 2020-2021 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

#![allow(deprecated)]

use bee_crypto::ternary::{Hash, HASH_LENGTH};
use bee_ternary::Btrit;

#[test]
fn hash_weight() {
    for i in 0..20 {
        let mut hash = Hash::zeros();
        hash.as_trits_mut().set(HASH_LENGTH - i - 1, Btrit::PlusOne);
        assert_eq!(hash.weight(), i as u8);
    }
}