0

So I've been playing around with a Rust Monero library and I wrote this piece of code.

fn main() {
    let msg = "inwardly jester boss puzzled medicate iris terminal problems epoxy atrium newt dummy aided bovine navy flying dozen lunar hiker enlist sovereign tucks velvet wonders aided";
    let s = curve25519_dalek::scalar::Scalar::hash_from_bytes::<sha2::Sha512>(msg.as_bytes());
    let private_key = monero::util::key::PrivateKey::from_scalar(s);
    let public_key = monero::util::key::PublicKey::from_private_key(&private_key);
    let kp = monero::util::key::KeyPair{view: private_key, spend: private_key};
    let address = monero::Address::from_keypair(monero::Network::Stagenet, &kp);
   println!("wallet: {}, priv key: {}", address, private_key);
}

I'm pretty sure I'm doing something wrong. Also how can one wallet have 2 private keys with 1 mnemonic. I don't understand that.

1 Answer 1

0

Also how can one wallet have 2 private keys with 1 mneomonic

Monero uses two key pairs, view and spend. So there is a private view key, a public view key, a private spend key and a public spend key. When restoring from a seed (which is a recovery key), the private view and spend keys are then derived from the recovery key.

let kp = monero::util::key::KeyPair{view: private_key, spend: private_key};

Your code is incorrect as it is trying to set both view and spend the private keys to the same value. They should be different.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.