Skip to content

Commit

Permalink
Don't use [0; 32] for the embedded keys in the coordinator rotation…
Browse files Browse the repository at this point in the history
… test

The key_gen function expects the random values already decided.
  • Loading branch information
kayabaNerve committed Aug 15, 2024
1 parent 6bc746e commit 35c54da
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
18 changes: 9 additions & 9 deletions tests/coordinator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ impl Processor {

use serai_client::primitives::insecure_arbitrary_key_from_name;
let substrate_key = Arc::new(AsyncMutex::new(None));
let embedwards25519_evrf_key = (Embedwards25519::generator() *
insecure_arbitrary_key_from_name::<Embedwards25519>(name))
.to_bytes();
let mut res = Processor {
network,

Expand All @@ -189,8 +192,7 @@ impl Processor {
abort_handle: None,

evrf_public_keys: (
(Embedwards25519::generator() * insecure_arbitrary_key_from_name::<Embedwards25519>(name))
.to_bytes(),
embedwards25519_evrf_key,
match network {
NetworkId::Serai => panic!("mock processor for the serai network"),
NetworkId::Bitcoin | NetworkId::Ethereum => {
Expand All @@ -200,13 +202,7 @@ impl Processor {
let key: &[u8] = key.as_ref();
key.to_vec()
}
NetworkId::Monero => {
let key = (Embedwards25519::generator() *
insecure_arbitrary_key_from_name::<Embedwards25519>(name))
.to_bytes();
let key: &[u8] = key.as_ref();
key.to_vec()
}
NetworkId::Monero => embedwards25519_evrf_key.to_vec(),
},
),

Expand Down Expand Up @@ -355,6 +351,10 @@ impl Processor {
res
}

pub fn network(&self) -> NetworkId {
self.network
}

pub fn evrf_public_keys(&self) -> ([u8; 32], Vec<u8>) {
self.evrf_public_keys.clone()
}
Expand Down
8 changes: 4 additions & 4 deletions tests/coordinator/src/tests/rotation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ async fn set_rotation_test() {

// excluded participant
let pair5 = insecure_pair_from_name("Eve");
let network = NetworkId::Bitcoin;
let network = excluded.network();
let amount = Amount(1_000_000 * 10_u64.pow(8));
let serai = processors[0].serai().await;

Expand All @@ -162,15 +162,15 @@ async fn set_rotation_test() {
set_embedded_elliptic_curve_key(
&serai,
EmbeddedEllipticCurve::Embedwards25519,
vec![0; 32],
excluded.evrf_public_keys().0.to_vec(),
&pair5,
0,
)
.await;
set_embedded_elliptic_curve_key(
&serai,
EmbeddedEllipticCurve::Secq256k1,
vec![0; 33],
*excluded.network().embedded_elliptic_curves().last().unwrap(),
excluded.evrf_public_keys().1.clone(),
&pair5,
1,
)
Expand Down

0 comments on commit 35c54da

Please sign in to comment.