Documentation ¶
Overview ¶
Package p2pcrypto defines the cryptographic primitives used to communicate and identify in the p2p network, it uses go stdlib's NaCL box implementation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateKeyPair ¶
func GenerateKeyPair() (PrivateKey, PublicKey, error)
GenerateKeyPair generates ed25519 private key and a public key derived from it.
func PrependPubkey ¶
PrependPubkey adds a public key at the beginning on a byte array.
Types ¶
type Key ¶
type Key interface { Bytes() []byte Array() [32]byte String() string Field() log.Field // contains filtered or unexported methods }
Key represents a 32 bit cryptographic key, public or private.
type PrivateKey ¶
type PrivateKey interface { Key }
PrivateKey is a private key of 32 byte.
func NewPrivateKeyFromBase58 ¶
func NewPrivateKeyFromBase58(s string) (PrivateKey, error)
NewPrivateKeyFromBase58 creates a private key from a base58 string.
type PublicKey ¶
type PublicKey interface { Key }
PublicKey is a public key of 32 byte.
func ExtractPubkey ¶
ExtractPubkey extracts a public key from the beginning of a byte array.
func NewPubkeyFromBytes ¶
NewPubkeyFromBytes creates a public key from a byte array.
func NewPublicKeyFromBase58 ¶
NewPublicKeyFromBase58 creates a public key from a base58 string.
func NewRandomPubkey ¶
func NewRandomPubkey() PublicKey
NewRandomPubkey reads random bytes and creates a public key from them. used for testing
func PublicKeyFromArray ¶
PublicKeyFromArray creates a public key using a fixed sized byte array.
type SharedSecret ¶
type SharedSecret interface { Key }
SharedSecret is created using two participants key to enable Sealing and Opening of messages (NaCL).
func GenerateSharedSecret ¶
func GenerateSharedSecret(privkey PrivateKey, peerPubkey PublicKey) SharedSecret
GenerateSharedSecret creates a key derived from a private and a public key.