Struct aleo_wasm::account::private_key::PrivateKey
source · pub struct PrivateKey(/* private fields */);
Expand description
Private key of an Aleo account
Implementations§
source§impl PrivateKey
impl PrivateKey
sourcepub fn new() -> Self
pub fn new() -> Self
Generate a new private key using a cryptographically secure random number generator
@returns {PrivateKey}
sourcepub fn from_seed_unchecked(seed: &[u8]) -> PrivateKey
pub fn from_seed_unchecked(seed: &[u8]) -> PrivateKey
Get a private key from a series of unchecked bytes
@param {Uint8Array} seed Unchecked 32 byte long Uint8Array acting as the seed for the private key @returns {PrivateKey}
sourcepub fn from_string(private_key: &str) -> Result<PrivateKey, String>
pub fn from_string(private_key: &str) -> Result<PrivateKey, String>
Get a private key from a string representation of a private key
@param {string} seed String representation of a private key @returns {PrivateKey}
sourcepub fn to_string(&self) -> String
pub fn to_string(&self) -> String
Get a string representation of the private key. This function should be used very carefully as it exposes the private key plaintext
@returns {string} String representation of a private key
sourcepub fn to_view_key(&self) -> ViewKey
pub fn to_view_key(&self) -> ViewKey
Get the view key corresponding to the private key
@returns {ViewKey}
sourcepub fn to_address(&self) -> Address
pub fn to_address(&self) -> Address
Get the address corresponding to the private key
@returns {Address}
sourcepub fn sign(&self, message: &[u8]) -> Signature
pub fn sign(&self, message: &[u8]) -> Signature
Sign a message with the private key
@param {Uint8Array} Byte array representing a message signed by the address @returns {Signature} Signature generated by signing the message with the address
sourcepub fn new_encrypted(secret: &str) -> Result<PrivateKeyCiphertext, String>
pub fn new_encrypted(secret: &str) -> Result<PrivateKeyCiphertext, String>
Get a new randomly generated private key ciphertext using a secret. The secret is sensitive and will be needed to decrypt the private key later, so it should be stored securely
@param {string} secret Secret used to encrypt the private key @returns {PrivateKeyCiphertext | Error} Ciphertext representation of the private key
sourcepub fn to_ciphertext(
&self,
secret: &str
) -> Result<PrivateKeyCiphertext, String>
pub fn to_ciphertext( &self, secret: &str ) -> Result<PrivateKeyCiphertext, String>
Encrypt an existing private key with a secret. The secret is sensitive and will be needed to decrypt the private key later, so it should be stored securely
@param {string} secret Secret used to encrypt the private key @returns {PrivateKeyCiphertext | Error} Ciphertext representation of the private key
sourcepub fn from_private_key_ciphertext(
ciphertext: &PrivateKeyCiphertext,
secret: &str
) -> Result<PrivateKey, String>
pub fn from_private_key_ciphertext( ciphertext: &PrivateKeyCiphertext, secret: &str ) -> Result<PrivateKey, String>
Get private key from a private key ciphertext and secret originally used to encrypt it
@param {PrivateKeyCiphertext} ciphertext Ciphertext representation of the private key @param {string} secret Secret originally used to encrypt the private key @returns {PrivateKey | Error} Private key
Methods from Deref<Target = PrivateKey<Testnet3>>§
pub fn sign<R>(
&self,
message: &[Field<N>],
rng: &mut R
) -> Result<Signature<N>, Error>where
R: Rng + CryptoRng,
pub fn sign<R>( &self, message: &[Field<N>], rng: &mut R ) -> Result<Signature<N>, Error>where R: Rng + CryptoRng,
Returns a signature for the given message (as field elements) using the private key.
pub fn sign_bytes<R>(
&self,
message: &[u8],
rng: &mut R
) -> Result<Signature<N>, Error>where
R: Rng + CryptoRng,
pub fn sign_bytes<R>( &self, message: &[u8], rng: &mut R ) -> Result<Signature<N>, Error>where R: Rng + CryptoRng,
Returns a signature for the given message (as bytes) using the private key.
pub fn sign_bits<R>(
&self,
message: &[bool],
rng: &mut R
) -> Result<Signature<N>, Error>where
R: Rng + CryptoRng,
pub fn sign_bits<R>( &self, message: &[bool], rng: &mut R ) -> Result<Signature<N>, Error>where R: Rng + CryptoRng,
Returns a signature for the given message (as bits) using the private key.
pub fn seed(&self) -> Field<N>
pub fn seed(&self) -> Field<N>
Returns the account seed.
pub fn sk_sig(&self) -> Scalar<N>
pub fn sk_sig(&self) -> Scalar<N>
Returns the signature secret key.
pub fn r_sig(&self) -> Scalar<N>
pub fn r_sig(&self) -> Scalar<N>
Returns the signature randomizer.
Trait Implementations§
source§impl Clone for PrivateKey
impl Clone for PrivateKey
source§fn clone(&self) -> PrivateKey
fn clone(&self) -> PrivateKey
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for PrivateKey
impl Debug for PrivateKey
source§impl Deref for PrivateKey
impl Deref for PrivateKey
source§impl Display for PrivateKey
impl Display for PrivateKey
source§impl From<&PrivateKey> for PrivateKey<Testnet3>
impl From<&PrivateKey> for PrivateKey<Testnet3>
source§fn from(private_key: &PrivateKey) -> Self
fn from(private_key: &PrivateKey) -> Self
source§impl From<PrivateKey<Testnet3>> for PrivateKey
impl From<PrivateKey<Testnet3>> for PrivateKey
source§impl From<PrivateKey> for JsValue
impl From<PrivateKey> for JsValue
source§fn from(value: PrivateKey) -> Self
fn from(value: PrivateKey) -> Self
source§impl From<PrivateKey> for PrivateKey<Testnet3>
impl From<PrivateKey> for PrivateKey<Testnet3>
source§fn from(private_key: PrivateKey) -> Self
fn from(private_key: PrivateKey) -> Self
source§impl FromStr for PrivateKey
impl FromStr for PrivateKey
source§impl FromWasmAbi for PrivateKey
impl FromWasmAbi for PrivateKey
source§impl IntoWasmAbi for PrivateKey
impl IntoWasmAbi for PrivateKey
source§impl LongRefFromWasmAbi for PrivateKey
impl LongRefFromWasmAbi for PrivateKey
source§impl OptionFromWasmAbi for PrivateKey
impl OptionFromWasmAbi for PrivateKey
source§impl OptionIntoWasmAbi for PrivateKey
impl OptionIntoWasmAbi for PrivateKey
source§impl PartialEq for PrivateKey
impl PartialEq for PrivateKey
source§fn eq(&self, other: &PrivateKey) -> bool
fn eq(&self, other: &PrivateKey) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl RefFromWasmAbi for PrivateKey
impl RefFromWasmAbi for PrivateKey
§type Anchor = Ref<'static, PrivateKey>
type Anchor = Ref<'static, PrivateKey>
Self
for the duration of the
invocation of the function that has an &Self
parameter. This is
required to ensure that the lifetimes don’t persist beyond one function
call, and so that they remain anonymous.source§impl RefMutFromWasmAbi for PrivateKey
impl RefMutFromWasmAbi for PrivateKey
source§impl TryFromJsValue for PrivateKey
impl TryFromJsValue for PrivateKey
source§impl VectorFromWasmAbi for PrivateKey
impl VectorFromWasmAbi for PrivateKey
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi(js: Self::Abi) -> Box<[PrivateKey]>
source§impl VectorIntoWasmAbi for PrivateKey
impl VectorIntoWasmAbi for PrivateKey
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi(vector: Box<[PrivateKey]>) -> Self::Abi
source§impl WasmDescribeVector for PrivateKey
impl WasmDescribeVector for PrivateKey
impl Eq for PrivateKey
impl StructuralEq for PrivateKey
impl StructuralPartialEq for PrivateKey
Auto Trait Implementations§
impl RefUnwindSafe for PrivateKey
impl Send for PrivateKey
impl Sync for PrivateKey
impl Unpin for PrivateKey
impl UnwindSafe for PrivateKey
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
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§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> Pointable for T
impl<T> Pointable for T
source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere T: IntoWasmAbi,
§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
IntoWasmAbi::Abi
source§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
IntoWasmAbi::into_abi
, except that it may throw and never
return in the case of Err
.