identity

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package identity provides decentralized identity (DID) derivation from wallet public keys. DIDs are deterministically derived from compressed secp256k1 public keys and mapped to libp2p peer IDs for P2P networking. Private keys never leave the wallet layer.

Index

Constants

View Source
const (
	// DIDPrefix is the method-specific prefix for Lango DIDs.
	DIDPrefix = "did:lango:"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DID

type DID struct {
	ID        string  `json:"id"`        // "did:lango:<hex-compressed-pubkey>"
	PublicKey []byte  `json:"publicKey"` // compressed secp256k1 public key
	PeerID    peer.ID `json:"peerId"`    // libp2p peer ID derived from pubkey
}

DID represents a decentralized identifier derived from a wallet public key.

func DIDFromPublicKey

func DIDFromPublicKey(pubkey []byte) (*DID, error)

DIDFromPublicKey creates a DID from a compressed secp256k1 public key.

func ParseDID

func ParseDID(didStr string) (*DID, error)

ParseDID parses a "did:lango:<hexkey>" string into a DID.

type Provider

type Provider interface {
	// DID returns the DID for the current wallet.
	DID(ctx context.Context) (*DID, error)
	// VerifyDID checks that a DID matches the claimed peer ID.
	VerifyDID(did *DID, peerID peer.ID) error
}

Provider creates and verifies DIDs.

type WalletDIDProvider

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

WalletDIDProvider derives DIDs from a wallet's public key.

func NewProvider

func NewProvider(w wallet.WalletProvider, logger *zap.SugaredLogger) *WalletDIDProvider

NewProvider creates a new WalletDIDProvider.

func (*WalletDIDProvider) DID

func (p *WalletDIDProvider) DID(ctx context.Context) (*DID, error)

DID returns the DID for the current wallet, caching the result since the wallet key does not change.

func (*WalletDIDProvider) VerifyDID

func (p *WalletDIDProvider) VerifyDID(did *DID, peerID peer.ID) error

VerifyDID checks that a DID's public key produces the claimed peer ID.

Jump to

Keyboard shortcuts

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