use std::process::ExitCode;
use bee::swarm::{Error, PrivateKey};
use rand::RngCore;
fn main() -> ExitCode {
match run() {
Ok(()) => ExitCode::SUCCESS,
Err(e) => {
eprintln!("error: {e}");
ExitCode::FAILURE
}
}
}
fn run() -> Result<(), Error> {
let mut bytes = [0u8; 32];
rand::thread_rng().fill_bytes(&mut bytes);
let signer = PrivateKey::new(&bytes)?;
let public = signer.public_key()?;
let address = public.address();
println!("Generated secp256k1 keypair");
println!("===========================");
println!("Private key: 0x{}", signer.to_hex());
println!("Public key (uncomp): 0x{}", public.to_hex());
println!("Public key (comp): 0x{}", public.compressed_hex()?);
println!("Ethereum address: {}", address.to_checksum());
println!();
println!("Usage hints:");
println!(
"- Set BEE_SIGNER_HEX={} to drive feed-update / pss / soc examples",
signer.to_hex()
);
println!("- The address is what readers need to follow your feeds");
Ok(())
}