Continue filling out main loop

Adds generics to the db_channel macro, fixes the bug where it needed at least
one key.
This commit is contained in:
Luke Parker
2024-09-11 08:58:58 -04:00
parent 723f529659
commit 59fa49f750
7 changed files with 186 additions and 64 deletions

View File

@@ -1,3 +1,20 @@
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()
}