ownerEntropyWithLotSeq static method

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

Generate owner entropy with lot and sequence numbers.

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

Implementation

static List<int> ownerEntropyWithLotSeq(int lotNum, int sequenceNum) {
  if (lotNum < Bip38EcConst.lotNumMinVal ||
      lotNum > Bip38EcConst.lotNumMaxVal) {
    throw ArgumentException.invalidOperationArguments(
      "ownerEntropyWithLotSeq",
      name: "lotNum",
      reason: 'Invalid lot number ($lotNum)',
    );
  }
  if (sequenceNum < Bip38EcConst.seqNumMinVal ||
      sequenceNum > Bip38EcConst.seqNumMaxVal) {
    throw ArgumentException.invalidOperationArguments(
      "ownerEntropyWithLotSeq",
      name: "sequenceNum",
      reason: '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 [...ownerSalt, ...lotSequence];
}