Documentation
¶
Index ¶
- Constants
- Variables
- type Block
- func (b *Block) Accept(ctx context.Context) error
- func (b *Block) Bytes() []byte
- func (b *Block) Height() uint64
- func (b *Block) ID() ids.ID
- func (b *Block) Marshal() ([]byte, error)
- func (b *Block) Parent() ids.ID
- func (b *Block) ParentID() ids.ID
- func (b *Block) Publish()
- func (b *Block) Reject(ctx context.Context) error
- func (b *Block) Status() uint8
- func (b *Block) Timestamp() time.Time
- func (b *Block) Verify(ctx context.Context) error
- func (b *Block) Write(db database.Database) error
- type Config
- type CreateIdentityArgs
- type CreateIdentityReply
- type CreateProofArgs
- type CreateProofReply
- type Credential
- type CredentialProof
- type CredentialReply
- type Factory
- type Genesis
- type GetCredentialArgs
- type GetCredentialReply
- type GetIdentityArgs
- type GetIdentityReply
- type GetIssuerArgs
- type GetIssuerReply
- type HealthArgs
- type HealthReply
- type Identity
- type IdentityReply
- type IssueCredentialArgs
- type IssueCredentialReply
- type Issuer
- type IssuerReply
- type ListIssuersArgs
- type ListIssuersReply
- type RegisterIssuerArgs
- type RegisterIssuerReply
- type ResolveIdentityArgs
- type ResolveIdentityReply
- type RevocationEntry
- type RevokeCredentialArgs
- type RevokeCredentialReply
- type Service
- func (s *Service) CreateIdentity(r *http.Request, args *CreateIdentityArgs, reply *CreateIdentityReply) error
- func (s *Service) CreateProof(r *http.Request, args *CreateProofArgs, reply *CreateProofReply) error
- func (s *Service) GetCredential(r *http.Request, args *GetCredentialArgs, reply *GetCredentialReply) error
- func (s *Service) GetIdentity(r *http.Request, args *GetIdentityArgs, reply *GetIdentityReply) error
- func (s *Service) GetIssuer(r *http.Request, args *GetIssuerArgs, reply *GetIssuerReply) error
- func (s *Service) Health(r *http.Request, args *HealthArgs, reply *HealthReply) error
- func (s *Service) IssueCredential(r *http.Request, args *IssueCredentialArgs, reply *IssueCredentialReply) error
- func (s *Service) ListIssuers(r *http.Request, args *ListIssuersArgs, reply *ListIssuersReply) error
- func (s *Service) RegisterIssuer(r *http.Request, args *RegisterIssuerArgs, reply *RegisterIssuerReply) error
- func (s *Service) ResolveIdentity(r *http.Request, args *ResolveIdentityArgs, reply *ResolveIdentityReply) error
- func (s *Service) RevokeCredential(r *http.Request, args *RevokeCredentialArgs, reply *RevokeCredentialReply) error
- func (s *Service) VerifyCredential(r *http.Request, args *VerifyCredentialArgs, reply *VerifyCredentialReply) error
- type ServiceEndpoint
- type VM
- func (vm *VM) BuildBlock(ctx context.Context) (vmchain.Block, error)
- func (vm *VM) Connected(ctx context.Context, nodeID ids.NodeID, nodeVersion *vmchain.VersionInfo) error
- func (vm *VM) CreateCredentialProof(credID ids.ID, zkProof []byte, selectiveDisclosure []string) (*artifacts.CredentialProof, error)
- func (vm *VM) CreateHandlers(ctx context.Context) (map[string]http.Handler, error)
- func (vm *VM) CreateIdentity(publicKey []byte, metadata map[string]string) (*Identity, error)
- func (vm *VM) Disconnected(ctx context.Context, nodeID ids.NodeID) error
- func (vm *VM) FeePolicy() fee.Policy
- func (vm *VM) GetBlock(ctx context.Context, blockID ids.ID) (vmchain.Block, error)
- func (vm *VM) GetBlockIDAtHeight(ctx context.Context, height uint64) (ids.ID, error)
- func (vm *VM) GetCredential(credID ids.ID) (*Credential, error)
- func (vm *VM) GetIdentity(identityID ids.ID) (*Identity, error)
- func (vm *VM) GetIssuer(issuerID ids.ID) (*Issuer, error)
- func (vm *VM) HealthCheck(ctx context.Context) (vmchain.HealthResult, error)
- func (vm *VM) Initialize(ctx context.Context, vmInit vmcore.Init) error
- func (vm *VM) IssueCredential(issuerID, subjectID ids.ID, credType []string, claims map[string]interface{}, ...) (*Credential, error)
- func (vm *VM) LastAccepted(ctx context.Context) (ids.ID, error)
- func (vm *VM) NewHTTPHandler(ctx context.Context) (http.Handler, error)
- func (vm *VM) ParseBlock(ctx context.Context, blockBytes []byte) (vmchain.Block, error)
- func (vm *VM) RegisterIssuer(name string, publicKey []byte, types []string, trustLevel int) (*Issuer, error)
- func (vm *VM) ResolveIdentity(did string) (*Identity, error)
- func (vm *VM) RevokeCredential(credID ids.ID, revokerID ids.ID, reason string) error
- func (vm *VM) SetPreference(ctx context.Context, blockID ids.ID) error
- func (vm *VM) SetState(ctx context.Context, state uint32) error
- func (vm *VM) Shutdown(ctx context.Context) error
- func (vm *VM) VerifyCredential(credID ids.ID) (bool, error)
- func (vm *VM) Version(ctx context.Context) (string, error)
- func (vm *VM) WaitForEvent(ctx context.Context) (vmcore.Message, error)
- type VerifyCredentialArgs
- type VerifyCredentialReply
Constants ¶
const ( Name = "identityvm" // Credential states CredentialActive = "active" CredentialRevoked = "revoked" CredentialExpired = "expired" CredentialPending = "pending" )
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 ¶
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 ¶
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) Marshal ¶ added in v1.7.6
Marshal encodes the block (excluding the derived ID_/cache fields) to canonical wire. blockID = sha256(this).
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 ¶
Reject discards the block. It wrote nothing, so there is nothing to undo; its credentials stay queued for a later block.
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 ¶
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 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 ¶
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 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 ¶
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 ¶
CreateHandlers implements chain.ChainVM
func (*VM) CreateIdentity ¶
CreateIdentity creates a new decentralized identity
func (*VM) Disconnected ¶
Disconnected implements chain.ChainVM
func (*VM) FeePolicy ¶ added in v1.2.6
FeePolicy exposes the chain's declared fee policy for diagnostics and the boot-time Validate gate.
func (*VM) GetBlockIDAtHeight ¶
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 ¶
GetIdentity returns an identity by ID
func (*VM) HealthCheck ¶
HealthCheck implements chain.ChainVM
func (*VM) Initialize ¶
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 ¶
LastAccepted implements chain.ChainVM
func (*VM) NewHTTPHandler ¶
NewHTTPHandler implements chain.ChainVM
func (*VM) ParseBlock ¶
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 ¶
ResolveIdentity resolves an identity by DID
func (*VM) RevokeCredential ¶
RevokeCredential revokes a credential
func (*VM) SetPreference ¶
SetPreference implements chain.ChainVM
func (*VM) VerifyCredential ¶
VerifyCredential verifies a credential is valid
func (*VM) WaitForEvent ¶
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