[−][src]Module monero::util::key
Monero public and private keys
Support for (de)serializable and manipulation of Monero public and private keys.
Parsing
extern crate monero; use std::str::FromStr; use monero::util::key::{PrivateKey, PublicKey}; // parse private key from hex let privkey = PrivateKey::from_str("77916d0cd56ed1920aef6ca56d8a41bac915b68e4c46a589e0956e27a7b77404"); // parse public key from hex let pubkey = PublicKey::from_str("eac2cc96e0ae684388e3185d5277e51313bff98b9ad4a12dcd9205f20d37f1a3"); // or get the public key from private key let pubkey: Option<PublicKey> = match privkey { Ok(privkey) => Some(PublicKey::from_private_key(&privkey)), Err(_) => None, };
Arithmetic
Support for private key addition and public key addition.
extern crate monero; use std::str::FromStr; use monero::util::key::{PrivateKey, PublicKey}; let priv1 = PrivateKey::from_str("77916d0cd56ed1920aef6ca56d8a41bac915b68e4c46a589e0956e27a7b77404").unwrap(); let priv2 = PrivateKey::from_str("8163466f1883598e6dd14027b8da727057165da91485834314f5500a65846f09").unwrap(); let priv_res = priv1 + priv2; assert_eq!("f8f4b37bedf12a2178c0adcc2565b42a212c133861cb28cdf48abf310c3ce40d", priv_res.to_string()); let pub1 = PublicKey::from_private_key(&priv1); let pub2 = PublicKey::from_private_key(&priv2); let pub_res = pub1 + pub2; assert_eq!("d35ad191b220a627977bb2912ea21fd59b24937f46c1d3814dbcb7943ff1f9f2", pub_res.to_string()); let pubkey = PublicKey::from_private_key(&priv_res); assert_eq!(pubkey, pub_res);
Structs
KeyPair | Two Monero private keys, view and spend key |
PrivateKey | Monero private key |
PublicKey | Monero public key |
ViewPair | View pair can scan transaction outputs and retreive amounts, but can't spend outputs |
Enums
Error | An error that might occur during key decoding |