identity

package
v0.0.0-...-97e1097 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2023 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package identity defines an identity key.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Key

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

Key represents a public identity key.

func NewKey

func NewKey(key []byte) (Key, error)

NewKey returns a public identity key from the given key bytes.

func (Key) Bytes

func (k Key) Bytes() []byte

Bytes returns an encoding of the identity key.

func (Key) Equal

func (k Key) Equal(key Key) bool

Equal determines if the identity keys are the same.

func (Key) PublicKey

func (k Key) PublicKey() curve.PublicKey

PublicKey returns the identity key's public key.

func (Key) VerifyAlternateIdentity

func (k Key) VerifyAlternateIdentity(signature []byte, other Key) (bool, error)

VerifyAlternateIdentity verifies other key represents an alternate identity for this user.

It is expected the signature is the output of KeyPair.SignAlternateIdentity.

type KeyPair

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

KeyPair represents a public/private identity key pair.

func GenerateKeyPair

func GenerateKeyPair(random io.Reader) (KeyPair, error)

GenerateKeyPair generates an identity key pair using the given random reader.

It is recommended to use a cryptographic random reader. If random is `nil`, then crypto/rand.Reader is used.

func NewKeyPair

func NewKeyPair(privateKey curve.PrivateKey, identityKey Key) KeyPair

NewKeyPair returns an identity key pair based on the given public and private keys.

func (KeyPair) IdentityKey

func (k KeyPair) IdentityKey() Key

IdentityKey returns the key pair's public identity key.

func (KeyPair) PrivateKey

func (k KeyPair) PrivateKey() curve.PrivateKey

PrivateKey returns the key pair's private key.

func (KeyPair) PublicKey

func (k KeyPair) PublicKey() curve.PublicKey

PublicKey returns the key pair's public key.

func (KeyPair) SignAlternateIdentity

func (k KeyPair) SignAlternateIdentity(random io.Reader, other Key) ([]byte, error)

SignAlternateIdentity generates a signature claiming other key represents the same user as this key pair.

type Store

type Store interface {
	// KeyPair returns the associated identity key pair.
	KeyPair(ctx context.Context) KeyPair
	// LocalRegistrationID returns the associated registration ID.
	LocalRegistrationID(ctx context.Context) uint32
	// Load loads the identity key associated with the remote address.
	Load(ctx context.Context, address address.Address) (Key, bool, error)
	// Store stores the identity key associated with the remote address and returns
	// "true" if there is already an entry for the address which is overwritten
	// with a new identity key.
	//
	// Storing the identity key for the remote address implies the identity key
	// is trusted for the given address.
	Store(ctx context.Context, address address.Address, identity Key) (bool, error)
	// Clear removes all items from the store.
	Clear() error
	// IsTrustedIdentity returns "true" if the given identity key for the given address is already trusted.
	//
	// If there is no entry for the given address, the given identity key is trusted.
	IsTrustedIdentity(ctx context.Context, address address.Address, identity Key, direction direction.Direction) (bool, error)
}

Store defines an identity key store.

An identity key store is associated with a local identity key pair and registration ID.

func NewInMemStore

func NewInMemStore(keyPair KeyPair, registrationID uint32) Store

NewInMemStore creates a new in-memory identity key store.

Jump to

Keyboard shortcuts

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