p2pcrypto

package
v0.1.23-profiler Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 6, 2021 License: MIT Imports: 7 Imported by: 0

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

func PrependPubkey(message []byte, pubkey PublicKey) []byte

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(key string) 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

func ExtractPubkey(message []byte) ([]byte, PublicKey, error)

ExtractPubkey extracts a public key from the beginning of a byte array.

func NewPubkeyFromBytes

func NewPubkeyFromBytes(bytes []byte) (PublicKey, error)

NewPubkeyFromBytes creates a public key from a byte array.

func NewPublicKeyFromBase58

func NewPublicKeyFromBase58(s string) (PublicKey, error)

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

func PublicKeyFromArray(ke [32]byte) PublicKey

PublicKeyFromArray creates a public key using a fixed sized byte array.

type SharedSecret

type SharedSecret interface {
	Key
	Seal(message []byte) (out []byte)
	Open(encryptedMessage []byte) (out []byte, err error)
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL