mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-14 06:59:24 +00:00
Correct amount of yx coefficients, get processor key gen test to pass
This commit is contained in:
@@ -78,11 +78,13 @@ create_db!(
|
||||
HashMap<Participant, Vec<u8>>,
|
||||
HashMap<Participant, Vec<u8>>,
|
||||
),
|
||||
GeneratedKeysDb: (session: &Session) -> Vec<u8>,
|
||||
// GeneratedKeysDb, KeysDb use `()` for their value as we manually serialize their values
|
||||
// TODO: Don't do that
|
||||
GeneratedKeysDb: (session: &Session) -> (),
|
||||
// These do assume a key is only used once across sets, which holds true if the threshold is
|
||||
// honest
|
||||
// TODO: Remove this assumption
|
||||
KeysDb: (network_key: &[u8]) -> Vec<u8>,
|
||||
KeysDb: (network_key: &[u8]) -> (),
|
||||
SessionDb: (network_key: &[u8]) -> Session,
|
||||
NetworkKeyDb: (session: Session) -> Vec<u8>,
|
||||
}
|
||||
@@ -411,7 +413,7 @@ impl<N: Network, D: Db> KeyGen<N, D> {
|
||||
// If we've already generated these keys, we don't actually need to save these
|
||||
// participations and continue. We solely have to verify them, as to identify malicious
|
||||
// participants and prevent DoSs, before returning
|
||||
if GeneratedKeysDb::get(txn, &session).is_some() {
|
||||
if txn.get(GeneratedKeysDb::key(&session)).is_some() {
|
||||
info!("already finished generating a key for {:?}", session);
|
||||
|
||||
match EvrfDkg::<Ristretto>::verify(
|
||||
@@ -482,9 +484,9 @@ impl<N: Network, D: Db> KeyGen<N, D> {
|
||||
{
|
||||
let mut participating_weight = 0;
|
||||
// This uses the Substrate maps as the maps are kept in synchrony
|
||||
let mut evrf_public_keys = substrate_evrf_public_keys.clone();
|
||||
let mut evrf_public_keys_mut = substrate_evrf_public_keys.clone();
|
||||
for i in substrate_participations.keys() {
|
||||
let evrf_public_key = evrf_public_keys[usize::from(u16::from(*i)) - 1];
|
||||
let evrf_public_key = substrate_evrf_public_keys[usize::from(u16::from(*i)) - 1];
|
||||
|
||||
// Remove this key from the Vec to prevent double-counting
|
||||
/*
|
||||
@@ -495,9 +497,9 @@ impl<N: Network, D: Db> KeyGen<N, D> {
|
||||
the shares for themselves and all other participants, so this is still a key
|
||||
generated by an amount of participants who could simply reconstruct the key.
|
||||
*/
|
||||
let start_len = evrf_public_keys.len();
|
||||
evrf_public_keys.retain(|key| *key != evrf_public_key);
|
||||
let end_len = evrf_public_keys.len();
|
||||
let start_len = evrf_public_keys_mut.len();
|
||||
evrf_public_keys_mut.retain(|key| *key != evrf_public_key);
|
||||
let end_len = evrf_public_keys_mut.len();
|
||||
let count = start_len - end_len;
|
||||
|
||||
participating_weight += count;
|
||||
|
||||
Reference in New Issue
Block a user