Skip to content

New Idemix Integration with W3C support, preparation #731

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

Open
wants to merge 7 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
19 changes: 11 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/hyperledger-labs/fabric-token-sdk
go 1.22.6

require (
github.com/IBM/idemix v0.0.2-0.20240816143710-3dce4618d760
github.com/IBM/idemix/bccsp/types v0.0.0-20240816143710-3dce4618d760
github.com/IBM/idemix v0.0.2-0.20240829143510-a3d85aa69d56
github.com/IBM/idemix/bccsp/types v0.0.0-20240829143510-a3d85aa69d56
github.com/IBM/mathlib v0.0.3-0.20231011094432-44ee0eb539da
github.com/gin-gonic/gin v1.10.0
github.com/gobuffalo/packr/v2 v2.7.1
Expand Down Expand Up @@ -44,6 +44,13 @@ require (
modernc.org/sqlite v1.33.1
)

require (
github.com/alecthomas/kingpin/v2 v2.4.0 // indirect
github.com/alecthomas/units v0.0.0-20240626203959-61d1e3462e30 // indirect
github.com/hyperledger/aries-bbs-go v0.0.0-20240528084656-761671ea73bc // indirect
github.com/xhit/go-str2duration/v2 v2.1.0 // indirect
)

require (
cloud.google.com/go v0.115.0 // indirect
cloud.google.com/go/auth v0.6.0 // indirect
Expand All @@ -54,13 +61,10 @@ require (
dario.cat/mergo v1.0.0 // indirect
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/BurntSushi/toml v1.4.0 // indirect
github.com/IBM/idemix/bccsp/schemes/aries v0.0.0-20240612072411-114d281b442d // indirect
github.com/IBM/idemix/bccsp/schemes/weak-bb v0.0.0-20240612072411-114d281b442d // indirect
github.com/IBM/idemix/bccsp/schemes/aries v0.0.0-20240820063231-23c21a416ee1 // indirect
github.com/IBM/idemix/bccsp/schemes/weak-bb v0.0.0-20240820063231-23c21a416ee1 // indirect
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/ale-linux/aries-framework-go/component/kmscrypto v0.0.0-20231023164747-f3f972769504 // indirect
github.com/alecthomas/kingpin/v2 v2.4.0 // indirect
github.com/alecthomas/units v0.0.0-20240626203959-61d1e3462e30 // indirect
github.com/benbjohnson/clock v1.3.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.13.0 // indirect
Expand Down Expand Up @@ -255,7 +259,6 @@ require (
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
github.com/xhit/go-str2duration/v2 v2.1.0 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.53.0 // indirect
Expand Down
22 changes: 10 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -626,14 +626,14 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0=
github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/IBM/idemix v0.0.2-0.20240816143710-3dce4618d760 h1:KkXCAlR4QIFcDc+/PNVCzGbSGs9sunN852ob8tUwA64=
github.com/IBM/idemix v0.0.2-0.20240816143710-3dce4618d760/go.mod h1:VJKQspYKuHLuG8ukNHfFsFgD+NaJHlNO58ZWShlnPi4=
github.com/IBM/idemix/bccsp/schemes/aries v0.0.0-20240612072411-114d281b442d h1:8w1yWLIk0VzLTHFE1O8GwCaXs5hT9M7u4KsO+IwIen0=
github.com/IBM/idemix/bccsp/schemes/aries v0.0.0-20240612072411-114d281b442d/go.mod h1:vHi4fk2Im6fO0ofevbRr/EvblygatrTb1t2XlER58ik=
github.com/IBM/idemix/bccsp/schemes/weak-bb v0.0.0-20240612072411-114d281b442d h1:jIDz71083inpGWt9IPVGb0DoqyF7tQW/YH0gBLb6sKo=
github.com/IBM/idemix/bccsp/schemes/weak-bb v0.0.0-20240612072411-114d281b442d/go.mod h1:FC0vVgNI6bv8GH0VTwjup+arwJ8Tau1iEhroWZ1oPwU=
github.com/IBM/idemix/bccsp/types v0.0.0-20240816143710-3dce4618d760 h1:4tcdWj0MONt4JtiqNESWMuWSb5rDInIFzlUSbncHlCM=
github.com/IBM/idemix/bccsp/types v0.0.0-20240816143710-3dce4618d760/go.mod h1:4bYvi+a50aXxmHf1vwuvR+Wd8YXZ6AhT+0p5oK4xdOA=
github.com/IBM/idemix v0.0.2-0.20240829143510-a3d85aa69d56 h1:IeYqGz6OlwI3Q2ZcqW9Xs7qBOiiUfMWOzFRdHcNcL50=
github.com/IBM/idemix v0.0.2-0.20240829143510-a3d85aa69d56/go.mod h1:2q9dra60To5q3IC36LaiLhMGRxNRi2DC69imYf5Gse0=
github.com/IBM/idemix/bccsp/schemes/aries v0.0.0-20240820063231-23c21a416ee1 h1:ndFBLK1XEDGQA+sXVfZ1CDKWIwWvvI78NpVoy/+91qA=
github.com/IBM/idemix/bccsp/schemes/aries v0.0.0-20240820063231-23c21a416ee1/go.mod h1:QW+GptKF4HtnlVK/T6KAprnbtTDbv4ZnWJ2wm9gWUus=
github.com/IBM/idemix/bccsp/schemes/weak-bb v0.0.0-20240820063231-23c21a416ee1 h1:/LQ8oNXkaSzk+0on7Blyd9vQWi802bIwXnNmvR3srmU=
github.com/IBM/idemix/bccsp/schemes/weak-bb v0.0.0-20240820063231-23c21a416ee1/go.mod h1:OlxSkCgdOahDJzm8uyw45a9R7rehCC+0YGyh3gf0b40=
github.com/IBM/idemix/bccsp/types v0.0.0-20240829143510-a3d85aa69d56 h1:vUwF8qQzzsR/tgQVUUHce14LzXMkHY4kD3UdwkVvCAw=
github.com/IBM/idemix/bccsp/types v0.0.0-20240829143510-a3d85aa69d56/go.mod h1:4bYvi+a50aXxmHf1vwuvR+Wd8YXZ6AhT+0p5oK4xdOA=
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/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c/go.mod h1:X0CRv0ky0k6m906ixxpzmDRLvX58TFUKS2eePweuyxk=
Expand All @@ -654,8 +654,6 @@ github.com/ajstarks/deck v0.0.0-20200831202436-30c9fc6549a9/go.mod h1:JynElWSGnm
github.com/ajstarks/deck/generate v0.0.0-20210309230005-c3f852c02e19/go.mod h1:T13YZdzov6OU0A1+RfKZiZN9ca6VeKdBdyDV+BY97Tk=
github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw=
github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b/go.mod h1:1KcenG0jGWcpt8ov532z81sp/kMMUG485J2InIOyADM=
github.com/ale-linux/aries-framework-go/component/kmscrypto v0.0.0-20231023164747-f3f972769504 h1:sQyFeDcHVHWJ3IeE437NSJjv0+J/6MvGQOJew4X+Cuw=
github.com/ale-linux/aries-framework-go/component/kmscrypto v0.0.0-20231023164747-f3f972769504/go.mod h1:z5xq4Ji1RQojJLZzKeZH5+LKCVZxgQRZpQ4xAJWi8r0=
github.com/alecthomas/kingpin/v2 v2.4.0 h1:f48lwail6p8zpO1bC4TxtqACaGqHYA22qkHjHpqDjYY=
github.com/alecthomas/kingpin/v2 v2.4.0/go.mod h1:0gyi0zQnjuFk8xrkNKamJoyUo382HRL7ATRpFZCw6tE=
github.com/alecthomas/units v0.0.0-20240626203959-61d1e3462e30 h1:t3eaIm0rUkzbrIewtiFmMK5RXHej2XnoXNhxVsAYUfg=
Expand Down Expand Up @@ -1070,14 +1068,14 @@ github.com/hidal-go/hidalgo v0.0.0-20201109092204-05749a6d73df/go.mod h1:bPkrxDl
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc=
github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8=
github.com/hyperledger-labs/fabric-smart-client v0.3.1-0.20241111074600-334cc6d09cd6 h1:muVqNcNGwDkPs6L5d/KZOSy5Y/YIwWRHCi4Ox3AbSC4=
github.com/hyperledger-labs/fabric-smart-client v0.3.1-0.20241111074600-334cc6d09cd6/go.mod h1:vZLAiVznnEdHyx1OV5nIqf34apnfdhonwJL+qEYniIQ=
github.com/hyperledger-labs/fabric-smart-client v0.3.1-0.20241114072958-8bdbea854812 h1:1GGnfSHFRKfnCZtho6Ia8ZneaGsI5abKDqXsdL8hVSo=
github.com/hyperledger-labs/fabric-smart-client v0.3.1-0.20241114072958-8bdbea854812/go.mod h1:vZLAiVznnEdHyx1OV5nIqf34apnfdhonwJL+qEYniIQ=
github.com/hyperledger-labs/orion-sdk-go v0.2.10 h1:lFgWgxyvngIhWnIqymYGBmtmq9D6uC5d0uLG9cbyh5s=
github.com/hyperledger-labs/orion-sdk-go v0.2.10/go.mod h1:iN2xZB964AqwVJwL+EnwPOs8z1EkMEbbIg/qYeC7gDY=
github.com/hyperledger-labs/orion-server v0.2.10 h1:G4zbQEL5Egk0Oj+TwHCZWdTOLDBHOjaAEvYOT4G7ozw=
github.com/hyperledger-labs/orion-server v0.2.10/go.mod h1:PfuEZFOxbR1o1TjdqL7gQXWD3B0WFET58u9p40rGN+Q=
github.com/hyperledger/aries-bbs-go v0.0.0-20240528084656-761671ea73bc h1:3Ykk6MtyfnlzMOQry9zkxsoLWpCWZwDPqehO/BJwArM=
github.com/hyperledger/aries-bbs-go v0.0.0-20240528084656-761671ea73bc/go.mod h1:Kofn6A6WWea1ZM8Rys5aBW9dszwJ7Ywa0kyyYL0TPYw=
github.com/hyperledger/fabric v1.4.0-rc1.0.20230405174026-695dd57e01c2 h1:w5BGxCYEsc9vjdDEdZGrZ5redvs263RYsdT2tqF7cNk=
github.com/hyperledger/fabric v1.4.0-rc1.0.20230405174026-695dd57e01c2/go.mod h1:LSwfuRgX/5C2uHkdT3hJtBFu/ALxuL7dFj1pmBby2R4=
github.com/hyperledger/fabric-amcl v0.0.0-20230602173724-9e02669dceb2 h1:B1Nt8hKb//KvgGRprk0h1t4lCnwhE9/ryb1WqfZbV+M=
Expand Down
16 changes: 8 additions & 8 deletions integration/ports.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,26 @@ var (
CommType: fsc.WebSocket,
ReplicationFactor: token.None,
}
LibP2PNoReplication = &InfrastructureType{
Label: ginkgo.Label("libp2p"),
CommType: fsc.LibP2P,
ReplicationFactor: token.None,
}
WebSocketWithReplication = &InfrastructureType{
Label: ginkgo.Label("replicas"),
CommType: fsc.WebSocket,
ReplicationFactor: 3,
}
LibP2PNoReplication = &InfrastructureType{
Label: ginkgo.Label("libp2p"),
CommType: fsc.LibP2P,
ReplicationFactor: token.None,
}

WebSocketNoReplicationOnly = []*InfrastructureType{
WebSocketNoReplication,
}
LibP2PNoReplicationOnly = []*InfrastructureType{
LibP2PNoReplication,
}
WebSocketWithReplicationOnly = []*InfrastructureType{
WebSocketWithReplication,
}
LibP2PNoReplicationOnly = []*InfrastructureType{
LibP2PNoReplication,
}

AllTestTypes = []*InfrastructureType{
WebSocketNoReplication,
Expand Down
5 changes: 3 additions & 2 deletions token/core/zkatdlog/crypto/audit/auditor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/hyperledger-labs/fabric-token-sdk/token/services/identity/msp"
"github.com/hyperledger-labs/fabric-token-sdk/token/services/identity/msp/idemix"
msp3 "github.com/hyperledger-labs/fabric-token-sdk/token/services/identity/msp/idemix/msp"
"github.com/hyperledger-labs/fabric-token-sdk/token/services/identity/msp/idemix/schema"
"github.com/hyperledger-labs/fabric-token-sdk/token/services/identity/sig"
"github.com/hyperledger-labs/fabric-token-sdk/token/services/logging"
msp2 "github.com/hyperledger/fabric/msp"
Expand All @@ -52,7 +53,7 @@ var _ = Describe("Auditor", func() {
Expect(err).NotTo(HaveOccurred())
pp, err = crypto.Setup(32, ipk, math.FP256BN_AMCL)
Expect(err).NotTo(HaveOccurred())
des, err := idemix.NewDeserializer(pp.IdemixIssuerPK, math.FP256BN_AMCL)
des, err := idemix.NewEidNymRhNymDeserializer(&schema.DefaultManager{}, "", pp.IdemixIssuerPK, math.FP256BN_AMCL)
Expect(err).NotTo(HaveOccurred())
auditor = audit.NewAuditor(logging.MustGetLogger("auditor"), &noop.Tracer{}, des, pp.PedersenGenerators, nil, fakeSigningIdentity, math.Curves[pp.Curve])
fakeSigningIdentity.SignReturns([]byte("auditor-signature"), nil)
Expand Down Expand Up @@ -255,7 +256,7 @@ func getIdemixInfo(dir string) (driver.Identity, *msp3.AuditInfo) {
Expect(err).NotTo(HaveOccurred())
cryptoProvider, err := msp3.NewBCCSP(keyStore, math.FP256BN_AMCL, false)
Expect(err).NotTo(HaveOccurred())
p, err := idemix.NewKeyManager(config, sigService, types.EidNymRhNym, cryptoProvider)
p, err := idemix.NewKeyManager(config, sigService, types.EidNymRhNym, cryptoProvider, &schema.DefaultManager{}, "")
Expect(err).NotTo(HaveOccurred())
Expect(p).NotTo(BeNil())

Expand Down
5 changes: 3 additions & 2 deletions token/core/zkatdlog/crypto/validator/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
"github.com/hyperledger-labs/fabric-token-sdk/token/services/identity/msp"
"github.com/hyperledger-labs/fabric-token-sdk/token/services/identity/msp/idemix"
msp3 "github.com/hyperledger-labs/fabric-token-sdk/token/services/identity/msp/idemix/msp"
"github.com/hyperledger-labs/fabric-token-sdk/token/services/identity/msp/idemix/schema"
"github.com/hyperledger-labs/fabric-token-sdk/token/services/identity/sig"
"github.com/hyperledger-labs/fabric-token-sdk/token/services/logging"
msp2 "github.com/hyperledger/fabric/msp"
Expand Down Expand Up @@ -75,7 +76,7 @@ var _ = Describe("validator", func() {
c := math.Curves[pp.Curve]

asigner, _ := prepareECDSASigner()
des, err := idemix.NewDeserializer(pp.IdemixIssuerPK, math.FP256BN_AMCL)
des, err := idemix.NewEidNymRhNymDeserializer(&schema.DefaultManager{}, "", pp.IdemixIssuerPK, math.FP256BN_AMCL)
Expect(err).NotTo(HaveOccurred())
auditor = audit.NewAuditor(logging.MustGetLogger("auditor"), &noop.Tracer{}, des, pp.PedersenGenerators, pp.IdemixIssuerPK, asigner, c)
araw, err := asigner.Serialize()
Expand Down Expand Up @@ -387,7 +388,7 @@ func getIdemixInfo(dir string) (driver.Identity, *msp3.AuditInfo, driver.Signing
Expect(err).NotTo(HaveOccurred())
cryptoProvider, err := msp3.NewBCCSP(keyStore, math.FP256BN_AMCL, false)
Expect(err).NotTo(HaveOccurred())
p, err := idemix.NewKeyManager(config, sigService, types.EidNymRhNym, cryptoProvider)
p, err := idemix.NewKeyManager(config, sigService, types.EidNymRhNym, cryptoProvider, &schema.DefaultManager{}, "")
Expect(err).NotTo(HaveOccurred())
Expect(p).NotTo(BeNil())

Expand Down
8 changes: 7 additions & 1 deletion token/core/zkatdlog/nogh/driver/deserializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/hyperledger-labs/fabric-token-sdk/token/services/identity/interop/htlc"
"github.com/hyperledger-labs/fabric-token-sdk/token/services/identity/msp"
"github.com/hyperledger-labs/fabric-token-sdk/token/services/identity/msp/idemix"
"github.com/hyperledger-labs/fabric-token-sdk/token/services/identity/msp/idemix/schema"
"github.com/hyperledger-labs/fabric-token-sdk/token/services/identity/msp/x509"
htlc2 "github.com/hyperledger-labs/fabric-token-sdk/token/services/interop/htlc"
"github.com/pkg/errors"
Expand All @@ -29,7 +30,12 @@ func NewDeserializer(pp *crypto.PublicParams) (*Deserializer, error) {
if pp == nil {
return nil, errors.New("failed to get deserializer: nil public parameters")
}
idemixDes, err := idemix.NewDeserializer(pp.IdemixIssuerPK, pp.IdemixCurveID)
idemixDes, err := idemix.NewEidNymRhNymDeserializer(
&schema.DefaultManager{},
"",
pp.IdemixIssuerPK,
pp.IdemixCurveID,
)
if err != nil {
return nil, errors.Wrapf(err, "failed getting idemix deserializer for passed public params [%d]", pp.IdemixCurveID)
}
Expand Down
132 changes: 53 additions & 79 deletions token/services/identity/msp/idemix/deserializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ package idemix
import (
"fmt"

msp "github.com/IBM/idemix"
csp "github.com/IBM/idemix/bccsp/types"
math "github.com/IBM/mathlib"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/hash"
Expand All @@ -23,47 +22,49 @@ type Deserializer struct {
*msp2.Deserializer
}

// NewDeserializer returns a new deserializer for the idemix ExpectEidNymRhNym verification strategy
func NewDeserializer(ipk []byte, curveID math.CurveID) (*Deserializer, error) {
logger.Debugf("new deserialized for dlog idemix")
// NewEidNymRhNymDeserializer returns a new deserializer that expects EID and RH Nyms identities.
// The returned deserializer checks the validly of the deserialized identities.
func NewEidNymRhNymDeserializer(
sm SchemaManager,
schema string,
ipk []byte,
curveID math.CurveID,
) (*Deserializer, error) {
cryptoProvider, err := msp2.NewBCCSPWithDummyKeyStore(curveID, curveID == math.BLS12_381_BBS)
if err != nil {
return nil, errors.WithMessagef(err, "failed to instantiate crypto provider for curve [%d]", curveID)
}
return NewDeserializerWithProvider(ipk, csp.ExpectEidNymRhNym, nil, cryptoProvider)
return NewDeserializer(sm, schema, ipk, csp.ExpectEidNymRhNym, nil, cryptoProvider)
}

// NewDeserializerWithProvider returns a new serialized for the passed arguments
func NewDeserializerWithProvider(
// NewDeserializer returns a new deserializer for the passed arguments.
// The returned deserializer checks the validly of the deserialized identities.
func NewDeserializer(
sm SchemaManager,
schema string,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imho the deserializer shouldn't know anything about the schema at construction time. Info on the schema type should come later through the normal APIs from the protobuf data. This is why in the initial implementation I had cached the value of the public key and only decided to parse it later as soon as the schema type was known through the proper channels. See here where I cached it and here where I deferred the parsing of the IPK.

ipk []byte,
verType csp.VerificationType,
nymEID []byte,
cryptoProvider csp.BCCSP,
) (*Deserializer, error) {
return NewDeserializerWithBCCSP(ipk, verType, nymEID, cryptoProvider)
}

func NewDeserializerWithBCCSP(ipk []byte, verType csp.VerificationType, nymEID []byte, cryptoProvider csp.BCCSP) (*Deserializer, error) {
logger.Debugf("Setting up Idemix-based MSP instance")

// Import Issuer Public Key
if len(ipk) == 0 {
return nil, errors.Errorf("no issuer public key provided")
}
var issuerPublicKey csp.Key
var err error
if len(ipk) != 0 {
issuerPublicKey, err = cryptoProvider.KeyImport(
ipk,
&csp.IdemixIssuerPublicKeyImportOpts{
Temporary: true,
AttributeNames: []string{
msp.AttributeNameOU,
msp.AttributeNameRole,
msp.AttributeNameEnrollmentId,
msp.AttributeNameRevocationHandle,
},
})
if err != nil {
return nil, err
}
// get the opts from the schema manager
opts, err := sm.PublicKeyImportOpts(schema)
if err != nil {
return nil, errors.Wrapf(err, "could not obtain PublicKeyImportOpts for schema '%s'", schema)
}
issuerPublicKey, err = cryptoProvider.KeyImport(
ipk,
opts,
)
if err != nil {
return nil, err
}

return &Deserializer{
Expand All @@ -73,79 +74,52 @@ func NewDeserializerWithBCCSP(ipk []byte, verType csp.VerificationType, nymEID [
IssuerPublicKey: issuerPublicKey,
VerType: verType,
NymEID: nymEID,
SchemaManager: sm,
Schema: schema,
},
}, nil
}

func (i *Deserializer) DeserializeVerifier(raw driver.Identity) (driver.Verifier, error) {
identity, err := i.Deserialize(raw, true)
if err != nil {
return nil, err
}

return &msp2.NymSignatureVerifier{
CSP: i.Deserializer.Csp,
IPK: i.Deserializer.IssuerPublicKey,
NymPK: identity.NymPublicKey,
}, nil
}

func (i *Deserializer) DeserializeVerifierAgainstNymEID(raw []byte, nymEID []byte) (driver.Verifier, error) {
identity, err := i.Deserializer.DeserializeAgainstNymEID(raw, true, nymEID)
func (d *Deserializer) DeserializeVerifier(raw driver.Identity) (driver.Verifier, error) {
identity, err := d.Deserialize(raw)
if err != nil {
return nil, err
}

return &msp2.NymSignatureVerifier{
CSP: i.Deserializer.Csp,
IPK: i.Deserializer.IssuerPublicKey,
NymPK: identity.NymPublicKey,
CSP: d.Deserializer.Csp,
IPK: d.Deserializer.IssuerPublicKey,
NymPK: identity.NymPublicKey,
SchemaManager: d.SchemaManager,
Schema: d.Schema,
}, nil
}

func (i *Deserializer) DeserializeSigner(raw []byte) (driver.Signer, error) {
return nil, errors.New("not supported")
}

func (i *Deserializer) DeserializeAuditInfo(raw []byte) (driver2.AuditInfo, error) {
return i.Deserializer.DeserializeAuditInfo(raw)
}

func (i *Deserializer) GetOwnerMatcher(raw []byte) (driver.Matcher, error) {
return i.Deserializer.DeserializeAuditInfo(raw)
func (d *Deserializer) DeserializeAuditInfo(raw []byte) (driver2.AuditInfo, error) {
return d.Deserializer.DeserializeAuditInfo(raw)
}

func (i *Deserializer) GetOwnerAuditInfo(raw []byte, p driver.AuditInfoProvider) ([][]byte, error) {
auditInfo, err := p.GetAuditInfo(raw)
if err != nil {
return nil, errors.Wrapf(err, "failed getting audit info for recipient identity [%s]", driver.Identity(raw).String())
}
return [][]byte{auditInfo}, nil
func (d *Deserializer) GetOwnerMatcher(raw []byte) (driver.Matcher, error) {
return d.Deserializer.DeserializeAuditInfo(raw)
}

func (i *Deserializer) Info(raw []byte, auditInfo []byte) (string, error) {
r, err := i.Deserialize(raw, false)
func (d *Deserializer) DeserializeVerifierAgainstNymEID(raw []byte, nymEID []byte) (driver.Verifier, error) {
identity, err := d.Deserializer.DeserializeAgainstNymEID(raw, nymEID)
if err != nil {
return "", err
}

eid := ""
if len(auditInfo) != 0 {
ai, err := msp2.DeserializeAuditInfo(auditInfo)
if err != nil {
return "", err
}
if err := ai.Match(raw); err != nil {
return "", err
}
eid = ai.EnrollmentID()
return nil, err
}

return fmt.Sprintf("MSP.Idemix: [%s][%s][%s][%s][%s]", eid, driver.Identity(raw).UniqueID(), r.SerializedIdentity.Mspid, r.OU.OrganizationalUnitIdentifier, r.Role.Role.String()), nil
return &msp2.NymSignatureVerifier{
CSP: d.Deserializer.Csp,
IPK: d.Deserializer.IssuerPublicKey,
NymPK: identity.NymPublicKey,
SchemaManager: d.SchemaManager,
Schema: d.Schema,
}, nil
}

func (i *Deserializer) String() string {
return fmt.Sprintf("Idemix with IPK [%s]", hash.Hashable(i.Ipk).String())
func (d *Deserializer) String() string {
return fmt.Sprintf("Idemix with IPK [%s]", hash.Hashable(d.Ipk).String())
}

type AuditInfoDeserializer struct{}
Expand Down
Loading
Loading