Aptos Unity SDK
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | Properties | List of all members
Aptos.Accounts.PrivateKey Class Reference

Represents a 64-byte extended private key. An extended private key is a requirement from Choas.NaCl. More...

Public Member Functions

 PrivateKey (byte[] privateKey)
 Initializes the PrivateKey object with a 64 byte array that represents the expanded private key from seed.
For example, using: Ed25519.ExpandedPrivateKeyFromSeed(seed).
This constructor is expected to be called from the Account constructor.
Note: To create a private key from a 32-byte string see PrivateKey(string key)
 
 PrivateKey (string key)
 Initializes the PrivateKey object with a 64 character (32-byte) ASCII representation of a private key.
Note: The undelying cryptographic library (Chaos.NaCL) uses an extended private key (64 byte) for fast computation.
This hex string is used as a seed to create an extended private key when KeyBytes is requested.
 
 PrivateKey (ReadOnlySpan< byte > privateKey)
 Initialize the PrivateKey object from the given string.
 
PublicKey PublicKey ()
 Derives public key from the private key bytes.
 
Signature Sign (byte[] message)
 Sign a message using the extended private key.
 
void Serialize (Serialization serializer)
 Serialize private key.
 
override bool Equals (object obj)
 
override int GetHashCode ()
 
override string ToString ()
 

Static Public Member Functions

static PrivateKey FromHex (string key)
 Create a private key from a string literal. Conforms to the standard Python and Typescript Aptos SDK.
 
static PrivateKey Random ()
 
static bool operator== (PrivateKey lhs, PrivateKey rhs)
 Compartor for two private keys.
 
static bool operator!= (PrivateKey lhs, PrivateKey rhs)
 
static implicit operator string (PrivateKey privateKey)
 Convert a PrivateKey object to hexadecimal string representation of private key.
 

Static Public Attributes

const int ExtendedKeyLength = 64
 Extended private key length.
 
const int KeyLength = 32
 Private key length.
 

Properties

string Key [get, set]
 The key as a 32-byte hexadecimal string (64 characters).

 
byte[] KeyBytes [get, set]
 The 32-byte private key in bytes. Checks if we have the 32-byte private key or 64-byte extended key, otherwise uses the string representation to create both.
 

Detailed Description

Represents a 64-byte extended private key. An extended private key is a requirement from Choas.NaCl.

Note that the hexadecimal string representation is of the 32-byte private key on it's own.

Constructor & Destructor Documentation

◆ PrivateKey() [1/3]

Aptos.Accounts.PrivateKey.PrivateKey ( byte[]  privateKey)
inline

Initializes the PrivateKey object with a 64 byte array that represents the expanded private key from seed.
For example, using: Ed25519.ExpandedPrivateKeyFromSeed(seed).
This constructor is expected to be called from the Account constructor.
Note: To create a private key from a 32-byte string see PrivateKey(string key)

Parameters
privateKey64-byte array representation of the private key.

◆ PrivateKey() [2/3]

Aptos.Accounts.PrivateKey.PrivateKey ( string  key)
inline

Initializes the PrivateKey object with a 64 character (32-byte) ASCII representation of a private key.
Note: The undelying cryptographic library (Chaos.NaCL) uses an extended private key (64 byte) for fast computation.
This hex string is used as a seed to create an extended private key when KeyBytes is requested.

Parameters
keyThe private key as an ASCII encoded string.
Example: 0x64f57603b58af16907c18a866123286e1cbce89790613558dc1775abb3fc5c8c

◆ PrivateKey() [3/3]

Aptos.Accounts.PrivateKey.PrivateKey ( ReadOnlySpan< byte >  privateKey)
inline

Initialize the PrivateKey object from the given string.

Parameters
keyThe private key as a hex encoded byte array.

Member Function Documentation

◆ FromHex()

static PrivateKey Aptos.Accounts.PrivateKey.FromHex ( string  key)
inlinestatic

Create a private key from a string literal. Conforms to the standard Python and Typescript Aptos SDK.

Parameters
keyThe private key as an ASCII encoded string.
Returns
Private key object.

◆ operator string()

static implicit Aptos.Accounts.PrivateKey.operator string ( PrivateKey  privateKey)
static

Convert a PrivateKey object to hexadecimal string representation of private key.

Parameters
privateKeyThe PrivateKey object.
Returns
Hexadecimal string representing the private key.

◆ operator==()

static bool Aptos.Accounts.PrivateKey.operator== ( PrivateKey  lhs,
PrivateKey  rhs 
)
inlinestatic

Compartor for two private keys.

Parameters
lhsFirst private key in comparison..
rhsSecond private key in comparison.
Returns

◆ PublicKey()

PublicKey Aptos.Accounts.PrivateKey.PublicKey ( )
inline

Derives public key from the private key bytes.

Returns
PublicKey object.

◆ Serialize()

void Aptos.Accounts.PrivateKey.Serialize ( Serialization  serializer)
inline

Serialize private key.

Parameters
serializerSerializer object

◆ Sign()

Signature Aptos.Accounts.PrivateKey.Sign ( byte[]  message)
inline

Sign a message using the extended private key.

Parameters
messageThe message to sign, represented in bytes.
Returns
The signature generated for the message as an object

The documentation for this class was generated from the following file: