componentsGenerator static method

Map<String, Uint8List> componentsGenerator(
  1. Uint8List wotsSeed
)

Implementation

static Map<String, Uint8List> componentsGenerator(Uint8List wotsSeed) {
  // Concatenate wotsSeed bytes with ASCII bytes of "seed", "publ", "addr"
  final privateSeedInput = Uint8List(wotsSeed.length + 4);
  privateSeedInput.setRange(0, wotsSeed.length, wotsSeed);
  privateSeedInput.setRange(
      wotsSeed.length, wotsSeed.length + 4, 'seed'.codeUnits);

  final publicSeedInput = Uint8List(wotsSeed.length + 4);
  publicSeedInput.setRange(0, wotsSeed.length, wotsSeed);
  publicSeedInput.setRange(
      wotsSeed.length, wotsSeed.length + 4, 'publ'.codeUnits);

  final addrSeedInput = Uint8List(wotsSeed.length + 4);
  addrSeedInput.setRange(0, wotsSeed.length, wotsSeed);
  addrSeedInput.setRange(
      wotsSeed.length, wotsSeed.length + 4, 'addr'.codeUnits);

  final privateSeed = MochimoHasher.hash(privateSeedInput);
  final publicSeed = MochimoHasher.hash(publicSeedInput);
  final addrSeed = MochimoHasher.hash(addrSeedInput);

  return {
    'private_seed': privateSeed,
    'public_seed': publicSeed,
    'addr_seed': addrSeed,
  };
}