Skip to content

Commit

Permalink
align
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-lj committed Oct 7, 2024
1 parent 0ef2cb1 commit 77f7a5d
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions fastcrypto-vdf/src/vdf/pietrzak.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use fastcrypto::hash::{HashFunction, Keccak256};
use num_bigint::BigUint;
use num_integer::Integer;
use serde::Serialize;
use std::{iter, mem};
use std::mem;

/// Default size in bytes of the Fiat-Shamir challenge used in proving and verification.
///
Expand Down Expand Up @@ -72,28 +72,22 @@ where

let mut proof = Vec::new();

let t = iter::successors(Some(self.iterations), |t| Some((*t + 1) >> 1))
.skip(1)
.take_while(|t| *t > 1);

if self.iterations.is_odd() {
y = y.double();
}
let mut t = self.iterations;

// Compute the full proof. This loop may stop at any time which will give a shorter proof
// that is computationally harder to verify.
for t_i in t {
while t > 1 {
if check_parity_and_iterate(&mut t) {
y = y.double();
}

// TODO: Precompute some of the mu's to speed up the proof generation.
let mu = x.clone().repeated_doubling(t_i);
let mu = x.clone().repeated_doubling(t);

let r = self.compute_challenge(&x, &y, &mu);
x = x.multiply(&r, &self.group_parameter) + μ
y = mu.multiply(&r, &self.group_parameter) + &y;

if t_i.is_odd() {
y = y.double();
}

proof.push(mu);
}

Expand Down

0 comments on commit 77f7a5d

Please sign in to comment.