crypto

package
v1.28.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2023 License: LGPL-3.0 Imports: 3 Imported by: 23

Documentation

Index

Constants

View Source
const (
	AES = iota
	ThirdDES
	RSA
	Secp256k1
	ECDSA_P256
	ECDSA_P384
	ECDSA_P521
	SM2
	Ed25519
)

Variables

View Source
var CryptoNameType = map[string]KeyType{
	"AES":        AES,
	"ThirdDES":   ThirdDES,
	"RSA":        RSA,
	"Secp256k1":  Secp256k1,
	"ECDSA_P256": ECDSA_P256,
	"ECDSA_P384": ECDSA_P384,
	"ECDSA_P521": ECDSA_P521,
	"SM2":        SM2,
	"Ed25519":    Ed25519,
}

Functions

This section is empty.

Types

type CipherKey added in v1.0.1

type CipherKey struct {
	Data   string `json:"data"`
	Cipher string `json:"cipher"`
}

type Key

type Key interface {
	// Bytes returns a serialized, storable representation of this key
	Bytes() ([]byte, error)

	// Type represent the type of key
	Type() KeyType
}

type KeyStore added in v1.0.1

type KeyStore struct {
	Type   KeyType    `json:"type"`
	Cipher *CipherKey `json:"cipher"`
}

func (*KeyStore) Pretty added in v1.0.1

func (key *KeyStore) Pretty() (string, error)

type KeyType added in v1.0.1

type KeyType int

func CryptoNameToType added in v1.20.0

func CryptoNameToType(name string) (KeyType, error)

type PrivateKey

type PrivateKey interface {
	Key

	// Sign signs digest using key k.
	Sign(digest []byte) ([]byte, error)

	// Return a public key paired with this private key
	PublicKey() PublicKey
}

PrivateKey represents a private key that can be used to generate a public key and sign data

type PublicKey

type PublicKey interface {
	Key

	// Address gets address from public key
	Address() (*types.Address, error)

	// Verify that 'sig' is the signed hash of 'data'
	Verify(digest []byte, sig []byte) (bool, error)
}

PublicKey is a public key that can be used to verify data signed with the corresponding private key

type SymmetricKey

type SymmetricKey interface {
	Key

	// Encrypt encrypts plain text using symmetric key.
	Encrypt(plain []byte) (cipher []byte, err error)

	// Decrypt decrypts ciphertext using symmetric key.
	Decrypt(cipher []byte) (plain []byte, err error)
}

SymmetricKey is a interface that provides symmetric encrypt and decrypt.

Directories

Path Synopsis
ecdsa/secp256k1
Package secp256k1 wraps the bitcoin secp256k1 C library.
Package secp256k1 wraps the bitcoin secp256k1 C library.

Jump to

Keyboard shortcuts

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