-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopts_idemix.go
149 lines (128 loc) · 4.76 KB
/
opts_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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
// Copyright © 2018 The IPFN Developers. All Rights Reserved.
// Copyright © 2016-2018 IBM Corp. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package bccsp
import "crypto"
const (
// IDEMIX constant to identify Idemix related algorithms
IDEMIX = "IDEMIX"
)
// IdemixIssuerKeyGenOpts contains the options for the Idemix Issuer key-generation.
// A list of attribytes may be optionally passed
type IdemixIssuerKeyGenOpts struct {
// Temporary tells if the key is ephemeral
Temporary bool
// AttributeNames is a list of attributes
AttributeNames []string
}
// Algorithm returns the key generation algorithm identifier (to be used).
func (*IdemixIssuerKeyGenOpts) Algorithm() string {
return IDEMIX
}
// Ephemeral returns true if the key to generate has to be ephemeral,
// false otherwise.
func (o *IdemixIssuerKeyGenOpts) Ephemeral() bool {
return o.Temporary
}
// IdemixUserSecretKeyGenOpts contains the options for the generation of an Idemix credential secret key.
type IdemixUserSecretKeyGenOpts struct {
Temporary bool
}
// Algorithm returns the key generation algorithm identifier (to be used).
func (*IdemixUserSecretKeyGenOpts) Algorithm() string {
return IDEMIX
}
// Ephemeral returns true if the key to generate has to be ephemeral,
// false otherwise.
func (o *IdemixUserSecretKeyGenOpts) Ephemeral() bool {
return o.Temporary
}
// IdemixNymKeyDerivationOpts contains the options to create a new unlinkable pseudonym from a
// credential secret key with the respect to the specified issuer public key
type IdemixNymKeyDerivationOpts struct {
// Temporary tells if the key is ephemeral
Temporary bool
// IssuerPK is the public-key of the issuer
IssuerPK Key
}
// Algorithm returns the key derivation algorithm identifier (to be used).
func (*IdemixNymKeyDerivationOpts) Algorithm() string {
return IDEMIX
}
// Ephemeral returns true if the key to derive has to be ephemeral,
// false otherwise.
func (o *IdemixNymKeyDerivationOpts) Ephemeral() bool {
return o.Temporary
}
// IssuerPublicKey returns the issuer public key used to derive
// a new unlinkable pseudonym from a credential secret key
func (o *IdemixNymKeyDerivationOpts) IssuerPublicKey() Key {
return o.IssuerPK
}
// IdemixCredentialRequestSignerOpts contains the option to create a Idemix credential request.
type IdemixCredentialRequestSignerOpts struct {
// Attributes contains a list of indices of the attributes to be included in the
// credential. The indices are with the respect to IdemixIssuerKeyGenOpts#AttributeNames.
Attributes []int
// HashFun is the hash function to be used
H crypto.Hash
}
func (o *IdemixCredentialRequestSignerOpts) HashFunc() crypto.Hash {
return o.H
}
// IdemixCredentialSignerOpts contains the options to produce a credential starting from a credential request
type IdemixCredentialSignerOpts struct {
Attributes []int
// HashFun is the hash function to be used
H crypto.Hash
}
// HashFunc returns an identifier for the hash function used to produce
// the message passed to Signer.Sign, or else zero to indicate that no
// hashing was done.
func (o *IdemixCredentialSignerOpts) HashFunc() crypto.Hash {
return o.H
}
// IdemixSignerOpts contains the options to generate an Idemix signature
type IdemixSignerOpts struct {
// Nym is the pseudonym to be used
Nym Key
// IssuerPK is the public-key of the issuer
IssuerPK Key
// Credential is the byte representation of the credential signed by the issuer
Credential []byte
// Disclosure specifies which attribute should be disclosed. If Disclosure[i] = 0
// then the i-th credential attribute should not be disclosed, otherwise the i-th
// credential attribute will be disclosed.
Disclosure []byte
// H is the hash function to be used
H crypto.Hash
}
func (o *IdemixSignerOpts) HashFunc() crypto.Hash {
return o.H
}
// IdemixNymSignerOpts contains the options to generate an idemix pseudonym signature.
type IdemixNymSignerOpts struct {
// Nym is the pseudonym to be used
Nym Key
// IssuerPK is the public-key of the issuer
IssuerPK Key
// H is the hash function to be used
H crypto.Hash
}
// HashFunc returns an identifier for the hash function used to produce
// the message passed to Signer.Sign, or else zero to indicate that no
// hashing was done.
func (o *IdemixNymSignerOpts) HashFunc() crypto.Hash {
return o.H
}