github.com/hyperledger/aries-framework-go@v0.3.2/pkg/client/issuecredential/rfc0593/dependencies.go (about) 1 /* 2 Copyright SecureKey Technologies Inc. All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 package rfc0593 8 9 import ( 10 "github.com/piprate/json-gold/ld" 11 12 "github.com/hyperledger/aries-framework-go/pkg/crypto" 13 "github.com/hyperledger/aries-framework-go/pkg/didcomm/protocol/issuecredential" 14 "github.com/hyperledger/aries-framework-go/pkg/doc/signature/signer" 15 "github.com/hyperledger/aries-framework-go/pkg/doc/signature/suite" 16 "github.com/hyperledger/aries-framework-go/pkg/doc/signature/suite/bbsblssignature2020" 17 "github.com/hyperledger/aries-framework-go/pkg/doc/signature/suite/ed25519signature2018" 18 "github.com/hyperledger/aries-framework-go/pkg/doc/verifiable" 19 "github.com/hyperledger/aries-framework-go/pkg/framework/aries/api/vdr" 20 "github.com/hyperledger/aries-framework-go/pkg/kms" 21 "github.com/hyperledger/aries-framework-go/pkg/vdr/fingerprint" 22 "github.com/hyperledger/aries-framework-go/spi/storage" 23 ) 24 25 // ServiceProvider is used to lookup the issuecredential service. 26 type ServiceProvider interface { 27 Service(name string) (interface{}, error) 28 } 29 30 // IssueCredentialService defines the API required on the issue-credential protocol service implementation. 31 type IssueCredentialService interface { 32 AddMiddleware(...issuecredential.Middleware) 33 } 34 35 // JSONLDDocumentLoaderProvider provides an ld.DocumentLoader. 36 // 37 // See also: context.Provider. 38 type JSONLDDocumentLoaderProvider interface { 39 JSONLDDocumentLoader() ld.DocumentLoader 40 } 41 42 // TransientStorage provides transient storage. 43 type TransientStorage interface { 44 ProtocolStateStorageProvider() storage.Provider 45 } 46 47 // Provider provides all dependencies. 48 // 49 // See also: context.Provider. 50 type Provider interface { 51 JSONLDDocumentLoaderProvider 52 TransientStorage 53 KMS() kms.KeyManager 54 Crypto() crypto.Crypto 55 VDRegistry() vdr.Registry 56 } 57 58 // Signer is used to create signer.SignatureSuite and attach LD proofs. 59 type Signer interface { 60 Sign(data []byte) ([]byte, error) 61 Alg() string 62 } 63 64 // SignatureSuiteSpec specifies how to instantiate a signature suite and its proof. 65 type SignatureSuiteSpec struct { 66 KeyType kms.KeyType 67 KeyMultiCodec uint64 68 SignatureRepresentation verifiable.SignatureRepresentation 69 Suite func(...suite.Opt) signer.SignatureSuite 70 Signer func(Provider, interface{}) Signer 71 } 72 73 // DefaultSignatureSuiteSpecs are the signature suites supported by default. 74 // TODO make signaturesuite specs configurable. 75 var DefaultSignatureSuiteSpecs = map[string]SignatureSuiteSpec{ // nolint:gochecknoglobals 76 ed25519signature2018.SignatureType: { 77 KeyType: kms.ED25519Type, 78 KeyMultiCodec: fingerprint.ED25519PubKeyMultiCodec, 79 Suite: func(opts ...suite.Opt) signer.SignatureSuite { 80 return ed25519signature2018.New(opts...) 81 }, 82 SignatureRepresentation: verifiable.SignatureJWS, 83 Signer: func(p Provider, kh interface{}) Signer { 84 return suite.NewCryptoSigner(p.Crypto(), kh) 85 }, 86 }, 87 bbsblssignature2020.SignatureType: { 88 KeyType: kms.BLS12381G2Type, 89 KeyMultiCodec: fingerprint.BLS12381g2PubKeyMultiCodec, 90 Suite: func(opts ...suite.Opt) signer.SignatureSuite { 91 return bbsblssignature2020.New(opts...) 92 }, 93 SignatureRepresentation: verifiable.SignatureProofValue, 94 Signer: func(p Provider, kh interface{}) Signer { 95 return newBBSSigner(p.KMS(), p.Crypto(), kh) 96 }, 97 }, 98 }