pub struct PrivateKeyAccount(_, pub PublicKeyAccount);
Expand description
An account possessing a private key. PrivateKeyAccount
is tied to an address and can sign transactions.
Waves uses an asymmetric cryptographic system based on the elliptic curve Curve25519-ED25519 with X25519 keys.
Unlike centralized applications, users do not have usernames and passwords on the blockchain. User identification and validation of their actions are performed using a cryptographically bound key pair:
- The private key is used to sign transactions or orders.
- The public key allows to verify the digital signature.
Example private key in base58:
6yCStrsBs4VgTmYcSgF37pmQhCo6t9LZk5bQqUyUNSAs
§Usage
use gemblockchain::account::{PrivateKeyAccount, TESTNET};
let account = PrivateKeyAccount::from_seed("seed");
println!(
"My TESTNET address: {}",
account.public_key().to_address(TESTNET).to_string()
);
Tuple Fields§
§1: PublicKeyAccount
Implementations§
Source§impl PrivateKeyAccount
impl PrivateKeyAccount
Sourcepub fn public_key(&self) -> &PublicKeyAccount
pub fn public_key(&self) -> &PublicKeyAccount
Get PublicKeyAccount
struct.
Examples found in repository?
examples/sign_transaction.rs (line 12)
7fn main() {
8 let phrase = generate_phrase();
9 let account = PrivateKeyAccount::from_seed(&phrase);
10 println!(
11 "My TESTNET address: {}",
12 account.public_key().to_address(TESTNET).to_string()
13 );
14
15 let ts = SystemTime::now()
16 .duration_since(UNIX_EPOCH)
17 .unwrap()
18 .as_secs()
19 * 1000;
20 let tx = Transaction::new_alias(&account.public_key(), "rhino", TESTNET, 100000, ts);
21 println!("ID is {}", tx.id().to_string());
22 let ptx = account.sign_transaction(tx);
23 println!(
24 "Proofs are {:?}",
25 ptx.proofs
26 .iter()
27 .map(|p| p.to_base58())
28 .collect::<Vec<String>>()
29 );
30}
Sourcepub fn private_key(&self) -> [u8; 32]
pub fn private_key(&self) -> [u8; 32]
Gets the internal byte value of PrivateKeyAccount
.
Sourcepub fn from_key_pair(sk: [u8; 32], pk: [u8; 32]) -> PrivateKeyAccount
pub fn from_key_pair(sk: [u8; 32], pk: [u8; 32]) -> PrivateKeyAccount
Create an PrivateKeyAccount
from internal byte values.
Sourcepub fn from_seed(seed: &str) -> PrivateKeyAccount
pub fn from_seed(seed: &str) -> PrivateKeyAccount
Create an PrivateKeyAccount
from seed string.
Examples found in repository?
examples/sign_transaction.rs (line 9)
7fn main() {
8 let phrase = generate_phrase();
9 let account = PrivateKeyAccount::from_seed(&phrase);
10 println!(
11 "My TESTNET address: {}",
12 account.public_key().to_address(TESTNET).to_string()
13 );
14
15 let ts = SystemTime::now()
16 .duration_since(UNIX_EPOCH)
17 .unwrap()
18 .as_secs()
19 * 1000;
20 let tx = Transaction::new_alias(&account.public_key(), "rhino", TESTNET, 100000, ts);
21 println!("ID is {}", tx.id().to_string());
22 let ptx = account.sign_transaction(tx);
23 println!(
24 "Proofs are {:?}",
25 ptx.proofs
26 .iter()
27 .map(|p| p.to_base58())
28 .collect::<Vec<String>>()
29 );
30}
Sourcepub fn sign_bytes(&self, data: &[u8]) -> [u8; 64]
pub fn sign_bytes(&self, data: &[u8]) -> [u8; 64]
Signs internal byte values.
Sourcepub fn sign_transaction<'a>(&self, tx: Transaction<'a>) -> ProvenTransaction<'a>
pub fn sign_transaction<'a>(&self, tx: Transaction<'a>) -> ProvenTransaction<'a>
Signs Transaction
struct.
Examples found in repository?
examples/sign_transaction.rs (line 22)
7fn main() {
8 let phrase = generate_phrase();
9 let account = PrivateKeyAccount::from_seed(&phrase);
10 println!(
11 "My TESTNET address: {}",
12 account.public_key().to_address(TESTNET).to_string()
13 );
14
15 let ts = SystemTime::now()
16 .duration_since(UNIX_EPOCH)
17 .unwrap()
18 .as_secs()
19 * 1000;
20 let tx = Transaction::new_alias(&account.public_key(), "rhino", TESTNET, 100000, ts);
21 println!("ID is {}", tx.id().to_string());
22 let ptx = account.sign_transaction(tx);
23 println!(
24 "Proofs are {:?}",
25 ptx.proofs
26 .iter()
27 .map(|p| p.to_base58())
28 .collect::<Vec<String>>()
29 );
30}
Trait Implementations§
Source§impl Clone for PrivateKeyAccount
impl Clone for PrivateKeyAccount
Source§fn clone(&self) -> PrivateKeyAccount
fn clone(&self) -> PrivateKeyAccount
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for PrivateKeyAccount
impl Debug for PrivateKeyAccount
Source§impl Default for PrivateKeyAccount
impl Default for PrivateKeyAccount
Source§fn default() -> PrivateKeyAccount
fn default() -> PrivateKeyAccount
Returns the “default value” for a type. Read more
Source§impl Display for PrivateKeyAccount
impl Display for PrivateKeyAccount
Source§impl Hash for PrivateKeyAccount
impl Hash for PrivateKeyAccount
Source§impl Ord for PrivateKeyAccount
impl Ord for PrivateKeyAccount
Source§fn cmp(&self, other: &PrivateKeyAccount) -> Ordering
fn cmp(&self, other: &PrivateKeyAccount) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for PrivateKeyAccount
impl PartialEq for PrivateKeyAccount
Source§impl PartialOrd for PrivateKeyAccount
impl PartialOrd for PrivateKeyAccount
impl Copy for PrivateKeyAccount
impl Eq for PrivateKeyAccount
impl StructuralPartialEq for PrivateKeyAccount
Auto Trait Implementations§
impl Freeze for PrivateKeyAccount
impl RefUnwindSafe for PrivateKeyAccount
impl Send for PrivateKeyAccount
impl Sync for PrivateKeyAccount
impl Unpin for PrivateKeyAccount
impl UnwindSafe for PrivateKeyAccount
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.