identities

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package identities creates, stores, signs with and verifies OrbitDB identities.

It mirrors src/identities/identities.js in @orbitdb/core. Creating an identity for id "alice" with the default publickey provider works as follows:

  1. the provider's key "alice" is fetched or created; its public key (hex) becomes the identity id;
  2. a signing key stored under that identity id is fetched or created; its public key becomes identity.PublicKey;
  3. the signing key signs the identity id (Signatures.ID) and the provider key signs PublicKey+Signatures.ID (Signatures.PublicKey).

The identity block is written to the identities storage so peers can fetch it by the hash entries refer to.

Index

Constants

This section is empty.

Variables

View Source
var DefaultKeysPath = filepath.Join(".", "orbitdb", "identities")

DefaultKeysPath is where New keeps keys when neither Keystore nor Path is set.

Functions

This section is empty.

Types

type CreateOptions

type CreateOptions struct {
	// ID is the caller-chosen id the provider derives the identity from.
	ID string
	// Provider creates the identity. Defaults to a PublicKeyProvider over
	// the Identities' keystore.
	Provider providers.Provider
}

CreateOptions configures CreateIdentity.

type Identities

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

Identities manages identities backed by a keystore.

func New

func New(opts Options) (*Identities, error)

New returns an Identities.

func (*Identities) CreateIdentity

func (ids *Identities) CreateIdentity(ctx context.Context, opts CreateOptions) (*identitytypes.Identity, error)

CreateIdentity creates an identity and adds it to storage.

func (*Identities) GetIdentity

func (ids *Identities) GetIdentity(ctx context.Context, hash string) (*identitytypes.Identity, error)

GetIdentity returns the identity stored under hash. It may be fetched from peers when the storage is IPFS-backed. The identity can sign only if its key is in this Identities' keystore.

func (*Identities) Keystore

func (ids *Identities) Keystore() *keystore.KeyStore

Keystore returns the keystore identities are created from.

func (*Identities) Sign

func (ids *Identities) Sign(ctx context.Context, identity *identitytypes.Identity, data []byte) (string, error)

Sign signs data with identity's private key, which must be in the keystore. It implements identitytypes.Signer.

func (*Identities) Verify

func (ids *Identities) Verify(signature, publicKey string, data []byte) bool

Verify reports whether signature is publicKey's signature of data.

func (*Identities) VerifyIdentity

func (ids *Identities) VerifyIdentity(ctx context.Context, identity *identitytypes.Identity) (bool, error)

VerifyIdentity checks both of the identity's signatures: that its signing key signed its id, and that its provider vouched for the signing key.

type Options

type Options struct {
	// Keystore holds the private keys. If nil, one is opened at Path.
	Keystore *keystore.KeyStore
	// Path is the keystore directory used when Keystore is nil. Defaults to
	// DefaultKeysPath.
	Path string
	// Storage holds identity blocks by hash. OrbitDB passes an LRU cache in
	// front of IPFS block storage so identities replicate between peers.
	// Defaults to an in-memory storage.
	Storage storage.Storage
}

Options configures New.

Directories

Path Synopsis
Package identitytypes defines the Identity record that signs OrbitDB log entries, and its dag-cbor encoding.
Package identitytypes defines the Identity record that signs OrbitDB log entries, and its dag-cbor encoding.
Package providers implements identity providers, which decide what an identity id is and vouch for the identity's signing key.
Package providers implements identity providers, which decide what an identity id is and vouch for the identity's signing key.

Jump to

Keyboard shortcuts

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