crypto

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 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 ExtractSignature added in v0.4.0

func ExtractSignature(data, signature []byte) (*ecdsa.PublicKey, error)

ExtractSignature returns a public key for a given data and signature.

func ExtractSignatures

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

ExtractSignatures extract from tuples of signatures content a public key DEPRECATED: use ExtractSignature

func Sign

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

Sign signs the hash of arbitrary data. DEPRECATED: use SignStringAsHex instead.

func SignBytes added in v0.3.0

func SignBytes(data []byte, identity *ecdsa.PrivateKey) ([]byte, error)

SignBytes signs the hash of arbitrary data.

func SignBytesAsHex added in v0.3.0

func SignBytesAsHex(data []byte, identity *ecdsa.PrivateKey) (string, error)

SignStringAsHex signs the Keccak256 hash of arbitrary data and returns its hex representation.

func SignStringAsHex added in v0.3.0

func SignStringAsHex(data string, identity *ecdsa.PrivateKey) (string, error)

SignStringAsHex signs the Keccak256 hash of arbitrary string and returns its hex representation.

func VerifySignatures

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

VerifySignatures verifies 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, error)

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, error)

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) (dr.Key, dr.Key)

See the Crypto interface.

func (EthereumCrypto) KdfRK

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

See the Crypto interface.

Jump to

Keyboard shortcuts

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