Class PrivateKey
- Namespace
- Aptos
- Assembly
- Aptos.dll
public abstract class PrivateKey : Serializable, IDisposable
- Inheritance
-
PrivateKey
- Implements
- Derived
- Inherited Members
Constructors
PrivateKey(PrivateKeyVariant)
protected PrivateKey(PrivateKeyVariant type)
Parameters
typePrivateKeyVariant
Fields
AIP80_PREFIXES
The AIP-80 compliant prefixes for each private key type
public static readonly Dictionary<PrivateKeyVariant, string> AIP80_PREFIXES
Field Value
Remarks
Read about AIP-80: https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md
Type
public PrivateKeyVariant Type
Field Value
Properties
IsDisposed
Whether this key has been disposed and its bytes zeroed out. Use ThrowIfDisposed() to enforce in concrete subclasses before reading the underlying material.
protected bool IsDisposed { get; }
Property Value
Methods
Dispose()
Zeros out the in-memory copy of the private key material. After Dispose() is called, subsequent calls that read the key (e.g. Sign(byte[]) or ToByteArray()) will throw ObjectDisposedException.
Notes:
public void Dispose()
DisposeCore()
Implemented by subclasses to perform the actual byte scrubbing.
protected abstract void DisposeCore()
FormatPrivateKey(byte[], PrivateKeyVariant)
Format a HexInput to an AIP-80 compliant string.
public static string FormatPrivateKey(byte[] privateKey, PrivateKeyVariant type)
Parameters
privateKeybyte[]The HexString or byte array format of the private key.
typePrivateKeyVariantThe private key type
Returns
- string
AIP-80 compliant string.
Remarks
Read about AIP-80: https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md
FormatPrivateKey(string, PrivateKeyVariant)
Format a HexInput to an AIP-80 compliant string.
public static string FormatPrivateKey(string privateKey, PrivateKeyVariant type)
Parameters
privateKeystringThe HexString or byte array format of the private key.
typePrivateKeyVariantThe private key type
Returns
- string
AIP-80 compliant string.
Remarks
Read about AIP-80: https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md
ParseHexInput(byte[], PrivateKeyVariant)
Parse a HexInput that may be a HexString, byte array, or a AIP-80 compliant string to a Hex instance.
public static Hex ParseHexInput(byte[] value, PrivateKeyVariant type)
Parameters
valuebyte[]A HexString, byte array, or AIP-80 compliant string.
typePrivateKeyVariantThe private key type
Returns
- Hex
A Hex instance.
ParseHexInput(string, PrivateKeyVariant, bool?)
Parse a HexInput that may be a HexString, byte array, or a AIP-80 compliant string to a Hex instance.
public static Hex ParseHexInput(string value, PrivateKeyVariant type, bool? strict = null)
Parameters
valuestringA HexString, byte array, or AIP-80 compliant string.
typePrivateKeyVariantThe private key type
strictbool?If true, the value MUST be compliant with AIP-80. If false, the value MAY be compliant with AIP-80 and ignore warnings.
Returns
- Hex
A Hex instance.
PublicKey()
public abstract PublicKey PublicKey()
Returns
Sign(byte[])
public abstract PublicKeySignature Sign(byte[] message)
Parameters
messagebyte[]
Returns
Sign(string)
public virtual PublicKeySignature Sign(string message)
Parameters
messagestring
Returns
ThrowIfDisposed()
Throws ObjectDisposedException if this key has been disposed. Concrete subclasses should call this before reading their key material.
protected void ThrowIfDisposed()
ToAIP80String()
public virtual string ToAIP80String()
Returns
ToByteArray()
public abstract byte[] ToByteArray()
Returns
- byte[]
ToHexString()
public virtual string ToHexString()
Returns
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.