Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Use bccsp instead of directly idemix #374

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions api/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package api

import (
idemix2 "github.com/IBM/idemix/bccsp/schemes/dlog/crypto"
"github.com/cloudflare/cfssl/signer"
)

Expand Down Expand Up @@ -46,8 +45,9 @@ type EnrollmentRequestNet struct {

// IdemixEnrollmentRequestNet is a request to enroll an identity and get idemix credential
type IdemixEnrollmentRequestNet struct {
*idemix2.CredRequest `json:"request"`
CAName string `json:"caname"`
CredRequest []byte `json:"request"`
IssuerNonce []byte `json:"nonce"`
CAName string `json:"caname"`
}

// ReenrollmentRequestNet is a request to reenroll an identity.
Expand Down
14 changes: 9 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
module github.com/hyperledger/fabric-ca

go 1.20
go 1.19

require (
github.com/IBM/idemix v0.0.2-0.20230510082947-a0c3ee5ebe35
github.com/IBM/mathlib v0.0.3-0.20231011094432-44ee0eb539da
github.com/IBM/idemix v0.0.2-0.20230914074304-f8eb4a0f6606
github.com/IBM/idemix/bccsp/types v0.0.0-20230914074304-f8eb4a0f6606
github.com/IBM/mathlib v0.0.3-0.20230831091907-c532c4d3b65c
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible
github.com/cloudflare/cfssl v1.4.1
github.com/felixge/httpsnoop v1.0.1
Expand All @@ -15,7 +16,6 @@ require (
github.com/gorilla/mux v1.8.0
github.com/grantae/certinfo v0.0.0-20170412194111-59d56a35515b
github.com/hyperledger/fabric v0.0.0-20240123171006-370ebe56cea8
github.com/hyperledger/fabric-amcl v0.0.0-20230602173724-9e02669dceb2
github.com/hyperledger/fabric-lib-go v1.0.0
github.com/jinzhu/copier v0.3.5
github.com/jmoiron/sqlx v1.2.0
Expand All @@ -32,12 +32,15 @@ require (
github.com/spf13/cobra v1.5.0
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.7.0
github.com/stretchr/testify v1.8.2
github.com/stretchr/testify v1.8.4
golang.org/x/crypto v0.17.0
gopkg.in/ldap.v2 v2.5.1
)

require (
github.com/IBM/idemix/bccsp/schemes/aries v0.0.0-20230818093228-308e96f529c9 // indirect
github.com/IBM/idemix/bccsp/schemes/weak-bb v0.0.0-20230818093228-308e96f529c9 // indirect
github.com/ale-linux/aries-framework-go/component/kmscrypto v0.0.0-20230817163708-4b3de6d91874 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.7.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
Expand All @@ -48,6 +51,7 @@ require (
github.com/go-logfmt/logfmt v0.5.1 // indirect
github.com/google/certificate-transparency-go v1.0.21 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hyperledger/fabric-amcl v0.0.0-20230602173724-9e02669dceb2 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jmhodges/clock v0.0.0-20160418191101-880ee4c33548 // indirect
github.com/kilic/bls12-381 v0.1.0 // indirect
Expand Down
24 changes: 17 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,16 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/GeertJohan/go.incremental v1.0.0/go.mod h1:6fAjUhbVuX1KcMD3c8TEgVUqmo4seqhv0i0kdATSkM0=
github.com/GeertJohan/go.rice v1.0.0/go.mod h1:eH6gbSOAUv07dQuZVnBmoDP8mgsM1rtixis4Tib9if0=
github.com/IBM/idemix v0.0.2-0.20230510082947-a0c3ee5ebe35 h1:2ucH1TS+pe18L6R2jww9UX5I8GrVWkwjcDbIChDUyfc=
github.com/IBM/idemix v0.0.2-0.20230510082947-a0c3ee5ebe35/go.mod h1:LKHePSqL9g67JezDTU8Y/HCRyzBP3zYbY7q9Hllx6y0=
github.com/IBM/mathlib v0.0.3-0.20231011094432-44ee0eb539da h1:qqGozq4tF6EOVnWoTgBoJGudRKKZXSAYnEtDggzTnsw=
github.com/IBM/mathlib v0.0.3-0.20231011094432-44ee0eb539da/go.mod h1:Tco9QzE3fQzjMS7nPbHDeFfydAzctStf1Pa8hsh6Hjs=
github.com/IBM/idemix v0.0.2-0.20230914074304-f8eb4a0f6606 h1:2F/8jqTCOyCxwpDaaLFd+eYlCtvl03f9owb/YTD+2v0=
github.com/IBM/idemix v0.0.2-0.20230914074304-f8eb4a0f6606/go.mod h1:A9w6lDhpXujKBck1rcw6unxAzJtx+QsuT5qd1CS7BKc=
github.com/IBM/idemix/bccsp/schemes/aries v0.0.0-20230818093228-308e96f529c9 h1:Epm1kxDcOvZug9zY/McvBPyGd7zOiXvzfwZ9cF5zomY=
github.com/IBM/idemix/bccsp/schemes/aries v0.0.0-20230818093228-308e96f529c9/go.mod h1:V1hC/kU/g+eZ2GOlSj4WBTB7FuGbWI0w4U2z7a4i/ew=
github.com/IBM/idemix/bccsp/schemes/weak-bb v0.0.0-20230818093228-308e96f529c9 h1:Lc0yhsKb1+LcJd8U62cLB6WDVpm7kcQLwJXN17Da5G4=
github.com/IBM/idemix/bccsp/schemes/weak-bb v0.0.0-20230818093228-308e96f529c9/go.mod h1:n86zzYREwJdjUybye3rerxmAFfgVJtPvNOrRX30CbrU=
github.com/IBM/idemix/bccsp/types v0.0.0-20230914074304-f8eb4a0f6606 h1:Fp53nUsttyhgkFc33rOxDSElCVbxIOsovGF3EwiOUvI=
github.com/IBM/idemix/bccsp/types v0.0.0-20230914074304-f8eb4a0f6606/go.mod h1:2lO6nmsoSH3WDJdat4kIicU+WTs4qDntGZkF8XdgHm8=
github.com/IBM/mathlib v0.0.3-0.20230831091907-c532c4d3b65c h1:QVrlfdfx7MslApfSdSLiLIOFmYlLhP6wY4LyRBVed4I=
github.com/IBM/mathlib v0.0.3-0.20230831091907-c532c4d3b65c/go.mod h1:k0NBSWMYVgaZ2keDuI8DSwdIEhUNhp8XnlVmm6Xwyuk=
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible h1:1G1pk05UrOh0NlF1oeaaix1x8XzrfjIDK47TY0Zehcw=
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
Expand All @@ -50,6 +56,8 @@ github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrd
github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g=
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c=
github.com/akavel/rsrc v0.8.0/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c=
github.com/ale-linux/aries-framework-go/component/kmscrypto v0.0.0-20230817163708-4b3de6d91874 h1:O08ZCyb1f7UeyOmTeItAw7eSZOlyM0fBnrPgaYgKEiA=
github.com/ale-linux/aries-framework-go/component/kmscrypto v0.0.0-20230817163708-4b3de6d91874/go.mod h1:4sHtFlGI84SVjaSW7u1pCfC0bjijd9ZeqbKptU/Qljs=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
Expand All @@ -74,6 +82,7 @@ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kB
github.com/bits-and-blooms/bitset v1.7.0 h1:YjAGVd3XmtK9ktAbX8Zg2g2PwLIMjGREZJHlV4j7NEo=
github.com/bits-and-blooms/bitset v1.7.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA=
github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84=
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce h1:YtWJF7RHm2pYCvA5t0RPmAaLUhREsKuKd+SLhxFbFeQ=
github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
Expand Down Expand Up @@ -269,6 +278,7 @@ github.com/hyperledger/fabric-amcl v0.0.0-20230602173724-9e02669dceb2 h1:B1Nt8hK
github.com/hyperledger/fabric-amcl v0.0.0-20230602173724-9e02669dceb2/go.mod h1:X+DIyUsaTmalOpmpQfIvFZjKHQedrURQ5t4YqquX7lE=
github.com/hyperledger/fabric-lib-go v1.0.0 h1:UL1w7c9LvHZUSkIvHTDGklxFv2kTeva1QI2emOVc324=
github.com/hyperledger/fabric-lib-go v1.0.0/go.mod h1:H362nMlunurmHwkYqR5uHL2UDWbQdbfz74n8kbCFsqc=
github.com/hyperledger/fabric-protos-go v0.3.2 h1:mQmbHw3lyDV2+W5b0FitV/SjM4LLDjMTQJWW9taitDM=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
Expand Down Expand Up @@ -450,7 +460,7 @@ github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40T
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
Expand Down Expand Up @@ -500,8 +510,8 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/sykesm/zap-logfmt v0.0.4 h1:U2WzRvmIWG1wDLCFY3sz8UeEmsdHQjHFNlIdmroVFaI=
Expand Down
38 changes: 24 additions & 14 deletions lib/ca.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ import (
"sync"
"time"

i "github.com/IBM/idemix/bccsp"
"github.com/IBM/idemix/bccsp/keystore"
"github.com/IBM/idemix/bccsp/schemes/dlog/crypto/translator/amcl"
math "github.com/IBM/mathlib"
"github.com/cloudflare/cfssl/certdb"
"github.com/cloudflare/cfssl/config"
cfcsr "github.com/cloudflare/cfssl/csr"
Expand All @@ -32,7 +36,6 @@ import (
"github.com/hyperledger/fabric-ca/lib/attr"
"github.com/hyperledger/fabric-ca/lib/attrmgr"
"github.com/hyperledger/fabric-ca/lib/caerrors"
idemix2 "github.com/hyperledger/fabric-ca/lib/common/idemix"
"github.com/hyperledger/fabric-ca/lib/metadata"
"github.com/hyperledger/fabric-ca/lib/server/db"
cadb "github.com/hyperledger/fabric-ca/lib/server/db"
Expand Down Expand Up @@ -138,8 +141,14 @@ func initCA(ca *CA, homeDir string, config *CAConfig, server *Server, renew bool
if err != nil {
return err
}

CSP, err := i.New(&keystore.Dummy{}, curveID, &amcl.Gurvy{C: curveID}, true)
if err != nil {
return err
}

ca.issuer = idemix.NewIssuer(ca.Config.CA.Name, ca.HomeDir,
&ca.Config.Idemix, ca.csp, idemix.NewLib(curveID), curveID)
&ca.Config.Idemix, CSP)
err = ca.issuer.Init(renew, ca.db, ca.levels)
if err != nil {
return errors.WithMessage(err, fmt.Sprintf("Failed to initialize Idemix issuer for CA '%s'", err.Error()))
Expand Down Expand Up @@ -1296,17 +1305,18 @@ func getMigrator(driverName string, tx cadb.FabricCATx, curLevels, srvLevels *db
return migrator, nil
}

func curveIDFromConfig(idemixCurveName string) (idemix2.CurveID, error) {
if idemixCurveName == "" {
idemixCurveName = idemix2.DefaultIdemixCurve
log.Debugf("CurveID for Idemix not specified, defaulting to %s", idemixCurveName)
return idemix2.Curves.ByName(idemixCurveName), nil
}
func curveIDFromConfig(idemixCurveName string) (*math.Curve, error) {
return math.Curves[math.BLS12_381_BBS], nil

curveID := idemix2.Curves.ByName(idemixCurveName)
if curveID == idemix2.Undefined {
return 0, errors.Errorf("CurveID '%s' doesn't exist, expecting one of %s", idemixCurveName, idemix2.Curves.Names())
}
log.Debugf("Using curve %s for Idemix", idemixCurveName)
return curveID, nil
// if idemixCurveName == "" {
// log.Debugf("CurveID for Idemix not specified, defaulting to %s", idemixCurveName)
// return math.Curves[math.BLS12_381_BBS], nil
// }

// curveID := idemix2.Curves.ByName(idemixCurveName)
// if curveID == idemix2.Undefined {
// return 0, errors.Errorf("CurveID '%s' doesn't exist, expecting one of %s", idemixCurveName, idemix2.Curves.Names())
// }
// log.Debugf("Using curve %s for Idemix", idemixCurveName)
// return curveID, nil
}
Loading
Loading