@sodot/sodot-node-sdk • Docs
@sodot/sodot-node-sdk / MessageHash
Class: MessageHash
A 32 byte message hash used for signing ECDSA messages.
Example
// A SHA256 hash of the string 'Hello World'
const messageHash = MessageHash.sha256('Hello World');
// A Keccak256 hash of the string 'Hello World'
const messageHash = MessageHash.keccak256('Hello World');
// In case you already have a hashed value you can just call the constructor with it:
const messageHash = new MessageHash('aabbccddeeff00112233445566778899aabbccddeeff00112233445566778899');
Constructors
new MessageHash()
new MessageHash(
bytes
):MessageHash
Creates a new MessageHash object from a 32 byte hash represented as Uint8Array or hex string of length 64
Parameters
• bytes: string
| Uint8Array
The 32 bytes of the message hash. Can be a hex string or a Uint8Array
Returns
Properties
bytes
readonly
bytes:Uint8Array
LENGTH
readonly
static
LENGTH:32
=32
Methods
toHex()
toHex():
string
Returns
string
keccak256()
static
keccak256(message
):MessageHash
A helper function to create a MessageHash from a string or Uint8Array using keccak256.
Parameters
• message: string
| Uint8Array
The message to hash. Can be a string or a Uint8Array.
Returns
A MessageHash object representing the keccak256 hash of the message.
sha256()
static
sha256(message
):MessageHash
A helper function to create a MessageHash from a string or Uint8Array using SHA256.
Parameters
• message: string
| Uint8Array
The message to hash. Can be a string or a Uint8Array.
Returns
A MessageHash object representing the SHA256 hash of the message.
sha256d()
static
sha256d(message
):MessageHash
A helper function to create a MessageHash from a string or Uint8Array using Double SHA256 (Bitcoin's Sha256d)
Parameters
• message: string
| Uint8Array
The message to hash. Can be a string or a Uint8Array.
Returns
A MessageHash object representing the Double-SHA256 hash of the message.