did

package module
v2.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: MIT Imports: 28 Imported by: 0

README

did-sdk-go

Introduction

Provides general purpose operations for MetaBlox according to W3C spec.

Installation and usage

The import path for the package is gopkg.in/yaml.v3.

To install it, run:

go get github.com/metablox/did-sdk-go

API documentation

API stability

License

The did-sdk-go package is licensed under the MIT license. Please see the LICENSE file for details.

Example

package main

import (
	"fmt"
)

func main() {
	fmt.Println("did-sdk-go,hello world!")
}

Documentation

Overview

Package did Package did-sdk-go provides general purpose operations for MetaBlox according to W3C spec.

Index

Constants

View Source
const (
	ArbitrumChainName     string = "arbitrum"
	EthereumChainName     string = "ethereum"
	GoerliChainName       string = "goerli"
	OkChainName           string = "okexchain"
	PolygonChainName      string = "polygon"
	PolygonZkEVMChainName string = "polygonzkevm"
	SepoliaChainName      string = "sepolia"
	SolanaChainName       string = "solana"
	HarmonyChainName      string = "harmony"
)
View Source
const BaseIDString = "https://metablox.io/credentials/"

All credential ids use a format of this value plus a number. ex. 'http://metablox.com/credentials/5' Only the number is stored in the db as the ID; the full string is only used in formal credentials

View Source
const ContextCredential = "https://www.w3.org/2018/credentials/v1"
View Source
const ContextDID = "https://w3id.org/did/v1"
View Source
const ContextEIP712 = "https://w3c-ccg.github.io/ethereum-eip712-signature-2021-spec"
View Source
const ContextEd25519 = "https://w3id.org/security/suites/ed25519-2020/v1"
View Source
const ContextSecp256k1 = "https://identity.foundation/EcdsaSecp256k1RecoverySignature2020#"
View Source
const EIP712DomainName = "EIP712Verifiable"
View Source
const EIP712DomainVCPrimayType = "VerifiableCredential"
View Source
const EIP712DomainVPPrimayType = "VerifiablePresentation"
View Source
const EIP712DomainVersion = "1"
View Source
const EIP712Sig = "Eip712Signature2021"
View Source
const Ed25519Key = "Ed25519VerificationKey2020"
View Source
const Ed25519Sig = "Ed25519Signature2020"
View Source
const PurposeAuth = "Authentication"
View Source
const Secp256k1Key = "EcdsaSecp256k1RecoveryMethod2020"
View Source
const Secp256k1Sig = "EcdsaSecp256k1Signature2019"
View Source
const TypeCredential = "VerifiableCredential"
View Source
const TypeMining = "MiningLicense"
View Source
const TypePresentation = "VerifiablePresentation"
View Source
const TypeWifi = "WifiAccess"

Variables

View Source
var (
	ErrRenewRevoked          = errors.New("VC has been revoked, cannot renew")
	ErrUnknownIssuer         = errors.New("unknown issuer")
	ErrSecp256k1WrongVMType  = errors.New("must use a verification method with a type of 'EcdsaSecp256k1RecoveryMethod2020' to verify a 'EcdsaSecp256k1Signature2019' proof")
	ErrEd25519WrongVMType    = errors.New("must use a verification method with a type of 'Ed25519VerificationKey2020' to verify a 'Ed25519Signature2020' proof")
	ErrUnknownProofType      = errors.New("unknown proof type")
	ErrUnknownCredentialType = errors.New("unknown credential type")
	ErrWrongProofType        = errors.New("proof type is incorrect")
	ErrMissingVM             = errors.New("failed to find verification method")
	ErrWrongAddress          = errors.New("provided public key does not match issuer address")
	ErrETHAddress            = errors.New("provided address is not a correct ETH address")
	ErrInvalidDID            = errors.New("provided DID is invalid")
	ErrInValidSignature      = errors.New("provided signature is invalid")
	ErrInvalidBlockID        = errors.New("provided Block Account ID is invalid")
	ErrUnknownChainID        = errors.New("provided Chain ID is invalid")
	ErrUnknownChainName      = errors.New("provided Chain Name is invalid")
	ErrUnsupportedKeyType    = errors.New("provided key type is not supported on this chain")
)
View Source
var ChainId2NameMap = map[int]string{
	1:          EthereumChainName,
	5:          GoerliChainName,
	66:         OkChainName,
	137:        PolygonChainName,
	1101:       PolygonZkEVMChainName,
	42161:      ArbitrumChainName,
	11155111:   SepoliaChainName,
	1666600000: HarmonyChainName,
	245022926:  SolanaChainName,
}
View Source
var ChainName2ContractConfigMap = map[string]ContractConfig{
	GoerliChainName:  {RpcUrl: "https://ethereum-goerli.publicnode.com", ContractAddr: "0x28e038d24Ebcf16BC386141224535650A667146e", ChainName: "goerli"},
	HarmonyChainName: {RpcUrl: "https://api.harmony.one", ContractAddr: "0x275D3fC4C492a8d743Fe9AAB42266fEf92c89995", ChainName: "harmony"},
	SolanaChainName:  {RpcUrl: "https://devnet.neonevm.org", ContractAddr: "0x58C2AE9AE47a07A3D9928898BA32C00E4FE599Cc", ChainName: "solana"},
}
View Source
var ChainName2IdMap = map[string]int{
	EthereumChainName:     1,
	GoerliChainName:       5,
	OkChainName:           66,
	PolygonChainName:      137,
	PolygonZkEVMChainName: 1101,
	ArbitrumChainName:     42161,
	SepoliaChainName:      11155111,
	HarmonyChainName:      1666600000,
	SolanaChainName:       245022926,
}

Functions

func AddDelegate

func AddDelegate(did string, delegate common.Address, delegateType [32]byte, validity big.Int, privKey *ecdsa.PrivateKey, bound *BoundedContract) (string, error)

func AddDelegatePermit

func AddDelegatePermit(did string, delegate common.Address, delegateType [32]byte, validity big.Int, privKey *ecdsa.PrivateKey, deadline big.Int, signature []byte, bound *BoundedContract) (string, error)

func AddIssuer added in v2.1.0

func AddIssuer(did string) error

func ChangeAttribute

func ChangeAttribute(did string, attribute [32]byte, attributeValue []byte, validity big.Int, privKey *ecdsa.PrivateKey, bound *BoundedContract) (string, error)

func ChangeAttributePermit

func ChangeAttributePermit(did string, attribute [32]byte, attributeValue []byte, validity big.Int, privKey *ecdsa.PrivateKey, deadline big.Int, signature []byte, bound *BoundedContract) (string, error)

func ChangeController

func ChangeController(did string, newController common.Address, privKey *ecdsa.PrivateKey, bound *BoundedContract) (string, error)

func ChangeControllerPermit

func ChangeControllerPermit(did string, newController common.Address, privKey *ecdsa.PrivateKey, deadlinne big.Int, signature []byte, bound *BoundedContract) (string, error)

func CheckIssuer added in v2.1.0

func CheckIssuer(did string) bool

func CompareAddresses

func CompareAddresses(address1 string, address2 string) bool

Function to compare two Ethereum addresses by checking the identifiers and chainIDs

func ConvertDocToBytes

func ConvertDocToBytes(doc DIDDocument) []byte

convert document into byte array so it can be hashed (appears to be unused currently)

func ConvertServiceToBytes

func ConvertServiceToBytes(service Service) []byte

convert service to byte array. Used as part of converting document to bytes

func ConvertTimesFromDBFormat

func ConvertTimesFromDBFormat(vc *VerifiableCredential) error

convert issuance and expiration times of credential from db format to RFC3339

func ConvertTimesToDBFormat

func ConvertTimesToDBFormat(vc *VerifiableCredential) error

convert issuance and expiration times of credential from RFC3339 to db format

func ConvertVCToBytes

func ConvertVCToBytes(vc VerifiableCredential) []byte

convert credential to bytes so it can be hashed

func ConvertVCToJWTPayload

func ConvertVCToJWTPayload(vc VerifiableCredential) (payloadByte []byte, err error)

func ConvertVMToBytes

func ConvertVMToBytes(vm VerificationMethod) []byte

convert VM to byte array. Used as part of converting document to bytes

func ConvertVPToBytes

func ConvertVPToBytes(vp VerifiablePresentation) []byte

convert presentation to bytes so it can be hashed

func ConvertVPToJWTPayload

func ConvertVPToJWTPayload(vp VerifiablePresentation) (payloadByte []byte, err error)

func CreateEIP712Signature

func CreateEIP712Signature(privKey *ecdsa.PrivateKey, typedDataHash common.Hash) (string, error)

func CreateEd25519JWSSignature added in v2.1.0

func CreateEd25519JWSSignature(privKey *ed25519.PrivateKey, message []byte) (string, error)

func CreateJWSSignature

func CreateJWSSignature(privKey *ecdsa.PrivateKey, message []byte) (string, error)

use a private key and a message to create a JWS format signature

func DocumentToJson

func DocumentToJson(document *DIDDocument) ([]byte, error)

TODO: check that this function can be safely removed

func GenerateDIDString

func GenerateDIDString(pubKey interface{}, network string) string

func GenerateEIP712VCTypedDataHash

func GenerateEIP712VCTypedDataHash(vc *VerifiableCredential, bound BoundedContract) (common.Hash, error)

func GenerateEIP712VPTypedDataHash

func GenerateEIP712VPTypedDataHash(vp *VerifiablePresentation, bound *BoundedContract) (common.Hash, error)

func GenerateTestPrivKey

func GenerateTestPrivKey() *ecdsa.PrivateKey

func GetChainNameFromDID added in v2.1.0

func GetChainNameFromDID(did string) (string, error)

func GetIssuerChainId

func GetIssuerChainId() *big.Int

func GetIssuerDidFromChainID added in v2.1.1

func GetIssuerDidFromChainID(targetChainID int) (string, error)

func GetIssuerDidFromChainName added in v2.1.1

func GetIssuerDidFromChainName(targetChainName string) (string, error)

func GetIssuerDids added in v2.1.0

func GetIssuerDids() []string

func GetIssuerECPrivateKey added in v2.1.0

func GetIssuerECPrivateKey() *ecdsa.PrivateKey

func GetIssuerEDPrivateKey added in v2.1.0

func GetIssuerEDPrivateKey() *ed25519.PrivateKey

func Init

func Init(cfg *Config) error

func IsDIDValid

func IsDIDValid(did []string) bool

check format of DID string

func PrepareDID

func PrepareDID(did string) ([]string, bool)

splits did and checks that it is formatted correctly

func RemoveIssuer added in v2.1.0

func RemoveIssuer(did string) error

func Resolve

generate the did document that matches the provided did string. Any errors are returned in the ResolutionMetadata. Note that options currently does nothing; including it is a requirement according to W3C specifications, but we don't do anything with it right now

func ResolveRepresentation

generate a did document and return it in a specific data format (currently just JSON)

func RevokeAttribute

func RevokeAttribute(did string, attribute [32]byte, attributeValue []byte, privKey *ecdsa.PrivateKey, bound *BoundedContract) (string, error)

func RevokeAttributePermit

func RevokeAttributePermit(did string, attribute [32]byte, attributeValue []byte, privKey *ecdsa.PrivateKey, deadline big.Int, signature []byte, bound *BoundedContract) (string, error)

func RevokeDelegate

func RevokeDelegate(did string, delegate common.Address, delegateType [32]byte, privKey *ecdsa.PrivateKey, bound *BoundedContract) (string, error)

func RevokeDelegatePermit

func RevokeDelegatePermit(did string, delegate common.Address, delegateType [32]byte, privKey *ecdsa.PrivateKey, deadline big.Int, signature []byte, bound *BoundedContract) (string, error)

func SplitDIDString

func SplitDIDString(did string) []string

split did string into 3 sections. First two should be 'did' and 'metablox', last one wil be the identifier

func VCToJson

func VCToJson(vc *VerifiableCredential) ([]byte, error)

convert credential to a JSON format. Currently unused

func VerifyEIP712Signature

func VerifyEIP712Signature(signature string, expectedFullBlkID string, message []byte) (bool, error)

Function to verify an Ethereum EIP-712 signature

func VerifyEIP712VC

func VerifyEIP712VC(credential *VerifiableCredential, bound *BoundedContract, expectedBlkID string) (bool, error)

func VerifyEIP712VP

func VerifyEIP712VP(presentation *VerifiablePresentation, bound *BoundedContract, expectedBlkID string) (bool, error)

func VerifyEd25519JWSSignature added in v2.1.0

func VerifyEd25519JWSSignature(signature string, pubKey ed25519.PublicKey, message []byte) (bool, error)

func VerifyEd25519VC added in v2.1.0

func VerifyEd25519VC(vc *VerifiableCredential) (bool, error)

func VerifyEd25519VP added in v2.1.0

func VerifyEd25519VP(presentation *VerifiablePresentation) (bool, error)

func VerifyJWSSignature

func VerifyJWSSignature(signature string, expectedFullBlkID string, message []byte) (bool, error)

verify a JWS format signature using the matching public key and the original message

func VerifySecp256k1VC

func VerifySecp256k1VC(vc *VerifiableCredential, expectedBlkID string) (bool, error)

Verify that the provided public key matches the signature in the proof. Since we've made sure that the address in the issuer vm matches this public key, verifying the signature here proves that the signature was made with the issuer's private key

func VerifySecp256k1VP

func VerifySecp256k1VP(presentation *VerifiablePresentation, expectedBlkID string) (bool, error)

Verify that the provided public key matches the signature in the proof. Since we've made sure that the address in the holder vm matches this public key, verifying the signature here proves that the signature was made with the holder's private key

func VerifyVC

func VerifyVC(vc *VerifiableCredential) (bool, error)

Need to make sure that the stated issuer of the VC actually created it (using the proof alongside the issuer's verification methods), as well as check that the issuer is a trusted source

func VerifyVP

func VerifyVP(presentation *VerifiablePresentation) (bool, error)

Verify a presentation. Need to first verify the presentation's proof using the holder's DID document. Afterwards, need to verify the proof of each credential included inside the presentation

Types

type BoundedContract

type BoundedContract struct {
	ContractAddr common.Address
	Client       *ethclient.Client
	Instance     *registry.Registry
	ChainID      *big.Int
	ChainName    string
}

func GetBoundedContract added in v2.1.0

func GetBoundedContract(chainName string) (*BoundedContract, error)

func GetRegistryInstance

func GetRegistryInstance(config ContractConfig) (bound *BoundedContract, err error)

type Config

type Config struct {
	Passphrase string `json:"passphrase"`
	Keystore   string `json:"keystore"`
	//ChainId    *big.Int `json:"chainId"`
	//ChainName  string   `json:"chainName"`
	ChainList []string `json:"chainList"`
}

type ContractConfig

type ContractConfig struct {
	RpcUrl       string
	ContractAddr string
	ChainName    string
}

type DIDDocument

type DIDDocument struct {
	Context            []string             `json:"@context" mapstructure:"@context"`
	ID                 string               `json:"id"`
	Created            string               `json:"created"`
	Updated            string               `json:"updated"`
	Version            int                  `json:"version"`
	VerificationMethod []VerificationMethod `json:"verificationMethod"`
	Authentication     string               `json:"authentication"`
	AssertionMethod    string               `json:"assertionMethod"`
	Service            []Service            `json:"service"`
}

func CreateDID

func CreateDID(publicKey interface{}, bound BoundedContract) *DIDDocument

TODO: check that this function can be safely removed. The foundation service doesn't need to create new DID documents; however, some other system may want to import this function

func CreateDIDDocument

func CreateDIDDocument() *DIDDocument

func GenerateTestDIDDocument

func GenerateTestDIDDocument() *DIDDocument

func GenerateTestResolvedDIDDocument

func GenerateTestResolvedDIDDocument() *DIDDocument

func GetDocument

func GetDocument(targetAddress string, chainName string) (*DIDDocument, [32]byte, error)

func JsonToDocument

func JsonToDocument(jsonDoc []byte) (*DIDDocument, error)

TODO: check that this function can be safely removed

func (*DIDDocument) AddService

func (doc *DIDDocument) AddService(service Service)

func (DIDDocument) RetrieveVerificationMethod

func (doc DIDDocument) RetrieveVerificationMethod(vmID string) (VerificationMethod, error)

type DocumentMetadata

type DocumentMetadata struct {
	Created       string   `json:"created"`
	Updated       string   `json:"updated"`
	Deactivated   string   `json:"deactivated"`
	NextUpdate    string   `json:"nextUpdate"`
	VersionID     string   `json:"versionId"`
	NextVersionID string   `json:"nextVersionId"`
	EquivalentID  []string `json:"equivalentId"`
	CanonicalID   string   `json:"canonicalId"`
}

type EIP712Domain

type EIP712Domain struct {
	Name              string `json:"name"`
	ChainID           string `json:"chainID"`
	VerifyingContract string `json:"verifyingContract"`
	Version           string `json:"version"`
}

type EIP712VC

type EIP712VC struct {
	Domain      EIP712Domain `json:"domain"`
	Types       string       `json:"types"`
	PrimaryType string       `json:"primaryType"`
}

type EIP712VCData

type EIP712VCData struct {
	Types       interface{}  `json:"types"`
	Doamin      EIP712Domain `json:"domain"`
	PrimaryType string       `json:"primaryType"`
	Message     EIP712VC     `json:"message"`
}

type EIP712VCProof

type EIP712VCProof struct {
	Type               string `json:"type"`
	Created            string `json:"created"`
	VerificationMethod string `json:"verificationMethod"`
	ProofPurpose       string `json:"proofPurpose"`
	//EIP712             EIP712VC `json:"eip712"`
	ProofValue string `json:"proofValue"`
}

func CreateEIP712VCProof

func CreateEIP712VCProof() *EIP712VCProof

func CreateVCEIP712Proof

func CreateVCEIP712Proof(vm string) EIP712VCProof

type EIP712VP

type EIP712VP struct {
	Domain      EIP712Domain `json:"domain"`
	Types       string       `json:"types"`
	PrimaryType string       `json:"primaryType"`
}

type EIP712VPData

type EIP712VPData struct {
	Types       interface{}  `json:"types"`
	Doamin      EIP712Domain `json:"domain"`
	PrimaryType string       `json:"primaryType"`
	Message     EIP712VP     `json:"message"`
}

type EIP712VPProof

type EIP712VPProof struct {
	Type               string `json:"type"`
	Created            string `json:"created"`
	VerificationMethod string `json:"verificationMethod"`
	ProofPurpose       string `json:"proofPurpose"`
	//EIP712             EIP712VP `json:"eip712"`
	ProofValue string `json:"proofValue"`
	Nonce      string `json:"nonce"` //random value generated by verifier that must be included in proof
}

func CreateEIP712VPProof

func CreateEIP712VPProof() *EIP712VPProof

func CreateVPEIP712Proof

func CreateVPEIP712Proof(vm string, nonce string) EIP712VPProof

type Ed25519VCProof added in v2.1.0

type Ed25519VCProof struct {
	Type               string `json:"type"`
	Created            string `json:"created"`
	VerificationMethod string `json:"verificationMethod"`
	ProofPurpose       string `json:"proofPurpose"`
	PublicKeyMultibase string `json:"publicKeyMultibase"`
	JWSSignature       string `json:"jws"` //signature is created from a hash of the VC
}

func CreateEd25519VCProof added in v2.1.0

func CreateEd25519VCProof() *Ed25519VCProof

func CreateVCEd25519Proof added in v2.1.0

func CreateVCEd25519Proof(vm string) Ed25519VCProof

type Ed25519VPProof added in v2.1.0

type Ed25519VPProof struct {
	Type               string `json:"type"`
	Created            string `json:"created"`
	VerificationMethod string `json:"verificationMethod"`
	ProofPurpose       string `json:"proofPurpose"`
	PublicKeyMultibase string `json:"publicKeyMultibase"`
	JWSSignature       string `json:"jws"`   //signature is created from a hash of the VP
	Nonce              string `json:"nonce"` //random value generated by verifier that must be included in proof
}

func CreateEd25519VPProof added in v2.1.0

func CreateEd25519VPProof() *Ed25519VPProof

func CreateVPEd25519Proof added in v2.1.0

func CreateVPEd25519Proof(vm string, nonce string) Ed25519VPProof

type JwtCredentialPayload

type JwtCredentialPayload struct {
	Exp int64  `json:"exp,omitempty"` // Expiration
	Iat int64  `json:"iat,omitempty"` // Issued At
	Iss string `json:"iss,omitempty"` // Issuer
	Jti string `json:"jti,omitempty"` // JWT ID
	Nbf int64  `json:"nbf,omitempty"` // Not Valid Before
	Sub string `json:"sub,omitempty"` // Subject
	Vc  struct {
		Context           []string    `json:"@context" mapstructure:"@context"`
		CredentialSubject interface{} `json:"credentialSubject"`
		Type              []string    `json:"type"`
		Description       string      `json:"description"`
		Revoked           bool        `json:"revoked"`
	} `json:"vc,omitempty"` // Verifiable Credential
}

type JwtPresentationPayload

type JwtPresentationPayload struct {
	Exp   int64  `json:"exp,omitempty"`   // Expiration
	Iat   int64  `json:"iat,omitempty"`   // Issued At
	Iss   string `json:"iss,omitempty"`   // Issuer, the holder of VP
	Nbf   int64  `json:"nbf,omitempty"`   // Not Valid Before
	Nonce string `json:"nonce,omitempty"` // Random value generated by verifier that must be included in proof
	Vp    struct {
		Context              []string               `json:"@context" mapstructure:"@context"`
		Type                 []string               `json:"type"`
		VerifiableCredential []VerifiableCredential `json:"verifiableCredential"`
	} `json:"vp"`
}

type MiningLicenseInfo

type MiningLicenseInfo struct {
	CredentialID string `json:"-" db:"CredentialID"`
	ID           string `json:"id" db:"ID"`     //id of the user the credential is assigned to
	Name         string `json:"name" db:"Name"` //manufacturer name
	Model        string `json:"model" db:"Model"`
	Serial       string `json:"serial" db:"Serial"` //serial number
}

func CreateMiningLicenseInfo

func CreateMiningLicenseInfo() *MiningLicenseInfo

func GenerateTestMiningLicenseInfo

func GenerateTestMiningLicenseInfo() *MiningLicenseInfo

func NewMiningLicenseInfo

func NewMiningLicenseInfo(credentialID, id, name, model, serial string) *MiningLicenseInfo

type RepresentationResolutionMetadata

type RepresentationResolutionMetadata struct {
	ContentType string `json:"contentType"`
	Error       string `json:"error"`
}

type RepresentationResolutionOptions

type RepresentationResolutionOptions struct {
	Accept string `json:"accept"`
}

type ResolutionMetadata

type ResolutionMetadata struct {
	Error string `json:"error"`
}

type ResolutionOptions

type ResolutionOptions struct {
	Accept string `json:"accept"`
}

func CreateResolutionOptions

func CreateResolutionOptions() *ResolutionOptions

type Secp256k1VCProof

type Secp256k1VCProof struct {
	Type               string `json:"type"`
	Created            string `json:"created"`
	VerificationMethod string `json:"verificationMethod"`
	ProofPurpose       string `json:"proofPurpose"`
	JWSSignature       string `json:"jws"` //signature is created from a hash of the VC
}

func CreateSecp256k1VCProof

func CreateSecp256k1VCProof() *Secp256k1VCProof

func CreateVCSecp256k1Proof

func CreateVCSecp256k1Proof(vm string) Secp256k1VCProof

create a credential proof using the provided verification method string

func NewVCProof

func NewVCProof(proofType, created, vm, purpose, sig string) *Secp256k1VCProof

type Secp256k1VPProof

type Secp256k1VPProof struct {
	Type               string `json:"type"`
	Created            string `json:"created"`
	VerificationMethod string `json:"verificationMethod"`
	ProofPurpose       string `json:"proofPurpose"`
	JWSSignature       string `json:"jws"`   //signature is created from a hash of the VP
	Nonce              string `json:"nonce"` //random value generated by verifier that must be included in proof
}

func CreateSecp256k1VPProof

func CreateSecp256k1VPProof() *Secp256k1VPProof

func CreateVPSecp256k1Proof

func CreateVPSecp256k1Proof(vm string, nonce string) Secp256k1VPProof

func NewVPProof

func NewVPProof(proofType, created, vm, purpose, sig, nonce string) *Secp256k1VPProof

type Service

type Service struct {
	ID              string `json:"id"`
	Type            string `json:"type"`
	ServiceEndpoint string `json:"serviceEndpoint"`
}

func CreateService

func CreateService() *Service

type SubjectInfo

type SubjectInfo struct {
	ID           string `json:"id"`
	GivenName    string `json:"givenName"`
	FamilyName   string `json:"familyName"`
	Gender       string `json:"gender"`
	BirthCountry string `json:"birthCountry"`
	BirthDate    string `json:"birthName"`
}

This can be a type of input form to set up the VC. Temp fields here currently, will be changed in the future

func CreateSubjectInfo

func CreateSubjectInfo() *SubjectInfo

func GenerateTestSubjectInfo

func GenerateTestSubjectInfo() *SubjectInfo

func NewSubjectInfo

func NewSubjectInfo(id string, givenName, familyName, gender, birthCountry, birthDate string) *SubjectInfo

type VCSchemaChanged

type VCSchemaChanged struct {
	VcName string
	Name   [32]byte
	Value  []byte
}

type VerifiableCredential

type VerifiableCredential struct {
	Context           []string    `json:"@context" mapstructure:"@context"`
	ID                string      `json:"id" db:"ID"`
	Type              []string    `json:"type"`
	Issuer            string      `json:"issuer" db:"Issuer"`
	IssuanceDate      string      `json:"issuanceDate" db:"IssuanceDate"`
	ExpirationDate    string      `json:"expirationDate" db:"ExpirationDate"`
	Description       string      `json:"description" db:"Description"`
	CredentialSubject interface{} `json:"credentialSubject"`
	Proof             interface{} `json:"proof"`
	Revoked           bool        `json:"revoked" db:"Revoked"`
}

func CreateVC

func CreateVC(issuerDocument *DIDDocument, proofType string) (*VerifiableCredential, error)

Base function for creating VCs. Called by any function that creates a type of VC to initialize universal values

func CreateVerifiableCredential

func CreateVerifiableCredential() *VerifiableCredential

func GenerateTestMiningLicenseVC

func GenerateTestMiningLicenseVC() *VerifiableCredential

func GenerateTestVC

func GenerateTestVC() *VerifiableCredential

func GenerateTestWifiAccessVC

func GenerateTestWifiAccessVC() *VerifiableCredential

func JsonToVC

func JsonToVC(jsonVC []byte) (*VerifiableCredential, error)

convert JSON formatted credential to object. Currently unused

func NewVerifiableCredential

func NewVerifiableCredential(context []string, id string, vctype []string, issuer, issuanceDate, expirationDate, description string, subject interface{}, proof interface{}, revoked bool) *VerifiableCredential

type VerifiablePresentation

type VerifiablePresentation struct {
	Context              []string               `json:"@context" mapstructure:"@context"`
	Type                 []string               `json:"type"`
	VerifiableCredential []VerifiableCredential `json:"verifiableCredential"`
	Holder               string                 `json:"holder"`
	Proof                interface{}            `json:"proof"`
}

func CreatePresentation

func CreatePresentation(credentials []VerifiableCredential, holderDocument DIDDocument, holderPrivKey interface{}, nonce string, proofType string) (*VerifiablePresentation, error)

create a presentation using 1 or more credentials. Currently unused

func GenerateTestPresentation

func GenerateTestPresentation() *VerifiablePresentation

func GenerateTestWifiAccessPresentation

func GenerateTestWifiAccessPresentation() *VerifiablePresentation

func NewPresentation

func NewPresentation(context, presentationType []string, credentials []VerifiableCredential, holder string, proof interface{}) *VerifiablePresentation

type VerificationMethod

type VerificationMethod struct {
	ID                  string `json:"id"`
	MethodType          string `json:"type"`
	Controller          string `json:"controller"`
	BlockchainAccountId string `json:"blockchainAccountId"`
}

type WifiAccessInfo

type WifiAccessInfo struct {
	CredentialID string `json:"-" db:"CredentialID"`
	ID           string `json:"id" db:"ID"`     //id of the user the credential is assigned to
	Type         string `json:"type" db:"Type"` //user or validator
}

func CreateWifiAccessInfo

func CreateWifiAccessInfo() *WifiAccessInfo

func GenerateTestWifiAccessInfo

func GenerateTestWifiAccessInfo() *WifiAccessInfo

func NewWifiAccessInfo

func NewWifiAccessInfo(credentialID, id, userType string) *WifiAccessInfo

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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