Documentation ¶
Overview ¶
Package did Package did-sdk-go provides general purpose operations for MetaBlox according to W3C spec.
Index ¶
- Constants
- Variables
- func AddDelegate(did string, delegate common.Address, delegateType [32]byte, validity big.Int, ...) (string, error)
- func AddDelegatePermit(did string, delegate common.Address, delegateType [32]byte, validity big.Int, ...) (string, error)
- func AddIssuer(did string) error
- func ChangeAttribute(did string, attribute [32]byte, attributeValue []byte, validity big.Int, ...) (string, error)
- func ChangeAttributePermit(did string, attribute [32]byte, attributeValue []byte, validity big.Int, ...) (string, error)
- func ChangeController(did string, newController common.Address, privKey *ecdsa.PrivateKey, ...) (string, error)
- func ChangeControllerPermit(did string, newController common.Address, privKey *ecdsa.PrivateKey, ...) (string, error)
- func CheckIssuer(did string) bool
- func CompareAddresses(address1 string, address2 string) bool
- func ConvertDocToBytes(doc DIDDocument) []byte
- func ConvertServiceToBytes(service Service) []byte
- func ConvertTimesFromDBFormat(vc *VerifiableCredential) error
- func ConvertTimesToDBFormat(vc *VerifiableCredential) error
- func ConvertVCToBytes(vc VerifiableCredential) []byte
- func ConvertVCToJWTPayload(vc VerifiableCredential) (payloadByte []byte, err error)
- func ConvertVMToBytes(vm VerificationMethod) []byte
- func ConvertVPToBytes(vp VerifiablePresentation) []byte
- func ConvertVPToJWTPayload(vp VerifiablePresentation) (payloadByte []byte, err error)
- func CreateEIP712Signature(privKey *ecdsa.PrivateKey, typedDataHash common.Hash) (string, error)
- func CreateEd25519JWSSignature(privKey *ed25519.PrivateKey, message []byte) (string, error)
- func CreateJWSSignature(privKey *ecdsa.PrivateKey, message []byte) (string, error)
- func DocumentToJson(document *DIDDocument) ([]byte, error)
- func GenerateDIDString(pubKey interface{}, network string) string
- func GenerateEIP712VCTypedDataHash(vc *VerifiableCredential, bound BoundedContract) (common.Hash, error)
- func GenerateEIP712VPTypedDataHash(vp *VerifiablePresentation, bound *BoundedContract) (common.Hash, error)
- func GenerateTestPrivKey() *ecdsa.PrivateKey
- func GetChainNameFromDID(did string) (string, error)
- func GetIssuerChainId() *big.Int
- func GetIssuerDidFromChainID(targetChainID int) (string, error)
- func GetIssuerDidFromChainName(targetChainName string) (string, error)
- func GetIssuerDids() []string
- func GetIssuerECPrivateKey() *ecdsa.PrivateKey
- func GetIssuerEDPrivateKey() *ed25519.PrivateKey
- func Init(cfg *Config) error
- func IsDIDValid(did []string) bool
- func PrepareDID(did string) ([]string, bool)
- func RemoveIssuer(did string) error
- func Resolve(did string, options *ResolutionOptions, bound *BoundedContract) (*ResolutionMetadata, *DIDDocument, *DocumentMetadata)
- func ResolveRepresentation(did string, options *RepresentationResolutionOptions, bound *BoundedContract) (*RepresentationResolutionMetadata, []byte, *DocumentMetadata)
- func RevokeAttribute(did string, attribute [32]byte, attributeValue []byte, ...) (string, error)
- func RevokeAttributePermit(did string, attribute [32]byte, attributeValue []byte, ...) (string, error)
- func RevokeDelegate(did string, delegate common.Address, delegateType [32]byte, ...) (string, error)
- func RevokeDelegatePermit(did string, delegate common.Address, delegateType [32]byte, ...) (string, error)
- func SplitDIDString(did string) []string
- func VCToJson(vc *VerifiableCredential) ([]byte, error)
- func VerifyEIP712Signature(signature string, expectedFullBlkID string, message []byte) (bool, error)
- func VerifyEIP712VC(credential *VerifiableCredential, bound *BoundedContract, expectedBlkID string) (bool, error)
- func VerifyEIP712VP(presentation *VerifiablePresentation, bound *BoundedContract, ...) (bool, error)
- func VerifyEd25519JWSSignature(signature string, pubKey ed25519.PublicKey, message []byte) (bool, error)
- func VerifyEd25519VC(vc *VerifiableCredential) (bool, error)
- func VerifyEd25519VP(presentation *VerifiablePresentation) (bool, error)
- func VerifyJWSSignature(signature string, expectedFullBlkID string, message []byte) (bool, error)
- func VerifySecp256k1VC(vc *VerifiableCredential, expectedBlkID string) (bool, error)
- func VerifySecp256k1VP(presentation *VerifiablePresentation, expectedBlkID string) (bool, error)
- func VerifyVC(vc *VerifiableCredential) (bool, error)
- func VerifyVP(presentation *VerifiablePresentation) (bool, error)
- type BoundedContract
- type Config
- type ContractConfig
- type DIDDocument
- func CreateDID(publicKey interface{}, bound BoundedContract) *DIDDocument
- func CreateDIDDocument() *DIDDocument
- func GenerateTestDIDDocument() *DIDDocument
- func GenerateTestResolvedDIDDocument() *DIDDocument
- func GetDocument(targetAddress string, chainName string) (*DIDDocument, [32]byte, error)
- func JsonToDocument(jsonDoc []byte) (*DIDDocument, error)
- type DocumentMetadata
- type EIP712Domain
- type EIP712VC
- type EIP712VCData
- type EIP712VCProof
- type EIP712VP
- type EIP712VPData
- type EIP712VPProof
- type Ed25519VCProof
- type Ed25519VPProof
- type JwtCredentialPayload
- type JwtPresentationPayload
- type MiningLicenseInfo
- type RepresentationResolutionMetadata
- type RepresentationResolutionOptions
- type ResolutionMetadata
- type ResolutionOptions
- type Secp256k1VCProof
- type Secp256k1VPProof
- type Service
- type SubjectInfo
- type VCSchemaChanged
- type VerifiableCredential
- func CreateVC(issuerDocument *DIDDocument, proofType string) (*VerifiableCredential, error)
- func CreateVerifiableCredential() *VerifiableCredential
- func GenerateTestMiningLicenseVC() *VerifiableCredential
- func GenerateTestVC() *VerifiableCredential
- func GenerateTestWifiAccessVC() *VerifiableCredential
- func JsonToVC(jsonVC []byte) (*VerifiableCredential, error)
- func NewVerifiableCredential(context []string, id string, vctype []string, ...) *VerifiableCredential
- type VerifiablePresentation
- func CreatePresentation(credentials []VerifiableCredential, holderDocument DIDDocument, ...) (*VerifiablePresentation, error)
- func GenerateTestPresentation() *VerifiablePresentation
- func GenerateTestWifiAccessPresentation() *VerifiablePresentation
- func NewPresentation(context, presentationType []string, credentials []VerifiableCredential, ...) *VerifiablePresentation
- type VerificationMethod
- type WifiAccessInfo
Constants ¶
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" )
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
const ContextCredential = "https://www.w3.org/2018/credentials/v1"
const ContextDID = "https://w3id.org/did/v1"
const ContextEIP712 = "https://w3c-ccg.github.io/ethereum-eip712-signature-2021-spec"
const ContextEd25519 = "https://w3id.org/security/suites/ed25519-2020/v1"
const ContextSecp256k1 = "https://identity.foundation/EcdsaSecp256k1RecoverySignature2020#"
const EIP712DomainName = "EIP712Verifiable"
const EIP712DomainVCPrimayType = "VerifiableCredential"
const EIP712DomainVPPrimayType = "VerifiablePresentation"
const EIP712DomainVersion = "1"
const EIP712Sig = "Eip712Signature2021"
const Ed25519Key = "Ed25519VerificationKey2020"
const Ed25519Sig = "Ed25519Signature2020"
const PurposeAuth = "Authentication"
const Secp256k1Key = "EcdsaSecp256k1RecoveryMethod2020"
const Secp256k1Sig = "EcdsaSecp256k1Signature2019"
const TypeCredential = "VerifiableCredential"
const TypeMining = "MiningLicense"
const TypePresentation = "VerifiablePresentation"
const TypeWifi = "WifiAccess"
Variables ¶
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") )
var ChainId2NameMap = map[int]string{ 1: EthereumChainName, 5: GoerliChainName, 66: OkChainName, 137: PolygonChainName, 1101: PolygonZkEVMChainName, 42161: ArbitrumChainName, 11155111: SepoliaChainName, 1666600000: HarmonyChainName, 245022926: SolanaChainName, }
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"}, }
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 AddDelegatePermit ¶
func ChangeAttribute ¶
func ChangeAttribute(did string, attribute [32]byte, attributeValue []byte, validity big.Int, privKey *ecdsa.PrivateKey, bound *BoundedContract) (string, error)
func ChangeAttributePermit ¶
func ChangeController ¶
func ChangeController(did string, newController common.Address, privKey *ecdsa.PrivateKey, bound *BoundedContract) (string, error)
func ChangeControllerPermit ¶
func CheckIssuer ¶ added in v2.1.0
func CompareAddresses ¶
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 ¶
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 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 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 GetIssuerChainId ¶
func GetIssuerDidFromChainID ¶ added in v2.1.1
func GetIssuerDidFromChainName ¶ added in v2.1.1
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 PrepareDID ¶
splits did and checks that it is formatted correctly
func RemoveIssuer ¶ added in v2.1.0
func Resolve ¶
func Resolve(did string, options *ResolutionOptions, bound *BoundedContract) (*ResolutionMetadata, *DIDDocument, *DocumentMetadata)
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 ¶
func ResolveRepresentation(did string, options *RepresentationResolutionOptions, bound *BoundedContract) (*RepresentationResolutionMetadata, []byte, *DocumentMetadata)
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 RevokeDelegate ¶
func RevokeDelegate(did string, delegate common.Address, delegateType [32]byte, privKey *ecdsa.PrivateKey, bound *BoundedContract) (string, error)
func RevokeDelegatePermit ¶
func SplitDIDString ¶
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 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 ¶
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 ContractConfig ¶
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 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 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 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 ¶
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 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