Documentation
¶
Index ¶
- Variables
- func EccDecrypt(cipherText []byte, priKey string) (plainText []byte, err error)
- func EccDecryptByBase64(base64CipherText, base64PriKey string) (plainText []byte, err error)
- func EccDecryptByHex(hexCipherText, hexPriKey string) (plainText []byte, err error)
- func EccEncrypt(plainText []byte, pubKey string) (cipherText []byte, err error)
- func EccEncryptToBase64(plainText []byte, base64PubKey string) (base64CipherText string, err error)
- func EccEncryptToHex(plainText []byte, hexPubKey string) (hexCipherText string, err error)
- func EccSign(msg []byte, priKey string) (hexrSign, hexsSign string, err error)
- func EccSignBase64(msg []byte, base64PriKey string) (base64rSign, base64sSign string, err error)
- func EccSignHex(msg []byte, hexPriKey string) (hexrSign, hexsSign string, err error)
- func EccVerifySign(msg []byte, hexrSign, hexsSign, pubKey string) bool
- func EccVerifySignBase64(msg []byte, base64rSign, base64sSign, base64PubKey string) bool
- func EccVerifySignHex(msg []byte, hexrSign, hexsSign, hexPubKey string) bool
- func Encrypt(rand io.Reader, pub *PublicKey, m, s1, s2 []byte) (ct []byte, err error)
- func MaxSharedKeyLength(pub *PublicKey) int
- type ECIESParams
- type EccKey
- type PrivateKey
- type PublicKey
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidCurve = fmt.Errorf("ecies: invalid elliptic curve") ErrInvalidPublicKey = fmt.Errorf("ecies: invalid public key") ErrUnsupportedECIESParameters = fmt.Errorf("ecies: unsupported ECIES parameters") )
var ( ErrKeyDataTooLong = fmt.Errorf("ecies: can't supply requested key data") ErrInvalidMessage = fmt.Errorf("ecies: invalid message") )
var ( ECIESAes128Sha256 = &ECIESParams{ Hash: sha256.New, hashAlgo: crypto.SHA256, Cipher: aes.NewCipher, BlockSize: aes.BlockSize, KeyLen: 16, } ECIESAes256Sha384 = &ECIESParams{ Hash: sha512.New384, hashAlgo: crypto.SHA384, Cipher: aes.NewCipher, BlockSize: aes.BlockSize, KeyLen: 32, } ECIESAes256Sha512 = &ECIESParams{ Hash: sha512.New, hashAlgo: crypto.SHA512, Cipher: aes.NewCipher, BlockSize: aes.BlockSize, KeyLen: 32, } )
Functions ¶
func EccDecryptByBase64 ¶
func EccDecryptByHex ¶
func EccEncryptToBase64 ¶
func EccEncryptToHex ¶
func EccSignBase64 ¶
func EccSignHex ¶
func EccVerifySign ¶
func EccVerifySignBase64 ¶
func EccVerifySignHex ¶
func Encrypt ¶
Encrypt encrypts a message using ECIES as specified in SEC 1, 5.1.
s1 and s2 contain shared information that is not part of the resulting ciphertext. s1 is fed into key derivation, s2 is fed into the MAC. If the shared information parameters aren't being used, they should be nil.
func MaxSharedKeyLength ¶
MaxSharedKeyLength returns the maximum length of the shared key the public key can produce.
Types ¶
type ECIESParams ¶
type ECIESParams struct { Hash func() hash.Hash // hash function Cipher func([]byte) (cipher.Block, error) // symmetric cipher BlockSize int // block size of symmetric cipher KeyLen int // length of symmetric key // contains filtered or unexported fields }
func ParamsFromCurve ¶
func ParamsFromCurve(curve elliptic.Curve) (params *ECIESParams)
以下为从以太坊源码/crypt/ecies/params.go中截取过来
type PrivateKey ¶
PrivateKey is a representation of an elliptic curve private key.
func GenerateKey ¶
func GenerateKey(rand io.Reader, curve elliptic.Curve, params *ECIESParams) (prv *PrivateKey, err error)
Generate an elliptic curve public / private keypair. If params is nil, the recommended default parameters for the key will be chosen.
func ImportECDSA ¶
func ImportECDSA(prv *ecdsa.PrivateKey) *PrivateKey
Import an ECDSA private key as an ECIES private key.
func (*PrivateKey) Decrypt ¶
func (prv *PrivateKey) Decrypt(c, s1, s2 []byte) (m []byte, err error)
Decrypt decrypts an ECIES ciphertext.
func (*PrivateKey) ExportECDSA ¶
func (prv *PrivateKey) ExportECDSA() *ecdsa.PrivateKey
Export an ECIES private key as an ECDSA private key.
func (*PrivateKey) GenerateShared ¶
func (prv *PrivateKey) GenerateShared(pub *PublicKey, skLen, macLen int) (sk []byte, err error)
ECDH key agreement method used to establish secret keys for encryption.
type PublicKey ¶
PublicKey is a representation of an elliptic curve public key.
func ImportECDSAPublic ¶
Import an ECDSA public key as an ECIES public key.
func (*PublicKey) ExportECDSA ¶
Export an ECIES public key as an ECDSA public key.