Documentation ¶
Index ¶
- Constants
- Variables
- func DecodeAddress(address string) (*ecdsa.PublicKey, error)
- func DecodePemToPrivateKey(block *pem.Block, password *string) (*ecdsa.PrivateKey, error)
- func DecodePemToPublicKey(block *pem.Block, password *string) (*ecdsa.PublicKey, error)
- func Decrypt(priv *ecdsa.PrivateKey, data []byte) ([]byte, error)
- func DeserializePrivateKey(privBytes []byte) (*ecdsa.PrivateKey, error)
- func DeserializePublicKey(pubBytes []byte) (*ecdsa.PublicKey, error)
- func EncodeAddress(pub *ecdsa.PublicKey) (string, error)
- func EncodePrivateKeyToPem(priv *ecdsa.PrivateKey, password *string) (*pem.Block, error)
- func EncodePublicKeyToPem(pub *ecdsa.PublicKey, password *string) (*pem.Block, error)
- func Encrypt(pub *ecdsa.PublicKey, data []byte) ([]byte, error)
- func GetPublicKey(priv *ecdsa.PrivateKey) (*ecdsa.PublicKey, error)
- func NewKeyPair() (*ecdsa.PrivateKey, *ecdsa.PublicKey, error)
- func NewPrivateKey() (*ecdsa.PrivateKey, error)
- func PublicKeyFromBytes(pub []byte) (*ecdsa.PublicKey, error)
- func PublicKeyToBytes(pub *ecdsa.PublicKey) ([]byte, error)
- func ReadKeyPairFromPem(fileName string, password *string) (*ecdsa.PrivateKey, *ecdsa.PublicKey, error)
- func ReadPrivateKeyFromPem(fileName string, password *string) (*ecdsa.PrivateKey, error)
- func ReadPublicKeyFromPem(fileName string, password *string) (*ecdsa.PublicKey, error)
- func SerializePrivateKey(priv *ecdsa.PrivateKey) ([]byte, error)
- func SerializePublicKey(pub *ecdsa.PublicKey) ([]byte, error)
- func Sign(priv *ecdsa.PrivateKey, data []byte) (*big.Int, *big.Int, error)
- func Verify(pub *ecdsa.PublicKey, data []byte, r, s *big.Int) (bool, error)
- func WriteKeyPairToPem(priv *ecdsa.PrivateKey, pub *ecdsa.PublicKey, password *string, ...) error
- func WritePrivateKeyToPemFile(priv *ecdsa.PrivateKey, password *string, fileName string) error
- func WritePublicKeyToPemFile(pub *ecdsa.PublicKey, password *string, fileName string) error
Constants ¶
View Source
const ( // EncryptionCipher ... EncryptionCipher = x509.PEMCipherAES256 // PrivateKeyPEMType ... PrivateKeyPEMType = "ECDSA PRIVATE KEY" // PublicKeyPEMType ... PublicKeyPEMType = "ECDSA PUBLIC KEY" )
Variables ¶
View Source
var ( // ErrNilPrivateKey ... ErrNilPrivateKey = errors.New("private key is nil") // ErrNilPublicKey ... ErrNilPublicKey = errors.New("public key is nil") // ErrNilData ... ErrNilData = errors.New("data is nil") // ErrNilSigParams ... ErrNilSigParams = errors.New("r and s params cannot be nil") // ErrInvalidPublicKey ... ErrInvalidPublicKey = errors.New("invalid public key") // ErrGeneratingECIESPublicKey ... ErrGeneratingECIESPublicKey = errors.New("could not generate ecies public key from ecda public key") // ErrGeneratingECIESPrivateKey ... ErrGeneratingECIESPrivateKey = errors.New("could not generate ecies private key from ecdsa private key") // ErrGeneratingECDSAPublicKey ... ErrGeneratingECDSAPublicKey = errors.New("could not generate ecdsa public key from ecdsa private key") // ErrNotECDSAPubKey ... ErrNotECDSAPubKey = errors.New("not an ecdsa public key") // Curve ... Curve = elliptic.P256() )
Functions ¶
func DecodeAddress ¶
DecodeAddress [for now] decodes public address hex to ECDSA public key. Public key are treated as public address at the moment.
func DecodePemToPrivateKey ¶
DecodePemToPrivateKey ...
func DecodePemToPublicKey ¶
DecodePemToPublicKey ...
func DeserializePrivateKey ¶
func DeserializePrivateKey(privBytes []byte) (*ecdsa.PrivateKey, error)
DeserializePrivateKey ...
func DeserializePublicKey ¶
DeserializePublicKey ...
func EncodePrivateKeyToPem ¶
EncodePrivateKeyToPem ... note password is optional
func EncodePublicKeyToPem ¶
EncodePublicKeyToPem ... note: password is optional
func GetPublicKey ¶
func GetPublicKey(priv *ecdsa.PrivateKey) (*ecdsa.PublicKey, error)
GetPublicKey ...
func PublicKeyFromBytes ¶
PublicKeyFromBytes ...
func PublicKeyToBytes ¶
PublicKeyToBytes ...
func ReadKeyPairFromPem ¶
func ReadKeyPairFromPem(fileName string, password *string) (*ecdsa.PrivateKey, *ecdsa.PublicKey, error)
ReadKeyPairFromPem ...
func ReadPrivateKeyFromPem ¶
func ReadPrivateKeyFromPem(fileName string, password *string) (*ecdsa.PrivateKey, error)
ReadPrivateKeyFromPem ...
func ReadPublicKeyFromPem ¶
ReadPublicKeyFromPem ...
func SerializePrivateKey ¶
func SerializePrivateKey(priv *ecdsa.PrivateKey) ([]byte, error)
SerializePrivateKey ...
func SerializePublicKey ¶
SerializePublicKey ...
func WriteKeyPairToPem ¶
func WriteKeyPairToPem(priv *ecdsa.PrivateKey, pub *ecdsa.PublicKey, password *string, fileName string) error
WriteKeyPairToPem ...
func WritePrivateKeyToPemFile ¶
func WritePrivateKeyToPemFile(priv *ecdsa.PrivateKey, password *string, fileName string) error
WritePrivateKeyToPemFile ...
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.