diff --git a/encrypt_decrypt.go b/encrypt_decrypt.go index b67391f..452555b 100644 --- a/encrypt_decrypt.go +++ b/encrypt_decrypt.go @@ -123,7 +123,7 @@ var decrypt = &cli.Command{ res, err := kr.Decrypt(ctx, ciphertext, source) if err != nil { - return fmt.Errorf("failed to encrypt: %w", err) + return fmt.Errorf("failed to decrypt: %w", err) } stdout(res) } diff --git a/gift.go b/gift.go index d80bfed..a72eef2 100644 --- a/gift.go +++ b/gift.go @@ -179,7 +179,7 @@ a decoupled key (if it has been created or received with "nak dekey" previously) eSec, has, err := getDecoupledEncryptionSecretKey(ctx, configPath, receiver) if has { if err != nil { - return fmt.Errorf("our decoupled encryption key exists, but we failed to get it: %w; call `nak dekey` to attempt a fix or call this again with --use-direct to bypass", err) + return fmt.Errorf("receiver's decoupled encryption key exists, but we failed to get it: %w; call `nak dekey` to attempt a fix or call this again with --use-direct to bypass", err) } ciphers = append(ciphers, kr) ciphers[0] = keyer.NewPlainKeySigner(eSec) // pub decoupled key first @@ -209,9 +209,12 @@ a decoupled key (if it has been created or received with "nak dekey" previously) for c, potentialCipher := range ciphers { switch c { case 0: - log("- trying the receiver's decoupled encryption key %s\n", color.CyanString(eSec.Public().Hex())) + if eSec.Public() == nostr.ZeroPK { + continue + } + log("- trying receiver's decoupled encryption key %s\n", color.CyanString(eSec.Public().Hex())) case 1: - log("- trying the receiver's identity key %s\n", color.CyanString(receiver.Hex())) + log("- trying receiver's identity key %s\n", color.CyanString(receiver.Hex())) } sealj, thisErr := potentialCipher.Decrypt(ctx, wrap.Content, wrap.PubKey) @@ -247,11 +250,15 @@ a decoupled key (if it has been created or received with "nak dekey" previously) var rumor nostr.Event err = nil for s, senderEncryptionPublicKey := range senderEncryptionPublicKeys { + if senderEncryptionPublicKey == nostr.ZeroPK { + continue + } + switch s { case 0: - log("- trying the sender's decoupled encryption public key %s\n", color.CyanString(senderEncryptionPublicKey.Hex())) + log("- trying sender's decoupled encryption public key %s\n", color.CyanString(senderEncryptionPublicKey.Hex())) case 1: - log("- trying the sender's identity public key %s\n", color.CyanString(senderEncryptionPublicKey.Hex())) + log("- trying sender's identity public key %s\n", color.CyanString(senderEncryptionPublicKey.Hex())) } rumorj, thisErr := cipher.Decrypt(ctx, seal.Content, senderEncryptionPublicKey) diff --git a/helpers.go b/helpers.go index cee604f..1151591 100644 --- a/helpers.go +++ b/helpers.go @@ -86,7 +86,9 @@ func getJsonsOrBlank() iter.Seq[string] { }) if !hasStdin { - yield("{}") + if !yield("{}") { + return + } } if finalJsonErr != nil { @@ -105,7 +107,9 @@ func getStdinLinesOrBlank() iter.Seq[string] { }) if !hasStdin { - yield("") + if !yield("") { + return + } } } }