master method

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

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

Implementation

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

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

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

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

  PineNaClUtils.listZero(masterSecret);
  PineNaClUtils.listZero(rootChainCode);

  return rootKey;
}