Documentation
¶
Index ¶
- Constants
- Variables
- func DeleteStatusResolver(resolverType CredentialStatusType)
- func GetIssuerDID(ctx context.Context) *w3c.DID
- func GetSerializationAttrFromParsedContext(ldCtx *ld.Context, tp string) (string, error)
- func ParseSerializationAttr(serAttr string) (slotsPaths, error)
- func RegisterStatusResolver(resolverType CredentialStatusType, resolver CredentialStatusResolver)
- func WithIssuerDID(ctx context.Context, issuerDID *w3c.DID) context.Context
- type Authentication
- type BJJSignatureProof2021
- type CommonProof
- type CommonVerificationMethod
- type CoreClaimOptions
- type CredentialProof
- type CredentialProofs
- type CredentialSchema
- type CredentialStatus
- type CredentialStatusResolver
- type CredentialStatusResolverRegistry
- func (r *CredentialStatusResolverRegistry) Delete(resolverType CredentialStatusType)
- func (r *CredentialStatusResolverRegistry) Get(resolverType CredentialStatusType) (CredentialStatusResolver, error)
- func (r *CredentialStatusResolverRegistry) Register(resolverType CredentialStatusType, resolver CredentialStatusResolver)
- type CredentialStatusType
- type CredentialStatusValidationOption
- type DIDDocument
- type DIDResolver
- type DeviceMetadata
- type DisplayMethod
- type DisplayMethodType
- type EncryptedDeviceMetadata
- type GistInfo
- type HTTPDIDResolver
- type Iden3SparseMerkleProofdeprecated
- type Iden3SparseMerkleTreeProof
- type IdentityState
- type IssuerData
- type IssuerResolver
- type ProofData
- type ProofPurpose
- type ProofType
- type PushMetadata
- type PushService
- type RHSCredentialStatus
- type RefreshService
- type RefreshServiceType
- type RevocationStatus
- type Service
- type State
- type StateInfo
- type TreeState
- type W3CCredential
- func (vc *W3CCredential) GetCoreClaimFromProof(proofType ProofType) (*core.Claim, error)
- func (vc *W3CCredential) Merklize(ctx context.Context, opts ...merklize.MerklizeOption) (*merklize.Merklizer, error)
- func (vc *W3CCredential) ToCoreClaim(ctx context.Context, opts *CoreClaimOptions) (*core.Claim, error)
- func (vc *W3CCredential) VerifyProof(ctx context.Context, proofType ProofType, didResolver DIDResolver, ...) error
- type W3CProofVerificationOpt
- type WebRedirectService
- type ZKProof
Constants ¶
const ( // TypeW3CVerifiableCredential is of the w3c verifiable credential standard TypeW3CVerifiableCredential = "VerifiableCredential" // JSONLDSchemaIden3Credential is a schema for context with W3CCredential type JSONLDSchemaIden3Credential = "https://schema.iden3.io/core/jsonld/iden3proofs.jsonld" // JSONLDSchemaW3CCredential2018 is a schema for context with VerifiableCredential type JSONLDSchemaW3CCredential2018 = "https://www.w3.org/2018/credentials/v1" // JSONLDSchemaW3CCredential2020 is a schema for context with Display method type JSONLDSchemaIden3DisplayMethod = "https://schema.iden3.io/core/jsonld/displayMethod.jsonld" // SparseMerkleTreeProof is CredentialStatusType for standard MTP result handlers SparseMerkleTreeProof CredentialStatusType = "SparseMerkleTreeProof" // Iden3ReverseSparseMerkleTreeProof is CredentialStatusType for reverse iden3 algorithm Iden3ReverseSparseMerkleTreeProof CredentialStatusType = "Iden3ReverseSparseMerkleTreeProof" // JSONSchemaValidator2018 JSON schema for verification of W3CCredential // Deprecated: https://www.w3.org/2018/credentials/#JsonSchemaValidator2018 JSONSchemaValidator2018 = "JsonSchemaValidator2018" // JSONSchema2023 JSON schema for verification of W3CCredential (https://www.w3.org/TR/vc-json-schema/#jsonschema2023) JSONSchema2023 = "JsonSchema2023" // BJJSignatureProofType is a proof type for BJJ signature proofs BJJSignatureProofType ProofType = "BJJSignature2021" // Iden3SparseMerkleProofType is a proof type for MTP proofs with iden3 metadata // // Deprecated: Iden3SparseMerkleProofType is not correct semantically and replaced by Iden3SparseMerkleTreeProofType Iden3SparseMerkleProofType ProofType = "Iden3SparseMerkleProof" // Iden3SparseMerkleTreeProofType is a proof type for MTP proofs with iden3 metadata. Context is defined here: https://schema.iden3.io/core/jsonld/iden3proofs.jsonld Iden3SparseMerkleTreeProofType ProofType = "Iden3SparseMerkleTreeProof" // SparseMerkleTreeProofType ia a standard SMT proof type SparseMerkleTreeProofType ProofType = "SparseMerkleTreeProof" // ProofPurposeAuthentication defines a proof for authentication ProofPurposeAuthentication ProofPurpose = "Authentication" // Iden3CommServiceType is service type for iden3comm protocol Iden3CommServiceType = "iden3-communication" // PushNotificationServiceType is service type for delivering push notifications to identity PushNotificationServiceType = "push-notification" // Iden3MobileServiceType is service type for mobile function invoke to reach user agent in iden3 protocol Iden3MobileServiceType = "Iden3MobileServiceV1" // Iden3WebServiceType is service type for web redirects as a way to reach user agent in iden3 protocol Iden3WebServiceType = "Iden3WebRedirectServiceV1" // CredentialMerklizedRootPositionIndex is merklized root position of W3CCredential in the IndexDataSlotA (core claim) CredentialMerklizedRootPositionIndex = "index" // CredentialMerklizedRootPositionValue is merklized root position of W3CCredential in the ValueDataSlotA (core claim) CredentialMerklizedRootPositionValue = "value" // CredentialMerklizedRootPositionNone is for non-merklized W3CCredential CredentialMerklizedRootPositionNone = "" // CredentialSubjectPositionIndex is subject position of W3CCredential in index (core claim) CredentialSubjectPositionIndex = "index" // CredentialSubjectPositionValue is subject position of W3CCredential in value (core claim) CredentialSubjectPositionValue = "value" // CredentialSubjectRootPositionValue is subject position of W3CCredential in value (core claim) // Deprecated: use CredentialSubjectPositionValue instead CredentialSubjectRootPositionValue = "value" // Iden3commRevocationStatusV1 is CredentialStatusType for iden3comm revocation status Iden3commRevocationStatusV1 CredentialStatusType = "Iden3commRevocationStatusV1.0" // Iden3OnсhainSparseMerkleTreeProof2023 is a proof type for MTP proofs with iden3 metadata from blockchain Iden3OnchainSparseMerkleTreeProof2023 CredentialStatusType = "Iden3OnchainSparseMerkleTreeProof2023" // Iden3RefreshService2023 is the type of refresh service Iden3RefreshService2023 RefreshServiceType = "Iden3RefreshService2023" // Iden3BasicDisplayMethodV1 is the type fof basic display method Iden3BasicDisplayMethodV1 DisplayMethodType = "Iden3BasicDisplayMethodV1" )
const ( // DIDDocumentJSONSchema is a basic schema of did document DIDDocumentJSONSchema = `` /* 4463-byte string literal not displayed */ )
Variables ¶
var DefaultCredentialStatusResolverRegistry = &CredentialStatusResolverRegistry{}
var ErrCredentialIsRevoked = errors.New("credential is revoked")
var ErrProofNotFound = errors.New("proof not found")
ErrProofNotFound is an error when specific proof is not found in the credential
var ErrProofNotSupported = errors.New("proof not supported")
ErrProofNotSupported is an error when specific proof is not supported for validation
Functions ¶
func DeleteStatusResolver ¶ added in v2.3.0
func DeleteStatusResolver(resolverType CredentialStatusType)
func GetIssuerDID ¶ added in v2.3.0
GetIssuerDID extract the issuer DID from the context. Or nil if nothing is found.
func GetSerializationAttrFromParsedContext ¶ added in v2.3.1
func ParseSerializationAttr ¶ added in v2.3.1
func RegisterStatusResolver ¶ added in v2.3.0
func RegisterStatusResolver(resolverType CredentialStatusType, resolver CredentialStatusResolver)
Types ¶
type Authentication ¶
type Authentication struct { CommonVerificationMethod // contains filtered or unexported fields }
func (*Authentication) DID ¶
func (a *Authentication) DID() string
func (*Authentication) IsDID ¶
func (a *Authentication) IsDID() bool
func (*Authentication) MarshalJSON ¶
func (a *Authentication) MarshalJSON() ([]byte, error)
func (*Authentication) UnmarshalJSON ¶
func (a *Authentication) UnmarshalJSON(b []byte) error
type BJJSignatureProof2021 ¶
type BJJSignatureProof2021 struct { Type ProofType `json:"type"` IssuerData IssuerData `json:"issuerData"` CoreClaim string `json:"coreClaim"` Signature string `json:"signature"` }
BJJSignatureProof2021 JSON-LD BBJJSignatureProof
func (*BJJSignatureProof2021) GetCoreClaim ¶
func (p *BJJSignatureProof2021) GetCoreClaim() (*core.Claim, error)
func (*BJJSignatureProof2021) ProofType ¶
func (p *BJJSignatureProof2021) ProofType() ProofType
func (*BJJSignatureProof2021) UnmarshalJSON ¶
func (p *BJJSignatureProof2021) UnmarshalJSON(in []byte) error
type CommonProof ¶
type CommonProof jsonObj
func (*CommonProof) GetCoreClaim ¶
func (p *CommonProof) GetCoreClaim() (*core.Claim, error)
func (*CommonProof) ProofType ¶
func (p *CommonProof) ProofType() ProofType
func (*CommonProof) UnmarshalJSON ¶
func (p *CommonProof) UnmarshalJSON(bytes []byte) error
type CommonVerificationMethod ¶
type CommonVerificationMethod struct { ID string `json:"id"` Type string `json:"type"` Controller string `json:"controller"` PublicKeyJwk map[string]interface{} `json:"publicKeyJwk,omitempty"` PublicKeyMultibase string `json:"publicKeyMultibase,omitempty"` PublicKeyHex string `json:"publicKeyHex,omitempty"` PublicKeyBase58 string `json:"publicKeyBase58,omitempty"` EthereumAddress string `json:"ethereumAddress,omitempty"` BlockchainAccountID string `json:"blockchainAccountId,omitempty"` StateContractAddress string `json:"stateContractAddress,omitempty"` IdentityState }
CommonVerificationMethod DID doc verification method.
type CoreClaimOptions ¶ added in v2.3.1
type CoreClaimOptions struct { RevNonce uint64 `json:"revNonce"` Version uint32 `json:"version"` SubjectPosition string `json:"subjectPosition"` MerklizedRootPosition string `json:"merklizedRootPosition"` Updatable bool `json:"updatable"` MerklizerOpts []merklize.MerklizeOption }
CoreClaimOptions is params for core claim parsing
type CredentialProof ¶
type CredentialProofs ¶
type CredentialProofs []CredentialProof
func (*CredentialProofs) UnmarshalJSON ¶
func (cps *CredentialProofs) UnmarshalJSON(bs []byte) error
type CredentialSchema ¶
CredentialSchema represent the information about credential schema
type CredentialStatus ¶
type CredentialStatus struct { ID string `json:"id"` Type CredentialStatusType `json:"type"` RevocationNonce uint64 `json:"revocationNonce"` StatusIssuer *CredentialStatus `json:"statusIssuer,omitempty"` }
CredentialStatus represents the URL to fetch claim revocation info directly from the issuer.
type CredentialStatusResolver ¶ added in v2.3.0
type CredentialStatusResolver interface { Resolve(ctx context.Context, credentialStatus CredentialStatus) (RevocationStatus, error) }
CredentialStatusResolver is an interface that allows to interact with deifferent types of credential status to resolve revocation status
func GetStatusResolver ¶ added in v2.3.0
func GetStatusResolver( resolverType CredentialStatusType) (CredentialStatusResolver, error)
type CredentialStatusResolverRegistry ¶ added in v2.3.0
type CredentialStatusResolverRegistry struct {
// contains filtered or unexported fields
}
CredentialStatusResolverRegistry is a registry of CredentialStatusResolver
func (*CredentialStatusResolverRegistry) Delete ¶ added in v2.3.0
func (r *CredentialStatusResolverRegistry) Delete(resolverType CredentialStatusType)
func (*CredentialStatusResolverRegistry) Get ¶ added in v2.3.0
func (r *CredentialStatusResolverRegistry) Get(resolverType CredentialStatusType) (CredentialStatusResolver, error)
func (*CredentialStatusResolverRegistry) Register ¶ added in v2.3.0
func (r *CredentialStatusResolverRegistry) Register(resolverType CredentialStatusType, resolver CredentialStatusResolver)
type CredentialStatusType ¶
type CredentialStatusType string
CredentialStatusType type for understanding revocation type
type CredentialStatusValidationOption ¶ added in v2.3.0
type CredentialStatusValidationOption func(*credentialStatusValidationOpts) error
func WithValidationStatusResolverRegistry ¶ added in v2.3.0
func WithValidationStatusResolverRegistry( registry *CredentialStatusResolverRegistry) CredentialStatusValidationOption
type DIDDocument ¶
type DIDDocument struct { Context interface{} `json:"@context"` ID string `json:"id"` Service []interface{} `json:"service,omitempty"` VerificationMethod []CommonVerificationMethod `json:"verificationMethod,omitempty"` Authentication []Authentication `json:"authentication,omitempty"` KeyAgreement []interface{} `json:"keyAgreement,omitempty"` }
DIDDocument defines current supported did doc model.
type DIDResolver ¶ added in v2.3.0
type DeviceMetadata ¶
DeviceMetadata describes the structure of device metadata
type DisplayMethod ¶ added in v2.1.2
type DisplayMethod struct { ID string `json:"id"` Type DisplayMethodType `json:"type"` }
type DisplayMethodType ¶ added in v2.1.2
type DisplayMethodType string
type EncryptedDeviceMetadata ¶
type EncryptedDeviceMetadata struct { Ciphertext string `json:"ciphertext"` // base64 encoded Alg string `json:"alg"` }
EncryptedDeviceMetadata describes the structure of encrypted device metadata
type GistInfo ¶
type GistInfo struct { Root string `json:"root"` ReplacedByRoot string `json:"replacedByRoot"` CreatedAtTimestamp string `json:"createdAtTimestamp"` ReplacedAtTimestamp string `json:"replacedAtTimestamp"` CreatedAtBlock string `json:"createdAtBlock"` ReplacedAtBlock string `json:"replacedAtBlock"` }
GistInfo representation state of gist root.
type HTTPDIDResolver ¶ added in v2.3.0
type HTTPDIDResolver struct {
// contains filtered or unexported fields
}
func (HTTPDIDResolver) Resolve ¶ added in v2.3.0
func (r HTTPDIDResolver) Resolve(ctx context.Context, did *w3c.DID) (out DIDDocument, err error)
type Iden3SparseMerkleProof
deprecated
type Iden3SparseMerkleProof struct { Type ProofType `json:"type"` IssuerData IssuerData `json:"issuerData"` CoreClaim string `json:"coreClaim"` MTP *mt.Proof `json:"mtp"` }
Iden3SparseMerkleProof JSON-LD structure
Deprecated: replaced with Iden3SparseMerkleTreeProof
func (*Iden3SparseMerkleProof) GetCoreClaim ¶
func (p *Iden3SparseMerkleProof) GetCoreClaim() (*core.Claim, error)
func (*Iden3SparseMerkleProof) ProofType ¶
func (p *Iden3SparseMerkleProof) ProofType() ProofType
func (*Iden3SparseMerkleProof) UnmarshalJSON ¶
func (p *Iden3SparseMerkleProof) UnmarshalJSON(in []byte) error
type Iden3SparseMerkleTreeProof ¶
type Iden3SparseMerkleTreeProof struct { Type ProofType `json:"type"` IssuerData IssuerData `json:"issuerData"` CoreClaim string `json:"coreClaim"` MTP *mt.Proof `json:"mtp"` }
Iden3SparseMerkleTreeProof JSON-LD structure
func (*Iden3SparseMerkleTreeProof) GetCoreClaim ¶
func (p *Iden3SparseMerkleTreeProof) GetCoreClaim() (*core.Claim, error)
func (*Iden3SparseMerkleTreeProof) ProofType ¶
func (p *Iden3SparseMerkleTreeProof) ProofType() ProofType
func (*Iden3SparseMerkleTreeProof) UnmarshalJSON ¶
func (p *Iden3SparseMerkleTreeProof) UnmarshalJSON(in []byte) error
type IdentityState ¶
type IdentityState struct { Published *bool `json:"published,omitempty"` Info *StateInfo `json:"info,omitempty"` Global *GistInfo `json:"global,omitempty"` }
IdentityState representation all info about identity.
type IssuerData ¶
type IssuerData struct { ID string `json:"id,omitempty"` State State `json:"state,omitempty"` AuthCoreClaim string `json:"authCoreClaim,omitempty"` MTP *mt.Proof `json:"mtp,omitempty"` CredentialStatus interface{} `json:"credentialStatus,omitempty"` }
IssuerData is the data that is used to create a proof
type IssuerResolver ¶ added in v2.3.0
type IssuerResolver struct { }
func (IssuerResolver) Resolve ¶ added in v2.3.0
func (IssuerResolver) Resolve(ctx context.Context, credentialStatus CredentialStatus) (out RevocationStatus, err error)
type ProofData ¶
type ProofData struct { A []string `json:"pi_a"` B [][]string `json:"pi_b"` C []string `json:"pi_c"` Protocol string `json:"protocol"` }
ProofData is structure that represents SnarkJS library result of proof generation
type ProofPurpose ¶
type ProofPurpose string
ProofPurpose is alias for string, represents proof purpose
type PushMetadata ¶
type PushMetadata struct {
Devices []EncryptedDeviceMetadata `json:"devices"`
}
PushMetadata describes the structure of the data for push notifications
type PushService ¶
type PushService struct { Service Metadata PushMetadata `json:"metadata"` }
PushService describes the services of push notifications
type RHSCredentialStatus ¶
type RHSCredentialStatus struct { ID string `json:"id"` Type CredentialStatusType `json:"type"` RevocationNonce uint64 `json:"revocationNonce"` StatusIssuer *CredentialStatus `json:"statusIssuer,omitempty"` }
RHSCredentialStatus contains type, url to fetch RHS info, issuer ID and revocation nonce and backup option to fetch credential status Deprecated: use CredentialStatus instead
type RefreshService ¶ added in v2.1.0
type RefreshService struct { ID string `json:"id"` Type RefreshServiceType `json:"type"` }
RefreshService is struct that represents refresh service json-ld document
type RefreshServiceType ¶ added in v2.1.0
type RefreshServiceType string
RefreshServiceType represent refresh service types
type RevocationStatus ¶
type RevocationStatus struct { Issuer TreeState `json:"issuer"` MTP merkletree.Proof `json:"mtp"` }
RevocationStatus status of revocation nonce. Info required to check revocation state of claim in circuits
func ValidateCredentialStatus ¶ added in v2.3.0
func ValidateCredentialStatus(ctx context.Context, credStatus CredentialStatus, opts ...CredentialStatusValidationOption) (RevocationStatus, error)
ValidateCredentialStatus resolves the credential status (possibly download proofs from outer world) and validates the proof. May return ErrCredentialIsRevoked if the credential was revoked.
type Service ¶
type Service struct { ID string `json:"id"` Type string `json:"type"` ServiceEndpoint string `json:"serviceEndpoint"` }
Service describes standard DID document service field.
type State ¶
type State struct { TxID *string `json:"txId,omitempty"` BlockTimestamp *int `json:"blockTimestamp,omitempty"` BlockNumber *int `json:"blockNumber,omitempty"` RootOfRoots *string `json:"rootOfRoots,omitempty"` ClaimsTreeRoot *string `json:"claimsTreeRoot,omitempty"` RevocationTreeRoot *string `json:"revocationTreeRoot,omitempty"` Value *string `json:"value,omitempty"` Status string `json:"status,omitempty"` }
State represents the state of the issuer
type StateInfo ¶
type StateInfo struct { ID string `json:"id"` State string `json:"state"` ReplacedByState string `json:"replacedByState"` CreatedAtTimestamp string `json:"createdAtTimestamp"` ReplacedAtTimestamp string `json:"replacedAtTimestamp"` CreatedAtBlock string `json:"createdAtBlock"` ReplacedAtBlock string `json:"replacedAtBlock"` }
StateInfo is information about identity state
type W3CCredential ¶
type W3CCredential struct { ID string `json:"id,omitempty"` Context []string `json:"@context"` Type []string `json:"type"` Expiration *time.Time `json:"expirationDate,omitempty"` IssuanceDate *time.Time `json:"issuanceDate,omitempty"` CredentialSubject map[string]interface{} `json:"credentialSubject"` CredentialStatus interface{} `json:"credentialStatus,omitempty"` Issuer string `json:"issuer"` CredentialSchema CredentialSchema `json:"credentialSchema"` Proof CredentialProofs `json:"proof,omitempty"` RefreshService *RefreshService `json:"refreshService,omitempty"` DisplayMethod *DisplayMethod `json:"displayMethod,omitempty"` }
W3CCredential is struct that represents claim json-ld document
func (*W3CCredential) GetCoreClaimFromProof ¶
func (vc *W3CCredential) GetCoreClaimFromProof(proofType ProofType) (*core.Claim, error)
GetCoreClaimFromProof returns core claim from given proof
func (*W3CCredential) Merklize ¶
func (vc *W3CCredential) Merklize(ctx context.Context, opts ...merklize.MerklizeOption) (*merklize.Merklizer, error)
Merklize merklizes verifiable credential
func (*W3CCredential) ToCoreClaim ¶ added in v2.3.1
func (vc *W3CCredential) ToCoreClaim(ctx context.Context, opts *CoreClaimOptions) (*core.Claim, error)
ToCoreClaim returns Claim object from W3CCredential
func (*W3CCredential) VerifyProof ¶ added in v2.3.0
func (vc *W3CCredential) VerifyProof(ctx context.Context, proofType ProofType, didResolver DIDResolver, opts ...W3CProofVerificationOpt) error
VerifyProof verify credential proof
type W3CProofVerificationOpt ¶ added in v2.3.0
type W3CProofVerificationOpt func(opts *w3CProofVerificationConfig)
W3CProofVerificationOpt returns configuration options for W3C proof verification
func WithStatusResolverRegistry ¶ added in v2.3.0
func WithStatusResolverRegistry(registry *CredentialStatusResolverRegistry) W3CProofVerificationOpt
WithStatusResolverRegistry return new options
type WebRedirectService ¶ added in v2.3.2
WebRedirectService describes the service of web redirection