Documentation ¶
Overview ¶
Deprecated: This package has moved into go-libp2p as a sub-package: github.com/libp2p/go-libp2p/core/crypto.
Package crypto implements various cryptographic utilities used by libp2p. This includes a Public and Private key interface and key implementations for supported key algorithms.
Index ¶
- Constants
- Variables
- 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 stdcrypto.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) (stdcrypto.PrivateKey, error)
- func PubKeyToStdKey(pub PubKey) (stdcrypto.PublicKey, error)
- func PublicKeyToProto(k PubKey) (*pb.PublicKey, error)
- type ECDSAPrivateKey
- type ECDSAPublicKey
- type ECDSASig
- type Ed25519PrivateKey
- type Ed25519PublicKey
- type GenSharedKey
- type Key
- type PrivKey
- 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
- type PubKey
- 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
- type RsaPrivateKey
- type RsaPublicKey
- type Secp256k1PrivateKey
- type Secp256k1PublicKey
Constants ¶
const ( // RSA is an enum for the supported RSA key type RSA = iota // Ed25519 is an enum for the supported Ed25519 key type Ed25519 // Secp256k1 is an enum for the supported Secp256k1 key type Secp256k1 // ECDSA is an enum for the supported ECDSA key type ECDSA )
const WeakRsaKeyEnv = crypto.WeakRsaKeyEnv
WeakRsaKeyEnv is an environment variable which, when set, lowers the minimum required bits of RSA keys to 512. This should be used exclusively in test situations. Deprecated: use github.com/libp2p/go-libp2p/core/crypto.WeakRsaKeyEnv instead
Variables ¶
var ( // ErrNotECDSAPubKey is returned when the public key passed is not an ecdsa public key // Deprecated: use github.com/libp2p/go-libp2p/core/crypto.ErrNotECDSAPubKey instead ErrNotECDSAPubKey = crypto.ErrNotECDSAPubKey // ErrNilSig is returned when the signature is nil // Deprecated: use github.com/libp2p/go-libp2p/core/crypto.ErrNilSig instead ErrNilSig = crypto.ErrNilSig // ErrNilPrivateKey is returned when a nil private key is provided // Deprecated: use github.com/libp2p/go-libp2p/core/crypto.ErrNilPrivateKey instead ErrNilPrivateKey = crypto.ErrNilPrivateKey // ErrNilPublicKey is returned when a nil public key is provided // Deprecated: use github.com/libp2p/go-libp2p/core/crypto.ErrNilPublicKey instead ErrNilPublicKey = crypto.ErrNilPublicKey // ECDSACurve is the default ecdsa curve used // Deprecated: use github.com/libp2p/go-libp2p/core/crypto.ECDSACurve instead ECDSACurve = elliptic.P256() )
var ( // ErrBadKeyType is returned when a key is not supported ErrBadKeyType = errors.New("invalid or unsupported key type") // KeyTypes is a list of supported keys KeyTypes = []int{ RSA, Ed25519, Secp256k1, ECDSA, } )
var ErrRsaKeyTooSmall error
ErrRsaKeyTooSmall is returned when trying to generate or parse an RSA key that's smaller than MinRsaKeyBits bits. In test Deprecated: use github.com/libp2p/go-libp2p/core/crypto.ErrRsaKeyTooSmall instead
var MinRsaKeyBits = crypto.MinRsaKeyBits
Deprecated: use github.com/libp2p/go-libp2p/core/crypto.MinRsaKeyBits instead
var PrivKeyUnmarshallers = crypto.PrivKeyUnmarshallers
PrivKeyUnmarshallers is a map of unmarshallers by key type Deprecated: use github.com/libp2p/go-libp2p/core/crypto.PrivKeyUnmarshallers instead
var PubKeyUnmarshallers = crypto.PubKeyUnmarshallers
PubKeyUnmarshallers is a map of unmarshallers by key type Deprecated: use github.com/libp2p/go-libp2p/core/crypto.PubKeyUnmarshallers instead
Functions ¶
func ConfigDecodeKey ¶
ConfigDecodeKey decodes from b64 (for config file) to a byte array that can be unmarshalled. Deprecated: use github.com/libp2p/go-libp2p/core/crypto.ConfigDecodeKey instead
func ConfigEncodeKey ¶
ConfigEncodeKey encodes a marshalled key to b64 (for config file). Deprecated: use github.com/libp2p/go-libp2p/core/crypto.ConfigEncodeKey instead
func ECDSAKeyPairFromKey ¶
func ECDSAKeyPairFromKey(priv *ecdsa.PrivateKey) (PrivKey, PubKey, error)
ECDSAKeyPairFromKey generates a new ecdsa private and public key from an input private key Deprecated: use github.com/libp2p/go-libp2p/core/crypto.ECDSAKeyPairFromKey instead
func GenerateECDSAKeyPair ¶
GenerateECDSAKeyPair generates a new ecdsa private and public key Deprecated: use github.com/libp2p/go-libp2p/core/crypto.GenerateECDSAKeyPair instead
func GenerateECDSAKeyPairWithCurve ¶
GenerateECDSAKeyPairWithCurve generates a new ecdsa private and public key with a speicified curve Deprecated: use github.com/libp2p/go-libp2p/core/crypto.GenerateECDSAKeyPairWithCurve instead
func GenerateEd25519Key ¶
GenerateEd25519Key generates a new ed25519 private and public key pair. Deprecated: use github.com/libp2p/go-libp2p/core/crypto.GenerateEd25519Key instead
func GenerateKeyPair ¶
GenerateKeyPair generates a private and public key Deprecated: use github.com/libp2p/go-libp2p/core/crypto.GenerateKeyPair instead
func GenerateKeyPairWithReader ¶
GenerateKeyPairWithReader returns a keypair of the given type and bitsize Deprecated: use github.com/libp2p/go-libp2p/core/crypto.GenerateKeyPairWithReader instead
func GenerateRSAKeyPair ¶
GenerateRSAKeyPair generates a new rsa private and public key Deprecated: use github.com/libp2p/go-libp2p/core/crypto.GenerateRSAKeyPair
func GenerateSecp256k1Key ¶
GenerateSecp256k1Key generates a new Secp256k1 private and public key pair Deprecated: use github.com/libp2p/go-libp2p/core/crypto.GenerateSecp256k1Key instead
func KeyEqual ¶
KeyEqual checks whether two Keys are equivalent (have identical byte representations). Deprecated: use github.com/libp2p/go-libp2p/core/crypto.KeyEqual instead
func KeyPairFromStdKey ¶ added in v0.2.4
func KeyPairFromStdKey(priv stdcrypto.PrivateKey) (PrivKey, PubKey, error)
KeyPairFromStdKey wraps standard library (and secp256k1) private keys in libp2p/go-libp2p-core/crypto keys Deprecated: use github.com/libp2p/go-libp2p/core/crypto.KeyPairFromStdKey instead
func MarshalECDSAPrivateKey ¶
func MarshalECDSAPrivateKey(ePriv ECDSAPrivateKey) (res []byte, err error)
MarshalECDSAPrivateKey returns x509 bytes from a private key Deprecated: use github.com/libp2p/go-libp2p/core/crypto.MarshalECDSAPrivateKey instead
func MarshalECDSAPublicKey ¶
func MarshalECDSAPublicKey(ePub ECDSAPublicKey) (res []byte, err error)
MarshalECDSAPublicKey returns x509 bytes from a public key Deprecated: use github.com/libp2p/go-libp2p/core/crypto.MarshalECDSAPublicKey instead
func MarshalPrivateKey ¶
MarshalPrivateKey converts a key object into its protobuf serialized form. Deprecated: use github.com/libp2p/go-libp2p/core/crypto.MarshalPrivateKey instead
func MarshalPublicKey ¶
MarshalPublicKey converts a public key object into a protobuf serialized public key Deprecated: use github.com/libp2p/go-libp2p/core/crypto.MarshalPublicKey instead
func PrivKeyToStdKey ¶ added in v0.4.0
func PrivKeyToStdKey(priv PrivKey) (stdcrypto.PrivateKey, error)
PrivKeyToStdKey converts libp2p/go-libp2p-core/crypto private keys to standard library (and secp256k1) private keys Deprecated: use github.com/libp2p/go-libp2p/core/crypto.PrivKeyToStdKey instead
func PubKeyToStdKey ¶ added in v0.4.0
PubKeyToStdKey converts libp2p/go-libp2p-core/crypto private keys to standard library (and secp256k1) public keys Deprecated: use github.com/libp2p/go-libp2p/core/crypto.PubKeyToStdKey instead
Types ¶
type ECDSAPrivateKey ¶
type ECDSAPrivateKey = crypto.ECDSAPrivateKey
ECDSAPrivateKey is an implementation of an ECDSA private key Deprecated: use github.com/libp2p/go-libp2p/core/crypto.ECDSAPrivateKey instead
type ECDSAPublicKey ¶
type ECDSAPublicKey = crypto.ECDSAPublicKey
ECDSAPublicKey is an implementation of an ECDSA public key Deprecated: use github.com/libp2p/go-libp2p/core/crypto.ECDSAPublicKey instead
type ECDSASig ¶
ECDSASig holds the r and s values of an ECDSA signature Deprecated: use github.com/libp2p/go-libp2p/core/crypto.ECDSASig instead
type Ed25519PrivateKey ¶
type Ed25519PrivateKey = crypto.Ed25519PrivateKey
Ed25519PrivateKey is an ed25519 private key. Deprecated: use github.com/libp2p/go-libp2p/core/crypto.Ed25519PrivateKey instead
type Ed25519PublicKey ¶
type Ed25519PublicKey = crypto.Ed25519PublicKey
Ed25519PublicKey is an ed25519 public key. Deprecated: use github.com/libp2p/go-libp2p/core/crypto.Ed25519PublicKey instead
type GenSharedKey ¶
type GenSharedKey = crypto.GenSharedKey
GenSharedKey generates the shared key from a given private key Deprecated: use github.com/libp2p/go-libp2p/core/crypto.GenSharedKey instead
func GenerateEKeyPair ¶
func GenerateEKeyPair(curveName string) ([]byte, GenSharedKey, error)
GenerateEKeyPair returns an ephemeral public key and returns a function that will compute the shared secret key. Used in the identify module.
Focuses only on ECDH now, but can be made more general in the future. Deprecated: use github.com/libp2p/go-libp2p/core/crypto.GenerateEKeyPair instead
type Key ¶
Key represents a crypto key that can be compared to another key Deprecated: use github.com/libp2p/go-libp2p/core/crypto.Key instead
type PrivKey ¶
PrivKey represents a private key that can be used to generate a public key and sign data Deprecated: use github.com/libp2p/go-libp2p/core/crypto.PrivKey instead
func UnmarshalECDSAPrivateKey ¶
UnmarshalECDSAPrivateKey returns a private key from x509 bytes Deprecated: use github.com/libp2p/go-libp2p/core/crypto.MarshalECDSAPrivateKey instead
func UnmarshalEd25519PrivateKey ¶
UnmarshalEd25519PrivateKey returns a private key from input bytes. Deprecated: use github.com/libp2p/go-libp2p/core/crypto.UnmarshalEd25519PrivateKey instead
func UnmarshalPrivateKey ¶
UnmarshalPrivateKey converts a protobuf serialized private key into its representative object Deprecated: use github.com/libp2p/go-libp2p/core/crypto.UnmarshalPrivateKey instead
func UnmarshalRsaPrivateKey ¶
UnmarshalRsaPrivateKey returns a private key from the input x509 bytes Deprecated: use github.com/libp2p/go-libp2p/core/crypto.UnmarshalRsaPrivateKey
func UnmarshalSecp256k1PrivateKey ¶
UnmarshalSecp256k1PrivateKey returns a private key from bytes Deprecated: use github.com/libp2p/go-libp2p/core/crypto.UnmarshalSecp256k1PrivateKey instead
type PrivKeyUnmarshaller ¶
type PrivKeyUnmarshaller = crypto.PrivKeyUnmarshaller
PrivKeyUnmarshaller is a func that creates a PrivKey from a given slice of bytes Deprecated: use github.com/libp2p/go-libp2p/core/crypto.PrivKeyUnmarshaller instead
type PubKey ¶
PubKey is a public key that can be used to verifiy data signed with the corresponding private key Deprecated: use github.com/libp2p/go-libp2p/core/crypto.PubKey instead
func ECDSAPublicKeyFromPubKey ¶ added in v0.12.0
ECDSAPublicKeyFromPubKey generates a new ecdsa public key from an input public key Deprecated: use github.com/libp2p/go-libp2p/core/crypto.ECDSAPublicKeyFromPubKey instead
func PublicKeyFromProto ¶
PublicKeyFromProto converts an unserialized protobuf PublicKey message into its representative object. Deprecated: use github.com/libp2p/go-libp2p/core/crypto.PublicKeyFromProto instead
func UnmarshalECDSAPublicKey ¶
UnmarshalECDSAPublicKey returns the public key from x509 bytes Deprecated: use github.com/libp2p/go-libp2p/core/crypto.UnmarshalECDSAPublicKey instead
func UnmarshalEd25519PublicKey ¶
UnmarshalEd25519PublicKey returns a public key from input bytes. Deprecated: use github.com/libp2p/go-libp2p/core/crypto.UnmarshalEd25519PublicKey instead
func UnmarshalPublicKey ¶
UnmarshalPublicKey converts a protobuf serialized public key into its representative object Deprecated: use github.com/libp2p/go-libp2p/core/crypto.UnmarshalPublicKey instead
func UnmarshalRsaPublicKey ¶
UnmarshalRsaPublicKey returns a public key from the input x509 bytes Deprecated: use github.com/libp2p/go-libp2p/core/crypto.UnmarshalRsaPublicKey
func UnmarshalSecp256k1PublicKey ¶
UnmarshalSecp256k1PublicKey returns a public key from bytes Deprecated: use github.com/libp2p/go-libp2p/core/crypto.UnmarshalSecp256k1PublicKey instead
type PubKeyUnmarshaller ¶
type PubKeyUnmarshaller = crypto.PubKeyUnmarshaller
PubKeyUnmarshaller is a func that creates a PubKey from a given slice of bytes Deprecated: use github.com/libp2p/go-libp2p/core/crypto.PubKeyUnmarshaller instead
type RsaPrivateKey ¶
type RsaPrivateKey = crypto.RsaPrivateKey
RsaPrivateKey is an rsa private key Deprecated: use github.com/libp2p/go-libp2p/core/crypto.RsaPrivateKey instead
type RsaPublicKey ¶
type RsaPublicKey = crypto.RsaPublicKey
RsaPublicKey is an rsa public key Deprecated: use github.com/libp2p/go-libp2p/core/crypto.RsaPublicKey instead
type Secp256k1PrivateKey ¶
type Secp256k1PrivateKey = crypto.Secp256k1PrivateKey
Secp256k1PrivateKey is an Secp256k1 private key Deprecated: use github.com/libp2p/go-libp2p/core/crypto.Secp256k1PrivateKey instead
type Secp256k1PublicKey ¶
type Secp256k1PublicKey = crypto.Secp256k1PublicKey
Secp256k1PublicKey is an Secp256k1 public key Deprecated: use github.com/libp2p/go-libp2p/core/crypto.Secp256k1PublicKey instead