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
constructor
• new MessageHash(bytes
): MessageHash
Creates a new MessageHash object from a 32 byte hash represented as Uint8Array or hex string of length 64
Parameters
Name | Type | Description |
---|---|---|
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
▪ Static
Readonly
LENGTH: 32
Methods
toHex
▸ toHex(): string
Returns
string
keccak256
▸ keccak256(message
): MessageHash
A helper function to create a MessageHash from a string or Uint8Array using keccak256.
Parameters
Name | Type | Description |
---|---|---|
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
▸ sha256(message
): MessageHash
A helper function to create a MessageHash from a string or Uint8Array using SHA256.
Parameters
Name | Type | Description |
---|---|---|
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
▸ sha256d(message
): MessageHash
A helper function to create a MessageHash from a string or Uint8Array using Double SHA256 (Bitcoin's Sha256d)
Parameters
Name | Type | Description |
---|---|---|
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.