isValidSignature method
Verifies the signature returned by Phantom Wallet.
- We will verify the
signaturewithnonceand userPublicKey.
Implementation
Future<bool> isValidSignature(String signature, Uint8List nonce) async {
Uint8List hashedNonce = Hash.sha256(nonce);
var message =
"Sign this message for authenticating with your wallet. Nonce: ${base58encode(hashedNonce)}";
var messageBytes = message.codeUnits.toUint8List();
var signatureBytes = base58decode(signature);
bool verify = await verifySignature(
message: messageBytes,
signature: signatureBytes,
publicKey: Ed25519HDPublicKey.fromBase58(userPublicKey),
);
nonce = Uint8List(0);
return verify;
}