identityvm

package
v1.7.36 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: BSD-3-Clause Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Name = "identityvm"

	// Credential states
	CredentialActive  = "active"
	CredentialRevoked = "revoked"
	CredentialExpired = "expired"
	CredentialPending = "pending"
)
View Source
const MaxPendingCredentials = 4096

MaxPendingCredentials bounds the queue of credentials waiting for a block. Issuing is open to any authorized issuer, so without a bound the queue is whatever they choose to make it.

Variables

View Source
var VMID = ids.ID{'i', 'd', 'e', 'n', 't', 'i', 't', 'y', 'v', 'm'}

VMID is the unique identifier for IdentityVM (I-Chain)

Functions

This section is empty.

Types

type Block

type Block struct {
	ParentID_      ids.ID             `json:"parentId"`
	BlockHeight    uint64             `json:"height"`
	BlockTimestamp int64              `json:"timestamp"`
	Credentials    []*Credential      `json:"credentials"`
	Revocations    []*RevocationEntry `json:"revocations,omitempty"`
	Identities     []*Identity        `json:"identities,omitempty"`
	StateRoot      []byte             `json:"stateRoot"`

	// Cached values
	ID_ ids.ID
	// contains filtered or unexported fields
}

Block represents a block in the IdentityVM chain

func (*Block) Accept

func (b *Block) Accept(ctx context.Context) error

Accept applies the block. The store commits everything below in one batch, so a credential that cannot be written takes the whole block with it rather than leaving the chain holding half of one.

func (*Block) Bytes

func (b *Block) Bytes() []byte

Bytes returns the block bytes

func (*Block) Height

func (b *Block) Height() uint64

Height returns the block height

func (*Block) ID

func (b *Block) ID() ids.ID

ID returns the block ID

func (*Block) Marshal added in v1.7.6

func (b *Block) Marshal() ([]byte, error)

Marshal encodes the block (excluding the derived ID_/cache fields) to canonical wire. blockID = sha256(this).

func (*Block) Parent

func (b *Block) Parent() ids.ID

Parent is an alias for ParentID for compatibility

func (*Block) ParentID

func (b *Block) ParentID() ids.ID

ParentID returns the parent block ID

func (*Block) Publish added in v1.7.35

func (b *Block) Publish()

Publish makes the block's effects visible: the credentials it carries, the revocations it applies, the identities it introduces, and the block's own status. It runs after the commit, so nothing here can be believed and then lost — which is what setting them first did.

func (*Block) Reject

func (b *Block) Reject(ctx context.Context) error

Reject discards the block. It wrote nothing, so there is nothing to undo; its credentials stay queued for a later block.

func (*Block) Status

func (b *Block) Status() uint8

Status returns the block status

func (*Block) Timestamp

func (b *Block) Timestamp() time.Time

Timestamp returns the block timestamp

func (*Block) Verify

func (b *Block) Verify(ctx context.Context) error

Verify verifies the block

func (*Block) Write added in v1.7.35

func (b *Block) Write(db database.Database) error

Write records every credential the block carries. The error a Put returns used to be dropped here, which meant a credential silently missing from the database while the chain went on believing the block had been applied.

type Config

type Config struct {
	CredentialTTL   int64    `json:"credentialTTL"` // Seconds
	MaxClaims       int      `json:"maxClaims"`
	TrustedIssuers  []string `json:"trustedIssuers"`
	AllowSelfIssue  bool     `json:"allowSelfIssue"`
	RequireZKProofs bool     `json:"requireZKProofs"`
}

Config holds IdentityVM configuration

type CreateIdentityArgs

type CreateIdentityArgs struct {
	PublicKey string            `json:"publicKey"` // Base64-encoded
	Metadata  map[string]string `json:"metadata"`
	// Fee is the user-paid tx burn in nLUX; must satisfy MinTxFeeFloor.
	Fee uint64 `json:"fee"`
}

CreateIdentityArgs are arguments for CreateIdentity

type CreateIdentityReply

type CreateIdentityReply struct {
	ID  string `json:"id"`
	DID string `json:"did"`
}

CreateIdentityReply is the reply for CreateIdentity

type CreateProofArgs

type CreateProofArgs struct {
	CredentialID        string   `json:"credentialId"`
	ZKProof             string   `json:"zkProof,omitempty"` // Base64-encoded
	SelectiveDisclosure []string `json:"selectiveDisclosure,omitempty"`
	// Fee is the user-paid tx burn in nLUX.
	Fee uint64 `json:"fee"`
}

CreateProofArgs are arguments for CreateProof

type CreateProofReply

type CreateProofReply struct {
	CredentialID     string `json:"credentialId"`
	IssuerDID        string `json:"issuerDid"`
	SubjectDID       string `json:"subjectDid"`
	CredType         string `json:"credentialType"`
	ClaimsCommitment string `json:"claimsCommitment"` // Base64-encoded
	IssuedAt         int64  `json:"issuedAt"`
	ExpiresAt        int64  `json:"expiresAt"`
}

CreateProofReply is the reply for CreateProof

type Credential

type Credential struct {
	ID              ids.ID                 `json:"id"`
	Type            []string               `json:"type"`
	Issuer          ids.ID                 `json:"issuer"`
	Subject         ids.ID                 `json:"subject"`
	IssuanceDate    time.Time              `json:"issuanceDate"`
	ExpirationDate  time.Time              `json:"expirationDate"`
	Claims          map[string]interface{} `json:"claims"`
	Proof           *CredentialProof       `json:"proof,omitempty"`
	Status          string                 `json:"status"`
	RevocationIndex uint64                 `json:"revocationIndex,omitempty"`
}

Credential represents a verifiable credential

type CredentialProof

type CredentialProof struct {
	Type               string `json:"type"`
	Created            string `json:"created"`
	VerificationMethod string `json:"verificationMethod"`
	ProofPurpose       string `json:"proofPurpose"`
	ProofValue         []byte `json:"proofValue"`
	ZKProof            []byte `json:"zkProof,omitempty"` // Zero-knowledge proof
}

CredentialProof represents a proof for a credential

type CredentialReply

type CredentialReply struct {
	ID             string                 `json:"id"`
	Type           []string               `json:"type"`
	Issuer         string                 `json:"issuer"`
	Subject        string                 `json:"subject"`
	IssuanceDate   string                 `json:"issuanceDate"`
	ExpirationDate string                 `json:"expirationDate"`
	Claims         map[string]interface{} `json:"claims"`
	Status         string                 `json:"status"`
}

CredentialReply represents a credential in RPC responses

type Factory

type Factory = chain.Factory[VM]

Factory creates new IdentityVM instances.

type Genesis

type Genesis struct {
	Timestamp  int64       `json:"timestamp"`
	Config     *Config     `json:"config,omitempty"`
	Issuers    []*Issuer   `json:"issuers,omitempty"`
	Identities []*Identity `json:"identities,omitempty"`
	Message    string      `json:"message,omitempty"`
}

Genesis represents genesis data for IdentityVM

func ParseGenesis

func ParseGenesis(genesisBytes []byte) (*Genesis, error)

ParseGenesis parses genesis bytes

type GetCredentialArgs

type GetCredentialArgs struct {
	CredentialID string `json:"credentialId"`
}

GetCredentialArgs are arguments for GetCredential

type GetCredentialReply

type GetCredentialReply struct {
	Credential CredentialReply `json:"credential"`
}

GetCredentialReply is the reply for GetCredential

type GetIdentityArgs

type GetIdentityArgs struct {
	ID string `json:"id"`
}

GetIdentityArgs are arguments for GetIdentity

type GetIdentityReply

type GetIdentityReply struct {
	Identity IdentityReply `json:"identity"`
}

GetIdentityReply is the reply for GetIdentity

type GetIssuerArgs

type GetIssuerArgs struct {
	IssuerID string `json:"issuerId"`
}

GetIssuerArgs are arguments for GetIssuer

type GetIssuerReply

type GetIssuerReply struct {
	Issuer IssuerReply `json:"issuer"`
}

GetIssuerReply is the reply for GetIssuer

type HealthArgs

type HealthArgs struct{}

HealthArgs are arguments for Health

type HealthReply

type HealthReply struct {
	Healthy     bool `json:"healthy"`
	Identities  int  `json:"identities"`
	Credentials int  `json:"credentials"`
	Issuers     int  `json:"issuers"`
}

HealthReply is the reply for Health

type Identity

type Identity struct {
	ID          ids.ID            `json:"id"`
	DID         string            `json:"did"`         // Decentralized Identifier (e.g., did:lux:xyz)
	PublicKey   []byte            `json:"publicKey"`   // Primary public key
	Controllers []ids.ID          `json:"controllers"` // Controlling identities
	Services    []ServiceEndpoint `json:"services"`
	Created     time.Time         `json:"created"`
	Updated     time.Time         `json:"updated"`
	Metadata    map[string]string `json:"metadata"`
}

Identity represents a decentralized identity

type IdentityReply

type IdentityReply struct {
	ID        string            `json:"id"`
	DID       string            `json:"did"`
	PublicKey string            `json:"publicKey"`
	Created   string            `json:"created"`
	Updated   string            `json:"updated"`
	Metadata  map[string]string `json:"metadata"`
	Services  []ServiceEndpoint `json:"services"`
}

IdentityReply represents an identity in RPC responses

type IssueCredentialArgs

type IssueCredentialArgs struct {
	IssuerID   string                 `json:"issuerId"`
	SubjectID  string                 `json:"subjectId"`
	Type       []string               `json:"type"`
	Claims     map[string]interface{} `json:"claims"`
	TTLSeconds int64                  `json:"ttlSeconds"` // Optional, uses default if 0
	// Fee is the user-paid tx burn in nLUX.
	Fee uint64 `json:"fee"`
}

IssueCredentialArgs are arguments for IssueCredential

type IssueCredentialReply

type IssueCredentialReply struct {
	CredentialID   string `json:"credentialId"`
	ExpirationDate string `json:"expirationDate"`
}

IssueCredentialReply is the reply for IssueCredential

type Issuer

type Issuer struct {
	ID         ids.ID    `json:"id"`
	Name       string    `json:"name"`
	PublicKey  []byte    `json:"publicKey"`
	Types      []string  `json:"types"` // Types of credentials they can issue
	TrustLevel int       `json:"trustLevel"`
	CreatedAt  time.Time `json:"createdAt"`
	Status     string    `json:"status"`
}

Issuer represents a trusted credential issuer

type IssuerReply

type IssuerReply struct {
	ID         string   `json:"id"`
	Name       string   `json:"name"`
	PublicKey  string   `json:"publicKey"`
	Types      []string `json:"types"`
	TrustLevel int      `json:"trustLevel"`
	CreatedAt  string   `json:"createdAt"`
	Status     string   `json:"status"`
}

IssuerReply represents an issuer in RPC responses

type ListIssuersArgs

type ListIssuersArgs struct {
	Type   string `json:"type,omitempty"`   // Filter by credential type
	Status string `json:"status,omitempty"` // Filter by status
}

ListIssuersArgs are arguments for ListIssuers

type ListIssuersReply

type ListIssuersReply struct {
	Issuers []IssuerReply `json:"issuers"`
}

ListIssuersReply is the reply for ListIssuers

type RegisterIssuerArgs

type RegisterIssuerArgs struct {
	Name       string   `json:"name"`
	PublicKey  string   `json:"publicKey"` // Base64-encoded
	Types      []string `json:"types"`
	TrustLevel int      `json:"trustLevel"`
	// Fee is the user-paid tx burn in nLUX.
	Fee uint64 `json:"fee"`
}

RegisterIssuerArgs are arguments for RegisterIssuer

type RegisterIssuerReply

type RegisterIssuerReply struct {
	IssuerID string `json:"issuerId"`
}

RegisterIssuerReply is the reply for RegisterIssuer

type ResolveIdentityArgs

type ResolveIdentityArgs struct {
	DID string `json:"did"`
}

ResolveIdentityArgs are arguments for ResolveIdentity

type ResolveIdentityReply

type ResolveIdentityReply struct {
	Identity IdentityReply `json:"identity"`
}

ResolveIdentityReply is the reply for ResolveIdentity

type RevocationEntry

type RevocationEntry struct {
	CredentialID ids.ID    `json:"credentialId"`
	RevokedBy    ids.ID    `json:"revokedBy"`
	RevokedAt    time.Time `json:"revokedAt"`
	Reason       string    `json:"reason"`
}

RevocationEntry represents a credential revocation

type RevokeCredentialArgs

type RevokeCredentialArgs struct {
	CredentialID string `json:"credentialId"`
	RevokerID    string `json:"revokerId"`
	Reason       string `json:"reason"`
	// Fee is the user-paid tx burn in nLUX.
	Fee uint64 `json:"fee"`
}

RevokeCredentialArgs are arguments for RevokeCredential

type RevokeCredentialReply

type RevokeCredentialReply struct {
	Success bool `json:"success"`
}

RevokeCredentialReply is the reply for RevokeCredential

type Service

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

Service provides RPC access to the IdentityVM

func (*Service) CreateIdentity

func (s *Service) CreateIdentity(r *http.Request, args *CreateIdentityArgs, reply *CreateIdentityReply) error

CreateIdentity creates a new decentralized identity

func (*Service) CreateProof

func (s *Service) CreateProof(r *http.Request, args *CreateProofArgs, reply *CreateProofReply) error

CreateProof creates a credential proof artifact

func (*Service) GetCredential

func (s *Service) GetCredential(r *http.Request, args *GetCredentialArgs, reply *GetCredentialReply) error

GetCredential returns a credential by ID

func (*Service) GetIdentity

func (s *Service) GetIdentity(r *http.Request, args *GetIdentityArgs, reply *GetIdentityReply) error

GetIdentity returns an identity by ID

func (*Service) GetIssuer

func (s *Service) GetIssuer(r *http.Request, args *GetIssuerArgs, reply *GetIssuerReply) error

GetIssuer returns an issuer by ID

func (*Service) Health

func (s *Service) Health(r *http.Request, args *HealthArgs, reply *HealthReply) error

Health returns health status

func (*Service) IssueCredential

func (s *Service) IssueCredential(r *http.Request, args *IssueCredentialArgs, reply *IssueCredentialReply) error

IssueCredential issues a new verifiable credential

func (*Service) ListIssuers

func (s *Service) ListIssuers(r *http.Request, args *ListIssuersArgs, reply *ListIssuersReply) error

ListIssuers lists all issuers

func (*Service) RegisterIssuer

func (s *Service) RegisterIssuer(r *http.Request, args *RegisterIssuerArgs, reply *RegisterIssuerReply) error

RegisterIssuer registers a new credential issuer

func (*Service) ResolveIdentity

func (s *Service) ResolveIdentity(r *http.Request, args *ResolveIdentityArgs, reply *ResolveIdentityReply) error

ResolveIdentity resolves an identity by DID

func (*Service) RevokeCredential

func (s *Service) RevokeCredential(r *http.Request, args *RevokeCredentialArgs, reply *RevokeCredentialReply) error

RevokeCredential revokes a credential

func (*Service) VerifyCredential

func (s *Service) VerifyCredential(r *http.Request, args *VerifyCredentialArgs, reply *VerifyCredentialReply) error

VerifyCredential verifies a credential

type ServiceEndpoint

type ServiceEndpoint struct {
	ID              string `json:"id"`
	Type            string `json:"type"`
	ServiceEndpoint string `json:"serviceEndpoint"`
}

ServiceEndpoint represents a service associated with an identity

type VM

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

VM implements the IdentityVM for decentralized identity

func (*VM) BuildBlock

func (vm *VM) BuildBlock(ctx context.Context) (vmchain.Block, error)

BuildBlock implements chain.ChainVM. Reading the tip and registering the block on it happen in one step, so nothing can be accepted in between and leave the proposal hanging off a parent that is no longer the tip.

func (*VM) Connected

func (vm *VM) Connected(ctx context.Context, nodeID ids.NodeID, nodeVersion *vmchain.VersionInfo) error

Connected implements chain.ChainVM

func (*VM) CreateCredentialProof

func (vm *VM) CreateCredentialProof(credID ids.ID, zkProof []byte, selectiveDisclosure []string) (*artifacts.CredentialProof, error)

CreateCredentialProof creates a CredentialProof artifact

func (*VM) CreateHandlers

func (vm *VM) CreateHandlers(ctx context.Context) (map[string]http.Handler, error)

CreateHandlers implements chain.ChainVM

func (*VM) CreateIdentity

func (vm *VM) CreateIdentity(publicKey []byte, metadata map[string]string) (*Identity, error)

CreateIdentity creates a new decentralized identity

func (*VM) Disconnected

func (vm *VM) Disconnected(ctx context.Context, nodeID ids.NodeID) error

Disconnected implements chain.ChainVM

func (*VM) FeePolicy added in v1.2.6

func (vm *VM) FeePolicy() fee.Policy

FeePolicy exposes the chain's declared fee policy for diagnostics and the boot-time Validate gate.

func (*VM) GetBlock

func (vm *VM) GetBlock(ctx context.Context, blockID ids.ID) (vmchain.Block, error)

GetBlock implements chain.ChainVM

func (*VM) GetBlockIDAtHeight

func (vm *VM) GetBlockIDAtHeight(ctx context.Context, height uint64) (ids.ID, error)

GetBlockIDAtHeight answers from the height index the store writes in the same commit as the block itself, so the index can never name a block the chain did not accept.

func (*VM) GetCredential

func (vm *VM) GetCredential(credID ids.ID) (*Credential, error)

GetCredential returns a credential by ID

func (*VM) GetIdentity

func (vm *VM) GetIdentity(identityID ids.ID) (*Identity, error)

GetIdentity returns an identity by ID

func (*VM) GetIssuer

func (vm *VM) GetIssuer(issuerID ids.ID) (*Issuer, error)

GetIssuer returns an issuer by ID

func (*VM) HealthCheck

func (vm *VM) HealthCheck(ctx context.Context) (vmchain.HealthResult, error)

HealthCheck implements chain.ChainVM

func (*VM) Initialize

func (vm *VM) Initialize(
	ctx context.Context,
	vmInit vmcore.Init,
) error

Initialize implements chain.ChainVM

func (*VM) IssueCredential

func (vm *VM) IssueCredential(issuerID, subjectID ids.ID, credType []string, claims map[string]interface{}, ttl time.Duration) (*Credential, error)

IssueCredential issues a new verifiable credential

func (*VM) LastAccepted

func (vm *VM) LastAccepted(ctx context.Context) (ids.ID, error)

LastAccepted implements chain.ChainVM

func (*VM) NewHTTPHandler

func (vm *VM) NewHTTPHandler(ctx context.Context) (http.Handler, error)

NewHTTPHandler implements chain.ChainVM

func (*VM) ParseBlock

func (vm *VM) ParseBlock(ctx context.Context, blockBytes []byte) (vmchain.Block, error)

ParseBlock implements chain.ChainVM

func (*VM) RegisterIssuer

func (vm *VM) RegisterIssuer(name string, publicKey []byte, types []string, trustLevel int) (*Issuer, error)

RegisterIssuer registers a new credential issuer

func (*VM) ResolveIdentity

func (vm *VM) ResolveIdentity(did string) (*Identity, error)

ResolveIdentity resolves an identity by DID

func (*VM) RevokeCredential

func (vm *VM) RevokeCredential(credID ids.ID, revokerID ids.ID, reason string) error

RevokeCredential revokes a credential

func (*VM) SetPreference

func (vm *VM) SetPreference(ctx context.Context, blockID ids.ID) error

SetPreference implements chain.ChainVM

func (*VM) SetState

func (vm *VM) SetState(ctx context.Context, state uint32) error

SetState implements chain.ChainVM

func (*VM) Shutdown

func (vm *VM) Shutdown(ctx context.Context) error

Shutdown implements chain.ChainVM

func (*VM) VerifyCredential

func (vm *VM) VerifyCredential(credID ids.ID) (bool, error)

VerifyCredential verifies a credential is valid

func (*VM) Version

func (vm *VM) Version(ctx context.Context) (string, error)

Version implements chain.ChainVM

func (*VM) WaitForEvent

func (vm *VM) WaitForEvent(ctx context.Context) (vmcore.Message, error)

WaitForEvent implements chain.ChainVM WaitForEvent blocks until there is a credential to build a block from, or the VM stops. Waiting only on the context would mean BuildBlock is never called and the chain never leaves genesis, however many credentials are issued.

type VerifyCredentialArgs

type VerifyCredentialArgs struct {
	CredentialID string `json:"credentialId"`
}

VerifyCredentialArgs are arguments for VerifyCredential

type VerifyCredentialReply

type VerifyCredentialReply struct {
	Valid   bool   `json:"valid"`
	Status  string `json:"status"`
	Message string `json:"message,omitempty"`
}

VerifyCredentialReply is the reply for VerifyCredential

Directories

Path Synopsis
cmd
plugin command

Jump to

Keyboard shortcuts

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