plugin: build tag EncodeX25519Recipient which uses crypto/ecdh

This commit is contained in:
Filippo Valsorda
2023-08-06 18:36:38 +02:00
parent 9fd564d543
commit f1f96c25e0
2 changed files with 24 additions and 11 deletions
-11
View File
@@ -5,7 +5,6 @@
package plugin
import (
"crypto/ecdh"
"fmt"
"strings"
@@ -54,13 +53,3 @@ func ParseRecipient(s string) (name string, data []byte, err error) {
name = strings.TrimPrefix(hrp, "age1")
return name, data, nil
}
// EncodeX25519Recipient encodes a native X25519 recipient from a
// [crypto/ecdh.X25519] public key. It's meant for plugins that implement
// identities that are compatible with native recipients.
func EncodeX25519Recipient(pk *ecdh.PublicKey) (string, error) {
if pk.Curve() != ecdh.X25519() {
return "", fmt.Errorf("wrong ecdh Curve")
}
return bech32.Encode("age", pk.Bytes())
}