Skip to content

Commit

Permalink
[FAB-10485] Revendor Idemix Library
Browse files Browse the repository at this point in the history
The Idemix library in fabric has been updated. The Idemix library
in Fabric CA vendored again to keep the versions in sync.

Change-Id: I8cb9216c5a34d5da6a166febe36da3582a512e04
Signed-off-by: Saad Karim <[email protected]>
  • Loading branch information
Saad Karim committed Jul 9, 2018
1 parent 9e11a65 commit 6b86289
Show file tree
Hide file tree
Showing 22 changed files with 381 additions and 592 deletions.
4 changes: 2 additions & 2 deletions lib/server/idemix/enroll.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (h *EnrollRequestHandler) HandleRequest() (*EnrollmentResponse, error) {
}

// Check the if credential request is valid
err = req.CredRequest.Check(ik.GetIPk())
err = req.CredRequest.Check(ik.GetIpk())
if err != nil {
log.Errorf("Invalid Idemix credential request: %s", err.Error())
return nil, errors.WithMessage(err, "Invalid Idemix credential request")
Expand All @@ -99,7 +99,7 @@ func (h *EnrollRequestHandler) HandleRequest() (*EnrollmentResponse, error) {
}

// Get attributes for the identity
attrMap, attrs, err := h.GetAttributeValues(caller, ik.GetIPk(), rh)
attrMap, attrs, err := h.GetAttributeValues(caller, ik.GetIpk(), rh)
if err != nil {
return nil, err
}
Expand Down
8 changes: 4 additions & 4 deletions lib/server/idemix/enroll_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ func TestHandleIdemixEnrollNewCredError(t *testing.T) {
if err != nil {
t.Fatalf("Failed to create test credential request")
}
_, attrs, err := handler.GetAttributeValues(caller, ik.IPk, rh)
_, attrs, err := handler.GetAttributeValues(caller, ik.Ipk, rh)
if err != nil {
t.Fatalf("Failed to get attributes")
}
Expand Down Expand Up @@ -354,7 +354,7 @@ func TestHandleIdemixEnrollInsertCredError(t *testing.T) {
if err != nil {
t.Fatalf("Failed to create test credential request")
}
_, attrs, err := handler.GetAttributeValues(caller, ik.IPk, rh)
_, attrs, err := handler.GetAttributeValues(caller, ik.Ipk, rh)
if err != nil {
t.Fatalf("Failed to get attributes")
}
Expand Down Expand Up @@ -434,7 +434,7 @@ func TestHandleIdemixEnrollForCredentialSuccess(t *testing.T) {
if err != nil {
t.Fatalf("Failed to create test credential request")
}
_, attrs, err := handler.GetAttributeValues(caller, ik.IPk, rh)
_, attrs, err := handler.GetAttributeValues(caller, ik.Ipk, rh)
if err != nil {
t.Fatalf("Failed to get attributes")
}
Expand Down Expand Up @@ -543,5 +543,5 @@ func newIdemixCredentialRequest(t *testing.T, nonce *fp256bn.BIG) (*idemix.CredR
return nil, nil, err
}
sk := idemix.RandModOrder(rng)
return idemix.NewCredRequest(sk, nonce, ik.IPk, rng), sk, nil
return idemix.NewCredRequest(sk, nonce, ik.Ipk, rng), sk, nil
}
4 changes: 2 additions & 2 deletions lib/server/idemix/issuer.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (i *issuer) IssuerPublicKey() ([]byte, error) {
if err != nil {
return nil, err
}
ipkBytes, err := proto.Marshal(ik.IPk)
ipkBytes, err := proto.Marshal(ik.Ipk)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -235,7 +235,7 @@ func (i *issuer) VerifyToken(authHdr string, body []byte) (string, error) {
if err != nil {
return "", errors.WithMessage(err, "Failed to unmarshal signature bytes specified in the token")
}
err = sig.Ver(disclosure, issuerKey.IPk, digest, attrs, 3, ra.PublicKey(), epoch)
err = sig.Ver(disclosure, issuerKey.Ipk, digest, attrs, 3, ra.PublicKey(), epoch)
if err != nil {
return "", errors.WithMessage(err, "Failed to verify the token")
}
Expand Down
2 changes: 1 addition & 1 deletion lib/server/idemix/issuer_whitebox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func TestIssuerPublicKey(t *testing.T) {
t.Fatalf("Failed to load issuer credential: %s", err.Error())
}
ik, _ := issuerCred.GetIssuerKey()
ik.IPk = nil
ik.Ipk = nil
_, err = issuer.IssuerPublicKey()
assert.Error(t, err, "issuer.IssuerCredential() should return an error as it should fail to marshal issuer public key")
}
Expand Down
8 changes: 4 additions & 4 deletions lib/server/idemix/issuercredential.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ func (ic *caIdemixCredential) Load() error {
return errors.New("Issuer secret key file is empty")
}
ic.issuerKey = &idemix.IssuerKey{
IPk: pubKey,
ISk: privKey,
Ipk: pubKey,
Isk: privKey,
}
//TODO: check if issuer key is valid by checking public and secret key pair
return nil
Expand All @@ -101,7 +101,7 @@ func (ic *caIdemixCredential) Store() error {
return err
}

ipkBytes, err := proto.Marshal(ik.IPk)
ipkBytes, err := proto.Marshal(ik.Ipk)
if err != nil {
return errors.New("Failed to marshal Issuer public key")
}
Expand All @@ -112,7 +112,7 @@ func (ic *caIdemixCredential) Store() error {
return errors.New("Failed to store Issuer public key")
}

err = util.WriteFile(ic.secretKeyFile, ik.ISk, 0644)
err = util.WriteFile(ic.secretKeyFile, ik.Isk, 0644)
if err != nil {
log.Errorf("Failed to store Issuer secret key: %s", err.Error())
return errors.New("Failed to store Issuer secret key")
Expand Down
4 changes: 2 additions & 2 deletions lib/server/idemix/issuercredential_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func TestStoreReadonlyPublicKeyFilePath(t *testing.T) {
t.Fatalf("Failed to create read only directory: %s", err.Error())
}
ik := NewIssuerCredential(pubkeyfile, testSecretKeyFile, idemixLib)
ik.SetIssuerKey(&idemix.IssuerKey{IPk: pubKey})
ik.SetIssuerKey(&idemix.IssuerKey{Ipk: pubKey})
err = ik.Store()
assert.Error(t, err, "Should fail if issuer public key is being stored to readonly directory")
if err != nil {
Expand Down Expand Up @@ -200,7 +200,7 @@ func TestStoreReadonlySecretKeyFilePath(t *testing.T) {
t.Fatalf("Failed to create read only directory: %s", err.Error())
}
ik := NewIssuerCredential(testPublicKeyFile, privkeyfile, idemixLib)
ik.SetIssuerKey(&idemix.IssuerKey{IPk: pubKey})
ik.SetIssuerKey(&idemix.IssuerKey{Ipk: pubKey})
err = ik.Store()
assert.Error(t, err, "Should fail if issuer secret key is being stored to read-only directory")
if err != nil {
Expand Down
3 changes: 0 additions & 3 deletions lib/server/idemix/revocationauthority.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,6 @@ func (ra *revocationAuthority) CreateCRI() (*idemix.CredentialRevocationInformat
unrevokedHandles := ra.getUnRevokedHandles(info, revokedCreds)

alg := idemix.ALG_NO_REVOCATION
if len(revokedCreds) > 0 {
alg = idemix.ALG_PLAIN_SIGNATURE
}
cri, err := ra.issuer.IdemixLib().CreateCRI(ra.key.GetKey(), unrevokedHandles, info.Epoch, alg, ra.issuer.IdemixRand())
if err != nil {
return nil, err
Expand Down
4 changes: 0 additions & 4 deletions lib/server/idemix/revocationauthority_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -703,10 +703,6 @@ func getRevocationAuthority(t *testing.T, homeDir string, db *dmocks.FabricCADB,
validHandles = append(validHandles, fp256bn.NewBIGint(i))
}
alg := idemix.ALG_NO_REVOCATION
if revokedCred > 0 {
validHandles = append(validHandles[:revokedCred], validHandles[revokedCred+1:]...)
alg = idemix.ALG_PLAIN_SIGNATURE
}
if idemixCreateCRIError {
lib.On("CreateCRI", revocationKey, validHandles, 1, alg, rnd).Return(nil, errors.New("Idemix lib create CRI error"))
} else {
Expand Down
22 changes: 11 additions & 11 deletions vendor/github.com/hyperledger/fabric/idemix/credential.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6b86289

Please sign in to comment.