Show / Hide Table of Contents

Class K256KeyPair

A secp256k1 key pair whose private key is a 32-byte scalar.

Inheritance
object
K256KeyPair
Implements
IXrplKeyPair
Namespace: Xrpl.Keypairs.K256
Assembly: Xrpl.Keypairs.dll
Syntax
public class K256KeyPair : IXrplKeyPair

Constructors

| Edit this page View Source

K256KeyPair(byte[], bool)

Wraps a private key.

Declaration
public K256KeyPair(byte[] priv, bool nodeKey = false)
Parameters
Type Name Description
byte[] priv

The scalar, unsigned big-endian: 32 bytes, fewer when leading zeros were dropped, or more with leading zeros (the 33-byte XRPL form with the 00 prefix).

bool nodeKey

Whether this is the root key of a family, as a validator uses.

Exceptions
Type Condition
ArgumentNullException

priv is null.

ArgumentException

The key is zero or not below the curve order.

Methods

| Edit this page View Source

Id()

The 33-byte compressed public key, as upper-case hex.

Declaration
public string Id()
Returns
Type Description
string
| Edit this page View Source

Pk()

The private key in the XRPL form: 00 followed by the 32-byte scalar, as upper-case hex.

Declaration
public string Pk()
Returns
Type Description
string
| Edit this page View Source

Sign(byte[], byte[])

Signs the SHA-512Half of message, with a canonical (low) S.

Declaration
public static byte[] Sign(byte[] message, byte[] privateKey)
Parameters
Type Name Description
byte[] message

The message bytes.

byte[] privateKey

The private key, unsigned big-endian: the 33-byte form with the 00 prefix or the raw 32 bytes. It is read as unsigned, so a raw key whose first byte is 0x80 or above is not taken as negative.

Returns
Type Description
byte[]

The DER-encoded signature (RFC 6979 nonce).

Exceptions
Type Condition
ArgumentNullException

message or privateKey is null.

ArgumentException

The key is zero or not below the curve order.

| Edit this page View Source

Verify(byte[], byte[], byte[])

Verifies a DER signature over the SHA-512Half of message. A signature with a high S verifies; whether it is canonical is IsStrictlyCanonical(byte[]).

Declaration
public static bool Verify(byte[] signature, byte[] message, byte[] publicKey)
Parameters
Type Name Description
byte[] signature

The DER-encoded signature; anything else does not verify.

byte[] message

The message bytes.

byte[] publicKey

The public key, compressed (33 bytes) or uncompressed (65 bytes).

Returns
Type Description
bool
Exceptions
Type Condition
ArgumentNullException

message or publicKey is null.

ArgumentException

publicKey is not a point on the curve.

Implements

IXrplKeyPair

Extension Methods

KeyPairExtensions.PubKeyHash(IXrplKeyPair)
  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX