forked from hyperledger/fabric-sdk-go
/
identity.go
65 lines (47 loc) · 1.63 KB
/
identity.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
/*
Copyright SecureKey Technologies Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package msp
import (
"github.com/hyperledger/fabric-sdk-go/pkg/common/providers/core"
"github.com/pkg/errors"
)
var (
// ErrUserNotFound indicates the user was not found
ErrUserNotFound = errors.New("user not found")
)
// IdentityManager provides management of identities in Fabric network
type IdentityManager interface {
GetSigningIdentity(name string) (SigningIdentity, error)
}
// Identity represents a Fabric client identity
type Identity interface {
// Identifier returns the identifier of that identity
Identifier() *IdentityIdentifier
// Verify a signature over some message using this identity as reference
Verify(msg []byte, sig []byte) error
// Serialize converts an identity to bytes
Serialize() ([]byte, error)
// EnrollmentCertificate Returns the underlying ECert representing this user’s identity.
EnrollmentCertificate() []byte
}
// SigningIdentity is an extension of Identity to cover signing capabilities.
type SigningIdentity interface {
// Extends Identity
Identity
// Sign the message
Sign(msg []byte) ([]byte, error)
// GetPublicVersion returns the public parts of this identity
PublicVersion() Identity
// PrivateKey returns the crypto suite representation of the private key
PrivateKey() core.Key
}
// IdentityIdentifier is a holder for the identifier of a specific
// identity, naturally namespaced, by its provider identifier.
type IdentityIdentifier struct {
// The identifier of the associated membership service provider
MSPID string
// The identifier for an identity within a provider
ID string
}