-
Notifications
You must be signed in to change notification settings - Fork 8.9k
/
idemix.go
100 lines (78 loc) · 2.64 KB
/
idemix.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
99
100
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package msp
import (
"github.com/IBM/idemix"
"github.com/hyperledger/fabric-protos-go-apiv2/msp"
)
type idemixSigningIdentityWrapper struct {
*idemix.IdemixSigningIdentity
}
func (i *idemixSigningIdentityWrapper) GetPublicVersion() Identity {
return &idemixIdentityWrapper{Idemixidentity: i.IdemixSigningIdentity.GetPublicVersion().(*idemix.Idemixidentity)}
}
func (i *idemixSigningIdentityWrapper) GetIdentifier() *IdentityIdentifier {
return i.GetPublicVersion().GetIdentifier()
}
func (i *idemixSigningIdentityWrapper) GetOrganizationalUnits() []*OUIdentifier {
return i.GetPublicVersion().GetOrganizationalUnits()
}
type idemixIdentityWrapper struct {
*idemix.Idemixidentity
}
func (i *idemixIdentityWrapper) GetIdentifier() *IdentityIdentifier {
id := i.Idemixidentity.GetIdentifier()
return &IdentityIdentifier{
Mspid: id.Mspid,
Id: id.Id,
}
}
func (i *idemixIdentityWrapper) GetOrganizationalUnits() []*OUIdentifier {
ous := i.Idemixidentity.GetOrganizationalUnits()
wous := []*OUIdentifier{}
for _, ou := range ous {
wous = append(wous, &OUIdentifier{
CertifiersIdentifier: ou.CertifiersIdentifier,
OrganizationalUnitIdentifier: ou.OrganizationalUnitIdentifier,
})
}
return wous
}
type idemixMSPWrapper struct {
*idemix.Idemixmsp
}
func (i *idemixMSPWrapper) deserializeIdentityInternal(serializedIdentity []byte) (Identity, error) {
id, err := i.Idemixmsp.DeserializeIdentityInternal(serializedIdentity)
if err != nil {
return nil, err
}
return &idemixIdentityWrapper{id.(*idemix.Idemixidentity)}, nil
}
func (i *idemixMSPWrapper) DeserializeIdentity(serializedIdentity []byte) (Identity, error) {
id, err := i.Idemixmsp.DeserializeIdentity(serializedIdentity)
if err != nil {
return nil, err
}
return &idemixIdentityWrapper{id.(*idemix.Idemixidentity)}, nil
}
func (i *idemixMSPWrapper) GetVersion() MSPVersion {
return MSPVersion(i.Idemixmsp.GetVersion())
}
func (i *idemixMSPWrapper) GetType() ProviderType {
return ProviderType(i.Idemixmsp.GetType())
}
func (i *idemixMSPWrapper) GetDefaultSigningIdentity() (SigningIdentity, error) {
id, err := i.Idemixmsp.GetDefaultSigningIdentity()
if err != nil {
return nil, err
}
return &idemixSigningIdentityWrapper{id.(*idemix.IdemixSigningIdentity)}, nil
}
func (i *idemixMSPWrapper) Validate(id Identity) error {
return i.Idemixmsp.Validate(id.(*idemixIdentityWrapper).Idemixidentity)
}
func (i *idemixMSPWrapper) SatisfiesPrincipal(id Identity, principal *msp.MSPPrincipal) error {
return i.Idemixmsp.SatisfiesPrincipal(id.(*idemixIdentityWrapper).Idemixidentity, principal)
}