Documentation ¶
Index ¶
- func Decrypt(data []byte, priv *PrivateKey, ecdh ECDH, kdf KDF) ([]byte, error)
- func DecryptBase64(ciphertext string, priv *PrivateKey, ecdh ECDH, kdf KDF) ([]byte, error)
- func DecryptBase64String(ciphertext string, priv *PrivateKey, ecdh ECDH, kdf KDF) (string, error)
- func DecryptHex(ciphertext string, priv *PrivateKey, ecdh ECDH, kdf KDF) ([]byte, error)
- func DecryptHexString(ciphertext string, priv *PrivateKey, ecdh ECDH, kdf KDF) (string, error)
- func Encrypt(data []byte, pub *PublicKey, ecdh ECDH, kdf KDF) ([]byte, error)
- func EncryptStringToBase64(plaintext string, pub *PublicKey, ecdh ECDH, kdf KDF) (string, error)
- func EncryptStringToHex(plaintext string, pub *PublicKey, ecdh ECDH, kdf KDF) (string, error)
- func EncryptToBase64(data []byte, pub *PublicKey, ecdh ECDH, kdf KDF) (string, error)
- func EncryptToHex(data []byte, pub *PublicKey, ecdh ECDH, kdf KDF) (string, error)
- type ECDH
- type KDF
- type Point
- type PrivateKey
- func GenerateKey(curve elliptic.Curve) (*PrivateKey, error)
- func PrivateKeyFromBase64(base64Key string, curve elliptic.Curve) (*PrivateKey, error)
- func PrivateKeyFromBytes(b []byte, curve elliptic.Curve) *PrivateKey
- func PrivateKeyFromHex(hexKey string, curve elliptic.Curve) (*PrivateKey, error)
- func PrivateKeyFromPEMBytes(bytes []byte) (*PrivateKey, error)
- func PrivateKeyFromPEMFile(file string) (*PrivateKey, error)
- func PrivateKeyFromPEMString(str string) (*PrivateKey, error)
- type PublicKey
- func PublicKeyFromBase64(base64Key string, curve elliptic.Curve) (*PublicKey, error)
- func PublicKeyFromBytes(b []byte, curve elliptic.Curve) (*PublicKey, error)
- func PublicKeyFromHex(hexKey string, curve elliptic.Curve) (*PublicKey, error)
- func PublicKeyFromPEMBytes(bytes []byte) (*PublicKey, error)
- func PublicKeyFromPEMFile(path string) (*PublicKey, error)
- func PublicKeyFromPEMString(pemString string) (*PublicKey, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecryptBase64 ¶ added in v0.3.1
DecryptBase64 decrypts ciphertext in base64 form to raw data([]byte) by receiver private key
func DecryptBase64String ¶ added in v0.2.0
DecryptBase64String decrypts ciphertext in base64 form to plaintext by receiver private key
func DecryptHex ¶ added in v0.3.1
DecryptHex decrypts ciphertext in hex form to raw data([]byte) by receiver private key
func DecryptHexString ¶ added in v0.2.0
DecryptHexString decrypts ciphertext in hex form to plaintext by receiver private key
func EncryptStringToBase64 ¶ added in v0.2.0
EncryptStringToBase64 encrypts plaintext to ciphertext in base64 form using receiver public key
func EncryptStringToHex ¶ added in v0.2.0
EncryptStringToHex encrypts plaintext to ciphertext in hex form using receiver public key
func EncryptToBase64 ¶ added in v0.3.1
EncryptToBase64 encrypts data to ciphertext in base64 form using receiver public key
Types ¶
type ECDH ¶ added in v0.2.0
type ECDH func(priv *PrivateKey, pub *PublicKey) (masterSecret []byte)
ECDH calculates a master secret from a private key & a public key. Its output will be passed to a KDF for deriving the encryption key.
type PrivateKey ¶
type PrivateKey struct { Pub *PublicKey // contains filtered or unexported fields }
PrivateKey ...
func GenerateKey ¶
func GenerateKey(curve elliptic.Curve) (*PrivateKey, error)
GenerateKey generates a new elliptic curve key pair
func PrivateKeyFromBase64 ¶ added in v0.2.0
func PrivateKeyFromBase64(base64Key string, curve elliptic.Curve) (*PrivateKey, error)
PrivateKeyFromBase64 parses a private key from its base64 form
func PrivateKeyFromBytes ¶
func PrivateKeyFromBytes(b []byte, curve elliptic.Curve) *PrivateKey
PrivateKeyFromBytes parses a private key from its raw bytes
func PrivateKeyFromHex ¶
func PrivateKeyFromHex(hexKey string, curve elliptic.Curve) (*PrivateKey, error)
PrivateKeyFromHex parses a private key from its hex form
func PrivateKeyFromPEMBytes ¶ added in v0.3.3
func PrivateKeyFromPEMBytes(bytes []byte) (*PrivateKey, error)
PrivateKeyFromPEMBytes parses a private key from a PEM bytes
func PrivateKeyFromPEMFile ¶ added in v0.3.3
func PrivateKeyFromPEMFile(file string) (*PrivateKey, error)
PrivateKeyFromPEMFile parses a private key from a PEM file
func PrivateKeyFromPEMString ¶ added in v0.3.3
func PrivateKeyFromPEMString(str string) (*PrivateKey, error)
PrivateKeyFromPEMString parses a private key from a PEM string
func (*PrivateKey) Base64 ¶ added in v0.2.0
func (priv *PrivateKey) Base64() string
Base64 returns private key bytes in base64 form
func (*PrivateKey) Bytes ¶
func (priv *PrivateKey) Bytes() []byte
Bytes returns private key raw bytes
func (*PrivateKey) Hex ¶
func (priv *PrivateKey) Hex() string
Hex returns private key bytes in hex form
func (*PrivateKey) PEM ¶ added in v0.3.3
func (priv *PrivateKey) PEM() string
PEM returns private key in PEM form - string
func (*PrivateKey) SavePEMFile ¶ added in v0.3.3
func (priv *PrivateKey) SavePEMFile(file string) error
SavePEMFile saves private key to a PEM file
func (*PrivateKey) ToPEM ¶ added in v0.3.3
func (priv *PrivateKey) ToPEM() []byte
ToPEM returns private key in PEM form - bytes
type PublicKey ¶
type PublicKey struct { *Point // contains filtered or unexported fields }
PublicKey ...
func PublicKeyFromBase64 ¶ added in v0.2.0
PublicKeyFromBase64 parses a public key from its base64 form
func PublicKeyFromBytes ¶
PublicKeyFromBytes parses a public key from its uncompressed raw bytes
func PublicKeyFromHex ¶
PublicKeyFromHex parses a public key from its hex form
func PublicKeyFromPEMBytes ¶ added in v0.3.3
PublicKeyFromPEMBytes parses a public key from its PEM form
func PublicKeyFromPEMFile ¶ added in v0.3.3
PublicKeyFromPEMFile parses a public key from a PEM file
func PublicKeyFromPEMString ¶ added in v0.3.3
PublicKeyFromPEMString parses a public key from a PEM string
func (*PublicKey) Bytes ¶
Bytes returns the public key to raw bytes in uncompressed format (Ox04|x|y) https://secg.org/sec1-v2.pdf#subsubsection.2.3.3
func (*PublicKey) SaveToPEMFile ¶ added in v0.3.3
SaveToPEMFile saves the public key to a PEM file
func (*PublicKey) ScalarMult ¶ added in v0.3.0
func (pub *PublicKey) ScalarMult(priv *PrivateKey) *Point
ScalarMult returns publicKey * privateKey