mailchain: Index | Files | Directories

package crypto

import ""

go:generate mockgen -source=private.go -package=cryptotest -destination=./cryptotest/private_mock.go

go:generate mockgen -source=public.go -package=cryptotest -destination=./cryptotest/public_mock.go


Package Files

hash.go keys.go private.go public.go


const (
    // KindSECP256K1 string identifier for secp256k1 keys.
    KindSECP256K1 = "secp256k1"
    // KindED25519 string identifier for ed25519 keys.
    KindED25519 = "ed25519"
    // KindSR25519 string identifier for sr25519 keys.
    KindSR25519 = "sr25519"
const (
    // ByteSECP256K1 byte identifier for secp256k1 keys.
    ByteSECP256K1 = 0xe1
    // ByteED25519 byte identifier for ed25519 keys.
    ByteED25519 = 0xe2
    // ByteSR25519 byte identifier for sr25519 keys.
    ByteSR25519 = 0xe3

func CreateIntegrityHash Uses

func CreateIntegrityHash(encryptedData []byte) multihash.Multihash

CreateIntegrityHash returns a hash of the encrypted `[]byte` to allow easy checking it has not been tampered with.

func CreateMessageHash Uses

func CreateMessageHash(encodedData []byte) multihash.Multihash

CreateMessageHash used to verify if the contents of the message match the hash.

func KeyTypes Uses

func KeyTypes() map[string]bool

KeyTypes available key types.

type PrivateKey Uses

type PrivateKey interface {
    // Bytes returns the byte representation of the private key
    Bytes() []byte
    // PublicKey from the PrivateKey
    PublicKey() PublicKey
    // Kind returns the type of the key
    Kind() string
    // Sign signs the message with the key and returns the signature.
    Sign(message []byte) ([]byte, error)

PrivateKey definition usable in all mailchain crypto operations

type PublicKey Uses

type PublicKey interface {
    // Bytes returns the raw bytes representation of the public key.
    // The returned bytes are used for encrypting, verifying a signature, and locating an address.
    Bytes() []byte
    // Kind returns the type of the key.
    Kind() string
    // Verify verifies whether sig is a valid signature of message.
    Verify(message, sig []byte) bool

PublicKey definition usable in all mailchain crypto operations


cipherPackage cipher collects common cryptographic constants and interfaces.
cipher/aes256cbcPackage aes256cbc implements Advanced Encryption Standard with a 256 bit key length, using Chain Block Cipher mode (AES-256-CBC).
cipher/ciphertestPackage ciphertest is a generated GoMock package.
cipher/ecdhPackage ecdh has implementations for different asymmetric key exchange.
cipher/noopPackage noop is a no operation encryption algorithm for use when the message is intended to be publically readable.
cryptotestPackage cryptotest is a generated GoMock package.

Package crypto imports 1 packages (graph) and is imported by 33 packages. Updated 2020-02-19. Refresh now. Tools for package owners.