diff --git a/Makefile b/Makefile index 8d5ee9fc44..0812f856f3 100644 --- a/Makefile +++ b/Makefile @@ -104,27 +104,27 @@ clean: docker network prune -f docker container prune -f docker volume prune -f - rm -rf ./integration/token/fungible/dlog/cmd/ + rm -rf ./integration/token/fungible/dlog/out/ rm -rf ./integration/token/fungible/dlog/testdata/ - rm -rf ./integration/token/fungible/dlogx/cmd/ - rm -rf ./integration/token/fungible/dloghsm/cmd/ + rm -rf ./integration/token/fungible/dlogx/out/ + rm -rf ./integration/token/fungible/dloghsm/out/ rm -rf ./integration/token/fungible/dloghsm/testdata/ - rm -rf ./integration/token/fungible/dlogstress/cmd/ + rm -rf ./integration/token/fungible/dlogstress/out/ rm -rf ./integration/token/fungible/dlogstress/testdata/ - rm -rf ./integration/token/fungible/fabtoken/cmd/ + rm -rf ./integration/token/fungible/fabtoken/out/ rm -rf ./integration/token/fungible/fabtoken/testdata/ - rm -rf ./integration/token/fungible/odlog/cmd/ - rm -rf ./integration/token/fungible/ofabtoken/cmd/ - rm -rf ./integration/token/fungible/mixed/cmd/ - rm -rf ./integration/token/nft/dlog/cmd/ - rm -rf ./integration/token/nft/fabtoken/cmd/ - rm -rf ./integration/token/nft/odlog/cmd/ - rm -rf ./integration/token/nft/ofabtoken/cmd/ - rm -rf ./integration/token/dvp/dlog/cmd/ - rm -rf ./integration/token/dvp/fabtoken/cmd/ - rm -rf ./integration/token/interop/fabtoken/cmd/ - rm -rf ./integration/token/interop/dlog/cmd/ - rm -rf ./integration/token/fungible/update/cmd/ + rm -rf ./integration/token/fungible/odlog/out/ + rm -rf ./integration/token/fungible/ofabtoken/out/ + rm -rf ./integration/token/fungible/mixed/out/ + rm -rf ./integration/token/nft/dlog/out/ + rm -rf ./integration/token/nft/fabtoken/out/ + rm -rf ./integration/token/nft/odlog/out/ + rm -rf ./integration/token/nft/ofabtoken/out/ + rm -rf ./integration/token/dvp/dlog/out/ + rm -rf ./integration/token/dvp/fabtoken/out/ + rm -rf ./integration/token/interop/fabtoken/out/ + rm -rf ./integration/token/interop/dlog/out/ + rm -rf ./integration/token/fungible/update/out/ rm -rf ./integration/token/fungible/update/testdata/ .PHONY: clean-fabric-peer-images diff --git a/cmd/tokengen/README.md b/cmd/tokengen/README.md index 4e1152b3aa..10bbec604e 100644 --- a/cmd/tokengen/README.md +++ b/cmd/tokengen/README.md @@ -54,7 +54,7 @@ Flags: The `tokengen gen` command has two subcommands, as follows: - fabtoken.v1: generates the public parameters for the fabtoken driver -- zkatdlog.v1: generates the public parameters for the zkatdlog.v1 driver +- zkatdlognogh.v1: generates the public parameters for the zkatdlognogh.v1 driver ## tokengen gen fabtoken.v1 @@ -74,42 +74,44 @@ Flags: The public parameters are stored in the output folder with name `fabtokenv1_pp.json`. If version is overridden, then file name will be `("fabtokenv%d_pp.json", version)`. -### tokengen gen zkatdlog.v1 +### tokengen gen zkatdlognogh.v1 ``` Usage: - tokengen gen zkatdlog.v1 [flags] + tokengen gen zkatdlognogh.v1 [flags] Flags: - -a, --auditors strings list of auditor MSP directories containing the corresponding auditor certificate - -b, --base int base is used to define the maximum quantity a token can contain as Base^Exponent (default 100) - --cc generate chaincode package - -e, --exponent int exponent is used to define the maximum quantity a token can contain as Base^Exponent (default 2) - -h, --help help for zkatdlog.v1 - -i, --idemix string idemix msp dir - -s, --issuers strings list of issuer MSP directories containing the corresponding issuer certificate - -o, --output string output folder (default ".") - -v, --version uint allows the caller of tokengen to override the version number put in the public params + -r, --aries flag to indicate that aries should be used as backend for idemix + -a, --auditors strings list of auditor MSP directories containing the corresponding auditor certificate + -b, --bits uint bits is used to define the maximum quantity a token can contain (default 64) + --cc generate chaincode package + -x, --extra stringArray extra data in key=value format, where value is the path to a file containing the data to load and store in the key + -h, --help help for zkatdlognogh.v1 + -i, --idemix string idemix msp dir + -s, --issuers strings list of issuer MSP directories containing the corresponding issuer certificate + -o, --output string output folder (default ".") + -v, --version uint allows the caller of tokengen to override the version number put in the public params ``` The public parameters are stored in the output folder with name `zkatdlognoghv1_pp.json`. If version is overridden, then file name will be `("zkatdlognogh%d_pp.json", version)`. -### tokengen update zkatdlog.v1 +### tokengen update zkatdlognogh.v1 This command takes an existing `zkatdlognoghv1_pp.json` and allows you to update the issuer and/or auditor certificates, while keeping the public parameters intact. ``` Usage: - tokengen update zkatdlog.v1 [flags] + tokengen update zkatdlognogh.v1 [flags] Flags: - -a, --auditors strings list of auditor MSP directories containing the corresponding auditor certificate - -h, --help help for zkatdlog.v1 - -i, --input string path of the public param file - -s, --issuers strings list of issuer MSP directories containing the corresponding issuer certificate - -o, --output string output folder (default ".") - -v, --version uint allows the caller of tokengen to override the version number put in the public params + -a, --auditors strings list of auditor MSP directories containing the corresponding auditor certificate + -x, --extra stringArray extra data in key=value format, where is the path to a file containing the data to load and store in the key + -h, --help help for zkatdlognogh.v1 + -i, --input string path of the public param file + -s, --issuers strings list of issuer MSP directories containing the corresponding issuer certificate + -o, --output string output folder (default ".") + -v, --version uint allows the caller of tokengen to override the version number put in the public params ``` ## tokengen pp diff --git a/cmd/tokengen/cobra/pp/common/common.go b/cmd/tokengen/cobra/pp/common/common.go index c006c54bb4..06d0a6f0e6 100644 --- a/cmd/tokengen/cobra/pp/common/common.go +++ b/cmd/tokengen/cobra/pp/common/common.go @@ -130,3 +130,38 @@ func GetCertificatesFromDir(dir string) ([][]byte, error) { return content, nil } + +// LoadExtras parses strings in the format "key=file_path" and returns a map +// where keys are the extracted keys and values are the file contents as []byte. +func LoadExtras(extraFiles []string) (map[string][]byte, error) { + result := make(map[string][]byte, len(extraFiles)) + + for _, entry := range extraFiles { + // Split on the first colon to get key and filepath + parts := strings.SplitN(entry, "=", 2) + if len(parts) != 2 { + return nil, errors.Errorf("invalid format %q: expected key:filepath", entry) + } + + key := parts[0] + filepath := parts[1] + + // Check for empty key or filepath + if key == "" { + return nil, errors.Errorf("empty key in entry %q", entry) + } + if filepath == "" { + return nil, errors.Errorf("empty filepath for key %q", key) + } + + // Read the file + content, err := os.ReadFile(filepath) + if err != nil { + return nil, errors.Wrapf(err, "failed to read file for key %q (path: %s)", key, filepath) + } + + result[key] = content + } + + return result, nil +} diff --git a/cmd/tokengen/cobra/pp/common/common_test.go b/cmd/tokengen/cobra/pp/common/common_test.go new file mode 100644 index 0000000000..2560a8ca9a --- /dev/null +++ b/cmd/tokengen/cobra/pp/common/common_test.go @@ -0,0 +1,177 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ + +package common + +import ( + "os" + "path/filepath" + "testing" +) + +func TestLoadExtras(t *testing.T) { + // Create a temporary directory for test files + tempDir := t.TempDir() + + // Test case 1: Successfully load multiple files + t.Run("success_multiple_files", func(t *testing.T) { + // Create test files + file1Path := filepath.Join(tempDir, "test1.json") + file1Content := []byte(`{"key": "value1"}`) + if err := os.WriteFile(file1Path, file1Content, 0644); err != nil { + t.Fatalf("failed to create test file: %v", err) + } + + file2Path := filepath.Join(tempDir, "test2.json") + file2Content := []byte(`{"key": "value2"}`) + if err := os.WriteFile(file2Path, file2Content, 0644); err != nil { + t.Fatalf("failed to create test file: %v", err) + } + + extraFiles := []string{ + "foo=" + file1Path, + "bar=" + file2Path, + } + + result, err := LoadExtras(extraFiles) + if err != nil { + t.Fatalf("expected no error, got: %v", err) + } + + if len(result) != 2 { + t.Errorf("expected 2 entries, got %d", len(result)) + } + + if string(result["foo"]) != string(file1Content) { + t.Errorf("expected %q for foo, got %q", string(file1Content), string(result["foo"])) + } + + if string(result["bar"]) != string(file2Content) { + t.Errorf("expected %q for bar, got %q", string(file2Content), string(result["bar"])) + } + }) + + // Test case 2: Empty input slice + t.Run("empty_input", func(t *testing.T) { + extraFiles := []string{} + + result, err := LoadExtras(extraFiles) + if err != nil { + t.Fatalf("expected no error, got: %v", err) + } + + if len(result) != 0 { + t.Errorf("expected empty map, got %d entries", len(result)) + } + }) + + // Test case 3: File does not exist + t.Run("file_not_found", func(t *testing.T) { + extraFiles := []string{ + "missing=" + filepath.Join(tempDir, "nonexistent.json"), + } + + result, err := LoadExtras(extraFiles) + if err == nil { + t.Fatal("expected error for missing file, got nil") + } + + if result != nil { + t.Errorf("expected nil result on error, got: %v", result) + } + }) + + // Test case 4: Invalid format - no colon + t.Run("invalid_format_no_colon", func(t *testing.T) { + extraFiles := []string{"foobar"} + + result, err := LoadExtras(extraFiles) + if err == nil { + t.Fatal("expected error for invalid format, got nil") + } + + if result != nil { + t.Errorf("expected nil result on error, got: %v", result) + } + }) + + // Test case 5: Invalid format - empty key + t.Run("invalid_format_empty_key", func(t *testing.T) { + extraFiles := []string{"=" + filepath.Join(tempDir, "test.json")} + + result, err := LoadExtras(extraFiles) + if err == nil { + t.Fatal("expected error for empty key, got nil") + } + + if result != nil { + t.Errorf("expected nil result on error, got: %v", result) + } + }) + + // Test case 6: Invalid format - empty filepath + t.Run("invalid_format_empty_filepath", func(t *testing.T) { + extraFiles := []string{"key="} + + result, err := LoadExtras(extraFiles) + if err == nil { + t.Fatal("expected error for empty filepath, got nil") + } + + if result != nil { + t.Errorf("expected nil result on error, got: %v", result) + } + }) + + // Test case 7: Filepath with colons (e.g., Windows paths or URLs) + t.Run("filepath_with_colons", func(t *testing.T) { + filePath := filepath.Join(tempDir, "test.json") + fileContent := []byte("content") + if err := os.WriteFile(filePath, fileContent, 0644); err != nil { + t.Fatalf("failed to create test file: %v", err) + } + + // Simulate a key with filepath that might have colons + extraFiles := []string{ + "mykey=" + filePath, + } + + result, err := LoadExtras(extraFiles) + if err != nil { + t.Fatalf("expected no error, got: %v", err) + } + + if string(result["mykey"]) != string(fileContent) { + t.Errorf("expected %q, got %q", string(fileContent), string(result["mykey"])) + } + }) + + // Test case 8: Binary file content + t.Run("binary_content", func(t *testing.T) { + filePath := filepath.Join(tempDir, "binary.dat") + binaryContent := []byte{0x00, 0x01, 0x02, 0xFF, 0xFE, 0xFD} + if err := os.WriteFile(filePath, binaryContent, 0644); err != nil { + t.Fatalf("failed to create test file: %v", err) + } + + extraFiles := []string{"binary=" + filePath} + + result, err := LoadExtras(extraFiles) + if err != nil { + t.Fatalf("expected no error, got: %v", err) + } + + if len(result["binary"]) != len(binaryContent) { + t.Errorf("expected length %d, got %d", len(binaryContent), len(result["binary"])) + } + + for i, b := range binaryContent { + if result["binary"][i] != b { + t.Errorf("byte mismatch at index %d: expected %x, got %x", i, b, result["binary"][i]) + } + } + }) +} diff --git a/cmd/tokengen/cobra/pp/fabtokenv1/gen.go b/cmd/tokengen/cobra/pp/fabtokenv1/gen.go index 38729c38ee..531087cab2 100644 --- a/cmd/tokengen/cobra/pp/fabtokenv1/gen.go +++ b/cmd/tokengen/cobra/pp/fabtokenv1/gen.go @@ -14,7 +14,7 @@ import ( "github.com/hyperledger-labs/fabric-token-sdk/cmd/tokengen/cobra/pp/cc" "github.com/hyperledger-labs/fabric-token-sdk/cmd/tokengen/cobra/pp/common" "github.com/hyperledger-labs/fabric-token-sdk/integration/nwo/token/generators/crypto/fabtokenv1" - v1 "github.com/hyperledger-labs/fabric-token-sdk/token/core/fabtoken/v1/setup" + setupv1 "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-smart-client/pkg/utils/errors" @@ -34,6 +34,8 @@ var ( Auditors []string // Version allows the caller of tokengen to override the version number put in the public params Version uint + // Extras allows the caller to add extra parameters to the public parameters + Extras []string ) // Cmd returns the Cobra Command for Version @@ -45,6 +47,8 @@ func Cmd() *cobra.Command { flags.StringSliceVarP(&Auditors, "auditors", "a", nil, "list of auditor MSP directories containing the corresponding auditor certificate") flags.StringSliceVarP(&Issuers, "issuers", "s", nil, "list of issuer MSP directories containing the corresponding issuer certificate") flags.UintVarP(&Version, "version", "v", 0, "allows the caller of tokengen to override the version number put in the public params") + flags.StringArrayVarP(&Extras, "extra", "x", []string{}, "extra data in key=value format, where value is the path to a file containing the data to load and store in the key") + return cobraCommand } @@ -92,11 +96,11 @@ type GeneratorArgs struct { // Gen generates the public parameters for the FabToken driver func Gen(args *GeneratorArgs) ([]byte, error) { // Setup - ver := v1.ProtocolV1 + ver := setupv1.ProtocolV1 if Version != 0 { ver = driver.TokenDriverVersion(Version) } - pp, err := v1.SetupWithVersion(v1.DefaultPrecision, ver) + pp, err := setupv1.WithVersion(setupv1.DefaultPrecision, ver) if err != nil { return nil, errors.Wrap(err, "failed setting up public parameters") } @@ -104,6 +108,17 @@ func Gen(args *GeneratorArgs) ([]byte, error) { return nil, err } + // load extras + pp.ExtraData, err = common.LoadExtras(Extras) + if err != nil { + return nil, errors.Wrap(err, "failed loading extras") + } + + // validate + if err := pp.Validate(); err != nil { + return nil, errors.Wrapf(err, "failed to validate public parameters") + } + // warn in case no issuers are specified if len(pp.Issuers()) == 0 { fmt.Println("No issuers specified. The public parameters allow anyone to create tokens.") diff --git a/cmd/tokengen/cobra/pp/zkatdlognoghv1/gen.go b/cmd/tokengen/cobra/pp/zkatdlognoghv1/gen.go index 129b51987c..54671f9278 100644 --- a/cmd/tokengen/cobra/pp/zkatdlognoghv1/gen.go +++ b/cmd/tokengen/cobra/pp/zkatdlognoghv1/gen.go @@ -17,7 +17,7 @@ import ( "github.com/hyperledger-labs/fabric-token-sdk/cmd/tokengen/cobra/pp/common" "github.com/hyperledger-labs/fabric-token-sdk/cmd/tokengen/cobra/pp/idemix" "github.com/hyperledger-labs/fabric-token-sdk/integration/nwo/token/generators/crypto/zkatdlognoghv1" - v1 "github.com/hyperledger-labs/fabric-token-sdk/token/core/zkatdlog/nogh/v1/setup" + setupv1 "github.com/hyperledger-labs/fabric-token-sdk/token/core/zkatdlog/nogh/v1/setup" "github.com/hyperledger-labs/fabric-token-sdk/token/driver" "github.com/spf13/cobra" ) @@ -33,10 +33,8 @@ type GeneratorArgs struct { Issuers []string // Auditors is the list of auditor MSP directories containing the corresponding auditor certificate Auditors []string - // Base is a dlog driver related parameter - Base uint - // Exponent is a dlog driver related parameter - Exponent uint + // BitLength is a dlog driver related parameter + BitLength uint64 // Aries is a flag to indicate that aries should be used as backend for idemix Aries bool // Version allows the caller of tokengen to override the version number put in the public params @@ -54,16 +52,15 @@ var ( Issuers []string // Auditors is the list of auditor MSP directories containing the corresponding auditor certificate Auditors []string - // Base is a dlog driver related parameter. - // It is used to define the maximum quantity a token can contain as Base^Exponent - Base uint - // Exponent is a dlog driver related parameter - // It is used to define the maximum quantity a token can contain as Base^Exponent - Exponent uint + // BitLength is a dlog driver related parameter. + // It is used to define the maximum quantity a token can contain + BitLength uint64 // Aries is a flag to indicate that aries should be used as backend for idemix Aries bool // Version allows the caller of tokengen to override the version number put in the public params Version uint + // Extras allows the caller to add extra parameters to the public parameters + Extras []string ) // Cmd returns the Cobra Command for Version @@ -75,10 +72,10 @@ func Cmd() *cobra.Command { flags.StringSliceVarP(&Auditors, "auditors", "a", nil, "list of auditor MSP directories containing the corresponding auditor certificate") flags.StringSliceVarP(&Issuers, "issuers", "s", nil, "list of issuer MSP directories containing the corresponding issuer certificate") flags.StringVarP(&IdemixMSPDir, "idemix", "i", "", "idemix msp dir") - flags.UintVarP(&Base, "base", "b", 100, "base is used to define the maximum quantity a token can contain as Base^Exponent") - flags.UintVarP(&Exponent, "exponent", "e", 2, "exponent is used to define the maximum quantity a token can contain as Base^Exponent") + flags.Uint64VarP(&BitLength, "bits", "b", 64, "bits is used to define the maximum quantity a token can contain") flags.BoolVarP(&Aries, "aries", "r", false, "flag to indicate that aries should be used as backend for idemix") flags.UintVarP(&Version, "version", "v", 0, "allows the caller of tokengen to override the version number put in the public params") + flags.StringArrayVarP(&Extras, "extra", "x", []string{}, "extra data in key=value format, where value is the path to a file containing the data to load and store in the key") return cobraCommand } @@ -99,8 +96,7 @@ var cobraCommand = &cobra.Command{ GenerateCCPackage: GenerateCCPackage, Issuers: Issuers, Auditors: Auditors, - Base: Base, - Exponent: Exponent, + BitLength: BitLength, Aries: Aries, Version: Version, }) @@ -133,18 +129,31 @@ func Gen(args *GeneratorArgs) ([]byte, error) { if args.Aries { curveID = math3.BLS12_381_BBS_GURVY } - // todo range is hardcoded, to be changed - ver := v1.ProtocolV1 + ver := setupv1.ProtocolV1 if args.Version != 0 { ver = driver.TokenDriverVersion(args.Version) } - pp, err := v1.SetupWithVersion(64, ipkBytes, curveID, ver) + var bitLength uint64 + if args.BitLength != 0 { + bitLength = args.BitLength + } + pp, err := setupv1.WithVersion(bitLength, ipkBytes, curveID, ver) if err != nil { return nil, errors.Wrap(err, "failed setting up public parameters") } + + // issuers and auditors if err := common.SetupIssuersAndAuditors(pp, args.Auditors, args.Issuers); err != nil { return nil, errors.Wrap(err, "failed to setup issuer and auditors") } + + // load extras + pp.ExtraData, err = common.LoadExtras(Extras) + if err != nil { + return nil, errors.Wrap(err, "failed loading extras") + } + + // validate if err := pp.Validate(); err != nil { return nil, errors.Wrapf(err, "failed to validate public parameters") } diff --git a/cmd/tokengen/cobra/pp/zkatdlognoghv1/update.go b/cmd/tokengen/cobra/pp/zkatdlognoghv1/update.go index 27d3ae702f..a4dd7fb2d0 100644 --- a/cmd/tokengen/cobra/pp/zkatdlognoghv1/update.go +++ b/cmd/tokengen/cobra/pp/zkatdlognoghv1/update.go @@ -44,6 +44,7 @@ func UpdateCmd() *cobra.Command { flags.StringSliceVarP(&Auditors, "auditors", "a", nil, "list of auditor MSP directories containing the corresponding auditor certificate") flags.StringSliceVarP(&Issuers, "issuers", "s", nil, "list of issuer MSP directories containing the corresponding issuer certificate") flags.UintVarP(&Version, "version", "v", 0, "allows the caller of tokengen to override the version number put in the public params") + flags.StringArrayVarP(&Extras, "extra", "x", []string{}, "extra data in key=value format, where is the path to a file containing the data to load and store in the key") return cmd } @@ -104,13 +105,22 @@ func Update(args *UpdateArgs) error { return err } - // update version if needed + // update version, if needed ver := v1.ProtocolV1 if args.Version != 0 { ver = driver.TokenDriverVersion(args.Version) } pp.DriverVersion = ver + // update extras, if needed + extraData, err := common.LoadExtras(Extras) + if err != nil { + return errors.Wrap(err, "failed loading extras") + } + for k, v := range extraData { + pp.ExtraData[k] = v + } + // Store Public Params raw, err := pp.Serialize() if err != nil { diff --git a/cmd/tokengen/main_test.go b/cmd/tokengen/main_test.go index 8394a96539..08d5ea562f 100644 --- a/cmd/tokengen/main_test.go +++ b/cmd/tokengen/main_test.go @@ -57,6 +57,10 @@ func TestGenFullSuccess(t *testing.T) { "./testdata/auditors/msp", "--output", tempOutput, + "--extra", + "k1=./testdata/extras/f1.txt", + "--extra", + "k2=./testdata/extras/f2.txt", }, ) @@ -67,10 +71,11 @@ func TestGenFullSuccess(t *testing.T) { "./testdata/issuers/msp", "./testdata/idemix/msp/IssuerPublicKey", v1.ProtocolV1, + true, ) } -func TestGenFullSuccessWithVersionOverride(t *testing.T) { +func TestGenFullSuccessWithVersionOverrideAndNewExtras(t *testing.T) { gt := NewGomegaWithT(t) tokengen, err := gexec.Build("github.com/hyperledger-labs/fabric-token-sdk/cmd/tokengen") gt.Expect(err).NotTo(HaveOccurred()) @@ -95,6 +100,10 @@ func TestGenFullSuccessWithVersionOverride(t *testing.T) { tempOutput, "--version", "2", + "--extra", + "k1=./testdata/extras/f1.txt", + "--extra", + "k2=./testdata/extras/f2.txt", }, ) @@ -105,6 +114,7 @@ func TestGenFullSuccessWithVersionOverride(t *testing.T) { "./testdata/issuers/msp", "./testdata/idemix/msp/IssuerPublicKey", driver.TokenDriverVersion(2), + true, ) } @@ -132,6 +142,10 @@ func TestFullUpdate(t *testing.T) { "./testdata/zkatdlognoghv1_pp.json", "--output", tempOutput, + "--extra", + "k1=./testdata/extras/f1.txt", + "--extra", + "k2=./testdata/extras/f2.txt", }, ) @@ -142,6 +156,7 @@ func TestFullUpdate(t *testing.T) { "./testdata/auditors/msp", "./testdata/idemix/msp/IssuerPublicKey", v1.ProtocolV1, + true, ) } @@ -178,6 +193,7 @@ func TestPartialUpdate(t *testing.T) { "./testdata/auditors/msp", "./testdata/idemix/msp/IssuerPublicKey", v1.ProtocolV1, + false, ) } @@ -216,6 +232,7 @@ func TestPartialUpdateWithVersion(t *testing.T) { "./testdata/auditors/msp", "./testdata/idemix/msp/IssuerPublicKey", driver.TokenDriverVersion(2), + false, ) } @@ -298,6 +315,7 @@ func validateOutputEquivalent( gt *WithT, tempOutput, auditorsMSPdir, issuersMSPdir, idemixMSPdir string, version driver.TokenDriverVersion, + checkExtra bool, ) { ppRaw, err := os.ReadFile(filepath.Join( tempOutput, @@ -322,6 +340,15 @@ func validateOutputEquivalent( idemixPK, err := os.ReadFile(idemixMSPdir) gt.Expect(err).NotTo(HaveOccurred()) gt.Expect(idemixPK).To(BeEquivalentTo(slices.GetUnique(pp.IdemixIssuerPublicKeys).PublicKey)) + + extras := pp.Extras() + if checkExtra { + gt.Expect(extras).To(HaveLen(2)) + gt.Expect(extras["k1"]).To(BeEquivalentTo("f1")) + gt.Expect(extras["k2"]).To(BeEquivalentTo("f2")) + } else { + gt.Expect(extras).To(BeEmpty()) + } } func testGenRunWithError(gt *WithT, tokengen string, args []string, errMsg string) { diff --git a/cmd/tokengen/testdata/extras/f1.txt b/cmd/tokengen/testdata/extras/f1.txt new file mode 100644 index 0000000000..9dd7ac90b5 --- /dev/null +++ b/cmd/tokengen/testdata/extras/f1.txt @@ -0,0 +1 @@ +f1 \ No newline at end of file diff --git a/cmd/tokengen/testdata/extras/f2.txt b/cmd/tokengen/testdata/extras/f2.txt new file mode 100644 index 0000000000..70f80fc423 --- /dev/null +++ b/cmd/tokengen/testdata/extras/f2.txt @@ -0,0 +1 @@ +f2 \ No newline at end of file diff --git a/go.mod b/go.mod index 616baac85b..9487a6a194 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/dgraph-io/ristretto/v2 v2.3.0 github.com/gin-gonic/gin v1.10.0 github.com/hashicorp/go-uuid v1.0.3 - github.com/hyperledger-labs/fabric-smart-client v0.6.1-0.20251030075357-8bde666534da + github.com/hyperledger-labs/fabric-smart-client v0.6.1-0.20251104052518-2ce51a8935a9 github.com/hyperledger/fabric v1.4.0-rc1.0.20250510200036-435a7f1a780a github.com/hyperledger/fabric-chaincode-go/v2 v2.3.0 github.com/hyperledger/fabric-lib-go v1.1.3-0.20240523144151-25edd1eaf5f5 diff --git a/go.sum b/go.sum index 0d05a52e31..50b1eacc18 100644 --- a/go.sum +++ b/go.sum @@ -1055,8 +1055,8 @@ 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/SmartBFT v0.0.0-20250503203013-eb005eef8866 h1:Mu/6NJsfl9g3wM15Ue7hqPq4LtgYDoABh8MO4u8aW4g= github.com/hyperledger-labs/SmartBFT v0.0.0-20250503203013-eb005eef8866/go.mod h1:9aNHNXsCVy/leGz2gpTC1eOL5QecxbSAGjqsLh4T1LM= -github.com/hyperledger-labs/fabric-smart-client v0.6.1-0.20251030075357-8bde666534da h1:5e/8UiCGNRyrzs4JP5I6PdP0KpE96oXhyAJWxiPAGs8= -github.com/hyperledger-labs/fabric-smart-client v0.6.1-0.20251030075357-8bde666534da/go.mod h1:Ib74lzDOsxuEGpl6Q3huBny9+X7b1HCEN6xhMbxIi9A= +github.com/hyperledger-labs/fabric-smart-client v0.6.1-0.20251104052518-2ce51a8935a9 h1:McQVdPOFvRfqnaFdn/o2yBldZ4Wt11NjwgU3gQaX6F8= +github.com/hyperledger-labs/fabric-smart-client v0.6.1-0.20251104052518-2ce51a8935a9/go.mod h1:Ib74lzDOsxuEGpl6Q3huBny9+X7b1HCEN6xhMbxIi9A= 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.20250510200036-435a7f1a780a h1:l9dE3iuE+mKj7K8Tcx904cF8zJpaNQONh3GNZdXnnyc= diff --git a/token/core/fabtoken/protos-go/pp/ftpp.pb.go b/token/core/fabtoken/protos-go/pp/ftpp.pb.go index 8d0e0bcf8d..3d726083a1 100644 --- a/token/core/fabtoken/protos-go/pp/ftpp.pb.go +++ b/token/core/fabtoken/protos-go/pp/ftpp.pb.go @@ -74,12 +74,13 @@ func (x *Identity) GetRaw() []byte { // PublicParameters describes typed public parameters type PublicParameters struct { state protoimpl.MessageState `protogen:"open.v1"` - TokenDriverName string `protobuf:"bytes,1,opt,name=token_driver_name,json=tokenDriverName,proto3" json:"token_driver_name,omitempty"` // the name of the token driver - TokenDriverVersion uint64 `protobuf:"varint,2,opt,name=token_driver_version,json=tokenDriverVersion,proto3" json:"token_driver_version,omitempty"` // the version of token driver - Auditor *Identity `protobuf:"bytes,7,opt,name=auditor,proto3" json:"auditor,omitempty"` // is the public key of the auditor. - Issuers []*Identity `protobuf:"bytes,8,rep,name=issuers,proto3" json:"issuers,omitempty"` // is a list of public keys of the entities that can issue tokens. - MaxToken uint64 `protobuf:"varint,9,opt,name=max_token,json=maxToken,proto3" json:"max_token,omitempty"` // is the maximum quantity a token can hold - QuantityPrecision uint64 `protobuf:"varint,10,opt,name=quantity_precision,json=quantityPrecision,proto3" json:"quantity_precision,omitempty"` // is the precision used to represent quantities + TokenDriverName string `protobuf:"bytes,1,opt,name=token_driver_name,json=tokenDriverName,proto3" json:"token_driver_name,omitempty"` // the name of the token driver + TokenDriverVersion uint64 `protobuf:"varint,2,opt,name=token_driver_version,json=tokenDriverVersion,proto3" json:"token_driver_version,omitempty"` // the version of token driver + Auditor *Identity `protobuf:"bytes,3,opt,name=auditor,proto3" json:"auditor,omitempty"` // is the public key of the auditor. + Issuers []*Identity `protobuf:"bytes,4,rep,name=issuers,proto3" json:"issuers,omitempty"` // is a list of public keys of the entities that can issue tokens. + MaxToken uint64 `protobuf:"varint,5,opt,name=max_token,json=maxToken,proto3" json:"max_token,omitempty"` // is the maximum quantity a token can hold + QuantityPrecision uint64 `protobuf:"varint,6,opt,name=quantity_precision,json=quantityPrecision,proto3" json:"quantity_precision,omitempty"` // is the precision used to represent quantities + ExtraData map[string][]byte `protobuf:"bytes,7,rep,name=extra_data,json=extraData,proto3" json:"extra_data,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` // extra_data allows to store arbitrary data in the public parameters unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -156,6 +157,13 @@ func (x *PublicParameters) GetQuantityPrecision() uint64 { return 0 } +func (x *PublicParameters) GetExtraData() map[string][]byte { + if x != nil { + return x.ExtraData + } + return nil +} + var File_ftpp_proto protoreflect.FileDescriptor const file_ftpp_proto_rawDesc = "" + @@ -163,15 +171,19 @@ const file_ftpp_proto_rawDesc = "" + "\n" + "ftpp.proto\x12\bfabtoken\"\x1c\n" + "\bIdentity\x12\x10\n" + - "\x03raw\x18\x01 \x01(\fR\x03raw\"\x98\x02\n" + + "\x03raw\x18\x01 \x01(\fR\x03raw\"\xa0\x03\n" + "\x10PublicParameters\x12*\n" + "\x11token_driver_name\x18\x01 \x01(\tR\x0ftokenDriverName\x120\n" + "\x14token_driver_version\x18\x02 \x01(\x04R\x12tokenDriverVersion\x12,\n" + - "\aauditor\x18\a \x01(\v2\x12.fabtoken.IdentityR\aauditor\x12,\n" + - "\aissuers\x18\b \x03(\v2\x12.fabtoken.IdentityR\aissuers\x12\x1b\n" + - "\tmax_token\x18\t \x01(\x04R\bmaxToken\x12-\n" + - "\x12quantity_precision\x18\n" + - " \x01(\x04R\x11quantityPrecisionBOZMgithub.com/hyperledger-labs/fabric-token-sdk/token/core/fabtoken/protos-go/ppb\x06proto3" + "\aauditor\x18\x03 \x01(\v2\x12.fabtoken.IdentityR\aauditor\x12,\n" + + "\aissuers\x18\x04 \x03(\v2\x12.fabtoken.IdentityR\aissuers\x12\x1b\n" + + "\tmax_token\x18\x05 \x01(\x04R\bmaxToken\x12-\n" + + "\x12quantity_precision\x18\x06 \x01(\x04R\x11quantityPrecision\x12H\n" + + "\n" + + "extra_data\x18\a \x03(\v2).fabtoken.PublicParameters.ExtraDataEntryR\textraData\x1a<\n" + + "\x0eExtraDataEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + + "\x05value\x18\x02 \x01(\fR\x05value:\x028\x01BOZMgithub.com/hyperledger-labs/fabric-token-sdk/token/core/fabtoken/protos-go/ppb\x06proto3" var ( file_ftpp_proto_rawDescOnce sync.Once @@ -185,19 +197,21 @@ func file_ftpp_proto_rawDescGZIP() []byte { return file_ftpp_proto_rawDescData } -var file_ftpp_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_ftpp_proto_msgTypes = make([]protoimpl.MessageInfo, 3) var file_ftpp_proto_goTypes = []any{ (*Identity)(nil), // 0: fabtoken.Identity (*PublicParameters)(nil), // 1: fabtoken.PublicParameters + nil, // 2: fabtoken.PublicParameters.ExtraDataEntry } var file_ftpp_proto_depIdxs = []int32{ 0, // 0: fabtoken.PublicParameters.auditor:type_name -> fabtoken.Identity 0, // 1: fabtoken.PublicParameters.issuers:type_name -> fabtoken.Identity - 2, // [2:2] is the sub-list for method output_type - 2, // [2:2] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name + 2, // 2: fabtoken.PublicParameters.extra_data:type_name -> fabtoken.PublicParameters.ExtraDataEntry + 3, // [3:3] is the sub-list for method output_type + 3, // [3:3] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name } func init() { file_ftpp_proto_init() } @@ -211,7 +225,7 @@ func file_ftpp_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_ftpp_proto_rawDesc), len(file_ftpp_proto_rawDesc)), NumEnums: 0, - NumMessages: 2, + NumMessages: 3, NumExtensions: 0, NumServices: 0, }, diff --git a/token/core/fabtoken/protos/ftpp.proto b/token/core/fabtoken/protos/ftpp.proto index 08c55f5d59..58cd57b905 100644 --- a/token/core/fabtoken/protos/ftpp.proto +++ b/token/core/fabtoken/protos/ftpp.proto @@ -18,8 +18,9 @@ message Identity { message PublicParameters { 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 - uint64 quantity_precision = 10; // is the precision used to represent quantities + Identity auditor = 3; // is the public key of the auditor. + repeated Identity issuers = 4; // is a list of public keys of the entities that can issue tokens. + uint64 max_token = 5; // is the maximum quantity a token can hold + uint64 quantity_precision = 6; // is the precision used to represent quantities + map extra_data = 7; // extra_data allows to store arbitrary data in the public parameters } \ No newline at end of file diff --git a/token/core/fabtoken/v1/setup/setup.go b/token/core/fabtoken/v1/setup/setup.go index b389fbe1a2..70543864e8 100644 --- a/token/core/fabtoken/v1/setup/setup.go +++ b/token/core/fabtoken/v1/setup/setup.go @@ -40,6 +40,8 @@ type PublicParams struct { Auditor []byte // This encodes the list of authorized issuers IssuerIDs []driver.Identity + // ExtraData contains any extra custom data + ExtraData driver.Extras } // Setup initializes PublicParams @@ -47,8 +49,8 @@ func Setup(precision uint64) (*PublicParams, error) { return NewWith(FabTokenDriverName, ProtocolV1, precision) } -// SetupWithVersion is like Setup with the additional possibility to specify the version number -func SetupWithVersion(precision uint64, version driver.TokenDriverVersion) (*PublicParams, error) { +// WithVersion is like Setup with the additional possibility to specify the version number +func WithVersion(precision uint64, version driver.TokenDriverVersion) (*PublicParams, error) { return NewWith(FabTokenDriverName, version, precision) } @@ -77,6 +79,7 @@ func NewWith(driverName driver.TokenDriverName, driverVersion driver.TokenDriver DriverVersion: driverVersion, QuantityPrecision: precision, MaxToken: uint64(1<[4294967295]", err.Error()) + }) } -func TestSetup_InvalidPrecision(t *testing.T) { - pp, err := Setup(65) - assert.Error(t, err) - assert.Nil(t, pp) - assert.Equal(t, "invalid precision [65], must be smaller or equal than 64", err.Error()) +func TestPublicParams_Serialization(t *testing.T) { + t.Run("valid serialization and deserialization", func(t *testing.T) { + original, err := Setup(32) + assert.NoError(t, err) + + // Add some data + original.AddAuditor([]byte("auditor1")) + original.AddIssuer([]byte("issuer1")) + original.ExtraData = map[string][]byte{"key1": []byte("value1")} + + // Serialize + serialized, err := original.Serialize() + assert.NoError(t, err) + + // Deserialize + deserialized := &PublicParams{ + DriverName: FabTokenDriverName, + DriverVersion: ProtocolV1, + } + err = deserialized.Deserialize(serialized) + assert.NoError(t, err) + + // Verify all fields match + assert.Equal(t, original.QuantityPrecision, deserialized.QuantityPrecision) + assert.Equal(t, original.MaxToken, deserialized.MaxToken) + assert.Equal(t, original.Auditor, deserialized.Auditor) + assert.Equal(t, original.IssuerIDs, deserialized.IssuerIDs) + assert.Equal(t, original.ExtraData, deserialized.ExtraData) + }) + + t.Run("invalid deserialization", func(t *testing.T) { + pp := &PublicParams{ + DriverName: FabTokenDriverName, + DriverVersion: ProtocolV1, + } + err := pp.Deserialize([]byte("invalid")) + assert.Error(t, err) + }) + + t.Run("mismatched driver identifier", func(t *testing.T) { + original, err := Setup(32) + assert.NoError(t, err) + serialized, err := original.Serialize() + assert.NoError(t, err) + + wrongDriver := &PublicParams{ + DriverName: "wrong", + DriverVersion: ProtocolV1, + } + err = wrongDriver.Deserialize(serialized) + assert.Error(t, err) + assert.Contains(t, err.Error(), "invalid identifier") + }) +} + +func TestPublicParams_BytesAndFromBytes(t *testing.T) { + t.Run("serialization with nil values", func(t *testing.T) { + pp := &PublicParams{ + DriverName: FabTokenDriverName, + QuantityPrecision: 32, + MaxToken: 1<<32 - 1, + IssuerIDs: nil, + Auditor: nil, + ExtraData: nil, + } + bytes, err := pp.Bytes() + assert.NoError(t, err) + assert.NotNil(t, bytes) + + // Test FromBytes with the serialized data + newPP := &PublicParams{} + err = newPP.FromBytes(bytes) + assert.NoError(t, err) + assert.Equal(t, pp.QuantityPrecision, newPP.QuantityPrecision) + assert.Equal(t, pp.MaxToken, newPP.MaxToken) + }) + + t.Run("serialization with invalid identity", func(t *testing.T) { + pp := &PublicParams{ + DriverName: FabTokenDriverName, + QuantityPrecision: 32, + MaxToken: 1<<32 - 1, + IssuerIDs: []driver.Identity{nil}, // Invalid identity + } + bytes, err := pp.Bytes() + assert.NoError(t, err) // Should handle nil identity + + newPP := &PublicParams{} + err = newPP.FromBytes(bytes) + assert.NoError(t, err) + }) + + t.Run("invalid protobuf data", func(t *testing.T) { + pp := &PublicParams{} + err := pp.FromBytes([]byte{0xFF, 0xFF, 0xFF}) // Invalid protobuf data + assert.Error(t, err) + }) } -func TestNewPublicParamsFromBytes_Valid(t *testing.T) { +func TestPublicParams_String(t *testing.T) { pp, err := Setup(32) assert.NoError(t, err) - raw, err := pp.Serialize() - assert.NoError(t, err) - pp2, err := NewPublicParamsFromBytes(raw, FabTokenDriverName, ProtocolV1) - assert.NoError(t, err) - assert.Equal(t, FabTokenDriverName, pp2.DriverName) - assert.Equal(t, ProtocolV1, pp2.DriverVersion) - assert.Equal(t, uint64(32), pp2.QuantityPrecision) - assert.Equal(t, uint64(4294967295), pp2.MaxToken) - assert.Nil(t, pp2.IssuerIDs) - assert.Nil(t, pp2.Auditor) - assert.Equal(t, pp, pp2) + pp.AddAuditor([]byte("auditor1")) + pp.AddIssuer([]byte("issuer1")) + pp.ExtraData = map[string][]byte{"key1": []byte("value1")} + + str := pp.String() + assert.NotEmpty(t, str) + assert.Contains(t, str, "QuantityPrecision") + assert.Contains(t, str, "MaxToken") } -func TestPublicParams_Validate_Valid(t *testing.T) { +func TestPublicParams_StringWithInvalidJSON(t *testing.T) { pp := &PublicParams{ DriverName: FabTokenDriverName, QuantityPrecision: 32, MaxToken: 1<<32 - 1, + // Add a channel which cannot be marshaled to JSON + ExtraData: map[string][]byte{ + "key": []byte("value"), + }, } - // without issuers - err := pp.Validate() - assert.NoError(t, err) - // with issuers - pp.IssuerIDs = []driver.Identity{[]byte("issuer1"), []byte("issuer2")} - err = pp.Validate() - assert.NoError(t, err) + str := pp.String() + assert.Contains(t, str, "QuantityPrecision") + assert.Contains(t, str, "MaxToken") + assert.Contains(t, str, "key") } -func TestPublicParams_Validate_InvalidPrecision(t *testing.T) { +func TestExtras(t *testing.T) { pp := &PublicParams{ - DriverName: FabTokenDriverName, - QuantityPrecision: 65, - MaxToken: 1<<64 - 1, + ExtraData: map[string][]byte{ + "key1": []byte("value1"), + "key2": []byte("value2"), + }, } - err := pp.Validate() - assert.Error(t, err) - assert.Equal(t, "invalid precision [65], must be less than 64", err.Error()) -} -func TestPublicParams_Validate_InvalidMaxToken(t *testing.T) { - pp := &PublicParams{ - DriverName: FabTokenDriverName, - QuantityPrecision: 32, - MaxToken: 1 << 32, - } - err := pp.Validate() - assert.Error(t, err) - assert.Equal(t, "max token value is invalid [4294967296]>[4294967295]", err.Error()) + extras := pp.Extras() + assert.Equal(t, pp.ExtraData, extras) + + // Verify nil case + pp = &PublicParams{} + assert.Nil(t, pp.Extras()) + + // Verify empty map case + pp.ExtraData = make(map[string][]byte) + assert.Empty(t, pp.Extras()) } diff --git a/token/core/zkatdlog/nogh/protos-go/actions/noghactions.pb.go b/token/core/zkatdlog/nogh/protos-go/actions/noghactions.pb.go index 5a607b9bad..d1642eb24b 100644 --- a/token/core/zkatdlog/nogh/protos-go/actions/noghactions.pb.go +++ b/token/core/zkatdlog/nogh/protos-go/actions/noghactions.pb.go @@ -5,8 +5,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.29.3 +// protoc-gen-go v1.36.6 +// protoc v5.28.1 // source: noghactions.proto package actions @@ -14,6 +14,7 @@ package actions import ( reflect "reflect" sync "sync" + unsafe "unsafe" actions "github.com/hyperledger-labs/fabric-token-sdk/token/core/fabtoken/protos-go/actions" math "github.com/hyperledger-labs/fabric-token-sdk/token/core/zkatdlog/nogh/protos-go/math" @@ -30,21 +31,18 @@ const ( ) type Token struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Owner []byte `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` // Owner is the owner of the token + Data *math.G1 `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` // Data is the Pedersen commitment to type and value unknownFields protoimpl.UnknownFields - - Owner []byte `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` // Owner is the owner of the token - Data *math.G1 `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` // Data is the Pedersen commitment to type and value + sizeCache protoimpl.SizeCache } func (x *Token) Reset() { *x = Token{} - if protoimpl.UnsafeEnabled { - mi := &file_noghactions_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_noghactions_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Token) String() string { @@ -55,7 +53,7 @@ func (*Token) ProtoMessage() {} func (x *Token) ProtoReflect() protoreflect.Message { mi := &file_noghactions_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -85,23 +83,20 @@ func (x *Token) GetData() *math.G1 { } type TokenMetadata struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` // Type is the type of the token - Value *math.Zr `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` // Value is the quantity of the token - BlindingFactor *math.Zr `protobuf:"bytes,3,opt,name=blinding_factor,json=blindingFactor,proto3" json:"blinding_factor,omitempty"` // BlindingFactor is the blinding factor used to commit type and value - Issuer *pp.Identity `protobuf:"bytes,4,opt,name=issuer,proto3" json:"issuer,omitempty"` // Issuer is the issuer of the token, if defined + state protoimpl.MessageState `protogen:"open.v1"` + Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` // Type is the type of the token + Value *math.Zr `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` // Value is the quantity of the token + BlindingFactor *math.Zr `protobuf:"bytes,3,opt,name=blinding_factor,json=blindingFactor,proto3" json:"blinding_factor,omitempty"` // BlindingFactor is the blinding factor used to commit type and value + Issuer *pp.Identity `protobuf:"bytes,4,opt,name=issuer,proto3" json:"issuer,omitempty"` // Issuer is the issuer of the token, if defined + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *TokenMetadata) Reset() { *x = TokenMetadata{} - if protoimpl.UnsafeEnabled { - mi := &file_noghactions_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_noghactions_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *TokenMetadata) String() string { @@ -112,7 +107,7 @@ func (*TokenMetadata) ProtoMessage() {} func (x *TokenMetadata) ProtoReflect() protoreflect.Message { mi := &file_noghactions_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -156,21 +151,18 @@ func (x *TokenMetadata) GetIssuer() *pp.Identity { } type TokenID struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Index uint64 `protobuf:"varint,2,opt,name=index,proto3" json:"index,omitempty"` unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Index uint64 `protobuf:"varint,2,opt,name=index,proto3" json:"index,omitempty"` + sizeCache protoimpl.SizeCache } func (x *TokenID) Reset() { *x = TokenID{} - if protoimpl.UnsafeEnabled { - mi := &file_noghactions_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_noghactions_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *TokenID) String() string { @@ -181,7 +173,7 @@ func (*TokenID) ProtoMessage() {} func (x *TokenID) ProtoReflect() protoreflect.Message { mi := &file_noghactions_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -211,22 +203,19 @@ func (x *TokenID) GetIndex() uint64 { } type TransferActionInput struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` TokenId *TokenID `protobuf:"bytes,1,opt,name=token_id,json=tokenId,proto3" json:"token_id,omitempty"` Input *Token `protobuf:"bytes,2,opt,name=input,proto3" json:"input,omitempty"` UpgradeWitness *TransferActionInputUpgradeWitness `protobuf:"bytes,3,opt,name=upgrade_witness,json=upgradeWitness,proto3" json:"upgrade_witness,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *TransferActionInput) Reset() { *x = TransferActionInput{} - if protoimpl.UnsafeEnabled { - mi := &file_noghactions_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_noghactions_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *TransferActionInput) String() string { @@ -237,7 +226,7 @@ func (*TransferActionInput) ProtoMessage() {} func (x *TransferActionInput) ProtoReflect() protoreflect.Message { mi := &file_noghactions_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -274,21 +263,18 @@ func (x *TransferActionInput) GetUpgradeWitness() *TransferActionInputUpgradeWit } type TransferActionInputUpgradeWitness struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Output *actions.Token `protobuf:"bytes,1,opt,name=output,proto3" json:"output,omitempty"` - BlindingFactor *math.Zr `protobuf:"bytes,2,opt,name=blinding_factor,json=blindingFactor,proto3" json:"blinding_factor,omitempty"` + state protoimpl.MessageState `protogen:"open.v1"` + Output *actions.Token `protobuf:"bytes,1,opt,name=output,proto3" json:"output,omitempty"` + BlindingFactor *math.Zr `protobuf:"bytes,2,opt,name=blinding_factor,json=blindingFactor,proto3" json:"blinding_factor,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *TransferActionInputUpgradeWitness) Reset() { *x = TransferActionInputUpgradeWitness{} - if protoimpl.UnsafeEnabled { - mi := &file_noghactions_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_noghactions_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *TransferActionInputUpgradeWitness) String() string { @@ -299,7 +285,7 @@ func (*TransferActionInputUpgradeWitness) ProtoMessage() {} func (x *TransferActionInputUpgradeWitness) ProtoReflect() protoreflect.Message { mi := &file_noghactions_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -329,20 +315,17 @@ func (x *TransferActionInputUpgradeWitness) GetBlindingFactor() *math.Zr { } type TransferActionOutput struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Token *Token `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` // Token is the new token unknownFields protoimpl.UnknownFields - - Token *Token `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` // Token is the new token + sizeCache protoimpl.SizeCache } func (x *TransferActionOutput) Reset() { *x = TransferActionOutput{} - if protoimpl.UnsafeEnabled { - mi := &file_noghactions_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_noghactions_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *TransferActionOutput) String() string { @@ -353,7 +336,7 @@ func (*TransferActionOutput) ProtoMessage() {} func (x *TransferActionOutput) ProtoReflect() protoreflect.Message { mi := &file_noghactions_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -376,20 +359,17 @@ func (x *TransferActionOutput) GetToken() *Token { } type Proof struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Proof []byte `protobuf:"bytes,1,opt,name=proof,proto3" json:"proof,omitempty"` unknownFields protoimpl.UnknownFields - - Proof []byte `protobuf:"bytes,1,opt,name=proof,proto3" json:"proof,omitempty"` + sizeCache protoimpl.SizeCache } func (x *Proof) Reset() { *x = Proof{} - if protoimpl.UnsafeEnabled { - mi := &file_noghactions_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_noghactions_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Proof) String() string { @@ -400,7 +380,7 @@ func (*Proof) ProtoMessage() {} func (x *Proof) ProtoReflect() protoreflect.Message { mi := &file_noghactions_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -423,25 +403,22 @@ func (x *Proof) GetProof() []byte { } type TransferAction struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Version uint64 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` + Inputs []*TransferActionInput `protobuf:"bytes,2,rep,name=inputs,proto3" json:"inputs,omitempty"` // inputs + Outputs []*TransferActionOutput `protobuf:"bytes,3,rep,name=outputs,proto3" json:"outputs,omitempty"` // outputs + Proof *Proof `protobuf:"bytes,4,opt,name=proof,proto3" json:"proof,omitempty"` // ZK Proof that shows that the transfer is correct + Metadata map[string][]byte `protobuf:"bytes,5,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` // Metadata contains the transfer action's metadata + Issuer *pp.Identity `protobuf:"bytes,6,opt,name=issuer,proto3" json:"issuer,omitempty"` // Issuer to sign the transfer action in redeem case unknownFields protoimpl.UnknownFields - - Version uint64 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` - Inputs []*TransferActionInput `protobuf:"bytes,2,rep,name=inputs,proto3" json:"inputs,omitempty"` // inputs - Outputs []*TransferActionOutput `protobuf:"bytes,3,rep,name=outputs,proto3" json:"outputs,omitempty"` // outputs - Proof *Proof `protobuf:"bytes,4,opt,name=proof,proto3" json:"proof,omitempty"` // ZK Proof that shows that the transfer is correct - Metadata map[string][]byte `protobuf:"bytes,5,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` // Metadata contains the transfer action's metadata - Issuer *pp.Identity `protobuf:"bytes,6,opt,name=issuer,proto3" json:"issuer,omitempty"` // Issuer to sign the transfer action in redeem case + sizeCache protoimpl.SizeCache } func (x *TransferAction) Reset() { *x = TransferAction{} - if protoimpl.UnsafeEnabled { - mi := &file_noghactions_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_noghactions_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *TransferAction) String() string { @@ -452,7 +429,7 @@ func (*TransferAction) ProtoMessage() {} func (x *TransferAction) ProtoReflect() protoreflect.Message { mi := &file_noghactions_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -510,21 +487,18 @@ func (x *TransferAction) GetIssuer() *pp.Identity { } type IssueActionInput struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Id *TokenID `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // is the token id of the token to be redeemed + Token []byte `protobuf:"bytes,2,opt,name=token,proto3" json:"token,omitempty"` // is the actual token to be redeemed unknownFields protoimpl.UnknownFields - - Id *TokenID `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // is the token id of the token to be redeemed - Token []byte `protobuf:"bytes,2,opt,name=token,proto3" json:"token,omitempty"` // is the actual token to be redeemed + sizeCache protoimpl.SizeCache } func (x *IssueActionInput) Reset() { *x = IssueActionInput{} - if protoimpl.UnsafeEnabled { - mi := &file_noghactions_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_noghactions_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *IssueActionInput) String() string { @@ -535,7 +509,7 @@ func (*IssueActionInput) ProtoMessage() {} func (x *IssueActionInput) ProtoReflect() protoreflect.Message { mi := &file_noghactions_proto_msgTypes[8] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -565,20 +539,17 @@ func (x *IssueActionInput) GetToken() []byte { } type IssueActionOutput struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Token *Token `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` // is the newly issued token unknownFields protoimpl.UnknownFields - - Token *Token `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` // is the newly issued token + sizeCache protoimpl.SizeCache } func (x *IssueActionOutput) Reset() { *x = IssueActionOutput{} - if protoimpl.UnsafeEnabled { - mi := &file_noghactions_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_noghactions_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *IssueActionOutput) String() string { @@ -589,7 +560,7 @@ func (*IssueActionOutput) ProtoMessage() {} func (x *IssueActionOutput) ProtoReflect() protoreflect.Message { mi := &file_noghactions_proto_msgTypes[9] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -612,25 +583,22 @@ func (x *IssueActionOutput) GetToken() *Token { } type IssueAction struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Version uint64 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` + Issuer *pp.Identity `protobuf:"bytes,2,opt,name=issuer,proto3" json:"issuer,omitempty"` // is the identity of issuer + Inputs []*IssueActionInput `protobuf:"bytes,3,rep,name=inputs,proto3" json:"inputs,omitempty"` // are the tokens to be redeemed by this issue action + Outputs []*IssueActionOutput `protobuf:"bytes,4,rep,name=outputs,proto3" json:"outputs,omitempty"` // are the newly issued tokens + Proof *Proof `protobuf:"bytes,5,opt,name=proof,proto3" json:"proof,omitempty"` // carries the ZKP of IssueAction validity + Metadata map[string][]byte `protobuf:"bytes,6,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` // Metadata of the issue action unknownFields protoimpl.UnknownFields - - Version uint64 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` - Issuer *pp.Identity `protobuf:"bytes,2,opt,name=issuer,proto3" json:"issuer,omitempty"` // is the identity of issuer - Inputs []*IssueActionInput `protobuf:"bytes,3,rep,name=inputs,proto3" json:"inputs,omitempty"` // are the tokens to be redeemed by this issue action - Outputs []*IssueActionOutput `protobuf:"bytes,4,rep,name=outputs,proto3" json:"outputs,omitempty"` // are the newly issued tokens - Proof *Proof `protobuf:"bytes,5,opt,name=proof,proto3" json:"proof,omitempty"` // carries the ZKP of IssueAction validity - Metadata map[string][]byte `protobuf:"bytes,6,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` // Metadata of the issue action + sizeCache protoimpl.SizeCache } func (x *IssueAction) Reset() { *x = IssueAction{} - if protoimpl.UnsafeEnabled { - mi := &file_noghactions_proto_msgTypes[10] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_noghactions_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *IssueAction) String() string { @@ -641,7 +609,7 @@ func (*IssueAction) ProtoMessage() {} func (x *IssueAction) ProtoReflect() protoreflect.Message { mi := &file_noghactions_proto_msgTypes[10] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -700,121 +668,65 @@ func (x *IssueAction) GetMetadata() map[string][]byte { var File_noghactions_proto protoreflect.FileDescriptor -var file_noghactions_proto_rawDesc = []byte{ - 0x0a, 0x11, 0x6e, 0x6f, 0x67, 0x68, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x6e, 0x6f, 0x67, 0x68, 0x1a, 0x0e, 0x6e, 0x6f, 0x67, 0x68, 0x6d, - 0x61, 0x74, 0x68, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0f, 0x66, 0x74, 0x61, 0x63, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0c, 0x6e, 0x6f, 0x67, 0x68, - 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x3b, 0x0a, 0x05, 0x54, 0x6f, 0x6b, 0x65, - 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, - 0x52, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x12, 0x1c, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x6e, 0x6f, 0x67, 0x68, 0x2e, 0x47, 0x31, 0x52, - 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x9e, 0x01, 0x0a, 0x0d, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x4d, - 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x05, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x6e, 0x6f, 0x67, - 0x68, 0x2e, 0x5a, 0x72, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x31, 0x0a, 0x0f, 0x62, - 0x6c, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x5f, 0x66, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x6e, 0x6f, 0x67, 0x68, 0x2e, 0x5a, 0x72, 0x52, 0x0e, - 0x62, 0x6c, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x46, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x26, - 0x0a, 0x06, 0x69, 0x73, 0x73, 0x75, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, - 0x2e, 0x6e, 0x6f, 0x67, 0x68, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x52, 0x06, - 0x69, 0x73, 0x73, 0x75, 0x65, 0x72, 0x22, 0x2f, 0x0a, 0x07, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x49, - 0x44, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, - 0x64, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, - 0x52, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x22, 0xb4, 0x01, 0x0a, 0x13, 0x54, 0x72, 0x61, 0x6e, - 0x73, 0x66, 0x65, 0x72, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x12, - 0x28, 0x0a, 0x08, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x0d, 0x2e, 0x6e, 0x6f, 0x67, 0x68, 0x2e, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x49, 0x44, - 0x52, 0x07, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x49, 0x64, 0x12, 0x21, 0x0a, 0x05, 0x69, 0x6e, 0x70, - 0x75, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x6e, 0x6f, 0x67, 0x68, 0x2e, - 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x05, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x12, 0x50, 0x0a, 0x0f, - 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x5f, 0x77, 0x69, 0x74, 0x6e, 0x65, 0x73, 0x73, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x6e, 0x6f, 0x67, 0x68, 0x2e, 0x54, 0x72, 0x61, - 0x6e, 0x73, 0x66, 0x65, 0x72, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x70, 0x75, 0x74, - 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x57, 0x69, 0x74, 0x6e, 0x65, 0x73, 0x73, 0x52, 0x0e, - 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x57, 0x69, 0x74, 0x6e, 0x65, 0x73, 0x73, 0x22, 0x7f, - 0x0a, 0x21, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x65, 0x72, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, - 0x49, 0x6e, 0x70, 0x75, 0x74, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x57, 0x69, 0x74, 0x6e, - 0x65, 0x73, 0x73, 0x12, 0x27, 0x0a, 0x06, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x66, 0x61, 0x62, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x2e, 0x54, - 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x06, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x12, 0x31, 0x0a, 0x0f, - 0x62, 0x6c, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x5f, 0x66, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x6e, 0x6f, 0x67, 0x68, 0x2e, 0x5a, 0x72, 0x52, - 0x0e, 0x62, 0x6c, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x46, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x22, - 0x39, 0x0a, 0x14, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x65, 0x72, 0x41, 0x63, 0x74, 0x69, 0x6f, - 0x6e, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x12, 0x21, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x6e, 0x6f, 0x67, 0x68, 0x2e, 0x54, 0x6f, - 0x6b, 0x65, 0x6e, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x1d, 0x0a, 0x05, 0x50, 0x72, - 0x6f, 0x6f, 0x66, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0c, 0x52, 0x05, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x22, 0xdb, 0x02, 0x0a, 0x0e, 0x54, 0x72, - 0x61, 0x6e, 0x73, 0x66, 0x65, 0x72, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, - 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x76, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x31, 0x0a, 0x06, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x73, - 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x6e, 0x6f, 0x67, 0x68, 0x2e, 0x54, 0x72, - 0x61, 0x6e, 0x73, 0x66, 0x65, 0x72, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x70, 0x75, - 0x74, 0x52, 0x06, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x73, 0x12, 0x34, 0x0a, 0x07, 0x6f, 0x75, 0x74, - 0x70, 0x75, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x6e, 0x6f, 0x67, - 0x68, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x65, 0x72, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, - 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x52, 0x07, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x73, 0x12, - 0x21, 0x0a, 0x05, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, - 0x2e, 0x6e, 0x6f, 0x67, 0x68, 0x2e, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x52, 0x05, 0x70, 0x72, 0x6f, - 0x6f, 0x66, 0x12, 0x3e, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x05, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x6e, 0x6f, 0x67, 0x68, 0x2e, 0x54, 0x72, 0x61, 0x6e, - 0x73, 0x66, 0x65, 0x72, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, - 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, - 0x74, 0x61, 0x12, 0x26, 0x0a, 0x06, 0x69, 0x73, 0x73, 0x75, 0x65, 0x72, 0x18, 0x06, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x6e, 0x6f, 0x67, 0x68, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, - 0x74, 0x79, 0x52, 0x06, 0x69, 0x73, 0x73, 0x75, 0x65, 0x72, 0x1a, 0x3b, 0x0a, 0x0d, 0x4d, 0x65, - 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, - 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, - 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x47, 0x0a, 0x10, 0x49, 0x73, 0x73, 0x75, 0x65, - 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x12, 0x1d, 0x0a, 0x02, 0x69, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x6e, 0x6f, 0x67, 0x68, 0x2e, 0x54, - 0x6f, 0x6b, 0x65, 0x6e, 0x49, 0x44, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, - 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, - 0x22, 0x36, 0x0a, 0x11, 0x49, 0x73, 0x73, 0x75, 0x65, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4f, - 0x75, 0x74, 0x70, 0x75, 0x74, 0x12, 0x21, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x6e, 0x6f, 0x67, 0x68, 0x2e, 0x54, 0x6f, 0x6b, 0x65, - 0x6e, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0xcf, 0x02, 0x0a, 0x0b, 0x49, 0x73, 0x73, - 0x75, 0x65, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, - 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, - 0x6f, 0x6e, 0x12, 0x26, 0x0a, 0x06, 0x69, 0x73, 0x73, 0x75, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x6e, 0x6f, 0x67, 0x68, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, - 0x74, 0x79, 0x52, 0x06, 0x69, 0x73, 0x73, 0x75, 0x65, 0x72, 0x12, 0x2e, 0x0a, 0x06, 0x69, 0x6e, - 0x70, 0x75, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x6e, 0x6f, 0x67, - 0x68, 0x2e, 0x49, 0x73, 0x73, 0x75, 0x65, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x70, - 0x75, 0x74, 0x52, 0x06, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x73, 0x12, 0x31, 0x0a, 0x07, 0x6f, 0x75, - 0x74, 0x70, 0x75, 0x74, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x6e, 0x6f, - 0x67, 0x68, 0x2e, 0x49, 0x73, 0x73, 0x75, 0x65, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4f, 0x75, - 0x74, 0x70, 0x75, 0x74, 0x52, 0x07, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x73, 0x12, 0x21, 0x0a, - 0x05, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x6e, - 0x6f, 0x67, 0x68, 0x2e, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x52, 0x05, 0x70, 0x72, 0x6f, 0x6f, 0x66, - 0x12, 0x3b, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x06, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x6e, 0x6f, 0x67, 0x68, 0x2e, 0x49, 0x73, 0x73, 0x75, 0x65, 0x41, - 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, - 0x74, 0x72, 0x79, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x1a, 0x3b, 0x0a, - 0x0d, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, - 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, - 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, - 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x59, 0x5a, 0x57, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x79, 0x70, 0x65, 0x72, 0x6c, 0x65, - 0x64, 0x67, 0x65, 0x72, 0x2d, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x66, 0x61, 0x62, 0x72, 0x69, 0x63, - 0x2d, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, - 0x2f, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x7a, 0x6b, 0x61, 0x74, 0x64, 0x6c, 0x6f, 0x67, 0x2f, 0x6e, - 0x6f, 0x67, 0x68, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2d, 0x67, 0x6f, 0x2f, 0x61, 0x63, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} +const file_noghactions_proto_rawDesc = "" + + "\n" + + "\x11noghactions.proto\x12\x04nogh\x1a\x0enoghmath.proto\x1a\x0fftactions.proto\x1a\fnoghpp.proto\";\n" + + "\x05Token\x12\x14\n" + + "\x05owner\x18\x01 \x01(\fR\x05owner\x12\x1c\n" + + "\x04data\x18\x02 \x01(\v2\b.nogh.G1R\x04data\"\x9e\x01\n" + + "\rTokenMetadata\x12\x12\n" + + "\x04type\x18\x01 \x01(\tR\x04type\x12\x1e\n" + + "\x05value\x18\x02 \x01(\v2\b.nogh.ZrR\x05value\x121\n" + + "\x0fblinding_factor\x18\x03 \x01(\v2\b.nogh.ZrR\x0eblindingFactor\x12&\n" + + "\x06issuer\x18\x04 \x01(\v2\x0e.nogh.IdentityR\x06issuer\"/\n" + + "\aTokenID\x12\x0e\n" + + "\x02id\x18\x01 \x01(\tR\x02id\x12\x14\n" + + "\x05index\x18\x02 \x01(\x04R\x05index\"\xb4\x01\n" + + "\x13TransferActionInput\x12(\n" + + "\btoken_id\x18\x01 \x01(\v2\r.nogh.TokenIDR\atokenId\x12!\n" + + "\x05input\x18\x02 \x01(\v2\v.nogh.TokenR\x05input\x12P\n" + + "\x0fupgrade_witness\x18\x03 \x01(\v2'.nogh.TransferActionInputUpgradeWitnessR\x0eupgradeWitness\"\x7f\n" + + "!TransferActionInputUpgradeWitness\x12'\n" + + "\x06output\x18\x01 \x01(\v2\x0f.fabtoken.TokenR\x06output\x121\n" + + "\x0fblinding_factor\x18\x02 \x01(\v2\b.nogh.ZrR\x0eblindingFactor\"9\n" + + "\x14TransferActionOutput\x12!\n" + + "\x05token\x18\x01 \x01(\v2\v.nogh.TokenR\x05token\"\x1d\n" + + "\x05Proof\x12\x14\n" + + "\x05proof\x18\x01 \x01(\fR\x05proof\"\xdb\x02\n" + + "\x0eTransferAction\x12\x18\n" + + "\aversion\x18\x01 \x01(\x04R\aversion\x121\n" + + "\x06inputs\x18\x02 \x03(\v2\x19.nogh.TransferActionInputR\x06inputs\x124\n" + + "\aoutputs\x18\x03 \x03(\v2\x1a.nogh.TransferActionOutputR\aoutputs\x12!\n" + + "\x05proof\x18\x04 \x01(\v2\v.nogh.ProofR\x05proof\x12>\n" + + "\bmetadata\x18\x05 \x03(\v2\".nogh.TransferAction.MetadataEntryR\bmetadata\x12&\n" + + "\x06issuer\x18\x06 \x01(\v2\x0e.nogh.IdentityR\x06issuer\x1a;\n" + + "\rMetadataEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + + "\x05value\x18\x02 \x01(\fR\x05value:\x028\x01\"G\n" + + "\x10IssueActionInput\x12\x1d\n" + + "\x02id\x18\x01 \x01(\v2\r.nogh.TokenIDR\x02id\x12\x14\n" + + "\x05token\x18\x02 \x01(\fR\x05token\"6\n" + + "\x11IssueActionOutput\x12!\n" + + "\x05token\x18\x01 \x01(\v2\v.nogh.TokenR\x05token\"\xcf\x02\n" + + "\vIssueAction\x12\x18\n" + + "\aversion\x18\x01 \x01(\x04R\aversion\x12&\n" + + "\x06issuer\x18\x02 \x01(\v2\x0e.nogh.IdentityR\x06issuer\x12.\n" + + "\x06inputs\x18\x03 \x03(\v2\x16.nogh.IssueActionInputR\x06inputs\x121\n" + + "\aoutputs\x18\x04 \x03(\v2\x17.nogh.IssueActionOutputR\aoutputs\x12!\n" + + "\x05proof\x18\x05 \x01(\v2\v.nogh.ProofR\x05proof\x12;\n" + + "\bmetadata\x18\x06 \x03(\v2\x1f.nogh.IssueAction.MetadataEntryR\bmetadata\x1a;\n" + + "\rMetadataEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + + "\x05value\x18\x02 \x01(\fR\x05value:\x028\x01BYZWgithub.com/hyperledger-labs/fabric-token-sdk/token/core/zkatdlog/nogh/protos-go/actionsb\x06proto3" var ( file_noghactions_proto_rawDescOnce sync.Once - file_noghactions_proto_rawDescData = file_noghactions_proto_rawDesc + file_noghactions_proto_rawDescData []byte ) func file_noghactions_proto_rawDescGZIP() []byte { file_noghactions_proto_rawDescOnce.Do(func() { - file_noghactions_proto_rawDescData = protoimpl.X.CompressGZIP(file_noghactions_proto_rawDescData) + file_noghactions_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_noghactions_proto_rawDesc), len(file_noghactions_proto_rawDesc))) }) return file_noghactions_proto_rawDescData } @@ -874,145 +786,11 @@ func file_noghactions_proto_init() { if File_noghactions_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_noghactions_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Token); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_noghactions_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*TokenMetadata); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_noghactions_proto_msgTypes[2].Exporter = func(v any, i int) any { - switch v := v.(*TokenID); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_noghactions_proto_msgTypes[3].Exporter = func(v any, i int) any { - switch v := v.(*TransferActionInput); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_noghactions_proto_msgTypes[4].Exporter = func(v any, i int) any { - switch v := v.(*TransferActionInputUpgradeWitness); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_noghactions_proto_msgTypes[5].Exporter = func(v any, i int) any { - switch v := v.(*TransferActionOutput); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_noghactions_proto_msgTypes[6].Exporter = func(v any, i int) any { - switch v := v.(*Proof); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_noghactions_proto_msgTypes[7].Exporter = func(v any, i int) any { - switch v := v.(*TransferAction); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_noghactions_proto_msgTypes[8].Exporter = func(v any, i int) any { - switch v := v.(*IssueActionInput); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_noghactions_proto_msgTypes[9].Exporter = func(v any, i int) any { - switch v := v.(*IssueActionOutput); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_noghactions_proto_msgTypes[10].Exporter = func(v any, i int) any { - switch v := v.(*IssueAction); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_noghactions_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_noghactions_proto_rawDesc), len(file_noghactions_proto_rawDesc)), NumEnums: 0, NumMessages: 13, NumExtensions: 0, @@ -1023,7 +801,6 @@ func file_noghactions_proto_init() { MessageInfos: file_noghactions_proto_msgTypes, }.Build() File_noghactions_proto = out.File - file_noghactions_proto_rawDesc = nil file_noghactions_proto_goTypes = nil file_noghactions_proto_depIdxs = nil } diff --git a/token/core/zkatdlog/nogh/protos-go/math/noghmath.pb.go b/token/core/zkatdlog/nogh/protos-go/math/noghmath.pb.go index 982fb94161..6ec6578bf6 100644 --- a/token/core/zkatdlog/nogh/protos-go/math/noghmath.pb.go +++ b/token/core/zkatdlog/nogh/protos-go/math/noghmath.pb.go @@ -5,7 +5,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.33.0 +// protoc-gen-go v1.36.6 // protoc v5.28.1 // source: noghmath.proto @@ -14,6 +14,7 @@ package math import ( reflect "reflect" sync "sync" + unsafe "unsafe" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" @@ -27,20 +28,17 @@ const ( ) type G1 struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Raw []byte `protobuf:"bytes,1,opt,name=raw,proto3" json:"raw,omitempty"` unknownFields protoimpl.UnknownFields - - Raw []byte `protobuf:"bytes,1,opt,name=raw,proto3" json:"raw,omitempty"` + sizeCache protoimpl.SizeCache } func (x *G1) Reset() { *x = G1{} - if protoimpl.UnsafeEnabled { - mi := &file_noghmath_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_noghmath_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *G1) String() string { @@ -51,7 +49,7 @@ func (*G1) ProtoMessage() {} func (x *G1) ProtoReflect() protoreflect.Message { mi := &file_noghmath_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -74,20 +72,17 @@ func (x *G1) GetRaw() []byte { } type Zr struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Raw []byte `protobuf:"bytes,1,opt,name=raw,proto3" json:"raw,omitempty"` unknownFields protoimpl.UnknownFields - - Raw []byte `protobuf:"bytes,1,opt,name=raw,proto3" json:"raw,omitempty"` + sizeCache protoimpl.SizeCache } func (x *Zr) Reset() { *x = Zr{} - if protoimpl.UnsafeEnabled { - mi := &file_noghmath_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_noghmath_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Zr) String() string { @@ -98,7 +93,7 @@ func (*Zr) ProtoMessage() {} func (x *Zr) ProtoReflect() protoreflect.Message { mi := &file_noghmath_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -121,20 +116,17 @@ func (x *Zr) GetRaw() []byte { } type CurveID struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` unknownFields protoimpl.UnknownFields - - Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + sizeCache protoimpl.SizeCache } func (x *CurveID) Reset() { *x = CurveID{} - if protoimpl.UnsafeEnabled { - mi := &file_noghmath_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_noghmath_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *CurveID) String() string { @@ -145,7 +137,7 @@ func (*CurveID) ProtoMessage() {} func (x *CurveID) ProtoReflect() protoreflect.Message { mi := &file_noghmath_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -169,36 +161,30 @@ func (x *CurveID) GetId() uint64 { var File_noghmath_proto protoreflect.FileDescriptor -var file_noghmath_proto_rawDesc = []byte{ - 0x0a, 0x0e, 0x6e, 0x6f, 0x67, 0x68, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x12, 0x04, 0x6e, 0x6f, 0x67, 0x68, 0x22, 0x16, 0x0a, 0x02, 0x47, 0x31, 0x12, 0x10, 0x0a, 0x03, - 0x72, 0x61, 0x77, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x72, 0x61, 0x77, 0x22, 0x16, - 0x0a, 0x02, 0x5a, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x72, 0x61, 0x77, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0c, 0x52, 0x03, 0x72, 0x61, 0x77, 0x22, 0x19, 0x0a, 0x07, 0x43, 0x75, 0x72, 0x76, 0x65, 0x49, - 0x44, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x02, 0x69, - 0x64, 0x42, 0x56, 0x5a, 0x54, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x68, 0x79, 0x70, 0x65, 0x72, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x72, 0x2d, 0x6c, 0x61, 0x62, 0x73, - 0x2f, 0x66, 0x61, 0x62, 0x72, 0x69, 0x63, 0x2d, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x2d, 0x73, 0x64, - 0x6b, 0x2f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x2f, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x7a, 0x6b, 0x61, - 0x74, 0x64, 0x6c, 0x6f, 0x67, 0x2f, 0x6e, 0x6f, 0x67, 0x68, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x73, 0x2d, 0x67, 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, -} +const file_noghmath_proto_rawDesc = "" + + "\n" + + "\x0enoghmath.proto\x12\x04nogh\"\x16\n" + + "\x02G1\x12\x10\n" + + "\x03raw\x18\x01 \x01(\fR\x03raw\"\x16\n" + + "\x02Zr\x12\x10\n" + + "\x03raw\x18\x01 \x01(\fR\x03raw\"\x19\n" + + "\aCurveID\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x04R\x02idBVZTgithub.com/hyperledger-labs/fabric-token-sdk/token/core/zkatdlog/nogh/protos-go/mathb\x06proto3" var ( file_noghmath_proto_rawDescOnce sync.Once - file_noghmath_proto_rawDescData = file_noghmath_proto_rawDesc + file_noghmath_proto_rawDescData []byte ) func file_noghmath_proto_rawDescGZIP() []byte { file_noghmath_proto_rawDescOnce.Do(func() { - file_noghmath_proto_rawDescData = protoimpl.X.CompressGZIP(file_noghmath_proto_rawDescData) + file_noghmath_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_noghmath_proto_rawDesc), len(file_noghmath_proto_rawDesc))) }) return file_noghmath_proto_rawDescData } var file_noghmath_proto_msgTypes = make([]protoimpl.MessageInfo, 3) -var file_noghmath_proto_goTypes = []interface{}{ +var file_noghmath_proto_goTypes = []any{ (*G1)(nil), // 0: nogh.G1 (*Zr)(nil), // 1: nogh.Zr (*CurveID)(nil), // 2: nogh.CurveID @@ -216,49 +202,11 @@ func file_noghmath_proto_init() { if File_noghmath_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_noghmath_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*G1); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_noghmath_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Zr); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_noghmath_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CurveID); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_noghmath_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_noghmath_proto_rawDesc), len(file_noghmath_proto_rawDesc)), NumEnums: 0, NumMessages: 3, NumExtensions: 0, @@ -269,7 +217,6 @@ func file_noghmath_proto_init() { MessageInfos: file_noghmath_proto_msgTypes, }.Build() File_noghmath_proto = out.File - file_noghmath_proto_rawDesc = nil file_noghmath_proto_goTypes = nil file_noghmath_proto_depIdxs = nil } diff --git a/token/core/zkatdlog/nogh/protos-go/pp/noghpp.pb.go b/token/core/zkatdlog/nogh/protos-go/pp/noghpp.pb.go index de84b41fc5..9e03a6f705 100644 --- a/token/core/zkatdlog/nogh/protos-go/pp/noghpp.pb.go +++ b/token/core/zkatdlog/nogh/protos-go/pp/noghpp.pb.go @@ -211,16 +211,17 @@ func (x *RangeProofParams) GetNumberOfRounds() uint64 { // PublicParameters describes typed public parameters type PublicParameters struct { state protoimpl.MessageState `protogen:"open.v1"` - TokenDriverName string `protobuf:"bytes,1,opt,name=token_driver_name,json=tokenDriverName,proto3" json:"token_driver_name,omitempty"` // the identifier of the token driver - TokenDriverVersion uint64 `protobuf:"varint,2,opt,name=token_driver_version,json=tokenDriverVersion,proto3" json:"token_driver_version,omitempty"` // the version of the token driver - CurveId *math.CurveID `protobuf:"bytes,3,opt,name=curve_id,json=curveId,proto3" json:"curve_id,omitempty"` // the pairing-friendly elliptic curve used for everything but Idemix. - PedersenGenerators []*math.G1 `protobuf:"bytes,4,rep,name=pedersen_generators,json=pedersenGenerators,proto3" json:"pedersen_generators,omitempty"` // contains the public parameters for the Pedersen commitment scheme. - RangeProofParams *RangeProofParams `protobuf:"bytes,5,opt,name=range_proof_params,json=rangeProofParams,proto3" json:"range_proof_params,omitempty"` // contains the public parameters for the range proof scheme. - IdemixIssuerPublicKeys []*IdemixIssuerPublicKey `protobuf:"bytes,6,rep,name=idemix_issuer_public_keys,json=idemixIssuerPublicKeys,proto3" json:"idemix_issuer_public_keys,omitempty"` // contains the idemix issuer public keys. Wallets should prefer the use of keys valid under the public key whose index in the array is the smallest. - Auditors []*Identity `protobuf:"bytes,7,rep,name=auditors,proto3" json:"auditors,omitempty"` // is the public key of the auditor. - Issuers []*Identity `protobuf:"bytes,8,rep,name=issuers,proto3" json:"issuers,omitempty"` // is a list of public keys of the entities that can issue tokens. - MaxToken uint64 `protobuf:"varint,9,opt,name=max_token,json=maxToken,proto3" json:"max_token,omitempty"` // is the maximum quantity a token can hold - QuantityPrecision uint64 `protobuf:"varint,10,opt,name=quantity_precision,json=quantityPrecision,proto3" json:"quantity_precision,omitempty"` // is the precision used to represent quantities + TokenDriverName string `protobuf:"bytes,1,opt,name=token_driver_name,json=tokenDriverName,proto3" json:"token_driver_name,omitempty"` // the identifier of the token driver + TokenDriverVersion uint64 `protobuf:"varint,2,opt,name=token_driver_version,json=tokenDriverVersion,proto3" json:"token_driver_version,omitempty"` // the version of the token driver + CurveId *math.CurveID `protobuf:"bytes,3,opt,name=curve_id,json=curveId,proto3" json:"curve_id,omitempty"` // the pairing-friendly elliptic curve used for everything but Idemix. + PedersenGenerators []*math.G1 `protobuf:"bytes,4,rep,name=pedersen_generators,json=pedersenGenerators,proto3" json:"pedersen_generators,omitempty"` // contains the public parameters for the Pedersen commitment scheme. + RangeProofParams *RangeProofParams `protobuf:"bytes,5,opt,name=range_proof_params,json=rangeProofParams,proto3" json:"range_proof_params,omitempty"` // contains the public parameters for the range proof scheme. + IdemixIssuerPublicKeys []*IdemixIssuerPublicKey `protobuf:"bytes,6,rep,name=idemix_issuer_public_keys,json=idemixIssuerPublicKeys,proto3" json:"idemix_issuer_public_keys,omitempty"` // contains the idemix issuer public keys. Wallets should prefer the use of keys valid under the public key whose index in the array is the smallest. + Auditors []*Identity `protobuf:"bytes,7,rep,name=auditors,proto3" json:"auditors,omitempty"` // is the public key of the auditor. + Issuers []*Identity `protobuf:"bytes,8,rep,name=issuers,proto3" json:"issuers,omitempty"` // is a list of public keys of the entities that can issue tokens. + MaxToken uint64 `protobuf:"varint,9,opt,name=max_token,json=maxToken,proto3" json:"max_token,omitempty"` // is the maximum quantity a token can hold + QuantityPrecision uint64 `protobuf:"varint,10,opt,name=quantity_precision,json=quantityPrecision,proto3" json:"quantity_precision,omitempty"` // is the precision used to represent quantities + ExtraData map[string][]byte `protobuf:"bytes,11,rep,name=extra_data,json=extraData,proto3" json:"extra_data,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` // extra_data allows to store arbitrary data in the public parameters unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -325,6 +326,13 @@ func (x *PublicParameters) GetQuantityPrecision() uint64 { return 0 } +func (x *PublicParameters) GetExtraData() map[string][]byte { + if x != nil { + return x.ExtraData + } + return nil +} + var File_noghpp_proto protoreflect.FileDescriptor const file_noghpp_proto_rawDesc = "" + @@ -343,7 +351,7 @@ const file_noghpp_proto_rawDesc = "" + "\x01Q\x18\x04 \x01(\v2\b.nogh.G1R\x01Q\x12\x1d\n" + "\n" + "bit_length\x18\x05 \x01(\x04R\tbitLength\x12(\n" + - "\x10number_of_rounds\x18\x06 \x01(\x04R\x0enumberOfRounds\"\x95\x04\n" + + "\x10number_of_rounds\x18\x06 \x01(\x04R\x0enumberOfRounds\"\x99\x05\n" + "\x10PublicParameters\x12*\n" + "\x11token_driver_name\x18\x01 \x01(\tR\x0ftokenDriverName\x120\n" + "\x14token_driver_version\x18\x02 \x01(\x04R\x12tokenDriverVersion\x12(\n" + @@ -355,7 +363,12 @@ const file_noghpp_proto_rawDesc = "" + "\aissuers\x18\b \x03(\v2\x0e.nogh.IdentityR\aissuers\x12\x1b\n" + "\tmax_token\x18\t \x01(\x04R\bmaxToken\x12-\n" + "\x12quantity_precision\x18\n" + - " \x01(\x04R\x11quantityPrecisionBTZRgithub.com/hyperledger-labs/fabric-token-sdk/token/core/zkatdlog/nogh/protos-go/ppb\x06proto3" + " \x01(\x04R\x11quantityPrecision\x12D\n" + + "\n" + + "extra_data\x18\v \x03(\v2%.nogh.PublicParameters.ExtraDataEntryR\textraData\x1a<\n" + + "\x0eExtraDataEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + + "\x05value\x18\x02 \x01(\fR\x05value:\x028\x01BTZRgithub.com/hyperledger-labs/fabric-token-sdk/token/core/zkatdlog/nogh/protos-go/ppb\x06proto3" var ( file_noghpp_proto_rawDescOnce sync.Once @@ -369,32 +382,34 @@ func file_noghpp_proto_rawDescGZIP() []byte { return file_noghpp_proto_rawDescData } -var file_noghpp_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_noghpp_proto_msgTypes = make([]protoimpl.MessageInfo, 5) var file_noghpp_proto_goTypes = []any{ (*Identity)(nil), // 0: nogh.Identity (*IdemixIssuerPublicKey)(nil), // 1: nogh.IdemixIssuerPublicKey (*RangeProofParams)(nil), // 2: nogh.RangeProofParams (*PublicParameters)(nil), // 3: nogh.PublicParameters - (*math.CurveID)(nil), // 4: nogh.CurveID - (*math.G1)(nil), // 5: nogh.G1 + nil, // 4: nogh.PublicParameters.ExtraDataEntry + (*math.CurveID)(nil), // 5: nogh.CurveID + (*math.G1)(nil), // 6: nogh.G1 } var file_noghpp_proto_depIdxs = []int32{ - 4, // 0: nogh.IdemixIssuerPublicKey.curver_id:type_name -> nogh.CurveID - 5, // 1: nogh.RangeProofParams.left_generators:type_name -> nogh.G1 - 5, // 2: nogh.RangeProofParams.right_generators:type_name -> nogh.G1 - 5, // 3: nogh.RangeProofParams.P:type_name -> nogh.G1 - 5, // 4: nogh.RangeProofParams.Q:type_name -> nogh.G1 - 4, // 5: nogh.PublicParameters.curve_id:type_name -> nogh.CurveID - 5, // 6: nogh.PublicParameters.pedersen_generators:type_name -> nogh.G1 + 5, // 0: nogh.IdemixIssuerPublicKey.curver_id:type_name -> nogh.CurveID + 6, // 1: nogh.RangeProofParams.left_generators:type_name -> nogh.G1 + 6, // 2: nogh.RangeProofParams.right_generators:type_name -> nogh.G1 + 6, // 3: nogh.RangeProofParams.P:type_name -> nogh.G1 + 6, // 4: nogh.RangeProofParams.Q:type_name -> nogh.G1 + 5, // 5: nogh.PublicParameters.curve_id:type_name -> nogh.CurveID + 6, // 6: nogh.PublicParameters.pedersen_generators:type_name -> nogh.G1 2, // 7: nogh.PublicParameters.range_proof_params:type_name -> nogh.RangeProofParams 1, // 8: nogh.PublicParameters.idemix_issuer_public_keys:type_name -> nogh.IdemixIssuerPublicKey 0, // 9: nogh.PublicParameters.auditors:type_name -> nogh.Identity 0, // 10: nogh.PublicParameters.issuers:type_name -> nogh.Identity - 11, // [11:11] is the sub-list for method output_type - 11, // [11:11] is the sub-list for method input_type - 11, // [11:11] is the sub-list for extension type_name - 11, // [11:11] is the sub-list for extension extendee - 0, // [0:11] is the sub-list for field type_name + 4, // 11: nogh.PublicParameters.extra_data:type_name -> nogh.PublicParameters.ExtraDataEntry + 12, // [12:12] is the sub-list for method output_type + 12, // [12:12] is the sub-list for method input_type + 12, // [12:12] is the sub-list for extension type_name + 12, // [12:12] is the sub-list for extension extendee + 0, // [0:12] is the sub-list for field type_name } func init() { file_noghpp_proto_init() } @@ -408,7 +423,7 @@ func file_noghpp_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_noghpp_proto_rawDesc), len(file_noghpp_proto_rawDesc)), NumEnums: 0, - NumMessages: 4, + NumMessages: 5, NumExtensions: 0, NumServices: 0, }, diff --git a/token/core/zkatdlog/nogh/protos/noghpp.proto b/token/core/zkatdlog/nogh/protos/noghpp.proto index 023080d1e3..33c44afd46 100644 --- a/token/core/zkatdlog/nogh/protos/noghpp.proto +++ b/token/core/zkatdlog/nogh/protos/noghpp.proto @@ -42,4 +42,5 @@ message PublicParameters { 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 uint64 quantity_precision = 10; // is the precision used to represent quantities + map extra_data = 11; // extra_data allows to store arbitrary data in the public parameters } \ No newline at end of file diff --git a/token/core/zkatdlog/nogh/v1/setup/setup.go b/token/core/zkatdlog/nogh/v1/setup/setup.go index f042da6211..41658a496d 100644 --- a/token/core/zkatdlog/nogh/v1/setup/setup.go +++ b/token/core/zkatdlog/nogh/v1/setup/setup.go @@ -178,6 +178,8 @@ type PublicParams struct { MaxToken uint64 // QuantityPrecision is the precision used to represent quantities QuantityPrecision uint64 + // ExtraData contains any extra custom data + ExtraData driver.Extras } func NewPublicParamsFromBytes( @@ -198,8 +200,8 @@ func Setup(bitLength uint64, idemixIssuerPK []byte, idemixCurveID mathlib.CurveI return NewWith(DLogNoGHDriverName, ProtocolV1, bitLength, idemixIssuerPK, idemixCurveID) } -// SetupWithVersion is like Setup with the additional possibility to specify the version number -func SetupWithVersion(bitLength uint64, idemixIssuerPK []byte, idemixCurveID mathlib.CurveID, version driver.TokenDriverVersion) (*PublicParams, error) { +// WithVersion is like Setup with the additional possibility to specify the version number +func WithVersion(bitLength uint64, idemixIssuerPK []byte, idemixCurveID mathlib.CurveID, version driver.TokenDriverVersion) (*PublicParams, error) { return NewWith(DLogNoGHDriverName, version, bitLength, idemixIssuerPK, idemixCurveID) } @@ -221,6 +223,7 @@ func NewWith(driverName driver.TokenDriverName, driverVersion driver.TokenDriver }, }, QuantityPrecision: bitLength, + ExtraData: driver.Extras{}, } if err := pp.GeneratePedersenParameters(); err != nil { return nil, errors.Wrapf(err, "failed to generated pedersen parameters") @@ -276,6 +279,9 @@ func (p *PublicParams) Precision() uint64 { } func (p *PublicParams) Serialize() ([]byte, error) { + if err := p.Validate(); err != nil { + return nil, errors.Wrapf(err, "failed to serialize public parameters") + } pg, err := utils2.ToProtoG1Slice(p.PedersenGenerators) if err != nil { return nil, errors.Wrapf(err, "failed to serialize public parameters") @@ -318,6 +324,7 @@ func (p *PublicParams) Serialize() ([]byte, error) { Issuers: issuers, MaxToken: p.MaxToken, QuantityPrecision: p.QuantityPrecision, + ExtraData: p.ExtraData, } raw, err := proto.Marshal(publicParams) if err != nil { @@ -393,6 +400,11 @@ func (p *PublicParams) Deserialize(raw []byte) error { return errors.Wrapf(err, "failed to deserialize range proof parameters") } + p.ExtraData = publicParams.ExtraData + if p.ExtraData == nil { + p.ExtraData = driver.Extras{} + } + return nil } @@ -477,13 +489,13 @@ func (p *PublicParams) String() string { } // Validate validates the public parameters. -// The list of issues can be empty meaning that anyone can create tokens. +// The list of issuers can be empty meaning that anyone can create tokens. func (p *PublicParams) Validate() error { if int(p.Curve) > len(mathlib.Curves)-1 { return errors.Errorf("invalid public parameters: invalid curveID [%d > %d]", int(p.Curve), len(mathlib.Curves)-1) } - if len(p.IdemixIssuerPublicKeys) != 1 { - return errors.Errorf("expected one idemix issuer public key, found [%d]", len(p.IdemixIssuerPublicKeys)) + if len(p.IdemixIssuerPublicKeys) == 0 { + return errors.Errorf("expected at least one idemix issuer public key, found [%d]", len(p.IdemixIssuerPublicKeys)) } for _, issuer := range p.IdemixIssuerPublicKeys { @@ -522,6 +534,10 @@ func (p *PublicParams) Validate() error { return nil } +func (p *PublicParams) Extras() driver.Extras { + return p.ExtraData +} + func log2(x uint64) uint64 { return 63 - uint64(bits.LeadingZeros64(x)) } diff --git a/token/core/zkatdlog/nogh/v1/setup/setup_test.go b/token/core/zkatdlog/nogh/v1/setup/setup_test.go index 042e0d79e0..0c62a4c3dd 100644 --- a/token/core/zkatdlog/nogh/v1/setup/setup_test.go +++ b/token/core/zkatdlog/nogh/v1/setup/setup_test.go @@ -6,42 +6,68 @@ SPDX-License-Identifier: Apache-2.0 package setup import ( + "encoding/json" + "fmt" "os" "testing" math3 "github.com/IBM/mathlib" "github.com/hyperledger-labs/fabric-token-sdk/token/driver" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) -func TestSerialization(t *testing.T) { - issuerPK, err := os.ReadFile("./testdata/idemix/msp/IssuerPublicKey") - assert.NoError(t, err) - pp, err := Setup(32, issuerPK, math3.BN254) - assert.NoError(t, err) - - ser, err := pp.Serialize() - assert.NoError(t, err) +// testingHelper is a test helper for creating test data +func testingHelper(t *testing.T) []byte { + t.Helper() + issuerPK, err := os.ReadFile("testdata/idemix/msp/IssuerPublicKey") + require.NoError(t, err) + require.NotEmpty(t, issuerPK) + return issuerPK +} - pp2, err := NewPublicParamsFromBytes(ser, DLogNoGHDriverName, ProtocolV1) - assert.NoError(t, err) +func TestSerialization(t *testing.T) { + t.Run("extras is not empty", func(t *testing.T) { + issuerPK := testingHelper(t) + pp, err := Setup(32, issuerPK, math3.BN254) + assert.NoError(t, err) + assert.NotNil(t, pp.Extras()) + ser, err := pp.Serialize() + assert.NoError(t, err) + pp2, err := NewPublicParamsFromBytes(ser, DLogNoGHDriverName, ProtocolV1) + assert.NoError(t, err) + assert.NotNil(t, pp2.Extras()) + }) - ser2, err := pp2.Serialize() - assert.NoError(t, err) + t.Run("valid setup", func(t *testing.T) { + // Use test helper instead of direct file read + issuerPK := testingHelper(t) + pp, err := Setup(32, issuerPK, math3.BN254) + assert.NoError(t, err) + assert.NotNil(t, pp.Extras()) + pp.ExtraData = map[string][]byte{ + "key1": []byte("value1"), + "key2": []byte("value2"), + } + assert.NoError(t, err) + ser, err := pp.Serialize() + assert.NoError(t, err) - assert.Equal(t, pp.IdemixIssuerPublicKeys, pp2.IdemixIssuerPublicKeys) - assert.Equal(t, pp.PedersenGenerators, pp2.PedersenGenerators) - assert.Equal(t, pp.RangeProofParams, pp2.RangeProofParams) + pp2, err := NewPublicParamsFromBytes(ser, DLogNoGHDriverName, ProtocolV1) + assert.NoError(t, err) + assert.Equal(t, pp, pp2) + assert.NotNil(t, pp2.Extras()) - assert.Equal(t, pp, pp2) - assert.Equal(t, ser, ser2) + _, err = pp2.Serialize() + assert.NoError(t, err) - // no issuers - assert.NoError(t, pp.Validate()) + // no issuers + assert.NoError(t, pp.Validate()) - // with issuers - pp.IssuerIDs = []driver.Identity{[]byte("issuer")} - assert.NoError(t, pp.Validate()) + // with issuers + pp.IssuerIDs = []driver.Identity{[]byte("issuer")} + assert.NoError(t, pp.Validate()) + }) } func TestComputeMaxTokenValue(t *testing.T) { @@ -68,3 +94,583 @@ func TestNewG1(t *testing.T) { assert.True(t, c.NewG1().IsInfinity()) } } + +func TestRangeProofParamsValidation(t *testing.T) { + curve := math3.BN254 + curveInst := math3.Curves[curve] + + // Create generators of the correct length + makeGenerators := func(length uint64) []*math3.G1 { + gen := make([]*math3.G1, length) + for i := range gen { + gen[i] = curveInst.GenG1 + } + return gen + } + + tests := []struct { + name string + params *RangeProofParams + expectedError string + }{ + { + name: "valid params", + params: &RangeProofParams{ + BitLength: 16, + NumberOfRounds: 4, + P: curveInst.GenG1, + Q: curveInst.GenG1, + LeftGenerators: makeGenerators(16), + RightGenerators: makeGenerators(16), + }, + expectedError: "", + }, + { + name: "zero bit length", + params: &RangeProofParams{ + BitLength: 0, + NumberOfRounds: 4, + P: curveInst.GenG1, + Q: curveInst.GenG1, + }, + expectedError: "invalid range proof parameters: bit length is zero", + }, + { + name: "zero rounds", + params: &RangeProofParams{ + BitLength: 16, + NumberOfRounds: 0, + P: curveInst.GenG1, + Q: curveInst.GenG1, + }, + expectedError: "invalid range proof parameters: number of rounds is zero", + }, + { + name: "too many rounds", + params: &RangeProofParams{ + BitLength: 16, + NumberOfRounds: 65, + P: curveInst.GenG1, + Q: curveInst.GenG1, + }, + expectedError: "invalid range proof parameters: number of rounds must be smaller or equal to 64", + }, + { + name: "mismatched generator lengths", + params: &RangeProofParams{ + BitLength: 16, + NumberOfRounds: 4, + P: curveInst.GenG1, + Q: curveInst.GenG1, + LeftGenerators: makeGenerators(15), + RightGenerators: makeGenerators(16), + }, + expectedError: "invalid range proof parameters: the size of the left generators does not match the size of the right generators", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.params.Validate(curve) + if tt.expectedError == "" { + assert.NoError(t, err) + } else { + assert.Contains(t, err.Error(), tt.expectedError) + } + }) + } +} + +func TestIdemixIssuerPublicKeyConversion(t *testing.T) { + original := &IdemixIssuerPublicKey{ + PublicKey: []byte("test-key"), + Curve: math3.BN254, + } + + proto, err := original.ToProtos() + require.NoError(t, err) + + recovered := &IdemixIssuerPublicKey{} + err = recovered.FromProtos(proto) + require.NoError(t, err) + + assert.Equal(t, original.PublicKey, recovered.PublicKey) + assert.Equal(t, original.Curve, recovered.Curve) +} + +func TestSetupWithInvalidParameters(t *testing.T) { + tests := []struct { + name string + bitLength uint64 + expectedError string + }{ + { + name: "bit length too large", + bitLength: 65, + expectedError: "invalid bit length [65], should be smaller than 64", + }, + { + name: "zero bit length", + bitLength: 0, + expectedError: "invalid bit length, should be greater than 0", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + _, err := Setup(tt.bitLength, []byte("test-key"), math3.BN254) + assert.Contains(t, err.Error(), tt.expectedError) + }) + } +} + +func TestPublicParamsModification(t *testing.T) { + pp, err := Setup(32, testingHelper(t), math3.BN254) + require.NoError(t, err) + + // Test AddAuditor + auditor1 := driver.Identity("auditor1") + auditor2 := driver.Identity("auditor2") + pp.AddAuditor(auditor1) + pp.AddAuditor(auditor2) + assert.Equal(t, []driver.Identity{auditor1, auditor2}, pp.Auditors()) + + // Test SetAuditors + newAuditors := []driver.Identity{driver.Identity("newAuditor")} + pp.SetAuditors(newAuditors) + assert.Equal(t, newAuditors, pp.Auditors()) + + // Test AddIssuer + issuer1 := driver.Identity("issuer1") + issuer2 := driver.Identity("issuer2") + pp.AddIssuer(issuer1) + pp.AddIssuer(issuer2) + assert.Equal(t, []driver.Identity{issuer1, issuer2}, pp.Issuers()) + + // Test SetIssuers + newIssuers := []driver.Identity{driver.Identity("newIssuer")} + pp.SetIssuers(newIssuers) + assert.Equal(t, newIssuers, pp.Issuers()) +} + +func TestPublicParamsValidation(t *testing.T) { + validIssuerPK := &IdemixIssuerPublicKey{ + PublicKey: []byte("valid-key"), + Curve: math3.BN254, + } + + tests := []struct { + name string + setupParams func() *PublicParams + expectedError string + }{ + { + name: "valid params", + setupParams: func() *PublicParams { + issuerPK := testingHelper(t) + pp, err := Setup(32, issuerPK, math3.BN254) + require.NoError(t, err) + return pp + }, + expectedError: "", + }, + { + name: "invalid curve ID", + setupParams: func() *PublicParams { + pp := &PublicParams{ + Curve: math3.CurveID(999), // Invalid curve ID + IdemixIssuerPublicKeys: []*IdemixIssuerPublicKey{validIssuerPK}, + } + return pp + }, + expectedError: "invalid public parameters: invalid curveID", + }, + { + name: "no idemix issuer public keys", + setupParams: func() *PublicParams { + pp := &PublicParams{ + Curve: math3.BN254, + IdemixIssuerPublicKeys: []*IdemixIssuerPublicKey{}, + } + return pp + }, + expectedError: "expected at least one idemix issuer public key", + }, + { + name: "nil idemix issuer public key", + setupParams: func() *PublicParams { + pp := &PublicParams{ + Curve: math3.BN254, + IdemixIssuerPublicKeys: []*IdemixIssuerPublicKey{nil}, + } + return pp + }, + expectedError: "invalid idemix issuer public key, it is nil", + }, + { + name: "empty idemix issuer public key", + setupParams: func() *PublicParams { + pp := &PublicParams{ + Curve: math3.BN254, + IdemixIssuerPublicKeys: []*IdemixIssuerPublicKey{ + { + PublicKey: []byte{}, + Curve: math3.BN254, + }, + }, + } + return pp + }, + expectedError: "expected idemix issuer public key to be non-empty", + }, + { + name: "invalid idemix curve ID", + setupParams: func() *PublicParams { + issuerPK := testingHelper(t) + pp, err := Setup(32, issuerPK, math3.BN254) + require.NoError(t, err) + pp.Curve = math3.CurveID(999) // Invalid curve ID + return pp + }, + expectedError: "invalid public parameters: invalid curveID [999 > 7]", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + pp := tt.setupParams() + err := pp.Validate() + if tt.expectedError == "" { + assert.NoError(t, err) + } else { + assert.Error(t, err) + assert.Contains(t, err.Error(), tt.expectedError) + } + }) + } +} + +func TestComputeHash(t *testing.T) { + pp, err := Setup(32, testingHelper(t), math3.BN254) + require.NoError(t, err) + + hash1, err := pp.ComputeHash() + require.NoError(t, err) + assert.NotEmpty(t, hash1) + + // Modify parameters and check hash changes + pp.AddIssuer(driver.Identity("newIssuer")) + hash2, err := pp.ComputeHash() + require.NoError(t, err) + assert.NotEqual(t, hash1, hash2) +} + +func TestWithVersion(t *testing.T) { + version := driver.TokenDriverVersion(2) + pp, err := WithVersion(32, testingHelper(t), math3.BN254, version) + require.NoError(t, err) + + assert.Equal(t, version, pp.TokenDriverVersion()) + assert.Equal(t, driver.TokenDriverName(DLogNoGHDriverName), pp.TokenDriverName()) +} + +func TestSerializationEdgeCases(t *testing.T) { + issuerPK := testingHelper(t) + pp, err := Setup(32, issuerPK, math3.BN254) + require.NoError(t, err) + + // Test invalid driver identifier + pp.DriverName = "invalid" + raw, err := pp.Serialize() + require.NoError(t, err) + _, err = NewPublicParamsFromBytes(raw, DLogNoGHDriverName, ProtocolV1) + assert.Error(t, err) + assert.Contains(t, err.Error(), "invalid identifier") + + // Test corrupted data + _, err = NewPublicParamsFromBytes([]byte("corrupted"), DLogNoGHDriverName, ProtocolV1) + assert.Error(t, err) + + // Test deserialize with invalid proto + _, err = NewPublicParamsFromBytes([]byte{0, 1, 2, 3}, DLogNoGHDriverName, ProtocolV1) + assert.Error(t, err) +} + +func TestPublicParamsString(t *testing.T) { + pp := &PublicParams{ + DriverName: DLogNoGHDriverName, + DriverVersion: ProtocolV1, + Curve: math3.BN254, + IdemixIssuerPublicKeys: []*IdemixIssuerPublicKey{ + { + PublicKey: []byte("test-key"), + Curve: math3.BN254, + }, + }, + AuditorIDs: []driver.Identity{[]byte("auditor1")}, + IssuerIDs: []driver.Identity{[]byte("issuer1")}, + ExtraData: map[string][]byte{ + "key": []byte("value"), + }, + } + + str := pp.String() + res, err := json.MarshalIndent(pp, " ", " ") + require.NoError(t, err) + assert.Equal(t, string(res), str) +} + +func TestRangeProofParamsGenerators(t *testing.T) { + curve := math3.BN254 + curveInst := math3.Curves[curve] + + // Test validation with nil generators + params := &RangeProofParams{ + BitLength: 16, + NumberOfRounds: 4, + P: curveInst.GenG1, + Q: curveInst.GenG1, + } + err := params.Validate(curve) + assert.Error(t, err) + assert.Contains(t, err.Error(), "invalid range proof parameters") + + // Test validation with nil P + params = &RangeProofParams{ + BitLength: 16, + NumberOfRounds: 4, + Q: curveInst.GenG1, + LeftGenerators: make([]*math3.G1, 16), + RightGenerators: make([]*math3.G1, 16), + } + err = params.Validate(curve) + assert.Error(t, err) + assert.Contains(t, err.Error(), "invalid range proof parameters") + + // Test validation with nil Q + params = &RangeProofParams{ + BitLength: 16, + NumberOfRounds: 4, + P: curveInst.GenG1, + LeftGenerators: make([]*math3.G1, 16), + RightGenerators: make([]*math3.G1, 16), + } + err = params.Validate(curve) + assert.Error(t, err) + assert.Contains(t, err.Error(), "invalid range proof parameters") +} + +func TestRangeProofParamsConversion(t *testing.T) { + curve := math3.BN254 + curveInst := math3.Curves[curve] + + original := &RangeProofParams{ + BitLength: 16, + NumberOfRounds: 4, + P: curveInst.GenG1, + Q: curveInst.GenG1, + LeftGenerators: []*math3.G1{curveInst.GenG1}, + RightGenerators: []*math3.G1{curveInst.GenG1}, + } + + proto, err := original.ToProtos() + require.NoError(t, err) + + recovered := &RangeProofParams{} + err = recovered.FromProto(proto) + require.NoError(t, err) + + assert.Equal(t, original.BitLength, recovered.BitLength) + assert.Equal(t, original.NumberOfRounds, recovered.NumberOfRounds) + assert.Equal(t, len(original.LeftGenerators), len(recovered.LeftGenerators)) + assert.Equal(t, len(original.RightGenerators), len(recovered.RightGenerators)) +} + +func TestGeneratePedersenParameters(t *testing.T) { + pp := &PublicParams{ + Curve: math3.BN254, + } + + err := pp.GeneratePedersenParameters() + require.NoError(t, err) + assert.Len(t, pp.PedersenGenerators, 3) + + // Test all generators are different + for i := 0; i < len(pp.PedersenGenerators); i++ { + for j := i + 1; j < len(pp.PedersenGenerators); j++ { + assert.False(t, pp.PedersenGenerators[i].Equals(pp.PedersenGenerators[j])) + } + } +} + +func TestGenerateRangeProofParameters(t *testing.T) { + pp := &PublicParams{ + Curve: math3.BN254, + } + + err := pp.GenerateRangeProofParameters(16) + require.NoError(t, err) + + assert.NotNil(t, pp.RangeProofParams) + assert.Equal(t, uint64(16), pp.RangeProofParams.BitLength) + assert.Equal(t, uint64(4), pp.RangeProofParams.NumberOfRounds) // log2(16) + assert.Len(t, pp.RangeProofParams.LeftGenerators, 16) + assert.Len(t, pp.RangeProofParams.RightGenerators, 16) + assert.NotNil(t, pp.RangeProofParams.P) + assert.NotNil(t, pp.RangeProofParams.Q) + + // Test that P and Q are different + assert.False(t, pp.RangeProofParams.P.Equals(pp.RangeProofParams.Q)) + + // Test all generators are different + for i, left := range pp.RangeProofParams.LeftGenerators { + for j, right := range pp.RangeProofParams.RightGenerators { + assert.False(t, left.Equals(right), "Left generator %d equals right generator %d", i, j) + } + } +} + +func TestFailedSerialization(t *testing.T) { + pp := &PublicParams{ + Curve: math3.CurveID(999), // Invalid curve + PedersenGenerators: []*math3.G1{nil}, // Invalid generator + } + + _, err := pp.Serialize() + assert.Error(t, err) + assert.Contains(t, err.Error(), "failed to serialize public parameters") +} + +func TestLog2(t *testing.T) { + tests := []struct { + input uint64 + expected uint64 + }{ + {1, 0}, + {2, 1}, + {4, 2}, + {8, 3}, + {16, 4}, + {32, 5}, + {64, 6}, + } + + for _, tt := range tests { + t.Run(fmt.Sprintf("log2(%d)", tt.input), func(t *testing.T) { + result := log2(tt.input) + assert.Equal(t, tt.expected, result) + }) + } +} + +func TestRangeProofParamsValidationWithMismatchedBitLength(t *testing.T) { + curve := math3.BN254 + curveInst := math3.Curves[curve] + + // Test when BitLength doesn't match the expected value based on NumberOfRounds + params := &RangeProofParams{ + BitLength: 32, // This should be 16 for NumberOfRounds=4 + NumberOfRounds: 4, + P: curveInst.GenG1, + Q: curveInst.GenG1, + LeftGenerators: make([]*math3.G1, 32), + RightGenerators: make([]*math3.G1, 32), + } + err := params.Validate(curve) + assert.Error(t, err) + assert.Contains(t, err.Error(), "invalid range proof parameters: bit length should be") +} + +func TestRangeProofParamsInvalidPoints(t *testing.T) { + curve := math3.BN254 + curveInst := math3.Curves[curve] + + // Create a point from another curve + invalidPoint := math3.Curves[math3.BLS12_381_BBS_GURVY].GenG1 + + issuerPK := testingHelper(t) + pp, err := Setup(32, issuerPK, math3.BN254) + require.NoError(t, err) + + tests := []struct { + name string + params *RangeProofParams + expectedError string + }{ + { + name: "invalid P point", + params: &RangeProofParams{ + BitLength: pp.RangeProofParams.BitLength, + NumberOfRounds: pp.RangeProofParams.NumberOfRounds, + P: invalidPoint, + Q: pp.RangeProofParams.Q, + }, + expectedError: "invalid range proof parameters: generator P is invalid", + }, + { + name: "invalid Q point", + params: &RangeProofParams{ + BitLength: pp.RangeProofParams.BitLength, + NumberOfRounds: pp.RangeProofParams.NumberOfRounds, + P: pp.RangeProofParams.P, + Q: invalidPoint, + }, + expectedError: "invalid range proof parameters: generator Q is invalid", + }, + { + name: "invalid left generator", + params: &RangeProofParams{ + BitLength: pp.RangeProofParams.BitLength, + NumberOfRounds: pp.RangeProofParams.NumberOfRounds, + P: pp.RangeProofParams.P, + Q: pp.RangeProofParams.Q, + LeftGenerators: []*math3.G1{ + curveInst.GenG1, + pp.RangeProofParams.LeftGenerators[1], + }, + RightGenerators: make([]*math3.G1, 2), + }, + expectedError: "invalid range proof parameters, left generators is invalid", + }, + { + name: "invalid right generator", + params: &RangeProofParams{ + BitLength: pp.RangeProofParams.BitLength, + NumberOfRounds: pp.RangeProofParams.NumberOfRounds, + P: curveInst.GenG1, + Q: curveInst.GenG1, + LeftGenerators: pp.RangeProofParams.LeftGenerators, + RightGenerators: make([]*math3.G1, len(pp.RangeProofParams.RightGenerators)), + }, + expectedError: "invalid range proof parameters, right generators is invalid", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.params.Validate(curve) + assert.Error(t, err) + assert.Contains(t, err.Error(), tt.expectedError) + }) + } +} + +func TestExtras(t *testing.T) { + pp := &PublicParams{ + ExtraData: map[string][]byte{ + "key1": []byte("value1"), + "key2": []byte("value2"), + }, + } + + extras := pp.Extras() + assert.Equal(t, pp.ExtraData, extras) + + // Verify nil case + pp = &PublicParams{} + assert.Nil(t, pp.Extras()) + + // Verify empty map case + pp.ExtraData = make(map[string][]byte) + assert.Empty(t, pp.Extras()) +} diff --git a/token/driver/mock/pp.go b/token/driver/mock/pp.go index 9fe6085f02..f5eebfb00e 100644 --- a/token/driver/mock/pp.go +++ b/token/driver/mock/pp.go @@ -28,6 +28,16 @@ type PublicParameters struct { certificationDriverReturnsOnCall map[int]struct { result1 string } + ExtrasStub func() driver.Extras + extrasMutex sync.RWMutex + extrasArgsForCall []struct { + } + extrasReturns struct { + result1 driver.Extras + } + extrasReturnsOnCall map[int]struct { + result1 driver.Extras + } GraphHidingStub func() bool graphHidingMutex sync.RWMutex graphHidingArgsForCall []struct { @@ -240,6 +250,59 @@ func (fake *PublicParameters) CertificationDriverReturnsOnCall(i int, result1 st }{result1} } +func (fake *PublicParameters) Extras() driver.Extras { + fake.extrasMutex.Lock() + ret, specificReturn := fake.extrasReturnsOnCall[len(fake.extrasArgsForCall)] + fake.extrasArgsForCall = append(fake.extrasArgsForCall, struct { + }{}) + stub := fake.ExtrasStub + fakeReturns := fake.extrasReturns + fake.recordInvocation("Extras", []interface{}{}) + fake.extrasMutex.Unlock() + if stub != nil { + return stub() + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *PublicParameters) ExtrasCallCount() int { + fake.extrasMutex.RLock() + defer fake.extrasMutex.RUnlock() + return len(fake.extrasArgsForCall) +} + +func (fake *PublicParameters) ExtrasCalls(stub func() driver.Extras) { + fake.extrasMutex.Lock() + defer fake.extrasMutex.Unlock() + fake.ExtrasStub = stub +} + +func (fake *PublicParameters) ExtrasReturns(result1 driver.Extras) { + fake.extrasMutex.Lock() + defer fake.extrasMutex.Unlock() + fake.ExtrasStub = nil + fake.extrasReturns = struct { + result1 driver.Extras + }{result1} +} + +func (fake *PublicParameters) ExtrasReturnsOnCall(i int, result1 driver.Extras) { + fake.extrasMutex.Lock() + defer fake.extrasMutex.Unlock() + fake.ExtrasStub = nil + if fake.extrasReturnsOnCall == nil { + fake.extrasReturnsOnCall = make(map[int]struct { + result1 driver.Extras + }) + } + fake.extrasReturnsOnCall[i] = struct { + result1 driver.Extras + }{result1} +} + func (fake *PublicParameters) GraphHiding() bool { fake.graphHidingMutex.Lock() ret, specificReturn := fake.graphHidingReturnsOnCall[len(fake.graphHidingArgsForCall)] @@ -780,6 +843,8 @@ func (fake *PublicParameters) Invocations() map[string][][]interface{} { defer fake.auditorsMutex.RUnlock() fake.certificationDriverMutex.RLock() defer fake.certificationDriverMutex.RUnlock() + fake.extrasMutex.RLock() + defer fake.extrasMutex.RUnlock() fake.graphHidingMutex.RLock() defer fake.graphHidingMutex.RUnlock() fake.issuersMutex.RLock() diff --git a/token/driver/publicparams.go b/token/driver/publicparams.go index dfe5196ae7..e5d416c543 100644 --- a/token/driver/publicparams.go +++ b/token/driver/publicparams.go @@ -36,6 +36,8 @@ type PublicParamsFetcher interface { Fetch() ([]byte, error) } +type Extras = map[string][]byte + //go:generate counterfeiter -o mock/pp.go -fake-name PublicParameters . PublicParameters // PublicParameters is the interface that must be implemented by the driver public parameters. @@ -64,11 +66,14 @@ type PublicParameters interface { Serialize() ([]byte, error) // Validate returns true if the public parameters are well-formed Validate() error + // Extras gives access to extra data, if available. + // Extras always returns an initialized Extras that can be modified. + Extras() Extras } //go:generate counterfeiter -o mock/ppm.go -fake-name PublicParamsManager . PublicParamsManager -// PublicParamsManager is the interface that must be implemented by the driver public parameters manager. +// PublicParamsManager is the interface that must be implemented by the driver public parameters' manager. type PublicParamsManager interface { // PublicParameters returns the public parameters. PublicParameters() PublicParameters diff --git a/token/services/identity/storage/kvs/hashicorp/go.mod b/token/services/identity/storage/kvs/hashicorp/go.mod index 1bfce5b9c6..36227f2486 100644 --- a/token/services/identity/storage/kvs/hashicorp/go.mod +++ b/token/services/identity/storage/kvs/hashicorp/go.mod @@ -8,7 +8,7 @@ require ( github.com/docker/docker v28.0.2+incompatible github.com/docker/go-connections v0.5.0 github.com/hashicorp/vault/api v1.16.0 - github.com/hyperledger-labs/fabric-smart-client v0.6.1-0.20251030075357-8bde666534da + github.com/hyperledger-labs/fabric-smart-client v0.6.1-0.20251104052518-2ce51a8935a9 github.com/hyperledger-labs/fabric-token-sdk v0.4.1-0.20250528165839-032fb9265504 github.com/stretchr/testify v1.10.0 ) diff --git a/token/services/identity/storage/kvs/hashicorp/go.sum b/token/services/identity/storage/kvs/hashicorp/go.sum index 1e0f60890f..2de97c7697 100644 --- a/token/services/identity/storage/kvs/hashicorp/go.sum +++ b/token/services/identity/storage/kvs/hashicorp/go.sum @@ -125,8 +125,8 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/vault/api v1.16.0 h1:nbEYGJiAPGzT9U4oWgaaB0g+Rj8E59QuHKyA5LhwQN4= github.com/hashicorp/vault/api v1.16.0/go.mod h1:KhuUhzOD8lDSk29AtzNjgAu2kxRA9jL9NAbkFlqvkBA= -github.com/hyperledger-labs/fabric-smart-client v0.6.1-0.20251030075357-8bde666534da h1:5e/8UiCGNRyrzs4JP5I6PdP0KpE96oXhyAJWxiPAGs8= -github.com/hyperledger-labs/fabric-smart-client v0.6.1-0.20251030075357-8bde666534da/go.mod h1:Ib74lzDOsxuEGpl6Q3huBny9+X7b1HCEN6xhMbxIi9A= +github.com/hyperledger-labs/fabric-smart-client v0.6.1-0.20251104052518-2ce51a8935a9 h1:McQVdPOFvRfqnaFdn/o2yBldZ4Wt11NjwgU3gQaX6F8= +github.com/hyperledger-labs/fabric-smart-client v0.6.1-0.20251104052518-2ce51a8935a9/go.mod h1:Ib74lzDOsxuEGpl6Q3huBny9+X7b1HCEN6xhMbxIi9A= github.com/hyperledger/fabric-amcl v0.0.0-20230602173724-9e02669dceb2 h1:B1Nt8hKb//KvgGRprk0h1t4lCnwhE9/ryb1WqfZbV+M= github.com/hyperledger/fabric-amcl v0.0.0-20230602173724-9e02669dceb2/go.mod h1:X+DIyUsaTmalOpmpQfIvFZjKHQedrURQ5t4YqquX7lE= github.com/hyperledger/fabric-lib-go v1.1.3-0.20240523144151-25edd1eaf5f5 h1:RPWTL5wxAb+xDOrsCU3QYZP65305F8v3PaOyzdbPVMU=