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