use std::collections::HashMap;
use crate::Ed448Shake256;
use crate::{frost, Ciphersuite, CryptoRng, Identifier, RngCore, Scalar};
use super::{SecretShare, VerifiableSecretSharingCommitment};
pub fn repair_share_step_1<C: Ciphersuite, R: RngCore + CryptoRng>(
helpers: &[Identifier],
share_i: &SecretShare,
rng: &mut R,
participant: Identifier,
) -> HashMap<Identifier, Scalar> {
frost::keys::repairable::repair_share_step_1(helpers, share_i, rng, participant)
}
pub fn repair_share_step_2(deltas_j: &[Scalar]) -> Scalar {
frost::keys::repairable::repair_share_step_2::<Ed448Shake256>(deltas_j)
}
pub fn repair_share_step_3(
sigmas: &[Scalar],
identifier: Identifier,
commitment: &VerifiableSecretSharingCommitment,
) -> SecretShare {
frost::keys::repairable::repair_share_step_3(sigmas, identifier, commitment)
}
#[cfg(test)]
mod tests {
use lazy_static::lazy_static;
use rand::thread_rng;
use serde_json::Value;
use crate::Ed448Shake256;
lazy_static! {
pub static ref REPAIR_SHARE: Value =
serde_json::from_str(include_str!("../../tests/helpers/repair-share.json").trim())
.unwrap();
}
#[test]
fn check_repair_share_step_1() {
let rng = thread_rng();
frost_core::tests::repairable::check_repair_share_step_1::<Ed448Shake256, _>(rng);
}
#[test]
fn check_repair_share_step_2() {
frost_core::tests::repairable::check_repair_share_step_2::<Ed448Shake256>(&REPAIR_SHARE);
}
#[test]
fn check_repair_share_step_3() {
let rng = thread_rng();
frost_core::tests::repairable::check_repair_share_step_3::<Ed448Shake256, _>(
rng,
&REPAIR_SHARE,
);
}
}