addressBuffer static method

ByteBuffer addressBuffer(
  1. Uint8List addr
)

Loads a 32-byte address the way wots_pkgen receives it.

The node casts those bytes to word32[8] on a little-endian machine. addr_to_bytes then writes each word big-endian, which is a byte swap of every 4-byte group. Chain, hash, and key/mask indexes overwrite words 5, 6, and 7 after this conversion.

Implementation

static ByteBuffer addressBuffer(Uint8List addr) {
  if (addr.length != PARAMSN) {
    throw ArgumentError('Invalid addr length');
  }
  final be = Uint8List(PARAMSN);
  for (int i = 0; i < PARAMSN; i += 4) {
    be[i] = addr[i + 3];
    be[i + 1] = addr[i + 2];
    be[i + 2] = addr[i + 1];
    be[i + 3] = addr[i];
  }
  return ByteBuffer.wrap(be);
}