crypto

package
v0.26.0-alpha.33 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2019 License: MPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecryptSymmetric

func DecryptSymmetric(key []byte, cyphertext []byte) ([]byte, error)

func EncryptSymmetric

func EncryptSymmetric(key, plaintext []byte) ([]byte, error)

func ExtractSignatures added in v0.16.3

func ExtractSignatures(signaturePairs [][2]string) ([]string, error)

ExtractSignatures extract from tuples of signatures content a public key

func Sign

func Sign(content string, identity *ecdsa.PrivateKey) (string, error)

Sign signs the hash of an arbitrary string

func VerifySignatures

func VerifySignatures(signaturePairs [][3]string) error

VerifySignatures verifys tuples of signatures content/hash/public key

Types

type DHPair

type DHPair struct {
	PrvKey dr.Key
	PubKey dr.Key
}

func (DHPair) PrivateKey

func (p DHPair) PrivateKey() dr.Key

func (DHPair) PublicKey

func (p DHPair) PublicKey() dr.Key

type EthereumCrypto

type EthereumCrypto struct{}

EthereumCrypto is an implementation of Crypto with cryptographic primitives recommended by the Double Ratchet Algorithm specification. However, some details are different, see function comments for details.

func (EthereumCrypto) DH

func (c EthereumCrypto) DH(dhPair dr.DHPair, dhPub dr.Key) dr.Key

See the Crypto interface.

func (EthereumCrypto) Decrypt

func (c EthereumCrypto) Decrypt(mk dr.Key, authCiphertext, ad []byte) ([]byte, error)

See the Crypto interface.

func (EthereumCrypto) Encrypt

func (c EthereumCrypto) Encrypt(mk dr.Key, plaintext, ad []byte) []byte

Encrypt uses a slightly different approach than in the algorithm specification: it uses AES-256-CTR instead of AES-256-CBC for security, ciphertext length and implementation complexity considerations.

func (EthereumCrypto) GenerateDH

func (c EthereumCrypto) GenerateDH() (dr.DHPair, error)

See the Crypto interface.

func (EthereumCrypto) KdfCK

func (c EthereumCrypto) KdfCK(ck dr.Key) (chainKey dr.Key, msgKey dr.Key)

See the Crypto interface.

func (EthereumCrypto) KdfRK

func (c EthereumCrypto) KdfRK(rk, dhOut dr.Key) (rootKey, chainKey, headerKey dr.Key)

See the Crypto interface.

Jump to

Keyboard shortcuts

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