deriveKeyHalves static method

(List<int>, List<int>) deriveKeyHalves(
  1. List<int> passpoint,
  2. List<int> addressHash,
  3. List<int> ownerEntropy
)

Derive key halves from passpoint, address hash, and owner entropy.

  • passpoint: The passpoint used in key derivation.
  • addressHash: The address hash to be combined in key derivation.
  • ownerEntropy: The owner entropy used in key derivation.

Implementation

static (List<int>, List<int>) deriveKeyHalves(
  List<int> passpoint,
  List<int> addressHash,
  List<int> ownerEntropy,
) {
  /// Derive a key using Scrypt with combined data.
  final key = Scrypt.deriveKey(
    passpoint,
    [...addressHash, ...ownerEntropy],
    dkLen: Bip38EcConst.scryptHalvesKeyLen,
    n: Bip38EcConst.scryptHalvesN,
    p: Bip38EcConst.scryptHalvesP,
    r: Bip38EcConst.scryptHalvesR,
  );

  /// Split the derived key into two halves.
  final derivedHalf1 = key.sublist(0, Bip38EcConst.scryptHalvesKeyLen ~/ 2);
  final derivedHalf2 = key.sublist(Bip38EcConst.scryptHalvesKeyLen ~/ 2);

  return (derivedHalf1, derivedHalf2);
}