hotshot_types/vid/
avidm_gf2.rs

1// Copyright (c) 2021-2024 Espresso Systems (espressosys.com)
2// This file is part of the HotShot repository.
3
4// You should have received a copy of the MIT License
5// along with the HotShot repository. If not, see <https://mit-license.org/>.
6
7//! Provides the implementation for AVID-M scheme over GF2 field.
8
9use hotshot_utils::anytrace::*;
10
11pub type AvidmGf2Scheme = vid::avidm_gf2::namespaced::NsAvidmGf2Scheme;
12pub type AvidmGf2Param = vid::avidm_gf2::namespaced::NsAvidmGf2Param;
13pub type AvidmGf2Commitment = vid::avidm_gf2::namespaced::NsAvidmGf2Commit;
14pub type AvidmGf2Share = vid::avidm_gf2::namespaced::NsAvidmGf2Share;
15pub type AvidmGf2Common = vid::avidm_gf2::namespaced::NsAvidmGf2Common;
16
17pub fn init_avidm_gf2_param(total_weight: usize) -> Result<AvidmGf2Param> {
18    let recovery_threshold = total_weight.div_ceil(3);
19    AvidmGf2Param::new(recovery_threshold, total_weight)
20        .map_err(|err| error!("Failed to initialize VID: {}", err.to_string()))
21}