Skip to content

Commit e109c52

Browse files
committed
pp extensions as requested + extensive unit-tests for the public parameters
Signed-off-by: Angelo De Caro <[email protected]>
1 parent efb3a87 commit e109c52

File tree

12 files changed

+1149
-573
lines changed

12 files changed

+1149
-573
lines changed

cmd/tokengen/cobra/pp/fabtokenv1/gen.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func Gen(args *GeneratorArgs) ([]byte, error) {
9696
if Version != 0 {
9797
ver = driver.TokenDriverVersion(Version)
9898
}
99-
pp, err := v1.SetupWithVersion(v1.DefaultPrecision, ver)
99+
pp, err := v1.WithVersion(v1.DefaultPrecision, ver)
100100
if err != nil {
101101
return nil, errors.Wrap(err, "failed setting up public parameters")
102102
}

cmd/tokengen/cobra/pp/zkatdlognoghv1/gen.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func Gen(args *GeneratorArgs) ([]byte, error) {
138138
if args.Version != 0 {
139139
ver = driver.TokenDriverVersion(args.Version)
140140
}
141-
pp, err := v1.SetupWithVersion(64, ipkBytes, curveID, ver)
141+
pp, err := v1.WithVersion(64, ipkBytes, curveID, ver)
142142
if err != nil {
143143
return nil, errors.Wrap(err, "failed setting up public parameters")
144144
}

token/core/fabtoken/protos-go/pp/ftpp.pb.go

Lines changed: 33 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

token/core/fabtoken/protos/ftpp.proto

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ message Identity {
1818
message PublicParameters {
1919
string token_driver_name = 1; // the name of the token driver
2020
uint64 token_driver_version = 2; // the version of token driver
21-
Identity auditor = 7; // is the public key of the auditor.
22-
repeated Identity issuers = 8; // is a list of public keys of the entities that can issue tokens.
23-
uint64 max_token = 9; // is the maximum quantity a token can hold
24-
uint64 quantity_precision = 10; // is the precision used to represent quantities
21+
Identity auditor = 3; // is the public key of the auditor.
22+
repeated Identity issuers = 4; // is a list of public keys of the entities that can issue tokens.
23+
uint64 max_token = 5; // is the maximum quantity a token can hold
24+
uint64 quantity_precision = 6; // is the precision used to represent quantities
25+
map<string, bytes> extra_data = 7; // extra_data allows to store arbitrary data in the public parameters
2526
}

token/core/fabtoken/v1/setup/setup.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,17 @@ type PublicParams struct {
4040
Auditor []byte
4141
// This encodes the list of authorized issuers
4242
IssuerIDs []driver.Identity
43+
// ExtraData contains any extra custom data
44+
ExtraData map[string][]byte
4345
}
4446

4547
// Setup initializes PublicParams
4648
func Setup(precision uint64) (*PublicParams, error) {
4749
return NewWith(FabTokenDriverName, ProtocolV1, precision)
4850
}
4951

50-
// SetupWithVersion is like Setup with the additional possibility to specify the version number
51-
func SetupWithVersion(precision uint64, version driver.TokenDriverVersion) (*PublicParams, error) {
52+
// WithVersion is like Setup with the additional possibility to specify the version number
53+
func WithVersion(precision uint64, version driver.TokenDriverVersion) (*PublicParams, error) {
5254
return NewWith(FabTokenDriverName, version, precision)
5355
}
5456

@@ -132,6 +134,7 @@ func (p *PublicParams) Bytes() ([]byte, error) {
132134
Issuers: issuers,
133135
MaxToken: p.MaxToken,
134136
QuantityPrecision: p.QuantityPrecision,
137+
ExtraData: p.ExtraData,
135138
}
136139
return proto.Marshal(params)
137140
}
@@ -157,6 +160,7 @@ func (p *PublicParams) FromBytes(data []byte) error {
157160
if publicParams.Auditor != nil {
158161
p.Auditor = publicParams.Auditor.Raw
159162
}
163+
p.ExtraData = publicParams.ExtraData
160164
return nil
161165
}
162166

0 commit comments

Comments
 (0)