Skip to content

upgradability: add multiplexing driver #1091 #1100

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

Merged
merged 5 commits into from
Jun 10, 2025
Merged
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
2 changes: 1 addition & 1 deletion cmd/tokengen/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func validateOutputEquivalent(gt *WithT, tempOutput, auditorsMSPdir, issuersMSPd
ppRaw, err := os.ReadFile(filepath.Join(tempOutput, "zkatdlog_pp.json"))
gt.Expect(err).NotTo(HaveOccurred())

pp, err := v1.NewPublicParamsFromBytes(ppRaw, v1.DLogPublicParameters)
pp, err := v1.NewPublicParamsFromBytes(ppRaw, v1.DLogIdentifier)
gt.Expect(err).NotTo(HaveOccurred())
gt.Expect(pp.Validate()).NotTo(HaveOccurred())

Expand Down
2 changes: 1 addition & 1 deletion cmd/tokengen/testdata/zkatdlog_pp.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion integration/token/fungible/fabtoken/fabtoken_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ func UpdatePublicParams(network *integration.Infrastructure, selector *token2.Re
auditorId := fungible.GetAuditorIdentity(tms, "newAuditor")
issuerId := fungible.GetIssuerIdentity(tms, "newIssuer")
publicParam := fabtokenv1.PublicParams{
Label: "fabtoken",
DriverName: "fabtoken",
DriverVersion: 1,
QuantityPrecision: uint64(64),
Auditor: auditorId,
IssuerIDs: []driver.Identity{issuerId},
Expand Down
17 changes: 9 additions & 8 deletions integration/token/fungible/support.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
common2 "github.com/hyperledger-labs/fabric-token-sdk/integration/token/common"
"github.com/hyperledger-labs/fabric-token-sdk/integration/token/fungible/views"
token2 "github.com/hyperledger-labs/fabric-token-sdk/token"
"github.com/hyperledger-labs/fabric-token-sdk/token/core"
"github.com/hyperledger-labs/fabric-token-sdk/token/core/common/encoding/pp"
fabtokenv1 "github.com/hyperledger-labs/fabric-token-sdk/token/core/fabtoken/v1/setup"
dlognoghv1 "github.com/hyperledger-labs/fabric-token-sdk/token/core/zkatdlog/nogh/v1/setup"
Expand Down Expand Up @@ -1438,11 +1439,11 @@ func PrepareUpdatedPublicParams(network *integration.Infrastructure, auditor str
}
var pp PP
switch genericPP.Identifier {
case dlognoghv1.DLogPublicParameters:
pp, err = dlognoghv1.NewPublicParamsFromBytes(ppBytes, dlognoghv1.DLogPublicParameters)
case string(core.DriverIdentifier(dlognoghv1.DLogIdentifier, dlognoghv1.ProtocolV1)):
pp, err = dlognoghv1.NewPublicParamsFromBytes(ppBytes, dlognoghv1.DLogIdentifier)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
case fabtokenv1.PublicParameters:
pp, err = fabtokenv1.NewPublicParamsFromBytes(ppBytes, fabtokenv1.PublicParameters)
case string(core.DriverIdentifier(fabtokenv1.FabTokenDriverName, fabtokenv1.ProtocolV1)):
pp, err = fabtokenv1.NewPublicParamsFromBytes(ppBytes, fabtokenv1.FabTokenDriverName)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
default:
gomega.Expect(false).To(gomega.BeTrue(), "unknown pp identifier [%s]", genericPP.Identifier)
Expand Down Expand Up @@ -1490,11 +1491,11 @@ func PreparePublicParamsWithNewIssuer(network *integration.Infrastructure, issue
}
var pp PP
switch genericPP.Identifier {
case dlognoghv1.DLogPublicParameters:
pp, err = dlognoghv1.NewPublicParamsFromBytes(ppBytes, dlognoghv1.DLogPublicParameters)
case string(core.DriverIdentifier(dlognoghv1.DLogIdentifier, dlognoghv1.ProtocolV1)):
pp, err = dlognoghv1.NewPublicParamsFromBytes(ppBytes, dlognoghv1.DLogIdentifier)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
case fabtokenv1.PublicParameters:
pp, err = fabtokenv1.NewPublicParamsFromBytes(ppBytes, fabtokenv1.PublicParameters)
case string(core.DriverIdentifier(fabtokenv1.FabTokenDriverName, fabtokenv1.ProtocolV1)):
pp, err = fabtokenv1.NewPublicParamsFromBytes(ppBytes, fabtokenv1.FabTokenDriverName)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
default:
gomega.Expect(false).To(gomega.BeTrue(), "unknown pp identitfier [%s]", genericPP.Identifier)
Expand Down
4 changes: 2 additions & 2 deletions integration/token/fungible/tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -1386,15 +1386,15 @@ func TestIdemixIssuerPublicKeyRotation(network *integration.Infrastructure, audi
CheckBalanceAndHolding(network, bob, "", "EUR", 110, auditor)

// rotate issuer public key, bob should be able to spend his token
pp, err := dlognoghv1.NewPublicParamsFromBytes(ppBytes, dlognoghv1.DLogPublicParameters)
pp, err := dlognoghv1.NewPublicParamsFromBytes(ppBytes, dlognoghv1.DLogIdentifier)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
gomega.Expect(pp.Validate()).NotTo(gomega.HaveOccurred())

tmsBis := GetTMSByAlias(network, "dlog-32bits-bis")
ppBytesBis, err := os.ReadFile(tokenPlatform.PublicParametersFile(tmsBis))
gomega.Expect(err).NotTo(gomega.HaveOccurred())
gomega.Expect(ppBytesBis).NotTo(gomega.BeNil())
ppBis, err := dlognoghv1.NewPublicParamsFromBytes(ppBytesBis, dlognoghv1.DLogPublicParameters)
ppBis, err := dlognoghv1.NewPublicParamsFromBytes(ppBytesBis, dlognoghv1.DLogIdentifier)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
gomega.Expect(ppBis.Validate()).NotTo(gomega.HaveOccurred())

Expand Down
12 changes: 6 additions & 6 deletions token/core/common/ppm.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,28 @@ import (
)

type PublicParamsDeserializer[T driver.PublicParameters] interface {
DeserializePublicParams(raw []byte, label string) (T, error)
DeserializePublicParams(raw []byte, name driver.TokenDriverName) (T, error)
}

type PublicParamsManager[T driver.PublicParameters] struct {
publicParameters T
// label of the public params
PPLabel string
ppHash driver.PPHash
DriverName driver.TokenDriverName
ppHash driver.PPHash
}

func NewPublicParamsManager[T driver.PublicParameters](
PublicParamsDeserializer PublicParamsDeserializer[T],
PPLabel string,
driverName driver.TokenDriverName,
ppRaw []byte,
) (*PublicParamsManager[T], error) {
ppm := &PublicParamsManager[T]{
PPLabel: PPLabel,
DriverName: driverName,
}
if len(ppRaw) == 0 {
return nil, errors.Errorf("empty public parameters")
}
pp, err := PublicParamsDeserializer.DeserializePublicParams(ppRaw, PPLabel)
pp, err := PublicParamsDeserializer.DeserializePublicParams(ppRaw, driverName)
if err != nil {
return nil, err
}
Expand Down
133 changes: 44 additions & 89 deletions token/core/fabtoken/protos-go/pp/ftpp.pb.go

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

4 changes: 2 additions & 2 deletions token/core/fabtoken/protos/ftpp.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ message Identity {

// PublicParameters describes typed public parameters
message PublicParameters {
string identifier = 1; // the identifier of the public parameters
uint64 version = 2; // the version of these public params
string token_driver_name = 1; // the name of the token driver
uint64 token_driver_version = 2; // the version of token driver
Identity auditor = 7; // is the public key of the auditor.
repeated Identity issuers = 8; // is a list of public keys of the entities that can issue tokens.
uint64 max_token = 9; // is the maximum quantity a token can hold
Expand Down
4 changes: 2 additions & 2 deletions token/core/fabtoken/v1/driver/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ import (
type base struct{}

func (d *base) PublicParametersFromBytes(params []byte) (driver.PublicParameters, error) {
pp, err := core2.NewPublicParamsFromBytes(params, core2.PublicParameters)
pp, err := core2.NewPublicParamsFromBytes(params, core2.FabTokenDriverName)
if err != nil {
return nil, errors.Wrap(err, "failed to unmarshal public parameters")
}
return pp, nil
}

func (d *base) DefaultValidator(pp driver.PublicParameters) (driver.Validator, error) {
logger := logging.DriverLoggerFromPP("token-sdk.driver.fabtoken", pp.Identifier())
logger := logging.DriverLoggerFromPP("token-sdk.driver.fabtoken", string(core.DriverIdentifierFromPP(pp)))
deserializer := NewDeserializer()
return validator.NewValidator(logger, pp.(*core2.PublicParams), deserializer), nil
}
Expand Down
5 changes: 3 additions & 2 deletions token/core/fabtoken/v1/driver/deserializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package driver
import (
"github.com/hyperledger-labs/fabric-token-sdk/token/core/common"
v1 "github.com/hyperledger-labs/fabric-token-sdk/token/core/fabtoken/v1/setup"
"github.com/hyperledger-labs/fabric-token-sdk/token/driver"
"github.com/hyperledger-labs/fabric-token-sdk/token/services/identity/deserializer"
"github.com/hyperledger-labs/fabric-token-sdk/token/services/identity/interop/htlc"
"github.com/hyperledger-labs/fabric-token-sdk/token/services/identity/multisig"
Expand All @@ -33,8 +34,8 @@ func NewDeserializer() *Deserializer {

type PublicParamsDeserializer struct{}

func (p *PublicParamsDeserializer) DeserializePublicParams(raw []byte, label string) (*v1.PublicParams, error) {
return v1.NewPublicParamsFromBytes(raw, label)
func (p *PublicParamsDeserializer) DeserializePublicParams(raw []byte, name driver.TokenDriverName) (*v1.PublicParams, error) {
return v1.NewPublicParamsFromBytes(raw, name)
}

// EIDRHDeserializer returns enrollment ID and revocation handle behind the owners of token
Expand Down
Loading
Loading