master method

  1. @override
Bip32Key master(
  1. Uint8List seed
)
override

The default implementation of the original BIP32-ED25519's master key generation.

Implementation

@override
Bip32Key master(Uint8List seed) {
  final secretBytes = Hash.sha512(seed);

  if ((secretBytes[31] & 0x20) != 0) {
    throw InvalidBip32Ed25519MasterSecretException();
  }

  final rootChainCode = Hash.sha256([0x01, ...seed].toUint8List());

  final rootKey = Bip32SigningKey.normalizeBytes(
      [...secretBytes, ...rootChainCode].toUint8List());

  PineNaClUtils.listZero(seed);
  PineNaClUtils.listZero(rootChainCode);

  return rootKey;
}