Wallet.createNew constructor
Wallet.createNew(
- EthPrivateKey credentials,
- String password,
- Random random, {
- int scryptN = 8192,
- int p = 1,
Creates a new wallet wrapping the specified credentials
by encrypting
the private key with the password
. The random
instance, which should
be cryptographically secure, is used to generate encryption keys.
You can configure the parameter N of the scrypt algorithm if you need to.
The default value for scryptN
is 8192. Be aware that this N must be a
power of two.
Implementation
factory Wallet.createNew(
EthPrivateKey credentials,
String password,
Random random, {
int scryptN = 8192,
int p = 1,
}) {
final passwordBytes = Uint8List.fromList(utf8.encode(password));
final dartRandom = RandomBridge(random);
final salt = dartRandom.nextBytes(32);
final derivator = _ScryptKeyDerivator(32, scryptN, 8, p, salt);
final uuid = generateUuidV4();
final iv = dartRandom.nextBytes(128 ~/ 8);
return Wallet._(credentials, derivator, passwordBytes, iv, uuid);
}