HermezWallet constructor
Initialize Babyjubjub wallet from private key @param {Uint8List} privateKey - 32 bytes buffer @param {String} hermezEthereumAddress - Hexadecimal string containing the public Ethereum Address
Implementation
HermezWallet(Uint8List privateKey, String hermezEthereumAddress) {
if (privateKey.length != 32) {
throw new ArgumentError('buf must be 32 bytes');
}
if (!isHermezEthereumAddress(hermezEthereumAddress)) {
throw new ArgumentError('Invalid Hermez Ethereum address');
}
final priv = eddsaBabyJub.PrivateKey(privateKey);
final eddsaBabyJub.PublicKey publicKey = priv.public();
this.privateKey = privateKey;
this.publicKey = [publicKey.p[0].toString(), publicKey.p[1].toString()];
this.publicKeyHex = [
publicKey.p[0].toRadixString(16),
publicKey.p[1].toRadixString(16)
];
final compressedPublicKey =
Uint8ArrayUtils.leBuff2int(publicKey.compress());
this.publicKeyCompressed = compressedPublicKey.toString();
this.publicKeyCompressedHex =
compressedPublicKey.toRadixString(16).padLeft(64, '0');
this.publicKeyBase64 = hexToBase64BJJ(publicKeyCompressedHex!);
this.hermezEthereumAddress = hermezEthereumAddress;
}