MCPcopy
hub / github.com/FiloSottile/age / ParseX25519Recipient

Function ParseX25519Recipient

x25519.go:50–63  ·  view source on GitHub ↗

ParseX25519Recipient returns a new X25519Recipient from a Bech32 public key encoding with the "age1" prefix.

(s string)

Source from the content-addressed store, hash-verified

48// ParseX25519Recipient returns a new X25519Recipient from a Bech32 public key
49// encoding with the "age1" prefix.
50func ParseX25519Recipient(s string) (*X25519Recipient, error) {
51 t, k, err := bech32.Decode(s)
52 if err != nil {
53 return nil, fmt.Errorf("malformed recipient %q: %v", s, err)
54 }
55 if t != "age" {
56 return nil, fmt.Errorf("malformed recipient %q: invalid type %q", s, t)
57 }
58 r, err := newX25519RecipientFromPoint(k)
59 if err != nil {
60 return nil, fmt.Errorf("malformed recipient %q: %v", s, err)
61 }
62 return r, nil
63}
64
65func (r *X25519Recipient) Wrap(fileKey []byte) ([]*Stanza, error) {
66 ephemeral := make([]byte, curve25519.ScalarSize)

Callers 5

TestX25519RoundTripFunction · 0.92
ExampleEncryptFunction · 0.92
ExampleNewWriterFunction · 0.92
parseRecipientFunction · 0.92
parseRecipientFunction · 0.85

Calls 2

DecodeFunction · 0.92

Tested by 3

TestX25519RoundTripFunction · 0.74
ExampleEncryptFunction · 0.74
ExampleNewWriterFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…