pub struct Secp256k1Account { /* private fields */ }Available on crate feature
secp256k1 only.Expand description
A Secp256k1 ECDSA account for signing transactions.
This account type uses the same elliptic curve as Bitcoin and Ethereum.
§Example
use aptos_sdk::account::Secp256k1Account;
let account = Secp256k1Account::generate();
println!("Address: {}", account.address());Implementations§
Source§impl Secp256k1Account
impl Secp256k1Account
Sourcepub fn from_private_key(private_key: Secp256k1PrivateKey) -> Self
pub fn from_private_key(private_key: Secp256k1PrivateKey) -> Self
Creates an account from a private key.
Sourcepub fn from_private_key_bytes(bytes: &[u8]) -> AptosResult<Self>
pub fn from_private_key_bytes(bytes: &[u8]) -> AptosResult<Self>
Creates an account from private key bytes.
§Errors
Returns an error if the bytes are not a valid Secp256k1 private key (must be exactly 32 bytes and a valid curve point).
Sourcepub fn from_private_key_hex(hex_str: &str) -> AptosResult<Self>
pub fn from_private_key_hex(hex_str: &str) -> AptosResult<Self>
Creates an account from a private key hex string.
§Errors
This function will return an error if:
- The hex string is invalid or cannot be decoded
- The decoded bytes are not a valid Secp256k1 private key
Sourcepub fn address(&self) -> AccountAddress
pub fn address(&self) -> AccountAddress
Returns the account address.
Sourcepub fn public_key(&self) -> &Secp256k1PublicKey
pub fn public_key(&self) -> &Secp256k1PublicKey
Returns the public key.
Sourcepub fn private_key(&self) -> &Secp256k1PrivateKey
pub fn private_key(&self) -> &Secp256k1PrivateKey
Returns a reference to the private key.
Sourcepub fn sign_message(&self, message: &[u8]) -> Secp256k1Signature
pub fn sign_message(&self, message: &[u8]) -> Secp256k1Signature
Signs a message and returns the Secp256k1 signature.
Trait Implementations§
Source§impl Account for Secp256k1Account
impl Account for Secp256k1Account
Source§fn address(&self) -> AccountAddress
fn address(&self) -> AccountAddress
Returns the account address.
Source§fn authentication_key(&self) -> AuthenticationKey
fn authentication_key(&self) -> AuthenticationKey
Returns the authentication key.
Source§fn sign(&self, message: &[u8]) -> AptosResult<Vec<u8>>
fn sign(&self, message: &[u8]) -> AptosResult<Vec<u8>>
Signs a message and returns the signature bytes. Read more
Source§fn signature_scheme(&self) -> u8
fn signature_scheme(&self) -> u8
Returns the scheme identifier for this account type.
Source§impl Clone for Secp256k1Account
impl Clone for Secp256k1Account
Source§fn clone(&self) -> Secp256k1Account
fn clone(&self) -> Secp256k1Account
Returns a duplicate 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 Secp256k1Account
impl Debug for Secp256k1Account
Source§impl From<Secp256k1Account> for AnyAccount
impl From<Secp256k1Account> for AnyAccount
Source§fn from(account: Secp256k1Account) -> Self
fn from(account: Secp256k1Account) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for Secp256k1Account
impl RefUnwindSafe for Secp256k1Account
impl Send for Secp256k1Account
impl Sync for Secp256k1Account
impl Unpin for Secp256k1Account
impl UnsafeUnpin for Secp256k1Account
impl UnwindSafe for Secp256k1Account
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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<A> Sponsor for Awhere
A: Account,
impl<A> Sponsor for Awhere
A: Account,
Source§fn sponsor<S: Account>(
&self,
sender: &S,
sender_sequence_number: u64,
payload: TransactionPayload,
chain_id: ChainId,
) -> AptosResult<SignedTransaction>
fn sponsor<S: Account>( &self, sender: &S, sender_sequence_number: u64, payload: TransactionPayload, chain_id: ChainId, ) -> AptosResult<SignedTransaction>
Sponsors a transaction for another account. Read more
Source§fn sponsor_with_gas<S: Account>(
&self,
sender: &S,
sender_sequence_number: u64,
payload: TransactionPayload,
chain_id: ChainId,
max_gas_amount: u64,
gas_unit_price: u64,
) -> AptosResult<SignedTransaction>
fn sponsor_with_gas<S: Account>( &self, sender: &S, sender_sequence_number: u64, payload: TransactionPayload, chain_id: ChainId, max_gas_amount: u64, gas_unit_price: u64, ) -> AptosResult<SignedTransaction>
Sponsors a transaction with custom gas settings. Read more