mirror of
https://github.com/serai-dex/serai.git
synced 2024-11-17 01:17:36 +00:00
Rename transaction file to tributary, add function for genesis
This commit is contained in:
parent
4d43c04916
commit
595cd6d404
3 changed files with 18 additions and 3 deletions
|
@ -1 +1 @@
|
|||
mod transaction;
|
||||
mod tributary;
|
||||
|
|
|
@ -7,7 +7,7 @@ use frost::Participant;
|
|||
|
||||
use tributary::{ReadWrite, tests::random_signed};
|
||||
|
||||
use crate::transaction::{SignData, Transaction};
|
||||
use crate::tributary::{SignData, Transaction};
|
||||
|
||||
fn random_u32<R: RngCore>(rng: &mut R) -> u32 {
|
||||
u32::try_from(rng.next_u64() >> 32).unwrap()
|
|
@ -1,14 +1,29 @@
|
|||
use std::{io, collections::HashMap};
|
||||
|
||||
use blake2::{Digest, Blake2s256};
|
||||
use transcript::{Transcript, RecommendedTranscript};
|
||||
|
||||
use frost::Participant;
|
||||
|
||||
use serai_client::validator_sets::primitives::ValidatorSet;
|
||||
|
||||
#[rustfmt::skip]
|
||||
use tributary::{
|
||||
ReadWrite, Signed, TransactionError, TransactionKind, Transaction as TransactionTrait
|
||||
ReadWrite, Signed, TransactionError, TransactionKind, Transaction as TransactionTrait,
|
||||
};
|
||||
|
||||
pub fn genesis(serai_block: [u8; 32], set: ValidatorSet) -> [u8; 32] {
|
||||
// Calculate the genesis for this Tributary
|
||||
let mut genesis = RecommendedTranscript::new(b"Serai Tributary Genesis");
|
||||
// This locks it to a specific Serai chain
|
||||
genesis.append_message(b"serai_block", serai_block);
|
||||
genesis.append_message(b"session", set.session.0.to_le_bytes());
|
||||
genesis.append_message(b"network", set.network.0.to_le_bytes());
|
||||
let genesis = genesis.challenge(b"genesis");
|
||||
let genesis_ref: &[u8] = genesis.as_ref();
|
||||
genesis_ref[.. 32].try_into().unwrap()
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub struct SignData {
|
||||
pub plan: [u8; 32],
|
Loading…
Reference in a new issue