Class PublicKey
A wrapper for a Public Key. Provides signature verification functionality.
Inheritance
System.Object
PublicKey
Assembly: Casper.Network.SDK.dll
Syntax
public class PublicKey : object
Constructors
PublicKey(Byte[], KeyAlgo)
Declaration
protected PublicKey(byte[] rawBytes, KeyAlgo keyAlgorithm)
Parameters
Type |
Name |
Description |
System.Byte[] |
rawBytes |
|
KeyAlgo |
keyAlgorithm |
|
Properties
KeyAlgorithm
Declaration
public KeyAlgo KeyAlgorithm { get; }
Property Value
RawBytes
Byte array without the Key algorithm identifier.
Declaration
public byte[] RawBytes { get; }
Property Value
Type |
Description |
System.Byte[] |
|
Methods
Equals(Object)
Declaration
public override bool Equals(object obj)
Parameters
Type |
Name |
Description |
System.Object |
obj |
|
Returns
Type |
Description |
System.Boolean |
|
FromBytes(Byte[])
Creates a PublicKey object from a byte array. First byte in the array must contain the
key algorithm identifier.
Declaration
public static PublicKey FromBytes(byte[] bytes)
Parameters
Type |
Name |
Description |
System.Byte[] |
bytes |
|
Returns
FromHexString(String)
Creates a PublicKey object from an hexadecimal string (containing the
Key algorithm identifier).
Declaration
public static PublicKey FromHexString(string hexBytes)
Parameters
Type |
Name |
Description |
System.String |
hexBytes |
|
Returns
FromPem(String)
Loads a PublicKey from a PEM file
Declaration
public static PublicKey FromPem(string filePath)
Parameters
Type |
Name |
Description |
System.String |
filePath |
|
Returns
FromRawBytes(Byte[], KeyAlgo)
Creates a PublicKey object from a byte array and the key algorithm identifier.
Declaration
public static PublicKey FromRawBytes(byte[] rawBytes, KeyAlgo keyAlgo)
Parameters
Type |
Name |
Description |
System.Byte[] |
rawBytes |
|
KeyAlgo |
keyAlgo |
|
Returns
GetAccountHash()
Returns the Account Hash associated to this Public Key.
Declaration
public string GetAccountHash()
Returns
Type |
Description |
System.String |
|
GetBytes()
Returns the bytes of the public key, including the Key algorithm as the first byte.
Declaration
Returns
Type |
Description |
System.Byte[] |
|
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type |
Description |
System.Int32 |
|
ToAccountHex()
Returns the key as an hexadecimal string, including the key algorithm in the first position.
Declaration
public string ToAccountHex()
Returns
Type |
Description |
System.String |
|
ToString()
Declaration
public override string ToString()
Returns
Type |
Description |
System.String |
|
VerifySignature(Byte[], Byte[])
Verifies the signature given its value and the original message.
Declaration
public bool VerifySignature(byte[] message, byte[] signature)
Parameters
Type |
Name |
Description |
System.Byte[] |
message |
|
System.Byte[] |
signature |
|
Returns
Type |
Description |
System.Boolean |
|
VerifySignature(String, String)
Verifies the signature given its value and the original message.
Declaration
public bool VerifySignature(string message, string signature)
Parameters
Type |
Name |
Description |
System.String |
message |
|
System.String |
signature |
|
Returns
Type |
Description |
System.Boolean |
|
WriteToPem(String)
Saves the public key to a PEM file.
Declaration
public void WriteToPem(string filePath)
Parameters
Type |
Name |
Description |
System.String |
filePath |
|
Operators
Explicit(PublicKey to String)
Declaration
public static explicit operator string (PublicKey pk)
Parameters
Returns
Type |
Description |
System.String |
|