Documentation ¶
Index ¶
- type Decryption
- func (s Decryption) Decrypt(ephemeralKey, mac, ciphertext []byte) ([]byte, error)
- func (a Decryption) Pickle(key []byte) ([]byte, error)
- func (a Decryption) PickleAsJSON(key []byte) ([]byte, error)
- func (a Decryption) PickleLen() int
- func (a Decryption) PickleLibOlm(target []byte) (int, error)
- func (s Decryption) PrivateKey() crypto.Curve25519PrivateKey
- func (s Decryption) PublicKey() id.Curve25519
- func (a *Decryption) Unpickle(pickled, key []byte) error
- func (a *Decryption) UnpickleAsJSON(pickled, key []byte) error
- func (a *Decryption) UnpickleLibOlm(value []byte) (int, error)
- type Encryption
- type Signing
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Decryption ¶
type Decryption struct {
KeyPair crypto.Curve25519KeyPair `json:"key_pair"`
}
Decryption is used to decrypt pk messages
func NewDecryption ¶
func NewDecryption() (*Decryption, error)
NewDecryption returns a new Decryption with a new generated key pair.
func NewDecryptionFromPrivate ¶
func NewDecryptionFromPrivate(privateKey crypto.Curve25519PrivateKey) (*Decryption, error)
NewDescriptionFromPrivate resturns a new Decryption with the private key fixed.
func (Decryption) Decrypt ¶
func (s Decryption) Decrypt(ephemeralKey, mac, ciphertext []byte) ([]byte, error)
Decrypt decrypts the ciphertext and verifies the MAC. The base64 encoded key is used to construct the shared secret.
func (Decryption) Pickle ¶
func (a Decryption) Pickle(key []byte) ([]byte, error)
Pickle returns a base64 encoded and with key encrypted pickled Decryption using PickleLibOlm().
func (Decryption) PickleAsJSON ¶
func (a Decryption) PickleAsJSON(key []byte) ([]byte, error)
PickleAsJSON returns an Decryption as a base64 string encrypted using the supplied key. The unencrypted representation of the Account is in JSON format.
func (Decryption) PickleLen ¶
func (a Decryption) PickleLen() int
PickleLen returns the number of bytes the pickled Decryption will have.
func (Decryption) PickleLibOlm ¶
func (a Decryption) PickleLibOlm(target []byte) (int, error)
PickleLibOlm encodes the Decryption into target. target has to have a size of at least PickleLen() and is written to from index 0. It returns the number of bytes written.
func (Decryption) PrivateKey ¶
func (s Decryption) PrivateKey() crypto.Curve25519PrivateKey
PrivateKey returns the private key.
func (Decryption) PublicKey ¶ added in v0.18.0
func (s Decryption) PublicKey() id.Curve25519
PublicKey returns the public key base 64 encoded.
func (*Decryption) Unpickle ¶
func (a *Decryption) Unpickle(pickled, key []byte) error
Unpickle decodes the base64 encoded string and decrypts the result with the key. The decrypted value is then passed to UnpickleLibOlm.
func (*Decryption) UnpickleAsJSON ¶
func (a *Decryption) UnpickleAsJSON(pickled, key []byte) error
UnpickleAsJSON updates an Decryption by a base64 encrypted string using the supplied key. The unencrypted representation has to be in JSON format.
func (*Decryption) UnpickleLibOlm ¶
func (a *Decryption) UnpickleLibOlm(value []byte) (int, error)
UnpickleLibOlm decodes the unencryted value and populates the Decryption accordingly. It returns the number of bytes read.
type Encryption ¶
type Encryption struct {
RecipientKey crypto.Curve25519PublicKey `json:"recipient_key"`
}
Encryption is used to encrypt pk messages
func NewEncryption ¶
func NewEncryption(pubKey id.Curve25519) (*Encryption, error)
NewEncryption returns a new Encryption with the base64 encoded public key of the recipient
func (Encryption) Encrypt ¶
func (e Encryption) Encrypt(plaintext []byte, privateKey crypto.Curve25519PrivateKey) (ciphertext, mac []byte, err error)
Encrypt encrypts the plaintext with the privateKey and returns the ciphertext and base64 encoded MAC.
type Signing ¶
type Signing struct {
// contains filtered or unexported fields
}
Signing is used for signing a pk
func NewSigning ¶
NewSigning returns a Signing based on a random seed
func NewSigningFromSeed ¶
NewSigningFromSeed constructs a new Signing based on a seed.