mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 20:29:23 +00:00
Bitcoin Key Gen
This commit is contained in:
26
processor/bitcoin/src/key_gen.rs
Normal file
26
processor/bitcoin/src/key_gen.rs
Normal file
@@ -0,0 +1,26 @@
|
||||
use ciphersuite::{group::GroupEncoding, Ciphersuite, Secp256k1};
|
||||
use frost::ThresholdKeys;
|
||||
|
||||
use key_gen::KeyGenParams;
|
||||
|
||||
use crate::scan::scanner;
|
||||
|
||||
pub(crate) struct KeyGen;
|
||||
impl KeyGenParams for KeyGen {
|
||||
const ID: &'static str = "Bitcoin";
|
||||
|
||||
type ExternalNetworkCurve = Secp256k1;
|
||||
|
||||
fn tweak_keys(keys: &mut ThresholdKeys<Self::ExternalNetworkCurve>) {
|
||||
*keys = bitcoin_serai::wallet::tweak_keys(keys);
|
||||
// Also create a scanner to assert these keys, and all expected paths, are usable
|
||||
scanner(keys.group_key());
|
||||
}
|
||||
|
||||
fn encode_key(key: <Self::ExternalNetworkCurve as Ciphersuite>::G) -> Vec<u8> {
|
||||
let key = key.to_bytes();
|
||||
let key: &[u8] = key.as_ref();
|
||||
// Skip the parity encoding as we know this key is even
|
||||
key[1 ..].to_vec()
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ pub(crate) use primitives::*;
|
||||
mod scan;
|
||||
|
||||
// App-logic trait satisfactions
|
||||
mod key_gen;
|
||||
mod rpc;
|
||||
mod scheduler;
|
||||
|
||||
@@ -224,12 +225,6 @@ impl Network for Bitcoin {
|
||||
// aggregation TX
|
||||
const COST_TO_AGGREGATE: u64 = 800;
|
||||
|
||||
fn tweak_keys(keys: &mut ThresholdKeys<Self::Curve>) {
|
||||
*keys = tweak_keys(keys);
|
||||
// Also create a scanner to assert these keys, and all expected paths, are usable
|
||||
scanner(keys.group_key());
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
async fn get_block_number(&self, id: &[u8; 32]) -> usize {
|
||||
self.rpc.get_block_number(id).await.unwrap()
|
||||
|
||||
Reference in New Issue
Block a user