deriveKeyHalves static method

(List<int>, List<int>) deriveKeyHalves(
  1. String passphrase,
  2. List<int> addressHash
)

Derive key halves from a passphrase and an address hash.

  • passphrase: The passphrase for key derivation.
  • addressHash: The address hash as input for key derivation.

Implementation

static (List<int>, List<int>) deriveKeyHalves(
  String passphrase,
  List<int> addressHash,
) {
  final key = Scrypt.deriveKey(
    StringUtils.encode(passphrase),
    addressHash,
    dkLen: Bip38NoEcConst.scryptKeyLen,
    n: Bip38NoEcConst.scryptN,
    r: Bip38NoEcConst.scryptR,
    p: Bip38NoEcConst.scryptP,
  );

  final derivedHalf1 = key.sublist(0, Bip38NoEcConst.scryptKeyLen ~/ 2);
  final derivedHalf2 = key.sublist(Bip38NoEcConst.scryptKeyLen ~/ 2);

  return (derivedHalf1, derivedHalf2);
}