Skip to content

Commit

Permalink
fix: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
rymnc committed Jul 5, 2024
1 parent 31d3b6a commit 25bb1ad
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions example/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ use stealth_address_kit::Secp256k1 as Curve;
use stealth_address_kit::StealthAddressOnCurve;

fn print_discriminator() {
println!("{}", "+".repeat(200));
println!("{}", "+".repeat(100));
}

fn print_key(label: &str, key: &impl std::fmt::UpperHex) {
println!("{}: 0x{:016X}", label, key);
}

fn main() {
Expand All @@ -13,10 +17,10 @@ fn main() {
println!("BOB PRE-COMPUTATION");
print_discriminator();

println!("Spending Key: 0x{:016X}", &spending_key.0);
println!("Spending Public Key: 0x{:016X}", &spending_public_key.x.0);
println!("Viewing Key: 0x{:016X}", &viewing_key.0);
println!("Viewing Public Key: 0x{:016X}", &viewing_public_key.x.0);
print_key("Spending Key", &spending_key.0);
print_key("Spending Public Key", &spending_public_key.x.0);
print_key("Viewing Key", &viewing_key.0);
print_key("Viewing Public Key", &viewing_public_key.x.0);

print_discriminator();

Expand All @@ -27,16 +31,16 @@ fn main() {
println!("ALICE COMPUTATION");
print_discriminator();

println!("Ephemeral Private Key: 0x{:016X}", &ephemeral_private_key.0);
println!("Ephemeral Public Key: 0x{:016X}", &ephemeral_public_key.x.0);
print_key("Ephemeral Private Key", &ephemeral_private_key.0);
print_key("Ephemeral Public Key", &ephemeral_public_key.x.0);

let (stealth_public_key, view_tag) = Curve::generate_stealth_address(
viewing_public_key,
spending_public_key,
ephemeral_private_key,
);

println!("Stealth Public Key: 0x{:016X}", &stealth_public_key.x.0);
print_key("Stealth Public Key", &stealth_public_key.x.0);
println!("View Tag: {}", &view_tag.to_string());

print_discriminator();
Expand All @@ -55,12 +59,11 @@ fn main() {
if let Some(stealth_private_key) = stealth_private_key_opt {
let derived_stealth_public_key = Curve::derive_public_key(&stealth_private_key);

println!(
"Derived Stealth Public Key: 0x{:016X}",
&derived_stealth_public_key.x.0
print_key(
"Derived Stealth Public Key",
&derived_stealth_public_key.x.0,
);

println!("Stealth Private Key: 0x{:016X}", &stealth_private_key.0);
print_key("Stealth Private Key", &stealth_private_key.0);

assert_eq!(derived_stealth_public_key, stealth_public_key);

Expand Down

0 comments on commit 25bb1ad

Please sign in to comment.