generateIntermediatePassphrase static method
Generate an intermediate passphrase from a regular passphrase.
passphrase: The regular passphrase to be transformed.lotNum: The optional lot number.sequenceNum: The optional sequence number.
Implementation
static String generateIntermediatePassphrase(
String passphrase, {
int? lotNum,
int? sequenceNum,
}) {
/// Determine if lot and sequence numbers are included.
final hasLotSeq = lotNum != null && sequenceNum != null;
/// Generate owner entropy based on lot and sequence numbers.
final ownerEntropy =
hasLotSeq
? Bip38EcUtils.ownerEntropyWithLotSeq(lotNum, sequenceNum)
: Bip38EcUtils.ownerEntropyNoLotSeq();
/// Derive passfactor and passpoint from the passphrase and owner entropy.
final passfactor = Bip38EcUtils.passFactor(
passphrase,
ownerEntropy,
hasLotSeq,
);
final passpoint = Bip38EcUtils.passPoint(passfactor);
/// Determine the appropriate magic number based on lot and sequence numbers.
final magic =
hasLotSeq
? Bip38EcConst.intPassMagicWithLotSeq
: Bip38EcConst.intPassMagicNoLotSeq;
/// Encode the intermediate passphrase
final intermediatePassphrase = Base58Encoder.checkEncode([
...magic,
...ownerEntropy,
...passpoint,
]);
return intermediatePassphrase;
}