You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.
The method itself works fine and other parties are able to verify signature generated by it.
But it's not clear how to verify it using web3dart library:
Signing:
final hash = keccak256(Uint8List.fromList(utf8.encode("Hello")));
final key = EthPrivateKey(hexToBytes(<private key>));
final signature = await key.signPersonalMessage(hash);
Verifying
final sig = MsgSignature(
bytesToInt(signature.getRange(0, 32).toList()),
bytesToInt(signature.getRange(32, 64).toList()),
signature.elementAt(64)
);
final pk = ecRecover(hash, sig);
print(bytesToHex(pk));
print(bytesToHex(key.encodedPublicKey));
last two print values return different results
(r, s, v) creation looks also correct for me(I checked in other languages where I'm able to verify signature)
The text was updated successfully, but these errors were encountered:
me too
final private = EthPrivateKey.fromHex(privakey);
final sign =await private.signPersonalMessage(Uint8List.fromList(utf8.encode(message)));
final signed =await private.signToSignature(Uint8List.fromList(utf8.encode(message)));
var pubKey=bytesToHex(private.publicKey.getEncoded().toList());
bool isV= isValidSignature(Uint8List.fromList(utf8.encode(message)),signed,hexToBytes(pubKey));
final adds= ecRecover(Uint8List.fromList(utf8.encode(message)), signed);
Later I found out, there is a ethereum prefix that's automatically beeing added inside ´signPersonalMessage´.
And if you use that library, you need to manuallly add it during verification
static const _messagePrefix = '\u0019Ethereum Signed Message:\n';
final prefix = _messagePrefix + payload.length.toString();
But I would still be interested if that can be included in the web3dart library
Hello,
I'm using the following method to sign messages:
https://github.com/simolus3/web3dart/blob/master/lib/src/credentials/credentials.dart#L51
The method itself works fine and other parties are able to verify signature generated by it.
But it's not clear how to verify it using web3dart library:
Signing:
Verifying
last two print values return different results
(r, s, v) creation looks also correct for me(I checked in other languages where I'm able to verify signature)
The text was updated successfully, but these errors were encountered: