Documentation
¶
Overview ¶
Package verifiable provides functionality managing verifiable credentials.
Index ¶
- Constants
- func Canonicalize(data any, ldProc *ld.JsonLdProcessor, ldOptions *ld.JsonLdOptions) ([]byte, error)
- func DefaultDocumentLoader(localSchemaURL, localSchema string) (ld.DocumentLoader, error)
- func DefaultLdOptions(localSchemaURL, localSchema string) (*ld.JsonLdOptions, error)
- func EncodeList(data []byte) (string, error)
- func HashData(transformedData, proofConfig []byte) ([]byte, error)
- func MustEncodeList(data []byte) string
- type BitstringStatusListSubject
- type CellID
- type Config
- type Credential
- type CredentialStatus
- type GatewayID
- type H3Cell
- type Issuer
- func (i *Issuer) CreateBitstringStatusListVC(tokenID uint32, revoked bool) ([]byte, error)
- func (i *Issuer) CreateJSONLDDoc() ([]byte, error)
- func (i *Issuer) CreateKeyControlDoc() ([]byte, error)
- func (i *Issuer) CreatePOMVC(subject POMSubject) ([]byte, error)
- func (i *Issuer) CreateVINVC(subject VINSubject, expirationDate time.Time) ([]byte, error)
- func (i *Issuer) CreateVocabWebpage() ([]byte, error)
- type Location
- type LocationValue
- type MultiKey
- type POMSubject
- type Proof
- type ProofOptions
- type ProofOptionsWithContext
- type VINSubject
- type VerificationControlDocument
Constants ¶
const ( Format = "application/n-quads" AlgorithmURDNA2015 = "URDNA2015" )
const ( // LocationTypeCellID represents the cell ID location type. LocationTypeCellID = "cellId" // LocationTypeH3Cell represents the latitude/longitude location type. LocationTypeH3Cell = "h3Cell" // LocationTypeGatewayID represents the gateway ID location type. LocationTypeGatewayID = "gatewayId" )
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(localSchemaURL, localSchema string) (ld.DocumentLoader, error)
func DefaultLdOptions ¶
func DefaultLdOptions(localSchemaURL, localSchema string) (*ld.JsonLdOptions, error)
DefaultLdOptions returns the default JSON-LD options.
func EncodeList ¶
EncodeList compresses and base64 encodes a list of bytes.
func MustEncodeList ¶
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 CellID ¶ added in v0.0.6
type CellID struct {
CellID string `json:"cellId"`
}
CellID represents a cell ID location value.
type Config ¶
type Config struct {
PrivateKey []byte
ChainID *big.Int
VehicleNFTAddress common.Address
BaseStatusURL *url.URL
BaseKeyURL *url.URL
BaseVocabURL *url.URL
BaseJSONLDURL *url.URL
}
Config contains the configuration for a Issuer.
type Credential ¶
type Credential struct {
Context []any `json:"@context,omitempty"`
ID string `json:"id,omitempty"`
Type []string `json:"type,omitempty"`
Issuer string `json:"issuer,omitempty"`
ValidFrom string `json:"validFrom,omitempty"`
ValidTo string `json:"validTo,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"`
StatusListCredential string `json:"statusListCredential,omitempty"`
}
CredentialStatus represents the status of the verifiable credential.
type GatewayID ¶ added in v0.0.6
type GatewayID struct {
GatewayID string `json:"gatewayId"`
}
GatewayID represents a gateway ID location value.
type H3Cell ¶ added in v0.0.6
type H3Cell struct {
CellID string `json:"h3CellId"`
}
H3Cell represents a latitude/longitude location value.
type Issuer ¶
type Issuer struct {
// contains filtered or unexported fields
}
Issuer issues various Verifiable Credentials.
func (*Issuer) CreateBitstringStatusListVC ¶
func (*Issuer) CreateJSONLDDoc ¶ added in v0.0.4
CreateJSONLDDoc creates a JSON-LD document for all VC types.
func (*Issuer) CreateKeyControlDoc ¶ added in v0.0.3
CreateKeyControlDoc creates a key control document for the issuer. This document is used to get the public key of the issuer.
func (*Issuer) CreatePOMVC ¶ added in v0.0.6
func (i *Issuer) CreatePOMVC(subject POMSubject) ([]byte, error)
func (*Issuer) CreateVINVC ¶
CreateVINVC creates a verifiable credential for a vehicle identification number and token ID.
func (*Issuer) CreateVocabWebpage ¶ added in v0.0.4
CreateVocabWebpage creates a webpage for the vocabulary.
type Location ¶ added in v0.0.6
type Location struct {
LocationType string `json:"locationType"`
LocationValue LocationValue `json:"locationValue"`
Timestamp time.Time `json:"timestamp"`
}
Location represents a single location event with type, value, and timestamp.
func (*Location) UnmarshalJSON ¶ added in v0.0.6
UnmarshalJSON custom unmarshals a Location to handle the polymorphic LocationValue.
type LocationValue ¶ added in v0.0.6
type LocationValue interface {
// contains filtered or unexported methods
}
LocationValue represents a generic interface for location values.
type POMSubject ¶ added in v0.0.6
type POMSubject struct {
ID string `json:"id,omitempty"`
// VehicleTokenID is the token ID of the vehicle NFT.
VehicleTokenID uint32 `json:"vehicleTokenId,omitempty"`
// VehicleContractAddress is the address of the vehicle contract.
VehicleContractAddress string `json:"vehicleContractAddress,omitempty"`
// RecordedBy is the entity that recorded the event.
RecordedBy string `json:"recordedBy,omitempty"`
Locations []Location `json:"locations"`
}
POMSubject represents the subject of the Proof of Movement VC.
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 []any `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"`
// VehicleTokenID is the token ID of the vehicle NFT.
VehicleTokenID uint32 `json:"vehicleTokenId,omitempty"`
// VehicleContractAddress is the address of the vehicle contract.
VehicleContractAddress string `json:"vehicleContractAddress,omitempty"`
// VehicleIdentificationNumber is the VIN of the vehicle.
VehicleIdentificationNumber string `json:"vehicleIdentificationNumber,omitempty"`
// RecordedBy is the entity that recoreded the VIN.
RecordedBy string `json:"recordedBy,omitempty"`
// RecorededAt is the time the VIN was recoreded.
RecordedAt time.Time `json:"recordedAt,omitempty"`
// CountryCode that VIN belongs to.
CountryCode string `json:"countryCode,omitempty"`
}
VINSubject represents the subject of the VIN verifiable credential.
type VerificationControlDocument ¶ added in v0.0.3
type VerificationControlDocument struct {
Context []string `json:"@context,omitempty"`
ID string `json:"id,omitempty"`
VerificationMethod []MultiKey `json:"verificationMethod,omitempty"`
Authentication []string `json:"authentication,omitempty"`
AssertionMethod []string `json:"assertionMethod,omitempty"`
CapabilityDelegation []string `json:"capabilityDelegation,omitempty"`
CapabilityInvocation []string `json:"capabilityInvocation,omitempty"`
}