verifiable

package
v1.3.1-nbo-0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2023 License: Apache-2.0, MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
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"

	// 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"

	// 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"
)
View Source
const (
	// DIDDocumentJSONSchema is a basic schema of did document
	DIDDocumentJSONSchema = `` /* 4391-byte string literal not displayed */

)

Variables

View Source
var ErrProofNotFound = errors.New("proof not found")

ErrProofNotFound is an error when specific proof is not found in the credential

Functions

This section is empty.

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"`
	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"`
}

CommonVerificationMethod DID doc verification method.

type CredentialProof

type CredentialProof interface {
	ProofType() ProofType
	GetCoreClaim() (*core.Claim, error)
}

type CredentialProofs

type CredentialProofs []CredentialProof

func (*CredentialProofs) UnmarshalJSON

func (cps *CredentialProofs) UnmarshalJSON(bs []byte) error

type CredentialSchema

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

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 CredentialStatusType

type CredentialStatusType string

CredentialStatusType type for understanding revocation type

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 DeviceMetadata

type DeviceMetadata struct {
	AppID     string `json:"app_id"`
	PushToken string `json:"push_token"`
}

DeviceMetadata describes the structure of device metadata

type EncryptedDeviceMetadata

type EncryptedDeviceMetadata struct {
	Ciphertext string `json:"ciphertext"` // base64 encoded
	Alg        string `json:"alg"`
}

EncryptedDeviceMetadata describes the structure of encrypted device metadata

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 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 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 ProofType

type ProofType string

ProofType represent proofs types.

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 RevocationStatus

type RevocationStatus struct {
	Issuer struct {
		State              *string `json:"state,omitempty"`
		RootOfRoots        *string `json:"rootOfRoots,omitempty"`
		ClaimsTreeRoot     *string `json:"claimsTreeRoot,omitempty"`
		RevocationTreeRoot *string `json:"revocationTreeRoot,omitempty"`
	} `json:"issuer"`
	MTP mt.Proof `json:"mtp"`
}

RevocationStatus status of revocation nonce. Info required to check revocation state of claim in circuits

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 W3CCredential

type W3CCredential struct {
	ID                string                 `json:"id"`
	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"`
}

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

Merklize merklizes verifiable credential

type ZKProof

type ZKProof struct {
	Proof      *ProofData `json:"proof"`
	PubSignals []string   `json:"pub_signals"`
}

ZKProof is proof data with public signals

Jump to

Keyboard shortcuts

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