Skip to content

Commit

Permalink
Refactor parity_npub.
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptoquick committed Mar 4, 2024
1 parent b951425 commit 0bb96c4
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,11 @@ pub async fn start() -> Result<()> {
}

pub fn parity_npub(nsec: &str) -> Result<()> {
use nostr::{
secp256k1::{Parity, Secp256k1},
FromBech32, PublicKey, SecretKey, ToBech32,
};
use nostr::{prelude::*, secp256k1::Parity};

let secret_key = SecretKey::from_bech32(nsec)?;
let secp = Secp256k1::new();
let pk = secret_key.public_key(&secp);
let (pk, parity) = pk.x_only_public_key();
let pk = PublicKey::from(pk);
let (xonly_public_key, parity) = secret_key.x_only_public_key(&SECP256K1);
let pk = PublicKey::from(xonly_public_key);

println!(
"Parity npub is: {}{}",
Expand Down

0 comments on commit 0bb96c4

Please sign in to comment.