ledger

package
v0.0.0-...-55a0270 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2022 License: Apache-2.0 Imports: 18 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var IDRx = regexp.MustCompile(idRxStr)

Functions

func Contains

func Contains(field string, required []string) bool

func Format

func Format(field interface{}) string

func GenerateB64EncodedEd25519DIDDoc

func GenerateB64EncodedEd25519DIDDoc(b64EncodedPrivKey string) (string, error)

GenerateB64EncodedEd25519DIDDoc creates a DIDDoc from a base64 encoded ed25519 PrivateKey.

func GenerateB64EncodedEd25519DeactivatedDIDDoc

func GenerateB64EncodedEd25519DeactivatedDIDDoc(b64EncodedPrivKey, b64EncDID string) (string, error)

GenerateB64EncodedEd25519DeactivatedDIDDoc creates a deactivated DID Document and returns it as base64 encoded JSON. Returns an error if the either the base64 encoded arguments cannot be decoded or if the key material is not a valid Ed25519 private key.

func GenerateKeyDIDDoc

func GenerateKeyDIDDoc(publicKey ed25519.PublicKey, keyRef string) *did.DIDDoc

GenerateKeyDIDDoc generates DID Document as defined by The did:key Method based on supplied ED25519 Public Key and keyref.

func GenerateRevocationKey

func GenerateRevocationKey(issuerDID did.DID, credentialID string) string

GenerateRevocationKey creates a hash of the issuer DID and the credential ID. This hash is used as the revocation ID. Revocations are issued by the Issuer of the credential. Using the issuer's DID in the hash effectively creates namespace for that issuer. The expectation is that the credential ID is a UUID and is therefore unique per credential. Hashing the two values together obfuscates the issuer's ID on the blockchain. Only parties that have already seen the credential, and therefore now the credential ID and issuer DID will be able to look up the revocation status in the ledger. This is intended to prevent data mining on the revocations store in an attempt to learn anything about the issuer.

func GenerateSchemaID

func GenerateSchemaID(author did.DID, version string) string

func GetKeyDef

func GetKeyDef(ctx context.Context, did did.DID, keyID string, provider DIDDocProvider) (*did.KeyDef, error)

GetKeyDef returns the Ed25519 public key with the given Key ID located on the DID Document.

func Type

func Type(field interface{}) string

func ValidateDID

func ValidateDID(did did.DID) error

func ValidateRevocations

func ValidateRevocations(ctx context.Context, revocations []Revocation, provider Provider) error

Revocation //

func ValidateSchemaID

func ValidateSchemaID(id string) error

func Verify

func Verify(ctx context.Context, provable proof.Provable, provider DIDDocProvider) error

Verify verifies the digital signature on the given Provable. The DIDDocProvider is used to look up the public key referenced as the Proof's verification method. The verification method must therefore be a fully qualified key reference (DID URL + Fragment).

Types

type DIDDoc

type DIDDoc struct {
	*Metadata
	*did.DIDDoc `json:"didDoc"`
}

func GenerateDeactivatedDIDDoc

func GenerateDeactivatedDIDDoc(signer proof.Signer, suite proof.SignatureSuite, did did.DID) (*DIDDoc, error)

GenerateDeactivatedDIDDoc creates a deactivated DID Document. Returns an error if the Signer fails to generate the digital signature.

func GenerateLedgerDIDDoc

func GenerateLedgerDIDDoc(keyType proof.KeyType, signatureType proof.SignatureType) (*DIDDoc, ed25519.PrivateKey)

func (*DIDDoc) GetProof

func (d *DIDDoc) GetProof() *proof.Proof

func (*DIDDoc) IsEmpty

func (d *DIDDoc) IsEmpty() bool

func (*DIDDoc) SetProof

func (d *DIDDoc) SetProof(p *proof.Proof)

func (DIDDoc) Validate

func (d DIDDoc) Validate(ctx context.Context, provider DIDDocProvider) error

func (DIDDoc) ValidateDeactivated

func (d DIDDoc) ValidateDeactivated() error

func (DIDDoc) ValidateMetadata

func (d DIDDoc) ValidateMetadata() error

func (*DIDDoc) ValidateNotEmpty

func (d *DIDDoc) ValidateNotEmpty() error

func (DIDDoc) ValidateProof

func (d DIDDoc) ValidateProof() error

func (DIDDoc) ValidateStatic

func (d DIDDoc) ValidateStatic() error

func (DIDDoc) ValidateUniqueness

func (d DIDDoc) ValidateUniqueness(ctx context.Context, provider DIDDocProvider) error

type DIDDocProvider

type DIDDocProvider func(ctx context.Context, did did.DID) (*DIDDoc, error)

type GenerateDIDDocInput

type GenerateDIDDocInput struct {
	// DID is a decentralized identifier in the format of "did:work:<id>".
	DID did.DID `validate:"required"`
	// FullyQualifiedKeyRef is a URI that points to a public key associated with the SigningKey,
	// which can be used to verify the digital signature. This key must be included in the
	// PublicKeys map.
	FullyQualifiedKeyRef string `validate:"required"`
	// Signer is an interface can be used to digitally sign the DID Document.
	Signer proof.Signer `validate:"required"`
	// SignatureType specifies the suite used to generate the DID Doc signature
	SignatureType proof.SignatureType `validate:"required"`
	// PublicKeys is a map of KeyID to Ed25519 public keys. These keys will be listed in the DID
	// Document's publicKeys field.
	PublicKeys map[string]ed25519.PublicKey `validate:"required"`
	// Issuer is an optional DID who controls the SigningKey. This is intended to be used by
	// Issuers that create a different DID Document per schema type.  Specifying the Issuer here
	// creates a linkage between the identities.
	Issuer did.DID `validate:"required"`
	// Services are service endpoints that are published in the DID Document.
	//
	// Workday uses a "schema" service endpoint to specify which schema an identity will issue
	// credentials against. This service endpoint is not strictly necessary, but may be useful
	// for Issuers managing multiple identities.
	Services []did.ServiceDef
}

func (GenerateDIDDocInput) GenerateLedgerDIDDoc

func (g GenerateDIDDocInput) GenerateLedgerDIDDoc() (*DIDDoc, error)

GenerateLedgerDIDDoc generates DID Document based on the current state of the input.

type HasLedgerMetadata

type HasLedgerMetadata interface {
	GetLedgerMetadata() *Metadata
}

type HasLedgerMetadataProvable

type HasLedgerMetadataProvable interface {
	proof.Provable
	HasLedgerMetadata
}

A unification of Provable and HasLedgerMetadata types as a utility to aid in the signing of objects that have ledger metadata

type JSONSchema

type JSONSchema struct {
	Schema JSONSchemaMap `json:"schema"`
}

Object for a credential that has not been signed

type JSONSchemaMap

type JSONSchemaMap map[string]interface{}

go representation of json schema document

func (JSONSchemaMap) AllowsAdditionalProperties

func (j JSONSchemaMap) AllowsAdditionalProperties() bool

func (JSONSchemaMap) Description

func (j JSONSchemaMap) Description() string

Assumes the json schema has a description field

func (JSONSchemaMap) Properties

func (j JSONSchemaMap) Properties() Properties

Assumes the json schema has a properties field

func (JSONSchemaMap) RequiredFields

func (j JSONSchemaMap) RequiredFields() []string

func (JSONSchemaMap) ToJSON

func (j JSONSchemaMap) ToJSON() string

type Metadata

type Metadata struct {
	Type         string       `json:"type"`
	ModelVersion string       `json:"modelVersion"`
	ID           string       `json:"id"`
	Name         string       `json:"name,omitempty"`
	Author       did.DID      `json:"author,omitempty"`
	Authored     string       `json:"authored,omitempty"`
	Proof        *proof.Proof `json:"proof,omitempty"`
}

Type, Model ModelVersion, and ID should always be present Depending on the model object, the remainder of the fields may be optional. This should be enforced by the platform and smart contracts.

func (*Metadata) GetLedgerMetadata

func (m *Metadata) GetLedgerMetadata() *Metadata

func (*Metadata) GetProof

func (m *Metadata) GetProof() *proof.Proof

func (*Metadata) IsEmpty

func (m *Metadata) IsEmpty() bool

func (*Metadata) SetProof

func (m *Metadata) SetProof(p *proof.Proof)

type Properties

type Properties map[string]interface{}

type Revocation

type Revocation struct {
	*Metadata
	*UnsignedRevocation `json:"revocation"`
}

func GenerateLedgerRevocation

func GenerateLedgerRevocation(credentialID string, issuer did.DID, signer proof.Signer, signatureType proof.SignatureType) (*Revocation, error)

func (*Revocation) IsEmpty

func (r *Revocation) IsEmpty() bool

func (Revocation) Validate

func (r Revocation) Validate(ctx context.Context, provider Provider) error

func (Revocation) ValidateKey

func (r Revocation) ValidateKey() error

func (Revocation) ValidateMetadata

func (r Revocation) ValidateMetadata() error

func (Revocation) ValidateNotEmpty

func (r Revocation) ValidateNotEmpty() error

func (Revocation) ValidateProof

func (r Revocation) ValidateProof(ctx context.Context, provider DIDDocProvider) error

func (Revocation) ValidateStatic

func (r Revocation) ValidateStatic() error

func (Revocation) ValidateUniqueness

func (r Revocation) ValidateUniqueness(ctx context.Context, provider RevocationProvider) error

type RevocationProvider

type RevocationProvider func(ctx context.Context, credentialID, revocationID string) (*Revocation, error)

type Schema

type Schema struct {
	*Metadata
	*JSONSchema
}

func GenerateLedgerSchema

func GenerateLedgerSchema(name string, author did.DID, signer proof.Signer, signatureType proof.SignatureType, schema map[string]interface{}) (*Schema, error)

func (*Schema) IsEmpty

func (s *Schema) IsEmpty() bool

func (Schema) Validate

func (s Schema) Validate(ctx context.Context, provider Provider) error

func (Schema) ValidateID

func (s Schema) ValidateID() error

ID validation is based on our public schema specification: This identifier is a method-specific DID parameter name based upon the author of the schema. For example, if the author had a did like did:work:abcdefghi a possible schema ID the author created would have an identifier such as: did:work:abcdefghi;schema=17de181feb67447da4e78259d92d0240;version=1.0

func (Schema) ValidateMetadata

func (s Schema) ValidateMetadata() error

func (Schema) ValidateNotEmpty

func (s Schema) ValidateNotEmpty() error

func (Schema) ValidateProof

func (s Schema) ValidateProof(ctx context.Context, provider DIDDocProvider) error

func (Schema) ValidateStatic

func (s Schema) ValidateStatic() error

func (Schema) ValidateUniqueness

func (s Schema) ValidateUniqueness(ctx context.Context, provider SchemaProvider) error

func (Schema) Version

func (s Schema) Version() (string, error)

Version assumes the version property is the only version in the identifier separated by periods

type SchemaProvider

type SchemaProvider func(ctx context.Context, schemaID string) (*Schema, error)

type UnsignedRevocation

type UnsignedRevocation struct {
	ID           string  `json:"id"`
	CredentialID string  `json:"credentialId,omitempty"`
	IssuerDID    did.DID `json:"issuerId,omitempty"`
	ReasonCode   int     `json:"reason,omitempty"`
	Revoked      string  `json:"revoked,omitempty"`
}

func (*UnsignedRevocation) IsEmpty

func (u *UnsignedRevocation) IsEmpty() bool

Jump to

Keyboard shortcuts

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