pk

package
v0.17.0-mod-1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 31, 2024 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

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(ciphertext, mac []byte, key id.Curve25519) ([]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) PubKey

func (s Decryption) PubKey() id.Curve25519

PubKey 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 {
	KeyPair crypto.Ed25519KeyPair `json:"key_pair"`
	Seed    []byte                `json:"seed"`
}

Signing is used for signing a pk

func NewSigning

func NewSigning() (*Signing, error)

NewSigning returns a Signing based on a random seed

func NewSigningFromSeed

func NewSigningFromSeed(seed []byte) (*Signing, error)

NewSigningFromSeed constructs a new Signing based on a seed.

func (Signing) PublicKey

func (s Signing) PublicKey() id.Ed25519

PublicKey returns the public key of the key pair base 64 encoded.

func (Signing) Sign

func (s Signing) Sign(message []byte) []byte

Sign returns the signature of the message base64 encoded.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL