verifiable

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package verifiable provides functionality managing verifiable credentials.

Index

Constants

View Source
const (
	Format             = "application/n-quads"
	AlgorithmURDNA2015 = "URDNA2015"
)

Variables

This section is empty.

Functions

func Canonicalize

func Canonicalize(data any, ldProc *ld.JsonLdProcessor, ldOptions *ld.JsonLdOptions) ([]byte, error)

Canonicalize canonicalizes the data using the given processor and options.

func DefaultDocumentLoader

func DefaultDocumentLoader() (ld.DocumentLoader, error)

func DefaultLdOptions

func DefaultLdOptions() (*ld.JsonLdOptions, error)

DefaultLdOptions returns the default JSON-LD options.

func EncodeList

func EncodeList(data []byte) (string, error)

EncodeList compresses and base64 encodes a list of bytes.

func HashData

func HashData(transformedData, proofConfig []byte) ([]byte, error)

HashData hashes the canonicalized data.

func MustEncodeList

func MustEncodeList(data []byte) string

MustEncodeList compresses and base64 encodes a list of bytes.

Types

type BitstringStatusListSubject

type BitstringStatusListSubject struct {
	ID            string `json:"id,omitempty"`
	Type          string `json:"type,omitempty"`
	StatusPurpose string `json:"statusPurpose,omitempty"`
	EncodedList   string `json:"encodedList,omitempty"`
}

BitstringStatusListSubject represents the subject of the bitstring status list verifiable credential.

type Config

type Config struct {
	PrivateKey        []byte
	ChainID           *big.Int
	VehicleNFTAddress common.Address
	BaseStatusURL     string
}

Config contains the configuration for a Issuer.

type Credential

type Credential struct {
	Context           []string         `json:"@context,omitempty"`
	ID                string           `json:"id,omitempty"`
	Type              []string         `json:"type,omitempty"`
	Issuer            string           `json:"issuer,omitempty"`
	IssuanceDate      string           `json:"issuanceDate,omitempty"`
	ValidFrom         string           `json:"validFrom,omitempty"`
	ExpirationDate    string           `json:"expirationDate,omitempty"`
	CredentialSubject json.RawMessage  `json:"credentialSubject,omitempty"`
	CredentialStatus  CredentialStatus `json:"credentialStatus,omitempty"`
	Proof             Proof            `json:"proof,omitempty"`
}

Credential represents a verifiable credential.

type CredentialStatus

type CredentialStatus struct {
	ID                   string `json:"id,omitempty"`
	Type                 string `json:"type,omitempty"`
	StatusPurpose        string `json:"statusPurpose,omitempty"`
	StatusListIndex      uint   `json:"statusListIndex,omitempty"`
	StatusListCredential string `json:"statusListCredential,omitempty"`
}

CredentialStatus represents the status of the verifiable credential.

type Issuer

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

Issuer issues various Verifiable Credentials.

func NewIssuer

func NewIssuer(config Config) (*Issuer, error)

NewIssuer creates a new instance of Issuer.

func (*Issuer) CreateBitstringStatusListVC

func (i *Issuer) CreateBitstringStatusListVC(tokenID uint32, revoked bool) ([]byte, error)

func (*Issuer) CreateVINVC

func (i *Issuer) CreateVINVC(vin, countryCode string, tokenID uint32, expirationDate time.Time) ([]byte, error)

CreateVINVC creates a verifiable credential for a vehicle identification number and token ID.

func (*Issuer) DID

func (i *Issuer) DID() string

DID returns the issuer's DID.

type Proof

type Proof struct {
	ProofOptions
	ProofValue string `json:"proofValue,omitempty"`
}

Proof contains the signed proof value and options.

func CreateProof

func CreateProof(unsecuredDocument Credential, options ProofOptions, privateKey *ecdsa.PrivateKey, ldProcessor *ld.JsonLdProcessor, ldOptions *ld.JsonLdOptions) (Proof, error)

CreateProof creates a proof for a document using ecdsa-rdfc-2019.

type ProofOptions

type ProofOptions struct {
	Type               string `json:"type,omitempty"`
	Cryptosuite        string `json:"cryptosuite,omitempty"`
	VerificationMethod string `json:"verificationMethod,omitempty"`
	Created            string `json:"created,omitempty"`
	ProofPurpose       string `json:"proofPurpose,omitempty"`
}

ProofOptions contains the options for generating a proof.

type ProofOptionsWithContext

type ProofOptionsWithContext struct {
	Context []string `json:"@context,omitempty"`
	ProofOptions
}

proofOptionsWithContext contains the proof options with the context. this is used for canonicalization.

type VINSubject

type VINSubject struct {
	ID                          string `json:"id,omitempty"`
	VehicleIdentificationNumber string `json:"vehicleIdentificationNumber,omitempty"`
	CountryCode                 string `json:"countryCode,omitempty"`
}

VINSubject represents the subject of the VIN verifiable credential.

Jump to

Keyboard shortcuts

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