nip04: augment tests with cross-compatibility vectors.

This commit is contained in:
fiatjaf 2023-12-02 13:13:32 -03:00
parent 2b9b4dfa2f
commit a9972245f3
No known key found for this signature in database
GPG Key ID: BAD43C4BE5C1A3A1

View File

@ -3,6 +3,8 @@ package nip04
import (
"strings"
"testing"
"github.com/nbd-wtf/go-nostr"
)
func TestEncryptionAndDecryption(t *testing.T) {
@ -45,3 +47,15 @@ func TestEncryptionAndDecryptionWithMultipleLengths(t *testing.T) {
}
}
}
func TestNostrToolsCompatibility(t *testing.T) {
sk1 := "92996316beebf94171065a714cbf164d1f56d7ad9b35b329d9fc97535bf25352"
sk2 := "591c0c249adfb9346f8d37dfeed65725e2eea1d7a6e99fa503342f367138de84"
pk2, _ := nostr.GetPublicKey(sk2)
shared, _ := ComputeSharedSecret(pk2, sk1)
ciphertext := "A+fRnU4aXS4kbTLfowqAww==?iv=QFYUrl5or/n/qamY79ze0A=="
plaintext, _ := Decrypt(ciphertext, shared)
if plaintext != "hello" {
t.Fatal("invalid decryption of nostr-tools payload")
}
}