From ad785573be2e2c087c044c85d58094587a6b1240 Mon Sep 17 00:00:00 2001 From: Alessandro Sorniotti Date: Thu, 14 Sep 2023 09:57:54 +0200 Subject: [PATCH] Add test to assert revocation PK import must succeed Signed-off-by: Alessandro Sorniotti # Conflicts: # bccsp/idemix_suite_test.go --- bccsp/idemix_suite_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/bccsp/idemix_suite_test.go b/bccsp/idemix_suite_test.go index 9dc53f1..57a2d2a 100644 --- a/bccsp/idemix_suite_test.go +++ b/bccsp/idemix_suite_test.go @@ -8,11 +8,37 @@ package idemix_test import ( "testing" + idemix "github.com/IBM/idemix/bccsp" + "github.com/IBM/idemix/bccsp/schemes/dlog/crypto/translator/amcl" + bccsp "github.com/IBM/idemix/bccsp/types" + math "github.com/IBM/mathlib" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + "github.com/stretchr/testify/assert" ) func TestPlain(t *testing.T) { RegisterFailHandler(Fail) RunSpecs(t, "Plain Suite") } + +func TestRevocationKeyExportImport(t *testing.T) { + curve := math.Curves[math.FP256BN_AMCL] + translator := &amcl.Fp256bn{C: curve} + + var err error + CSP, err := idemix.New(NewDummyKeyStore(), curve, translator, true) + assert.NoError(t, err) + + RevocationPrivateKey, err := CSP.KeyGen(&bccsp.IdemixRevocationKeyGenOpts{Temporary: true}) + assert.NoError(t, err) + + RevocationPublicKey, err := RevocationPrivateKey.PublicKey() + assert.NoError(t, err) + + RevocationPublicKeyBytes, err := RevocationPublicKey.Bytes() + assert.NoError(t, err) + + _, err = CSP.KeyImport(RevocationPublicKeyBytes, &bccsp.IdemixRevocationPublicKeyImportOpts{Temporary: true}) + assert.NoError(t, err) +}