identity

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package identity implements Canton identity operations such as party management and fingerprint-to-party mapping.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RecordValue

func RecordValue(fields ...*lapiv2.Value) *lapiv2.Value

Types

type Client

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

Client implements the Identity interface.

func New

func New(cfg *Config, l ledger.Ledger, opts ...Option) (*Client, error)

New creates a new identity client.

func (*Client) AllocateExternalParty

func (c *Client) AllocateExternalParty(ctx context.Context, hint string, spkiPublicKey []byte, signer ExternalPartyKey) (*Party, error)

AllocateExternalParty creates an external party using the Interactive Submission flow. External parties have no practical limit (unlike internal parties which are capped at ~200). spkiPublicKey is the DER-encoded X.509 SubjectPublicKeyInfo public key (use CantonKeyPair.SPKIPublicKey()). signer provides the SignDER capability for signing the topology multi-hash.

func (*Client) AllocateExternalPartyWithSignature

func (c *Client) AllocateExternalPartyWithSignature(
	ctx context.Context, topology *ExternalPartyTopology, derSignature []byte,
) (*Party, error)

func (*Client) AllocateParty

func (c *Client) AllocateParty(ctx context.Context, hint string) (*Party, error)

func (*Client) CreateFingerprintMapping

func (c *Client) CreateFingerprintMapping(ctx context.Context, req CreateFingerprintMappingRequest) (*FingerprintMapping, error)

func (*Client) GenerateExternalPartyTopology

func (c *Client) GenerateExternalPartyTopology(ctx context.Context, hint string, spkiPublicKey []byte) (*ExternalPartyTopology, error)

func (*Client) GetFingerprintMapping

func (c *Client) GetFingerprintMapping(ctx context.Context, fingerprint string) (*FingerprintMapping, error)

func (*Client) GetParticipantID

func (c *Client) GetParticipantID(ctx context.Context) (string, error)

func (*Client) GrantActAsParty

func (c *Client) GrantActAsParty(ctx context.Context, partyID string) error

func (*Client) ListParties

func (c *Client) ListParties(ctx context.Context) ([]*Party, error)

func (*Client) PackageID

func (c *Client) PackageID() string

PackageID returns the DAML package ID used by this client for identity templates.

type Config

type Config struct {
	DomainID    string `yaml:"domain_id"`
	IssuerParty string `yaml:"issuer_party"`
	UserID      string `yaml:"user_id"`
	PackageID   string `yaml:"package_id" validate:"required"` // package ID for FingerprintMapping (Common.FingerprintAuth)
}

Config contains the configuration required to initialize the identity client.

type CreateFingerprintMappingRequest

type CreateFingerprintMappingRequest struct {
	UserParty   string
	Fingerprint string
	EvmAddress  string
}

CreateFingerprintMappingRequest contains inputs for creating a FingerprintMapping.

type ExternalPartyKey

type ExternalPartyKey interface {
	SignDER(message []byte) ([]byte, error)
}

ExternalPartyKey holds the signing capability needed to allocate an external party. Canton returns a multihash that must be SHA-256 hashed and signed. Implemented by keys.CantonKeyPair.

type ExternalPartyTopology

type ExternalPartyTopology struct {
	TopologyTransactions [][]byte // Serialized topology transactions
	MultiHash            []byte   // Hash to be signed by the party's key
	Fingerprint          string   // Canton key fingerprint (multihash of SPKI public key)
}

ExternalPartyTopology holds the intermediate state from GenerateExternalPartyTopology needed to complete external party allocation with a client-provided signature.

type FingerprintMapping

type FingerprintMapping struct {
	ContractID  string
	Issuer      string
	UserParty   string
	Fingerprint string
	EvmAddress  string
}

FingerprintMapping represents a FingerprintMapping contract.

type Identity

type Identity interface {
	AllocateParty(ctx context.Context, hint string) (*Party, error)
	AllocateExternalParty(ctx context.Context, hint string, spkiPublicKey []byte, signer ExternalPartyKey) (*Party, error)
	ListParties(ctx context.Context) ([]*Party, error) // TODO: add iterator
	GetParticipantID(ctx context.Context) (string, error)

	CreateFingerprintMapping(ctx context.Context, req CreateFingerprintMappingRequest) (*FingerprintMapping, error)
	GetFingerprintMapping(ctx context.Context, fingerprint string) (*FingerprintMapping, error)

	GrantActAsParty(ctx context.Context, partyID string) error

	// GenerateExternalPartyTopology generates the topology transactions and multi-hash
	// needed for external party allocation. The multi-hash must be signed by the party's
	// private key and submitted via AllocateExternalPartyWithSignature.
	GenerateExternalPartyTopology(ctx context.Context, hint string, spkiPublicKey []byte) (*ExternalPartyTopology, error)

	// AllocateExternalPartyWithSignature completes external party allocation using
	// a client-provided DER signature of the topology multi-hash.
	AllocateExternalPartyWithSignature(ctx context.Context, topology *ExternalPartyTopology, derSignature []byte) (*Party, error)

	// PackageID returns the DAML package ID this client uses for identity templates
	// (e.g. Common.FingerprintAuth). Callers that need to query identity templates
	// using a ledger client directly (rather than through this client) can use this
	// to construct the correct template identifier.
	PackageID() string
}

Identity defines identity and party management operations.

type Option

type Option func(*settings)

Option configures the identity client.

func WithLogger

func WithLogger(l *zap.Logger) Option

WithLogger sets a custom logger for the identity client.

type Party

type Party struct {
	PartyID string
	IsLocal bool
}

Party contains the result of allocating a new Canton party.

Jump to

Keyboard shortcuts

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