Versions in this module Expand all Collapse all v0 v0.29.0 Jul 29, 2023 Changes in this version + const ECDSA + const Ed25519 + const RSA + const Secp256k1 + const WeakRsaKeyEnv + var ECDSACurve = elliptic.P256() + var ErrBadKeyType = errors.New("invalid or unsupported key type") + var ErrNilPrivateKey = errors.New("private key is nil") + var ErrNilPublicKey = errors.New("public key is nil") + var ErrNilSig = errors.New("sig is nil") + var ErrNotECDSAPubKey = errors.New("not an ecdsa public key") + var ErrRsaKeyTooSmall error + var KeyTypes = []int + var MinRsaKeyBits = 2048 + var PrivKeyUnmarshallers = map[pb.KeyType]PrivKeyUnmarshaller + var PubKeyUnmarshallers = map[pb.KeyType]PubKeyUnmarshaller + func ConfigDecodeKey(b string) ([]byte, error) + func ConfigEncodeKey(b []byte) string + func ECDSAKeyPairFromKey(priv *ecdsa.PrivateKey) (PrivKey, PubKey, error) + func GenerateECDSAKeyPair(src io.Reader) (PrivKey, PubKey, error) + func GenerateECDSAKeyPairWithCurve(curve elliptic.Curve, src io.Reader) (PrivKey, PubKey, error) + func GenerateEd25519Key(src io.Reader) (PrivKey, PubKey, error) + func GenerateKeyPair(typ, bits int) (PrivKey, PubKey, error) + func GenerateKeyPairWithReader(typ, bits int, src io.Reader) (PrivKey, PubKey, error) + func GenerateRSAKeyPair(bits int, src io.Reader) (PrivKey, PubKey, error) + func GenerateSecp256k1Key(src io.Reader) (PrivKey, PubKey, error) + func KeyEqual(k1, k2 Key) bool + func KeyPairFromStdKey(priv crypto.PrivateKey) (PrivKey, PubKey, error) + func MarshalECDSAPrivateKey(ePriv ECDSAPrivateKey) (res []byte, err error) + func MarshalECDSAPublicKey(ePub ECDSAPublicKey) (res []byte, err error) + func MarshalPrivateKey(k PrivKey) ([]byte, error) + func MarshalPublicKey(k PubKey) ([]byte, error) + func PrivKeyToStdKey(priv PrivKey) (crypto.PrivateKey, error) + func PubKeyToStdKey(pub PubKey) (crypto.PublicKey, error) + func PublicKeyToProto(k PubKey) (*pb.PublicKey, error) + type ECDSAPrivateKey struct + func (ePriv *ECDSAPrivateKey) Equals(o Key) bool + func (ePriv *ECDSAPrivateKey) GetPublic() PubKey + func (ePriv *ECDSAPrivateKey) Raw() (res []byte, err error) + func (ePriv *ECDSAPrivateKey) Sign(data []byte) (sig []byte, err error) + func (ePriv *ECDSAPrivateKey) Type() pb.KeyType + type ECDSAPublicKey struct + func (ePub *ECDSAPublicKey) Equals(o Key) bool + func (ePub *ECDSAPublicKey) Raw() ([]byte, error) + func (ePub *ECDSAPublicKey) Type() pb.KeyType + func (ePub *ECDSAPublicKey) Verify(data, sigBytes []byte) (success bool, err error) + type ECDSASig struct + R *big.Int + S *big.Int + type Ed25519PrivateKey struct + func (k *Ed25519PrivateKey) Equals(o Key) bool + func (k *Ed25519PrivateKey) GetPublic() PubKey + func (k *Ed25519PrivateKey) Raw() ([]byte, error) + func (k *Ed25519PrivateKey) Sign(msg []byte) (res []byte, err error) + func (k *Ed25519PrivateKey) Type() pb.KeyType + type Ed25519PublicKey struct + func (k *Ed25519PublicKey) Equals(o Key) bool + func (k *Ed25519PublicKey) Raw() ([]byte, error) + func (k *Ed25519PublicKey) Type() pb.KeyType + func (k *Ed25519PublicKey) Verify(data []byte, sig []byte) (success bool, err error) + type GenSharedKey func([]byte) ([]byte, error) + func GenerateEKeyPair(curveName string) ([]byte, GenSharedKey, error) + type Key interface + Equals func(Key) bool + Raw func() ([]byte, error) + Type func() pb.KeyType + type PrivKey interface + GetPublic func() PubKey + Sign func([]byte) ([]byte, error) + func UnmarshalECDSAPrivateKey(data []byte) (res PrivKey, err error) + func UnmarshalEd25519PrivateKey(data []byte) (PrivKey, error) + func UnmarshalPrivateKey(data []byte) (PrivKey, error) + func UnmarshalRsaPrivateKey(b []byte) (key PrivKey, err error) + func UnmarshalSecp256k1PrivateKey(data []byte) (k PrivKey, err error) + type PrivKeyUnmarshaller func(data []byte) (PrivKey, error) + type PubKey interface + Verify func(data []byte, sig []byte) (bool, error) + func ECDSAPublicKeyFromPubKey(pub ecdsa.PublicKey) (PubKey, error) + func PublicKeyFromProto(pmes *pb.PublicKey) (PubKey, error) + func UnmarshalECDSAPublicKey(data []byte) (key PubKey, err error) + func UnmarshalEd25519PublicKey(data []byte) (PubKey, error) + func UnmarshalPublicKey(data []byte) (PubKey, error) + func UnmarshalRsaPublicKey(b []byte) (key PubKey, err error) + func UnmarshalSecp256k1PublicKey(data []byte) (_k PubKey, err error) + type PubKeyUnmarshaller func(data []byte) (PubKey, error) + type RsaPrivateKey struct + func (sk *RsaPrivateKey) Equals(k Key) bool + func (sk *RsaPrivateKey) GetPublic() PubKey + func (sk *RsaPrivateKey) Raw() (res []byte, err error) + func (sk *RsaPrivateKey) Sign(message []byte) (sig []byte, err error) + func (sk *RsaPrivateKey) Type() pb.KeyType + type RsaPublicKey struct + func (pk *RsaPublicKey) Equals(k Key) bool + func (pk *RsaPublicKey) Raw() (res []byte, err error) + func (pk *RsaPublicKey) Type() pb.KeyType + func (pk *RsaPublicKey) Verify(data, sig []byte) (success bool, err error) + type Secp256k1PrivateKey secp256k1.PrivateKey + func (k *Secp256k1PrivateKey) Equals(o Key) bool + func (k *Secp256k1PrivateKey) GetPublic() PubKey + func (k *Secp256k1PrivateKey) Raw() ([]byte, error) + func (k *Secp256k1PrivateKey) Sign(data []byte) (_sig []byte, err error) + func (k *Secp256k1PrivateKey) Type() pb.KeyType + type Secp256k1PublicKey secp256k1.PublicKey + func (k *Secp256k1PublicKey) Equals(o Key) bool + func (k *Secp256k1PublicKey) Raw() (res []byte, err error) + func (k *Secp256k1PublicKey) Type() pb.KeyType + func (k *Secp256k1PublicKey) Verify(data []byte, sigStr []byte) (success bool, err error)