ParseX25519Recipient returns a new X25519Recipient from a Bech32 public key encoding with the "age1" prefix.
(s string)
| 48 | // ParseX25519Recipient returns a new X25519Recipient from a Bech32 public key |
| 49 | // encoding with the "age1" prefix. |
| 50 | func 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 | |
| 65 | func (r *X25519Recipient) Wrap(fileKey []byte) ([]*Stanza, error) { |
| 66 | ephemeral := make([]byte, curve25519.ScalarSize) |
searching dependent graphs…