Versions in this module Expand all Collapse all v1 v1.2.0 Nov 28, 2024 v1.1.0 Jan 28, 2023 v1.0.0 Dec 31, 2022 Changes in this version + const AccessKeyHeaderBodyHash + const AccessKeyHeaderClientKey + const AccessKeyHeaderDate + const AccessKeyType + const Ed25519VerificationKey2018Type + const KeySize + const MerkleID + const MessageTypeNewBlockNotification + const NTopicNewBlock + const NonceLength + const PiprateContextURL + const ProvTypeActivity + const ProvTypeAgent + const ProvTypeAssociation + const ProvTypeEntity + const ProvTypeRole + const ProvTypeUsage + const RcTypeAlgo0 + const RcTypeAlgo1 + const RecordFlagPublic + const RequestingCommitmentTag + const TypeResource + var DefaultMaxDistanceSeconds int64 = 5 * 60 + var ErrAssetHeadNotFound = errors.New("asset head not found") + var ErrAuthorizationNotFound = errors.New("missing or invalid Authorization in request header") + var ErrBlobNotFound = errors.New("blob not found") + var ErrBlockNotFound = errors.New("block not found") + var ErrDataAssetAccessDenied = errors.New("access to data asset denied") + var ErrDataAssetNotFound = errors.New("data asset not found") + var ErrDataSetNotFound = errors.New("dataset not found") + var ErrInvalidDID = errors.New("invalid DID identifier") + var ErrMissingClientKeyInHeader = errors.New("missing " + AccessKeyHeaderClientKey + " in request header") + var ErrMissingDateInHeader = errors.New("missing " + AccessKeyHeaderDate + " in request header") + var ErrOperationNotFound = errors.New("operation not found") + var ErrRecordNotFound = errors.New("record not found") + var ErrResourceNotFound = errors.New("resource not found") + func AnonDecrypt(cypherText, privateKey []byte) ([]byte, error) + func AnonEncrypt(msg, publicKey []byte) []byte + func BuildAuthorisingCommitmentInput(privKey *hdkeychain.ExtendedKey, opAddress string) []byte + func BuildDIDPrefix(method string) string + func BuildDigitalAssetID(data []byte, fingerprintAlgorithm, didMethod string) (string, error) + func BuildDigitalAssetIDFromFile(filename, fingerprintAlgorithm, didMethod string) (string, string, error) + func BuildDigitalAssetIDFromReader(r io.Reader, fingerprintAlgorithm, didMethod string) (string, error) + func BuildDigitalAssetIDWithFingerprint(fp []byte, didMethod string) string + func BuildRequestingCommitmentInput(leaseID string, expiresAt *time.Time) []byte + func BuildRoutingKey(key *btcec.PublicKey) (string, error) + func BuildSharedSecret(key *hdkeychain.ExtendedKey) string + func CompactDocument(input []byte, ctxURL string) ([]byte, error) + func DecryptAESCGM(ciphertext []byte, key *AESKey) (plaintext []byte, err error) + func DecryptCredentials(recipient *DID, credentials, subject string) (string, string, error) + func DefaultDocumentLoader() ld.DocumentLoader + func DeriveStorageAccessKey(leaseID string) (ed25519.PublicKey, ed25519.PrivateKey) + func EncryptAESCGM(plaintext []byte, key *AESKey) (ciphertext []byte, err error) + func EncryptCredentials(recipient *DID, keyID, secret, subject string) string + func ExpandDocument(input []byte) ([]byte, error) + func ExtractDIDMethod(didID string) (string, error) + func ExtractSignature(hdr http.Header) (string, string, error) + func FlattenDocument(input []byte, ctx any) ([]byte, error) + func GenerateAccessKeyID() string + func GenerateAccessToken(recordID, leaseID string, now, leaseExpiryTime int64) string + func GenerateDocumentNodeMap(input []byte) (map[string]any, error) + func GenerateNewHDKey(seed []byte) (*hdkeychain.ExtendedKey, *hdkeychain.ExtendedKey, error) + func Hash(tag string, data []byte) []byte + func HashRequestBody(body []byte) []byte + func HeadID(assetID string, lockerID string, sender *LockerParticipant, headName string) string + func NewAssetID(method string) string + func PackHeadBody(assetID, lockerID, participantID, name, recordID string) []byte + func Pad(src []byte) []byte + func PutBinaryContextIntoDefaultDocumentLoader(url string, ctx []byte) error + func PutContextIntoDefaultDocumentLoader(url, filePath string) error + func PutContextMapIntoDefaultDocumentLoader(contextMap map[string]string) error + func RandomKeyIndex() uint32 + func RecordsToCSV(recs []*Record) []byte + func SetDebugMode(v bool) + func SetDefaultDocumentLoader(l ld.DocumentLoader) + func SignRequest(hdr http.Header, keyID string, clientSecret *AESKey, clientHMACKey []byte, ...) (string, error) + func UnpackHeadBody(val []byte) (string, string, string, string, string) + func UnwrapDigitalAssetID(id string) string + func ValidateDIDMethodPrefix(methodPrefix string) error + func ValidateRequest(hdr http.Header, reqSig string, encryptedHMACKey []byte, reqTime time.Time, ...) (bool, error) + func VerifyAccessToken(at, dataAssetID string, now, maxDistanceSeconds int64, ledger AccessVerifier) bool + func VerifyDigitalAssetID(id, fingerprintAlgorithm string, data []byte) (bool, error) + func VerifySemanticDigitalAssetID(id, fingerprintAlgorithm string, data []byte) (bool, error) + type AESKey [32]byte + func DecodeAESKey(val string, privKey ed25519.PrivateKey) (*AESKey, error) + func DeriveClientAESKey(pk ed25519.PrivateKey) *AESKey + func DeriveEncryptionKey(secret1, secret2 []byte) *AESKey + func DeriveSymmetricalKey(secret []byte, pubKey *btcec.PublicKey) *AESKey + func NewAESKey(val []byte) *AESKey + func NewEncryptionKey() *AESKey + func SplitClientSecret(secret string) (ed25519.PrivateKey, *AESKey, []byte, error) + func (k *AESKey) Base64() string + func (k *AESKey) Zero() + func (k AESKey) Bytes() []byte + type AccessKey struct + AccessLevel AccessLevel + AccountID string + ClientHMACKey []byte + ClientSecret *AESKey + EncryptedHostedKey string + EncryptedManagedKey string + ID string + ManagementKey string + ManagementKeyPrv ed25519.PrivateKey + ManagementKeyPub ed25519.PublicKey + Secret string + Type string + func GenerateAccessKey(accountID string, accessLevel AccessLevel) (*AccessKey, error) + func (ak *AccessKey) AddHostedKey(key *AESKey) + func (ak *AccessKey) AddManagedKey(key *AESKey) + func (ak *AccessKey) Bytes() []byte + func (ak *AccessKey) ClientKeys() (string, string) + func (ak *AccessKey) Hydrate(secret string) error + func (ak *AccessKey) Neuter() + type AccessLevel int32 + const AccessLevelCold + const AccessLevelHosted + const AccessLevelLocal + const AccessLevelManaged + const AccessLevelNone + const AccessLevelRestricted + type AccessVerifier interface + GetDataAssetState func(id string) (DataAssetState, error) + GetRecord func(rid string) (*Record, error) + GetRecordState func(rid string) (*RecordState, error) + type Algorithm struct + Context any + ID string + Type any + type BlobManager interface + GetBlob func(res *StoredResource, accessToken string) (io.ReadCloser, error) + GetVaultMap func() (map[string]*VaultProperties, error) + PurgeBlob func(res *StoredResource) error + SendBlob func(data io.Reader, cleartext bool, vaultID string) (*StoredResource, error) + type Block struct + Hash string + Number int64 + ParentHash string + type Confirmation struct + Offer *KnowledgeOffer + Provenance []*QuotedFromEntity + Terms []*OfferTerms + Type string + type ConsentReceipt struct + CollectionMethod string + ConsentReceiptID string + ConsentTimestamp uint64 + DataController *DataController + Jurisdiction string + PolicyURL string + Sensitive bool + Services []*Service + SpiCat []string + Subject string + Version string + type Criteria struct + ID string + Name string + Params []map[string]any + Type string + Version string + type DID struct + ID string + SignKey string + VerKey string + func GenerateDID(options ...DIDOption) (*DID, error) + func NewDID(did, verKey, signKey string) *DID + func (did *DID) Bytes() []byte + func (did *DID) Copy() *DID + func (did *DID) NeuteredCopy() *DID + func (did *DID) Sign(message []byte) []byte + func (did *DID) SignKeyValue() ed25519.PrivateKey + func (did *DID) VerKeyValue() ed25519.PublicKey + func (did *DID) Verify(message, signature []byte) bool + func (did *DID) Zero() + type DIDDocument struct + Authentication []any + Context any + Created *time.Time + ID string + Proof *Proof + PublicKey []any + Service []any + Updated *time.Time + func SimpleDIDDocument(did *DID, created *time.Time) (*DIDDocument, error) + func (d *DIDDocument) Bytes() []byte + func (d *DIDDocument) Equals(anotherD *DIDDocument) bool + func (d *DIDDocument) ExtractIndyStyleDID() (*DID, error) + func (d *DIDDocument) Sign(identity string, key ed25519.PrivateKey) error + func (d *DIDDocument) Verify(key ed25519.PublicKey) (bool, error) + type DIDOption func(opts *didOptions) + func WithMethod(method string) DIDOption + func WithSeed(seed string) DIDOption + type DIDProvider interface + CreateDIDDocument func(ddoc *DIDDocument) error + GetDIDDocument func(iid string) (*DIDDocument, error) + type DataAssetState int + const DataAssetStateKeep + const DataAssetStateNotFound + const DataAssetStateRemove + type DataController struct + Address any + Contact string + Email string + OnBehalf bool + Org string + PIIControllerURL *url.URL + Phone string + type DataSet interface + BlockNumber func() int64 + DecodeMetaResource func(obj any) error + DecodeResource func(id string, obj any) error + ID func() string + Impression func() *Impression + Lease func() *Lease + LockerID func() string + MetaResource func() (io.ReadCloser, error) + ParticipantID func() string + Record func() *Record + Resource func(id string) (io.ReadCloser, error) + Resources func() []string + type Ed25519VerificationKey2018 struct + Context any + Controller string + Expires *time.Time + ID string + PublicKeyBase58 string + Type string + type Impression struct + Asset string + Context any + GeneratedAtTime *time.Time + ID string + MetaResource *MetaResource + Proof *Proof + ProvGraph any + RevisionMessage string + RevisionNumber int64 + SpecializationOf string + Type []string + WasAttributedTo string + WasRevisionOf string + func NewBlankImpression() *Impression + func NewImpression(body []byte) (*Impression, error) + func (ii *Impression) Bytes() []byte + func (ii *Impression) Compact() ([]byte, error) + func (ii *Impression) Copy() *Impression + func (ii *Impression) GetProvenance(resourceID string) any + func (ii *Impression) GetVariantID() string + func (ii *Impression) IsRoot() bool + func (ii *Impression) IsSigned() bool + func (ii *Impression) MerkleSign(identity string, key ed25519.PrivateKey) error + func (ii *Impression) MerkleVerify(key ed25519.PublicKey) (bool, error) + func (ii *Impression) Revision() int64 + func (ii *Impression) RevisionOf() string + type KnowledgeOffer struct + Asset any + DatasetPreview any + DatasetType string + Expires *time.Time + ID string + Proof *Proof + Recipient string + RevisionNumber int64 + Sender string + SpecializationOf string + Terms []*OfferTerms + Type string + WasRevisionOf string + func NewKnowledgeOffer(body []byte) (*KnowledgeOffer, error) + func (ko *KnowledgeOffer) Bytes() []byte + func (ko *KnowledgeOffer) MerkleSign(identity string, key ed25519.PrivateKey) error + func (ko *KnowledgeOffer) MerkleVerify(key ed25519.PublicKey) (bool, error) + type KnowledgeProspectus struct + Context any + Created *time.Time + Creator string + ID string + Offers []*KnowledgeOffer + Proof *Proof + Query *KnowledgeQuery + Type string + func NewKnowledgeProspectus(body []byte) (*KnowledgeProspectus, error) + func (kp *KnowledgeProspectus) Bytes() []byte + func (kp *KnowledgeProspectus) MerkleSign(identity string, key ed25519.PrivateKey) error + func (kp *KnowledgeProspectus) MerkleVerify(key ed25519.PublicKey) (bool, error) + type KnowledgeQuery struct + Context any + Created *time.Time + Creator string + Criteria *Criteria + ID string + Proof *Proof + Type string + type KnowledgeSharingRequest struct + Confirmations []*Confirmation + Context any + Created *time.Time + Creator string + ID string + Locker string + Proof *Proof + Prospectus *KnowledgeProspectus + Type string + Vault string + type KnowledgeSharingResult struct + ImpressionID string + Payload any + RecordID string + type Lease struct + DataSetType string + ExpiresAt *time.Time + ID string + Impression *Impression + Proof *Proof + Provenance *ProvEntity + Resources []*StoredResource + Type string + func NewLease(body []byte) (*Lease, error) + func (l *Lease) DataAssetList(includeMetaAsset bool) []string + func (l *Lease) GenerateAccessToken(rid string) string + func (l *Lease) GetResourceIDs() []string + func (l *Lease) MetaResource() *StoredResource + func (l *Lease) Resource(assetID string) *StoredResource + type Ledger interface + GetAssetHead func(headID string) (*Record, error) + GetBlock func(bn int64) (*Block, error) + GetBlockRecords func(bn int64) ([][]string, error) + GetChain func(startNumber int64, depth int) ([]*Block, error) + GetDataAssetState func(id string) (DataAssetState, error) + GetGenesisBlock func() (*Block, error) + GetRecord func(rid string) (*Record, error) + GetRecordState func(rid string) (*RecordState, error) + GetTopBlock func() (*Block, error) + SubmitRecord func(r *Record) error + type Locker struct + AccessLevel AccessLevel + Created *time.Time + Expires *time.Time + FirstBlock int64 + ID string + LastBlock int64 + Name string + Participants []*LockerParticipant + Sealed *time.Time + ThirdPartyAcceptedAtBlock int64 + func GenerateLocker(accessLevel AccessLevel, name string, expires *time.Time, firstBlock int64, ...) (*Locker, error) + func (l *Locker) AcceptedAtBlock() int64 + func (l *Locker) Bytes() []byte + func (l *Locker) Copy() *Locker + func (l *Locker) GetParticipant(participantID string) *LockerParticipant + func (l *Locker) Hydrate(pk ed25519.PrivateKey) error + func (l *Locker) IsHydrated() bool + func (l *Locker) IsUnilocker() bool + func (l *Locker) Perspective(iid string) *Locker + func (l *Locker) SetAcceptedAtBlock(block int64) + func (l *Locker) Them() *LockerParticipant + func (l *Locker) Us() *LockerParticipant + func (l *Locker) Zero() + type LockerParticipant struct + AcceptedAtBlock int64 + ID string + RootPrivateKeyEnc string + RootPublicKey string + Self bool + SharedSecret string + func (lp *LockerParticipant) GetOperationSymKey(idx uint32) *AESKey + func (lp *LockerParticipant) GetRecordPrivateKey(idx uint32) (*hdkeychain.ExtendedKey, error) + func (lp *LockerParticipant) GetRecordPublicKey(idx uint32) (*btcec.PublicKey, error) + func (lp *LockerParticipant) GetRootPrivateKey() string + func (lp *LockerParticipant) Hydrate(pk ed25519.PrivateKey) error + func (lp *LockerParticipant) IsHydrated() bool + func (lp *LockerParticipant) IsRecordOwner(routingKey string, idx uint32) (*btcec.PublicKey, *AESKey, error) + func (lp *LockerParticipant) Zero() + type MerkleSigner interface + MerkleSign func(identity string, key ed25519.PrivateKey) error + type MerkleVerifier interface + GetProof func() *Proof + MerkleVerify func(key ed25519.PublicKey) (bool, error) + type MetaResource struct + Asset string + ContentType string + Fingerprint string + FingerprintAlgorithm string + type NewBlockMessage struct + Number int64 + Type string + type OffChainStorage interface + GetOperation func(opAddr string) ([]byte, error) + PurgeOperation func(opAddr string) error + SendOperation func(opData []byte) (string, error) + type OfferTerms struct + Duration int64 + type OpType uint32 + var OpTypeAssetHead OpType = 3 + var OpTypeLease OpType = 1 + var OpTypeLeaseRevocation OpType = 2 + type PartyOption func() (*LockerParticipant, error) + func Them(did *DID, seed []byte) PartyOption + func Us(did *DID, seed []byte) PartyOption + type Proof struct + Creator string + Type string + Value string + type ProvActivity struct + Algorithm string + ID string + QualifiedAssociation []*ProvAssociation + QualifiedUsage []*ProvUsage + Type string + Used any + WasAssociatedWith string + type ProvAgent struct + ActedOnBehalfOf string + ID string + Type string + type ProvAssociation struct + Agent any + HadRole *ProvRole + Type string + type ProvBundle struct + Context any + GeneratedAtTime *time.Time + Graph any + HadPrimarySource string + ID string + Proof *Proof + QualifiedPrimarySource []*ProvPrimarySource + Type string + WasAttributedTo string + type ProvEntity struct + AsInBundle string + ContentType string + Context any + GeneratedAtTime *time.Time + ID string + MentionOf string + Proof *Proof + Type string + WasAccessibleTo any + WasAttributedTo string + WasGeneratedBy *ProvActivity + WasQuotedFrom any + func (pe *ProvEntity) Bytes() []byte + func (pe *ProvEntity) Copy() *ProvEntity + func (pe *ProvEntity) MerkleSign(identity string, key ed25519.PrivateKey) error + func (pe *ProvEntity) MerkleVerify(key ed25519.PublicKey) (bool, error) + type ProvPrimarySource struct + Algorithm string + Entity any + Type string + type ProvRole struct + Label string + Type string + type ProvUsage struct + Entity any + HadRole *ProvRole + Type string + type QuotedFromEntity struct + ID string + Type string + WasQuotedFrom string + type Record struct + AuthorisingCommitment string + AuthorisingCommitmentType byte + DataAssets []string + Flags uint32 + HeadBody string + HeadID string + ID string + ImpressionCommitment string + ImpressionCommitmentType byte + KeyIndex uint32 + Operation OpType + OperationAddress string + RequestingCommitment string + RequestingCommitmentType byte + RevocationProof []string + RoutingKey string + Signature string + Status RecordStatus + SubjectRecord string + func (r *Record) Bytes() []byte + func (r *Record) Copy() *Record + func (r *Record) Seal(pk *btcec.PrivateKey) error + func (r *Record) ToSlice() []string + func (r *Record) Validate() error + func (r *Record) Verify(publicKey *btcec.PublicKey) (bool, error) + type RecordState struct + BlockNumber int64 + Status RecordStatus + func (r *RecordState) Bytes() []byte + type RecordStatus string + const StatusFailed + const StatusPending + const StatusPublished + const StatusRevoked + const StatusUnknown + type SemanticAsset struct + Context any + Fingerprint string + FingerprintAlgorithm string + ID string + IsDigital bool + IsIdentity bool + Nonce string + Proof *Proof + Serial bool + Type any + WasGeneratedBy map[string]any + func GenerateNewSemanticAsset(serial, isIdentity bool, didMethod, nonce string) (*SemanticAsset, error) + func GenerateNewSemanticDigitalAsset(data []byte, fingerprintAlgorithm, didMethod string) (*SemanticAsset, error) + func GenerateNewSemanticDigitalAssetFromFile(filename, fingerprintAlgorithm, didMethod string) (*SemanticAsset, error) + func GenerateNewSemanticDigitalAssetFromReader(r io.Reader, fingerprintAlgorithm, didMethod string) (*SemanticAsset, error) + func GenerateNewSemanticDigitalAssetWithHash(fp []byte, fingerprintAlgorithm, didMethod string) (*SemanticAsset, error) + func GenerateValueAsset(functionID string, entityArgs, valueArgs map[string]any, didMethod string) (*SemanticAsset, error) + func (sa *SemanticAsset) MerkleSetID(didMethod string) error + func (sa *SemanticAsset) MerkleVerify() (bool, error) + type Service struct + ServiceName string + type SignableDocument struct + func NewSignableDocument(b []byte) (*SignableDocument, error) + func (dp *SignableDocument) Context() any + func (dp *SignableDocument) Copy() (*SignableDocument, error) + func (dp *SignableDocument) Hash() ([]byte, error) + func (dp *SignableDocument) ID() string + func (dp *SignableDocument) MerkleSetID(idPrefix string) (string, error) + func (dp *SignableDocument) MerkleSign(idPrefix string, identity string, key ed25519.PrivateKey) (string, *Proof, error) + func (dp *SignableDocument) MerkleVerify(idPrefix string, publicKey ed25519.PublicKey) (bool, error) + func (dp *SignableDocument) SetContext(ctx any) + func (dp *SignableDocument) Sign(identity string, key ed25519.PrivateKey) (*Proof, error) + func (dp *SignableDocument) Verify(publicKey ed25519.PublicKey) (bool, error) + type Signer interface + Sign func(message []byte) []byte + type StoredResource struct + Asset string + EncryptionKey string + ID string + MIMEType string + Method string + Params map[string]any + Size int64 + Type string + Vault string + func (sc *StoredResource) GetEncryptionKey() *AESKey + func (sc *StoredResource) StorageID() string + type VaultProperties struct + CAS bool + ID string + Name string + SSE bool + Type string + type Verifier interface + Verify func(message, signature []byte) bool