-
Notifications
You must be signed in to change notification settings - Fork 9
/
cri.go
42 lines (36 loc) · 992 Bytes
/
cri.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
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package idemix
import (
proto "github.com/golang/protobuf/proto"
"github.com/VoneChain-CS/fabric-ca-gm/api"
"github.com/VoneChain-CS/fabric-ca-gm/util"
"github.com/pkg/errors"
)
// CRIRequestHandler is the handler for Idemix CRI (credential revocation information) request
type CRIRequestHandler struct {
Ctx ServerRequestCtx
Issuer MyIssuer
}
// HandleRequest handles processing for idemix/cri request
func (ch *CRIRequestHandler) HandleRequest() (*api.GetCRIResponse, error) {
_, err := ch.Ctx.TokenAuthentication()
if err != nil {
return nil, err
}
cri, err := ch.Issuer.RevocationAuthority().CreateCRI()
if err != nil {
return nil, err
}
criBytes, err := proto.Marshal(cri)
if err != nil {
return nil, errors.New("Failed to marshal Idemix credential to bytes")
}
b64CriBytes := util.B64Encode(criBytes)
res := api.GetCRIResponse{
CRI: b64CriBytes,
}
return &res, nil
}