mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-14 06:59:24 +00:00
Add embedded elliptic curve keys to Substrate
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user