Skip to content

Commit

Permalink
Remove trait
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-lj committed Apr 24, 2024
1 parent 85a09ca commit 4b03382
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 16 deletions.
4 changes: 1 addition & 3 deletions fastcrypto-vdf/src/class_group/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//! for the composition.

use crate::math::extended_gcd::{extended_euclidean_algorithm, EuclideanAlgorithmOutput};
use crate::math::parameterized_group::{ParameterizedGroupElement, UnknownOrderGroupElement};
use crate::math::parameterized_group::ParameterizedGroupElement;
use core::cell::OnceCell;
use discriminant::Discriminant;
use fastcrypto::error::FastCryptoError::InvalidInput;
Expand Down Expand Up @@ -374,8 +374,6 @@ impl Neg for QuadraticForm {
}
}

impl UnknownOrderGroupElement for QuadraticForm {}

impl PartialEq for QuadraticForm {
fn eq(&self, other: &Self) -> bool {
// Ignore the partial_gcd_limit field
Expand Down
3 changes: 0 additions & 3 deletions fastcrypto-vdf/src/math/parameterized_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,3 @@ pub trait ParameterizedGroupElement:
/// Return the parameter for the group this element belongs to.
fn parameter(&self) -> Self::ParameterType;
}

/// Trait impl'd by elements of groups where the order is unknown.
pub trait UnknownOrderGroupElement {}
4 changes: 2 additions & 2 deletions fastcrypto-vdf/src/vdf/wesolowski/fiat_shamir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use crate::class_group::discriminant::Discriminant;
use crate::class_group::QuadraticForm;
use crate::math::hash_prime::hash_prime;
use crate::math::parameterized_group::{ParameterizedGroupElement, UnknownOrderGroupElement};
use crate::math::parameterized_group::ParameterizedGroupElement;
use crate::vdf::wesolowski::WesolowskisVDF;
use fastcrypto::groups::multiplier::ScalarMultiplier;
use num_bigint::BigInt;
Expand All @@ -13,7 +13,7 @@ use serde::Serialize;
/// Default size in bytes of the Fiat-Shamir challenge used in proving and verification.
pub const DEFAULT_CHALLENGE_SIZE_IN_BYTES: usize = 32;

pub trait FiatShamir<G: ParameterizedGroupElement + UnknownOrderGroupElement>: Sized {
pub trait FiatShamir<G: ParameterizedGroupElement>: Sized {
/// Compute the prime modulus used in proving and verification. This is a Fiat-Shamir construction
/// to make the Wesolowski VDF non-interactive.
fn compute_challenge<M: ScalarMultiplier<G, G::ScalarType>>(
Expand Down
13 changes: 5 additions & 8 deletions fastcrypto-vdf/src/vdf/wesolowski/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

use crate::class_group::QuadraticForm;
use crate::math::parameterized_group::{ParameterizedGroupElement, UnknownOrderGroupElement};
use crate::math::parameterized_group::ParameterizedGroupElement;
use crate::vdf::VDF;
use fastcrypto::error::FastCryptoError::{InvalidInput, InvalidProof};
use fastcrypto::error::FastCryptoResult;
Expand All @@ -19,7 +19,7 @@ mod fiat_shamir;
/// An implementation of Wesolowski's VDF construction (https://eprint.iacr.org/2018/623) over a
/// group of unknown order.
pub struct WesolowskisVDF<
G: ParameterizedGroupElement + UnknownOrderGroupElement,
G: ParameterizedGroupElement,
F: FiatShamir<G>,
M: ScalarMultiplier<G, G::ScalarType>,
> {
Expand All @@ -29,11 +29,8 @@ pub struct WesolowskisVDF<
_scalar_multiplier: PhantomData<M>,
}

impl<
G: ParameterizedGroupElement + UnknownOrderGroupElement,
F: FiatShamir<G>,
M: ScalarMultiplier<G, G::ScalarType>,
> WesolowskisVDF<G, F, M>
impl<G: ParameterizedGroupElement, F: FiatShamir<G>, M: ScalarMultiplier<G, G::ScalarType>>
WesolowskisVDF<G, F, M>
{
/// Create a new VDF using the group defined by the given group parameter. Evaluating this VDF
/// will require computing `2^iterations * input` which requires `iterations` group operations.
Expand All @@ -48,7 +45,7 @@ impl<
}

impl<
G: ParameterizedGroupElement<ScalarType = BigInt> + UnknownOrderGroupElement,
G: ParameterizedGroupElement<ScalarType = BigInt>,
F: FiatShamir<G>,
M: ScalarMultiplier<G, BigInt>,
> VDF for WesolowskisVDF<G, F, M>
Expand Down

0 comments on commit 4b03382

Please sign in to comment.