keyring

package
v0.0.0-...-891c386 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2021 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const InMemory = ":memory:"

InMemory lets us configure keys for testing that live in memory and get thrown out once we're done with them

Variables

View Source
var (
	ErrorDecryptFailedAsym = errors.New("assymmetric decryption failed")
	ErrorDecryptFailedSym  = errors.New("symmetric decryption failed")
	ErrorInvalidSignature  = errors.New("invalid or missing signature")
	ErrorUnknownChannel    = errors.New("unknown channel")
	ErrorUnknownKey        = errors.New("unknown key")
)

Functions

func DecodeP2PPrivKey

func DecodeP2PPrivKey(encoded string) (crypto.PrivKey, error)

Types

type CommunityKey

type CommunityKey *[32]byte

type KeyRing

type KeyRing struct {
	// contains filtered or unexported fields
}

func NewFromFile

func NewFromFile(uri, path string) (*KeyRing, error)

func NewKeyRing

func NewKeyRing() *KeyRing

func (*KeyRing) AddCommunityKey

func (kr *KeyRing) AddCommunityKey(channelURI string, key CommunityKey)

AddCommunityKey adds a community key to the channel keyring. TODO: this is a placeholder until we have an embedded pnode client.

func (*KeyRing) AddKeyPair

func (kr *KeyRing) AddKeyPair(channelURI string, id MemberID, pub MemberPublicKey, priv MemberPrivateKey)

AddKeyPair adds this client's keypair to the channel keyring. TODO: this is a placeholder until we have an embedded pnode client.

func (*KeyRing) AddMemberKey

func (kr *KeyRing) AddMemberKey(channelURI string, id MemberID, pub MemberPublicKey)

AddMemberKey adds a different member's public key to the keyring, for signing verification. TODO: this is a placeholder until we have an embedded pnode client.

func (*KeyRing) DecodeEntry

func (kr *KeyRing) DecodeEntry(entry *pb.Msg) ([]byte, error)

DecodeEntry verifies the signature of the entry, and returns the decrypted body

func (*KeyRing) EncodeEntry

func (kr *KeyRing) EncodeEntry(body []byte, channelURI string) (*pb.Msg, error)

EncodeEntry encrypts the body for a specific channel and signs the result, returning a new entry Msg. Note that we have to encode an entry for a specific channel because a given Member can have different keys for different channels.

func (*KeyRing) GetIdentityKey

func (kr *KeyRing) GetIdentityKey() crypto.PrivKey

GetIdentityKey gets the keyring's encoded identity key and returns it as a libp2p private key

func (*KeyRing) RemoveMemberKey

func (kr *KeyRing) RemoveMemberKey(channelURI string, id MemberID) error

RemoveMemberKey removes a different member's public key to the keyring, for signing verification. TODO: this is a placeholder until we have an embedded pnode client.

type KeySet

type KeySet struct {
	CommunityKey CommunityKey
	MemberID     MemberID         // this client's Id
	PrivateKey   MemberPrivateKey // this client's private key
	PublicKey    MemberPublicKey  // this client's public key
	// contains filtered or unexported fields
}

KeySet is associated with a Channel; the caller is responsible for tracking multiple keychains and rotating them if needed

func NewKeySet

func NewKeySet() *KeySet

type MemberID

type MemberID [20]byte

func MemberIDFromP2PPubKey

func MemberIDFromP2PPubKey(k crypto.PubKey) (MemberID, error)

func MemberIDFromString

func MemberIDFromString(s string) MemberID

type MemberPrivateKey

type MemberPrivateKey *[64]byte

func MemberPrivateKeyFromBytes

func MemberPrivateKeyFromBytes(b []byte) MemberPrivateKey

func MemberPrivateKeyFromP2PKey

func MemberPrivateKeyFromP2PKey(k crypto.PrivKey) (MemberPrivateKey, error)

type MemberPublicKey

type MemberPublicKey *[32]byte

func MemberPublicKeyDecodeBase64

func MemberPublicKeyDecodeBase64(s string) (MemberPublicKey, error)

func MemberPublicKeyFromBytes

func MemberPublicKeyFromBytes(b []byte) MemberPublicKey

func MemberPublicKeyFromP2PKey

func MemberPublicKeyFromP2PKey(k crypto.PubKey) (MemberPublicKey, error)

Jump to

Keyboard shortcuts

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