ECPrivate.fromWif constructor
ECPrivate.fromWif(
- String wif
creates an object from a WIF of WIFC format (string)
Implementation
factory ECPrivate.fromWif(String wif) {
final b64 = Uint8List.fromList(bs58.base58.decode(wif));
Uint8List keyBytes = b64.sublist(0, b64.length - 4);
final checksum = b64.sublist(b64.length - 4);
final h = doubleHash(keyBytes);
final isValid = isValidCheckSum(h.sublist(0, 4), checksum);
if (!isValid) {
throw Exception('Checksum is wrong. Possible mistype?'); // listtEqual
}
keyBytes = keyBytes.sublist(1);
if (keyBytes.length > 32) {
keyBytes = keyBytes.sublist(0, keyBytes.length - 1);
}
return ECPrivate.fromBytes(keyBytes);
}