pk

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decription

type Decription struct {
	KeyPair crypto.Curve25519KeyPair `json:"keyPair"`
}

Decription is used to decrypt pk messages

func NewDecription

func NewDecription() (*Decription, error)

NewDecription returns a new Decription with a new generated key pair.

func NewDecriptionFromPrivate

func NewDecriptionFromPrivate(privateKey crypto.Curve25519PrivateKey) (*Decription, error)

NewDescriptionFromPrivate resturns a new Decription with the private key fixed.

func (Decription) Decrypt

func (s Decription) 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 (Decription) Pickle

func (a Decription) Pickle(key []byte) ([]byte, error)

Pickle returns a base64 encoded and with key encrypted pickled Decription using PickleLibOlm().

func (Decription) PickleAsJSON

func (a Decription) PickleAsJSON(key []byte) ([]byte, error)

PickleAsJSON returns an Decription as a base64 string encrypted using the supplied key. The unencrypted representation of the Account is in JSON format.

func (Decription) PickleLen

func (a Decription) PickleLen() int

PickleLen returns the number of bytes the pickled Decription will have.

func (Decription) PickleLibOlm

func (a Decription) PickleLibOlm(target []byte) (int, error)

PickleLibOlm encodes the Decription 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 (Decription) PrivateKey

func (s Decription) PrivateKey() crypto.Curve25519PrivateKey

PrivateKey returns the private key.

func (Decription) PubKey

func (s Decription) PubKey() id.Curve25519

PubKey returns the public key base 64 encoded.

func (*Decription) Unpickle

func (a *Decription) 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 (*Decription) UnpickleAsJSON

func (a *Decription) UnpickleAsJSON(pickled, key []byte) error

UnpickleAsJSON updates an Decription by a base64 encrypted string using the supplied key. The unencrypted representation has to be in JSON format.

func (*Decription) UnpickleLibOlm

func (a *Decription) UnpickleLibOlm(value []byte) (int, error)

UnpickleLibOlm decodes the unencryted value and populates the Decription accordingly. It returns the number of bytes read.

type Encryption

type Encryption struct {
	RecipientKey crypto.Curve25519PublicKey
}

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:"keyPair"`
	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