use crate::{
consts::INITIAL_STATE,
hashfns::{execute_from_rounds, execute_until_rounds},
structs::{PenisBlock, SecsParam, State},
Penis,
};
#[derive(Debug)]
pub struct PenisVerifier(pub SecsParam);
impl PenisVerifier {
pub fn resume_with_initial_state(&self, penis: Penis, initial_state: &State) -> State {
let mut current_state = initial_state.clone();
let n = self.0.n as usize;
for block in penis.0 {
current_state = match block {
PenisBlock::Private(priv_block) => {
execute_from_rounds(&priv_block, current_state, n)
}
PenisBlock::Public(pub_block) => {
let tmpenis = execute_until_rounds(&pub_block, ¤t_state, n);
execute_from_rounds(&tmpenis, current_state, n)
}
};
}
current_state
}
#[inline]
pub fn resume(&self, penis: Penis) -> State {
self.resume_with_initial_state(penis, &INITIAL_STATE)
}
}