magicMessage static method

List<int> magicMessage(
  1. List<int> message,
  2. String messagePrefix
)

Applies the magic prefix and calculates the SHA-256 hash of the message for Bitcoin signing.

The message prefix is expected to start with the safe Bitcoin message prefix (0x18).

Implementation

static List<int> magicMessage(List<int> message, String messagePrefix) {
  final prefixBytes = StringUtils.encode(messagePrefix);
  if (prefixBytes[0] != BitcoinSignerUtils.safeBitcoinMessagePrefix) {
    throw const ArgumentException(
        "invalid message prefix. message prefix should start with 0x18");
  }
  final magic = _magicPrefix(message, prefixBytes);
  return QuickCrypto.sha256Hash(magic);
}