Add embedded elliptic curve keys to Substrate

This commit is contained in:
Luke Parker
2024-08-03 01:54:57 -04:00
parent 9e716c07fc
commit fc51c9b71c
11 changed files with 210 additions and 20 deletions

View File

@@ -82,6 +82,24 @@ pub async fn set_keys(
block
}
#[allow(dead_code)]
pub async fn set_embedded_elliptic_curve_key(
serai: &Serai,
pair: &Pair,
embedded_elliptic_curve: EmbeddedEllipticCurve,
key: BoundedVec<u8, ConstU32<{ MAX_KEY_LEN }>>,
nonce: u32,
) -> [u8; 32] {
// get the call
let tx = serai.sign(
pair,
SeraiValidatorSets::set_embedded_elliptic_curve_key(embedded_elliptic_curve, key),
nonce,
0,
);
publish_tx(serai, &tx).await
}
#[allow(dead_code)]
pub async fn allocate_stake(
serai: &Serai,

View File

@@ -221,12 +221,31 @@ async fn validator_set_rotation() {
// add 1 participant
let last_participant = accounts[4].clone();
// If this is the first iteration, set embedded elliptic curve keys
if i == 0 {
for (i, embedded_elliptic_curve) in
[EmbeddedEllipticCurve::Embedwards25519, EmbeddedEllipticCurve::Secq256k1]
.into_iter()
.enumerate()
{
set_embedded_elliptic_curve_key(
&serai,
embedded_elliptic_curve,
vec![0; 32].try_into().unwrap(),
&last_participant,
i.try_into().unwrap(),
)
.await;
}
}
let hash = allocate_stake(
&serai,
network,
key_shares[&network],
&last_participant,
i.try_into().unwrap(),
(2 + i).try_into().unwrap(),
)
.await;
participants.push(last_participant.public());