Show / Hide Table of Contents

Class XrplSigningKey

A signing key that holds its private key in a byte array and clears it on Dispose(), for an application that keeps keys encrypted at rest and decrypts one only for the signatures it needs.

Inheritance
object
XrplSigningKey
Namespace: Xrpl.Wallet
Assembly: Xrpl.dll
Syntax
public sealed class XrplSigningKey
Remarks

Signs exactly as XrplWallet does - the same routing for Batch inner signers, Sponsor and Counterparty co-signatures and multi-signature entries, and byte-identical blobs - but the key never becomes a string, which .NET cannot clear and which may outlive its use in swap, a hibernation file or a memory dump.

Both algorithms keep key material in buffers the SDK clears: secp256k1 signs on NBitcoin.Secp256k1, whose scalar and RFC 6979 nonce are value types cleared after each signature. The key itself sits in a pinned array, which the garbage collector never moves, so no stale copy of it is left behind by compaction; it is cleared on dispose, and a key that is never disposed stays in memory until the allocator reuses it. There is deliberately no finalizer: once a signature has read the key field, the runtime may finalize the object while the signature is still copying the key. What stays outside the SDK's reach is the state hash implementations keep, the HMAC-SHA256 of RFC 6979 included, the short-lived buffers of a single signature, and the operating system paging memory out to disk. The public key and address are not secret and are kept as strings.

Not safe for disposal concurrent with signing: dispose only once every signature has returned.

Constructors

| Edit this page View Source

XrplSigningKey(ReadOnlySpan<byte>, string?)

Creates a signing key from a private key in the 33-byte XRPL form: 0xED followed by the Ed25519 seed, or 0x00 followed by the secp256k1 scalar.

Declaration
public XrplSigningKey(ReadOnlySpan<byte> privateKey, string? masterAddress = null)
Parameters
Type Name Description
ReadOnlySpan<byte> privateKey

The key bytes. They are copied, so the caller can clear its own buffer as soon as this returns.

string masterAddress

The account this key signs for when it is the account's regular key; the key's own address when null.

Exceptions
Type Condition
ArgumentException

The key is not 33 bytes, has an unknown prefix, or is a secp256k1 scalar of zero or not below the curve order.

Properties

| Edit this page View Source

ClassicAddress

The classic address this key signs for: the master address when one was given.

Declaration
public string ClassicAddress { get; }
Property Value
Type Description
string
| Edit this page View Source

PublicKey

The public key, hex.

Declaration
public string PublicKey { get; }
Property Value
Type Description
string

Methods

| Edit this page View Source

Dispose()

Clears the private key. Signing afterwards throws System.ObjectDisposedException.

Declaration
public void Dispose()
| Edit this page View Source

FromEntropy(ReadOnlySpan<byte>, string, string?)

Derives the signing key of an account from 16 bytes of seed entropy without encoding a seed string: the key FromEntropy(byte[], string?, string?) derives from the same entropy.

Declaration
public static XrplSigningKey FromEntropy(ReadOnlySpan<byte> entropy, string algorithm = "ed25519", string? masterAddress = null)
Parameters
Type Name Description
ReadOnlySpan<byte> entropy

The 16 bytes of seed entropy; not retained.

string algorithm

Ed25519 or Secp256k1.

string masterAddress

The account this key signs for when it is a regular key.

Returns
Type Description
XrplSigningKey
Exceptions
Type Condition
ArgumentException

The entropy is not 16 bytes, or the algorithm is unknown.

| Edit this page View Source

Sign(Dictionary<string, object>, bool, string?)

Signs a transaction offline, as Sign(Dictionary<string, object>, bool, string?) does.

Declaration
public SignatureResult Sign(Dictionary<string, object> transaction, bool multisign = false, string? signingFor = null)
Parameters
Type Name Description
Dictionary<string, object> transaction

A transaction to be signed offline.

bool multisign

True to produce a multi-signature entry rather than a single signature.

string signingFor

The signing account (classic or X-address); this key's own by default.

Returns
Type Description
SignatureResult
Exceptions
Type Condition
ObjectDisposedException

The key has been disposed.

| Edit this page View Source

Sign(Dictionary<string, object>, bool, string?, SignatureRole)

Signs a transaction offline in a stated role, as Sign(Dictionary<string, object>, bool, string?, SignatureRole) does.

Declaration
public SignatureResult Sign(Dictionary<string, object> transaction, bool multisign, string? signingFor, SignatureRole role)
Parameters
Type Name Description
Dictionary<string, object> transaction

A transaction to be signed offline.

bool multisign

True to produce a multi-signature entry rather than a single signature.

string signingFor

The signing account (classic or X-address); this key's own by default.

SignatureRole role

Which signature of the transaction this key is producing.

Returns
Type Description
SignatureResult
Exceptions
Type Condition
ObjectDisposedException

The key has been disposed.

| Edit this page View Source

Sign(ITransactionRequest, bool, string?)

Signs a typed transaction offline, as Sign(ITransactionRequest, bool, string?) does.

Declaration
public SignatureResult Sign(ITransactionRequest transaction, bool multisign = false, string? signingFor = null)
Parameters
Type Name Description
ITransactionRequest transaction
bool multisign
string signingFor
Returns
Type Description
SignatureResult
Exceptions
Type Condition
ObjectDisposedException

The key has been disposed.

| Edit this page View Source

Sign(ITransactionRequest, bool, string?, SignatureRole)

Signs a typed transaction offline in a stated role, as Sign(ITransactionRequest, bool, string?, SignatureRole) does.

Declaration
public SignatureResult Sign(ITransactionRequest transaction, bool multisign, string? signingFor, SignatureRole role)
Parameters
Type Name Description
ITransactionRequest transaction
bool multisign
string signingFor
SignatureRole role
Returns
Type Description
SignatureResult
Exceptions
Type Condition
ObjectDisposedException

The key has been disposed.

  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX