(data []byte, key NyPublicKey)
| 22 | } |
| 23 | |
| 24 | func VerifyBundle(data []byte, key NyPublicKey) ([]byte, error) { |
| 25 | if len(data) < x25519.SignatureSize { |
| 26 | return nil, errors.New("invalid signature: too short") |
| 27 | } |
| 28 | signature := data[:x25519.SignatureSize] |
| 29 | plainText := data[x25519.SignatureSize:] |
| 30 | if !x25519.Verify(key[:], plainText, signature) { |
| 31 | return nil, errors.New("invalid signature") |
| 32 | } |
| 33 | return plainText, nil |
| 34 | } |
| 35 | |
| 36 | func SealBundle(data []byte, key []byte) ([]byte, error) { |
| 37 | ahead, err := chacha20poly1305.NewX(key[:]) |