Skip to content
This repository has been archived by the owner on Nov 23, 2023. It is now read-only.

Commit

Permalink
Add type for Threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
lazovicff committed Sep 20, 2023
1 parent f1870da commit 34bbcd0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
29 changes: 24 additions & 5 deletions eigentrust-zk/src/circuits/mod.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
use self::{
dynamic_sets::{native::EigenTrustSet as NativeEigenTrustSet, EigenTrustSet},
threshold::native::Threshold,
threshold::{native::Threshold, ThresholdCircuit},
};
use crate::{
ecdsa::native::{EcdsaKeypair, PublicKey, Signature},
eddsa::EddsaChipset,
edwards::params::BabyJubJub,
params::{
ecc::secp256k1::Secp256k1Params, hasher::poseidon_bn254_5x5::Params,
rns::secp256k1::Secp256k1_4_68,
ecc::{bn254::Bn254Params, secp256k1::Secp256k1Params},
hasher::poseidon_bn254_5x5::Params,
rns::{bn256::Bn256_4_68, secp256k1::Secp256k1_4_68},
},
poseidon::{
native::{sponge::PoseidonSponge, Poseidon},
sponge::StatefulSpongeChipset,
FullRoundChip, PartialRoundChip, PoseidonChipset,
},
};
use halo2::halo2curves::{bn256::Fr as Scalar, secp256k1::Secp256k1Affine};
use halo2::halo2curves::{
bn256::{Bn256, Fr as Scalar},
secp256k1::Secp256k1Affine,
};
use num_rational::BigRational;

/// EigenTrustSet
Expand Down Expand Up @@ -103,5 +107,20 @@ pub type EigenTrust4 = EigenTrustSet<
>;

/// Native Threshold for scores computed in EigenTrust4
pub type Threshold4 =
pub type NativeThreshold4 =
Threshold<Scalar, NUM_DECIMAL_LIMBS, POWER_OF_TEN, NUM_NEIGHBOURS, INITIAL_SCORE>;

/// Threshold Circuit for scores computed in EigenTrust4
pub type Threshold4 = ThresholdCircuit<
Bn256,
NUM_DECIMAL_LIMBS,
POWER_OF_TEN,
NUM_NEIGHBOURS,
INITIAL_SCORE,
NUM_LIMBS,
NUM_BITS,
Bn256_4_68,
Bn254Params,
SpongeHasher,
Params,
>;
4 changes: 2 additions & 2 deletions eigentrust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ use circuit::ScoresReport;
use eigentrust_zk::{
circuits::{
threshold::native::Threshold, ECDSAPublicKey, EigenTrust4, NativeEigenTrust4,
PoseidonNativeSponge, Threshold4, HASHER_WIDTH, MIN_PEER_COUNT, NUM_ITERATIONS,
NativeThreshold4, PoseidonNativeSponge, HASHER_WIDTH, MIN_PEER_COUNT, NUM_ITERATIONS,
NUM_NEIGHBOURS,
},
halo2::{
Expand Down Expand Up @@ -533,7 +533,7 @@ impl Client {
let threshold_fr = Scalar::from(threshold);
let score_ratio = BigRational::new(score_num.into(), score_den.into());

let th_circuit: Threshold4 = Threshold::new(score_fr, score_ratio, threshold_fr);
let th_circuit: NativeThreshold4 = Threshold::new(score_fr, score_ratio, threshold_fr);

th_circuit.check_threshold()
}
Expand Down

0 comments on commit 34bbcd0

Please sign in to comment.