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
/
api.go
73 lines (56 loc) · 2.14 KB
/
api.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
/*
Copyright SecureKey Technologies Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package suite
import (
"github.com/hyperledger/aries-framework-go/component/models/signature/api"
"github.com/hyperledger/aries-framework-go/component/models/signature/suite"
"github.com/hyperledger/aries-framework-go/spi/crypto"
)
// SignatureSuite defines general signature suite structure.
type SignatureSuite = suite.SignatureSuite
type signer interface {
// Sign will sign document and return signature
Sign(data []byte) ([]byte, error)
// Alg return alg.
Alg() string
}
type verifier interface {
// Verify will verify a signature.
Verify(pubKeyValue *api.PublicKey, doc, signature []byte) error
}
// Opt is the SignatureSuite option.
type Opt = suite.Opt
// WithSigner defines a signer for the Signature Suite.
func WithSigner(s signer) Opt {
return suite.WithSigner(s)
}
// WithVerifier defines a verifier for the Signature Suite.
func WithVerifier(v verifier) Opt {
return suite.WithVerifier(v)
}
// WithCompactProof indicates that proof compaction is needed, by default it is not done.
func WithCompactProof() Opt {
return suite.WithCompactProof()
}
// InitSuiteOptions initializes signature suite with options.
func InitSuiteOptions(signatureSuite *SignatureSuite, opts ...Opt) *SignatureSuite {
return suite.InitSuiteOptions(signatureSuite, opts...)
}
// CryptoSigner defines signer based on crypto.
type CryptoSigner = suite.CryptoSigner
// NewCryptoSigner creates a new CryptoSigner.
func NewCryptoSigner(cr crypto.Crypto, kh interface{}) *CryptoSigner {
return suite.NewCryptoSigner(cr, kh)
}
// CryptoVerifier defines signature verifier based on crypto.
type CryptoVerifier = suite.CryptoVerifier
// NewCryptoVerifier creates a new CryptoVerifier.
func NewCryptoVerifier(cr crypto.Crypto) *CryptoVerifier {
return suite.NewCryptoVerifier(cr)
}
// ErrSignerNotDefined is returned when Sign() is called but signer option is not defined.
var ErrSignerNotDefined = suite.ErrSignerNotDefined
// ErrVerifierNotDefined is returned when Verify() is called but verifier option is not defined.
var ErrVerifierNotDefined = suite.ErrVerifierNotDefined