pub fn from_key<P: AsRef<Path>>(path: P, verify: bool) -> Result<Self, String> {
        let mut key: VerifiableKey<RSAGroup> = serde_json::from_reader(
            std::fs::OpenOptions::new()
                .read(true)
                .open(path)
                .map_err(|e| e.to_string())?,
        )
        .map_err(|e| e.to_string())?;
        let proof = std::mem::take(&mut key.proof);
        if verify {
            let seed: &[&dyn FeedHasher] = &[&key.group, &key.g, &key.q, &key.max_d];
            let mut fiat = FiatShamirRng::new(seed, PierreGenPrime::new(128, 64));
            proof_of_precomputation(Prover::Proof(proof.clone()), &key, &mut fiat)?;
        }
        let VerifiableKey {
            p,
            q,
            group,
            g,
            max_d,
            g_powers,
            ..
        } = key;
        let rng = init_chacha20();
        let uniform = UniformRandom::new();
        let size_r = SIZE_R;
        let mut bound_alpha = Int::from(&p - 1);
        bound_alpha >>= 1;
        let mut p_1_2 = p.clone();
        p_1_2 += 1;
        p_1_2 >>= 1;
        Ok(Self {
            cache: PreComputation {
                g_powers: g_powers.into(),
                proof,
            },
            p,
            q,
            max_d,
            group,
            g,
            rng,
            uniform,
            bound_alpha,
            p_1_2,
            size_r,
        })
    }
/// Load a key and verify its proof.
Load a key and verify its proof.
Load a key and verify its proof .
pub fn from_key<P: AsRef<Path>>(path: P, verify: bool) -> Result<Self, String> {
        let mut key: VerifiableKey<RSAGroup> = serde_json::from_reader(
            std::fs::OpenOptions::new()
                .read(true)
                .open(path)
                .map_err(|e| e.to_string())?,
        )
        .map_err(|e| e.to_string())?;
        let proof = std::mem::take(&mut key.proof);
        if verify {
            let seed: &[&dyn FeedHasher] = &[&key.group, &key.g, &key.q, &key.max_d];
            let mut fiat = FiatShamirRng::new(seed, PierreGenPrime::new(128, 64));
            proof_of_precomputation(Prover::Proof(proof.clone()), &key, &mut fiat)?;
        }
        let VerifiableKey {
            p,
            q,
            group,
            g,
            max_d,
            g_powers,
            ..
        } = key;
        let rng = init_chacha20();
        let uniform = UniformRandom::new();
        let size_r = SIZE_R;
        let mut bound_alpha = Int::from(&p - 1);
        bound_alpha >>= 1;
        let mut p_1_2 = p.clone();
        p_1_2 += 1;
        p_1_2 >>= 1;
        Ok(Self {
            cache: PreComputation {
                g_powers: g_powers.into(),
                proof,
            },
            p,
            q,
            max_d,
            group,
            g,
            rng,
            uniform,
            bound_alpha,
            p_1_2,
            size_r,
        })
    }
pub fn from_key < P : AsRef < Path > > ( path : P , verify : bool ) -> Result < Self , String > { let mut key : VerifiableKey < RSAGroup > = serde_json :: from_reader ( std :: fs :: OpenOptions :: new ( ) . read ( true ) . open ( path ) . map_err ( | e | e . to_string ( ) ) ? , ) . map_err ( | e | e . to_string ( ) ) ? ; let proof = std :: mem :: take ( & mut key . proof ) ; if verify { let seed : & [ & dyn FeedHasher ] = & [ & key . group , & key . g , & key . q , & key . max_d ] ; let mut fiat = FiatShamirRng :: new ( seed , PierreGenPrime :: new ( 128 , 64 ) ) ; proof_of_precomputation ( Prover :: Proof ( proof . clone ( ) ) , & key , & mut fiat ) ? ; } let VerifiableKey { p , q , group , g , max_d , g_powers , .. } = key ; let rng = init_chacha20 ( ) ; let uniform = UniformRandom :: new ( ) ; let size_r = SIZE_R ; let mut bound_alpha = Int :: from ( & p - 1 ) ; bound_alpha >>= 1 ; let mut p_1_2 = p . clone ( ) ; p_1_2 += 1 ; p_1_2 >>= 1 ; Ok ( Self { cache : PreComputation { g_powers : g_powers . into ( ) , proof , } , p , q , max_d , group , g , rng , uniform , bound_alpha , p_1_2 , size_r , } ) }
Load a key and verify its proof.
Load a key and verify its proof .
path
P
verify
bool
path
P
verify
bool