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

Commit

Permalink
small updates
Browse files Browse the repository at this point in the history
  • Loading branch information
brech1 committed Oct 31, 2023
1 parent 9ceb421 commit 0c00ba9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
4 changes: 2 additions & 2 deletions eigentrust-zk/src/circuits/dynamic_sets/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ impl<
op_hash
}

/// Build the opinion group by unwrapping attestations and filling the empty ones with default values.
/// Enumerating to keep track of the participant this opinion is about.
/// Unwraps a `Vec<Option<SignedAttestation>>`.
/// `None` values are replaced by empty signed attestations with the correct about field.
pub fn parse_op_group(
&mut self, op: Vec<Option<SignedAttestation<C, N, NUM_LIMBS, NUM_BITS, P>>>,
) -> Vec<SignedAttestation<C, N, NUM_LIMBS, NUM_BITS, P>> {
Expand Down
23 changes: 13 additions & 10 deletions eigentrust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,27 +430,30 @@ impl Client {
native_et.add_member(scalar_set[i]);
}

// Declare defaults
let default_scalar_member: Scalar =
scalar_from_address(&address_from_ecdsa_key(&PublicKey::default())).unwrap();
let default_scalar_set = vec![default_scalar_member; NUM_NEIGHBOURS];
let default_op =
vec![
SignedAttestationScalar::empty_with_about(default_scalar_member, scalar_domain);
NUM_NEIGHBOURS
];

// Submit participants' opinion
let mut op_hashes: Vec<Scalar> = Vec::new();
for (origin_index, member) in address_set.clone().into_iter().enumerate() {
if let Some(pub_key) = pub_key_map.get(&member) {
debug!("Updating opinion for {}", member);
let opinion = attestation_matrix[origin_index].clone();
op_hashes.push(native_et.update_op(pub_key.clone(), opinion.clone()));
} else {
let def_scalar_member: Scalar =
scalar_from_address(&address_from_ecdsa_key(&PublicKey::default())).unwrap();
let def_att =
vec![
SignedAttestationScalar::empty_with_about(def_scalar_member, scalar_domain);
NUM_NEIGHBOURS
];
let op = Opinion4::new(PublicKey::default(), def_att, scalar_domain);
let (_, _, op_hash) = op.validate(vec![def_scalar_member; NUM_NEIGHBOURS]);
let op = Opinion4::new(PublicKey::default(), default_op.clone(), scalar_domain);
let (_, _, op_hash) = op.validate(default_scalar_set.clone());
op_hashes.push(op_hash)
}
}

// Generate opinions' sponge hash.
let mut sponge = PoseidonNativeSponge::new();
sponge.update(&op_hashes);
let opinions_hash = sponge.squeeze();
Expand Down

0 comments on commit 0c00ba9

Please sign in to comment.