Files
serai/processor/bitcoin/src/primitives/mod.rs
Luke Parker 59fa49f750 Continue filling out main loop
Adds generics to the db_channel macro, fixes the bug where it needed at least
one key.
2024-09-19 23:36:32 -07:00

21 lines
568 B
Rust

use ciphersuite::{Ciphersuite, Secp256k1};
use bitcoin_serai::bitcoin::key::{Parity, XOnlyPublicKey};
pub(crate) mod output;
pub(crate) mod transaction;
pub(crate) mod block;
pub(crate) fn x_coord_to_even_point(key: &[u8]) -> Option<<Secp256k1 as Ciphersuite>::G> {
if key.len() != 32 {
None?
};
// Read the x-only public key
let key = XOnlyPublicKey::from_slice(key).ok()?;
// Convert to a full public key
let key = key.public_key(Parity::Even);
// Convert to k256 (from libsecp256k1)
Secp256k1::read_G(&mut key.serialize().as_slice()).ok()
}