github.com/zhouxv/fabric@v2.1.1+incompatible/bccsp/idemixopts.go (about) 1 /* 2 Copyright IBM Corp. All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 package bccsp 7 8 import ( 9 "crypto" 10 ) 11 12 // RevocationAlgorithm identifies the revocation algorithm 13 type RevocationAlgorithm int32 14 15 const ( 16 // IDEMIX constant to identify Idemix related algorithms 17 IDEMIX = "IDEMIX" 18 ) 19 20 const ( 21 // AlgNoRevocation means no revocation support 22 AlgNoRevocation RevocationAlgorithm = iota 23 ) 24 25 // IdemixIssuerKeyGenOpts contains the options for the Idemix Issuer key-generation. 26 // A list of attribytes may be optionally passed 27 type IdemixIssuerKeyGenOpts struct { 28 // Temporary tells if the key is ephemeral 29 Temporary bool 30 // AttributeNames is a list of attributes 31 AttributeNames []string 32 } 33 34 // Algorithm returns the key generation algorithm identifier (to be used). 35 func (*IdemixIssuerKeyGenOpts) Algorithm() string { 36 return IDEMIX 37 } 38 39 // Ephemeral returns true if the key to generate has to be ephemeral, 40 // false otherwise. 41 func (o *IdemixIssuerKeyGenOpts) Ephemeral() bool { 42 return o.Temporary 43 } 44 45 // IdemixIssuerPublicKeyImportOpts contains the options for importing of an Idemix issuer public key. 46 type IdemixIssuerPublicKeyImportOpts struct { 47 Temporary bool 48 // AttributeNames is a list of attributes to ensure the import public key has 49 AttributeNames []string 50 } 51 52 // Algorithm returns the key generation algorithm identifier (to be used). 53 func (*IdemixIssuerPublicKeyImportOpts) Algorithm() string { 54 return IDEMIX 55 } 56 57 // Ephemeral returns true if the key to generate has to be ephemeral, 58 // false otherwise. 59 func (o *IdemixIssuerPublicKeyImportOpts) Ephemeral() bool { 60 return o.Temporary 61 } 62 63 // IdemixUserSecretKeyGenOpts contains the options for the generation of an Idemix credential secret key. 64 type IdemixUserSecretKeyGenOpts struct { 65 Temporary bool 66 } 67 68 // Algorithm returns the key generation algorithm identifier (to be used). 69 func (*IdemixUserSecretKeyGenOpts) Algorithm() string { 70 return IDEMIX 71 } 72 73 // Ephemeral returns true if the key to generate has to be ephemeral, 74 // false otherwise. 75 func (o *IdemixUserSecretKeyGenOpts) Ephemeral() bool { 76 return o.Temporary 77 } 78 79 // IdemixUserSecretKeyImportOpts contains the options for importing of an Idemix credential secret key. 80 type IdemixUserSecretKeyImportOpts struct { 81 Temporary bool 82 } 83 84 // Algorithm returns the key generation algorithm identifier (to be used). 85 func (*IdemixUserSecretKeyImportOpts) Algorithm() string { 86 return IDEMIX 87 } 88 89 // Ephemeral returns true if the key to generate has to be ephemeral, 90 // false otherwise. 91 func (o *IdemixUserSecretKeyImportOpts) Ephemeral() bool { 92 return o.Temporary 93 } 94 95 // IdemixNymKeyDerivationOpts contains the options to create a new unlinkable pseudonym from a 96 // credential secret key with the respect to the specified issuer public key 97 type IdemixNymKeyDerivationOpts struct { 98 // Temporary tells if the key is ephemeral 99 Temporary bool 100 // IssuerPK is the public-key of the issuer 101 IssuerPK Key 102 } 103 104 // Algorithm returns the key derivation algorithm identifier (to be used). 105 func (*IdemixNymKeyDerivationOpts) Algorithm() string { 106 return IDEMIX 107 } 108 109 // Ephemeral returns true if the key to derive has to be ephemeral, 110 // false otherwise. 111 func (o *IdemixNymKeyDerivationOpts) Ephemeral() bool { 112 return o.Temporary 113 } 114 115 // IssuerPublicKey returns the issuer public key used to derive 116 // a new unlinkable pseudonym from a credential secret key 117 func (o *IdemixNymKeyDerivationOpts) IssuerPublicKey() Key { 118 return o.IssuerPK 119 } 120 121 // IdemixNymPublicKeyImportOpts contains the options to import the public part of a pseudonym 122 type IdemixNymPublicKeyImportOpts struct { 123 // Temporary tells if the key is ephemeral 124 Temporary bool 125 } 126 127 // Algorithm returns the key derivation algorithm identifier (to be used). 128 func (*IdemixNymPublicKeyImportOpts) Algorithm() string { 129 return IDEMIX 130 } 131 132 // Ephemeral returns true if the key to derive has to be ephemeral, 133 // false otherwise. 134 func (o *IdemixNymPublicKeyImportOpts) Ephemeral() bool { 135 return o.Temporary 136 } 137 138 // IdemixCredentialRequestSignerOpts contains the option to create a Idemix credential request. 139 type IdemixCredentialRequestSignerOpts struct { 140 // Attributes contains a list of indices of the attributes to be included in the 141 // credential. The indices are with the respect to IdemixIssuerKeyGenOpts#AttributeNames. 142 Attributes []int 143 // IssuerPK is the public-key of the issuer 144 IssuerPK Key 145 // IssuerNonce is generated by the issuer and used by the client to generate the credential request. 146 // Once the issuer gets the credential requests, it checks that the nonce is the same. 147 IssuerNonce []byte 148 // HashFun is the hash function to be used 149 H crypto.Hash 150 } 151 152 func (o *IdemixCredentialRequestSignerOpts) HashFunc() crypto.Hash { 153 return o.H 154 } 155 156 // IssuerPublicKey returns the issuer public key used to derive 157 // a new unlinkable pseudonym from a credential secret key 158 func (o *IdemixCredentialRequestSignerOpts) IssuerPublicKey() Key { 159 return o.IssuerPK 160 } 161 162 // IdemixAttributeType represents the type of an idemix attribute 163 type IdemixAttributeType int 164 165 const ( 166 // IdemixHiddenAttribute represents an hidden attribute 167 IdemixHiddenAttribute IdemixAttributeType = iota 168 // IdemixStringAttribute represents a sequence of bytes 169 IdemixBytesAttribute 170 // IdemixIntAttribute represents an int 171 IdemixIntAttribute 172 ) 173 174 type IdemixAttribute struct { 175 // Type is the attribute's type 176 Type IdemixAttributeType 177 // Value is the attribute's value 178 Value interface{} 179 } 180 181 // IdemixCredentialSignerOpts contains the options to produce a credential starting from a credential request 182 type IdemixCredentialSignerOpts struct { 183 // Attributes to include in the credentials. IdemixHiddenAttribute is not allowed here 184 Attributes []IdemixAttribute 185 // IssuerPK is the public-key of the issuer 186 IssuerPK Key 187 // HashFun is the hash function to be used 188 H crypto.Hash 189 } 190 191 // HashFunc returns an identifier for the hash function used to produce 192 // the message passed to Signer.Sign, or else zero to indicate that no 193 // hashing was done. 194 func (o *IdemixCredentialSignerOpts) HashFunc() crypto.Hash { 195 return o.H 196 } 197 198 func (o *IdemixCredentialSignerOpts) IssuerPublicKey() Key { 199 return o.IssuerPK 200 } 201 202 // IdemixSignerOpts contains the options to generate an Idemix signature 203 type IdemixSignerOpts struct { 204 // Nym is the pseudonym to be used 205 Nym Key 206 // IssuerPK is the public-key of the issuer 207 IssuerPK Key 208 // Credential is the byte representation of the credential signed by the issuer 209 Credential []byte 210 // Attributes specifies which attribute should be disclosed and which not. 211 // If Attributes[i].Type = IdemixHiddenAttribute 212 // then the i-th credential attribute should not be disclosed, otherwise the i-th 213 // credential attribute will be disclosed. 214 // At verification time, if the i-th attribute is disclosed (Attributes[i].Type != IdemixHiddenAttribute), 215 // then Attributes[i].Value must be set accordingly. 216 Attributes []IdemixAttribute 217 // RhIndex is the index of attribute containing the revocation handler. 218 // Notice that this attributed cannot be discloused 219 RhIndex int 220 // CRI contains the credential revocation information 221 CRI []byte 222 // Epoch is the revocation epoch the signature should be produced against 223 Epoch int 224 // RevocationPublicKey is the revocation public key 225 RevocationPublicKey Key 226 // H is the hash function to be used 227 H crypto.Hash 228 } 229 230 func (o *IdemixSignerOpts) HashFunc() crypto.Hash { 231 return o.H 232 } 233 234 // IdemixNymSignerOpts contains the options to generate an idemix pseudonym signature. 235 type IdemixNymSignerOpts struct { 236 // Nym is the pseudonym to be used 237 Nym Key 238 // IssuerPK is the public-key of the issuer 239 IssuerPK Key 240 // H is the hash function to be used 241 H crypto.Hash 242 } 243 244 // HashFunc returns an identifier for the hash function used to produce 245 // the message passed to Signer.Sign, or else zero to indicate that no 246 // hashing was done. 247 func (o *IdemixNymSignerOpts) HashFunc() crypto.Hash { 248 return o.H 249 } 250 251 // IdemixRevocationKeyGenOpts contains the options for the Idemix revocation key-generation. 252 type IdemixRevocationKeyGenOpts struct { 253 // Temporary tells if the key is ephemeral 254 Temporary bool 255 } 256 257 // Algorithm returns the key generation algorithm identifier (to be used). 258 func (*IdemixRevocationKeyGenOpts) Algorithm() string { 259 return IDEMIX 260 } 261 262 // Ephemeral returns true if the key to generate has to be ephemeral, 263 // false otherwise. 264 func (o *IdemixRevocationKeyGenOpts) Ephemeral() bool { 265 return o.Temporary 266 } 267 268 // IdemixRevocationPublicKeyImportOpts contains the options for importing of an Idemix revocation public key. 269 type IdemixRevocationPublicKeyImportOpts struct { 270 Temporary bool 271 } 272 273 // Algorithm returns the key generation algorithm identifier (to be used). 274 func (*IdemixRevocationPublicKeyImportOpts) Algorithm() string { 275 return IDEMIX 276 } 277 278 // Ephemeral returns true if the key to generate has to be ephemeral, 279 // false otherwise. 280 func (o *IdemixRevocationPublicKeyImportOpts) Ephemeral() bool { 281 return o.Temporary 282 } 283 284 // IdemixCRISignerOpts contains the options to generate an Idemix CRI. 285 // The CRI is supposed to be generated by the Issuing authority and 286 // can be verified publicly by using the revocation public key. 287 type IdemixCRISignerOpts struct { 288 Epoch int 289 RevocationAlgorithm RevocationAlgorithm 290 UnrevokedHandles [][]byte 291 // H is the hash function to be used 292 H crypto.Hash 293 } 294 295 func (o *IdemixCRISignerOpts) HashFunc() crypto.Hash { 296 return o.H 297 }