Skip to content

Commit

Permalink
nip04: augment tests with cross-compatibility vectors.
Browse files Browse the repository at this point in the history
  • Loading branch information
fiatjaf committed Dec 2, 2023
1 parent 2b9b4df commit a997224
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions nip04/nip04_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package nip04
import (
"strings"
"testing"

"github.com/nbd-wtf/go-nostr"
)

func TestEncryptionAndDecryption(t *testing.T) {
Expand Down Expand Up @@ -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")
}
}

0 comments on commit a997224

Please sign in to comment.