ownerEntropyWithLotSeq static method

List<int> ownerEntropyWithLotSeq(
  1. int lotNum,
  2. int sequenceNum
)

Generate owner entropy with lot and sequence numbers.

Generates owner entropy by combining random owner salt with lot and sequence numbers. Ensure that the provided lot and sequence numbers are within valid ranges as defined by Bip38EcConst.lotNumMinVal and Bip38EcConst.seqNumMaxVal.

  • lotNum: The lot number to use for owner entropy.
  • sequenceNum: The sequence number to use for owner entropy.
  • Returns: A List

Implementation

static List<int> ownerEntropyWithLotSeq(int lotNum, int sequenceNum) {
  if (lotNum < Bip38EcConst.lotNumMinVal ||
      lotNum > Bip38EcConst.lotNumMaxVal) {
    throw ArgumentException('Invalid lot number ($lotNum)');
  }
  if (sequenceNum < Bip38EcConst.seqNumMinVal ||
      sequenceNum > Bip38EcConst.seqNumMaxVal) {
    throw ArgumentException('Invalid sequence number ($sequenceNum)');
  }

  final ownerSalt =
      QuickCrypto.generateRandom(Bip38EcConst.ownerSaltWithLotSeqByteLen);

  final lotSequence = IntUtils.toBytes(
      (lotNum * (Bip38EcConst.seqNumMaxVal + 1)) + sequenceNum,
      length: 4,
      byteOrder: Endian.little);
  return List<int>.from([...ownerSalt, ...lotSequence]);
}