Put in test so that DM sent to invalid pubkeys aren't taken as valid

invalid here means pubkeys with too many 0's in beginning ( 32 right now)
This commit is contained in:
Vishal 2022-11-18 20:15:38 +05:30
parent f305437862
commit d7c60c6096
2 changed files with 5 additions and 2 deletions

View File

@ -1423,7 +1423,9 @@ bool isValidDirectMessage(EventData directMessageData) {
});
if( directMessageData.pubkey == userPublicKey && allPtags.length == 1) {
validUserMessage = true; // case where this user is sender
if( allPtags[0].substring(0, 32) != "0".padLeft(32, '0')) { // check that the message hasn't been sent to an invalid pubkey
validUserMessage = true; // case where this user is sender
}
} else {
if ( directMessageData.pubkey != userPublicKey) {
if( allPtags.length == 1 && allPtags[0] == userPublicKey) {
@ -1526,7 +1528,7 @@ try {
String myEncrypt( String privateString,
String publicString,
String plainText) {
print("private = ${privateString.length} public = ${publicString.length}");
//print("private = ${privateString.length} public = ${publicString.length}");
Uint8List uintInputText = convert.Utf8Encoder().convert(plainText);
final encryptedString = myEncryptRaw(privateString, publicString, uintInputText);
return encryptedString;

View File

@ -5,6 +5,7 @@ homepage: https://github.com/vishalxl/nostr_console
# Release 0.1.3-beta
# nip05 build
# key 1 crashes fixed
environment:
sdk: '>=2.17.3 <3.0.0'