Skip to content

Commit

Permalink
self code review
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-roslaniec committed Jan 20, 2023
1 parent 364580e commit 89ebffc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions ferveo/src/dkg/pv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,14 +331,14 @@ pub(crate) mod test_common {
///
/// The correctness of this function is tested in the module [`test_dealing`]
pub fn setup_dealt_dkg() -> PubliclyVerifiableDkg<EllipticCurve> {
setup_dealt_dkg_with_n_validators(4, 2, 4)
setup_dealt_dkg_with_n_validators(2, 4)
}

pub fn setup_dealt_dkg_with_n_validators(
n_validators: u32,
security_threshold: u32,
shares_num: u32,
) -> PubliclyVerifiableDkg<EllipticCurve> {
let n_validators = shares_num;
// Make sure that the number of shares is a power of 2 for the FFT to work (Radix-2 FFT domain is being used)
let is_power_of_2 = |n: u32| n != 0 && (n & (n - 1)) == 0;
assert!(is_power_of_2(shares_num));
Expand Down
5 changes: 3 additions & 2 deletions ferveo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,12 @@ mod test_dkg_full {
#[test]
fn test_dkg_simple_decryption_variant_single_validator() {
let rng = &mut ark_std::test_rng();
let dkg = setup_dealt_dkg_with_n_validators(1, 1, 1);
let dkg = setup_dealt_dkg_with_n_validators(1, 1);

let msg: &[u8] = "abc".as_bytes();
let aad: &[u8] = "my-aad".as_bytes();
let public_key = dkg.final_key();

let ciphertext = tpke::encrypt::<_, E>(msg, aad, &public_key, rng);

let aggregate = aggregate_for_decryption(&dkg);
Expand Down Expand Up @@ -90,7 +91,7 @@ mod test_dkg_full {
#[test]
fn test_dkg_simple_decryption_variant() {
let rng = &mut ark_std::test_rng();
let dkg = setup_dealt_dkg_with_n_validators(4, 3, 4);
let dkg = setup_dealt_dkg_with_n_validators(3, 4);

let msg: &[u8] = "abc".as_bytes();
let aad: &[u8] = "my-aad".as_bytes();
Expand Down
7 changes: 4 additions & 3 deletions tpke/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ pub fn setup_fast<E: PairingEngine>(
pubkey_shares.chunks(1),
privkey_shares.chunks(1)
)
.enumerate()
.enumerate()
{
let private_key_share = PrivateKeyShare::<E> {
private_key_shares: private.to_vec(),
Expand Down Expand Up @@ -259,7 +259,7 @@ pub fn setup_simple<E: PairingEngine>(
pubkey_shares.chunks(1),
privkey_shares.chunks(1)
)
.enumerate()
.enumerate()
{
let private_key_share = PrivateKeyShare::<E> {
private_key_shares: private.to_vec(),
Expand Down Expand Up @@ -349,7 +349,8 @@ mod tests {
fn decryption_share_serialization() {
let decryption_share = DecryptionShareFast::<E> {
decrypter_index: 1,
decryption_share: ark_bls12_381::G1Affine::prime_subgroup_generator(),
decryption_share: ark_bls12_381::G1Affine::prime_subgroup_generator(
),
};

let serialized = decryption_share.to_bytes();
Expand Down

0 comments on commit 89ebffc

Please sign in to comment.