Class K256KeyPair
A secp256k1 key pair whose private key is a 32-byte scalar.
Inheritance
Implements
Namespace: Xrpl.Keypairs.K256
Assembly: Xrpl.Keypairs.dll
Syntax
public class K256KeyPair : IXrplKeyPair
Constructors
| Edit this page View SourceK256KeyPair(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 |
|
| ArgumentException | The key is zero or not below the curve order. |
Methods
| Edit this page View SourceId()
The 33-byte compressed public key, as upper-case hex.
Declaration
public string Id()
Returns
| Type | Description |
|---|---|
| string |
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 |
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 |
|
| ArgumentException | The key is zero or not below the curve order. |
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 |
|
| ArgumentException |
|