From a9972245f37043d43d95d39beb6023d0ddfe92d1 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Sat, 2 Dec 2023 13:13:32 -0300 Subject: [PATCH] nip04: augment tests with cross-compatibility vectors. --- nip04/nip04_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/nip04/nip04_test.go b/nip04/nip04_test.go index 199ff22..ee0adbb 100644 --- a/nip04/nip04_test.go +++ b/nip04/nip04_test.go @@ -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") + } +}