Skip to content

Commit 6bdf93f

Browse files
committed
dlog pp: support multiple auditor identities
Signed-off-by: Angelo De Caro <angelo.decaro@gmail.com>
1 parent 113ff9b commit 6bdf93f

File tree

5 files changed

+52
-42
lines changed

5 files changed

+52
-42
lines changed

cmd/tokengen/cobra/pp/dlog/update.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func Update(args *UpdateArgs) error {
9090
// Clear auditor and issuers if provided, and add them again.
9191
// If not provided, do not change them.
9292
if len(args.Auditors) > 0 {
93-
pp.Auditor = []byte{}
93+
pp.AuditorIDs = []driver.Identity{}
9494
}
9595
if len(args.Issuers) > 0 {
9696
pp.IssuerIDs = []driver.Identity{}

token/core/zkatdlog/nogh/protos-go/pp/noghpp.pb.go

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

token/core/zkatdlog/nogh/protos/noghpp.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ message PublicParameters {
3838
repeated G1 pedersen_generators = 4; // contains the public parameters for the Pedersen commitment scheme.
3939
RangeProofParams range_proof_params = 5; // contains the public parameters for the range proof scheme.
4040
repeated IdemixIssuerPublicKey idemix_issuer_public_keys = 6; // 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.
41-
Identity auditor = 7; // is the public key of the auditor.
41+
repeated Identity auditors = 7; // is the public key of the auditor.
4242
repeated Identity issuers = 8; // is a list of public keys of the entities that can issue tokens.
4343
uint64 max_token = 9; // is the maximum quantity a token can hold
4444
uint64 quantity_precision = 10; // is the precision used to represent quantities

token/core/zkatdlog/nogh/v1/setup/setup.go

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ type PublicParams struct {
170170
// IdemixIssuerPublicKeys contains the idemix issuer public keys
171171
// Wallets should prefer the use of keys valid under the public key whose index in the array is the smallest.
172172
IdemixIssuerPublicKeys []*IdemixIssuerPublicKey
173-
// Auditor is the public key of the auditor.
174-
Auditor driver.Identity
173+
// Auditors is a list of the public keys of the auditor(s).
174+
AuditorIDs []driver.Identity
175175
// IssuerIDs is a list of public keys of the entities that can issue tokens.
176176
IssuerIDs []driver.Identity
177177
// MaxToken is the maximum quantity a token can hold
@@ -253,10 +253,7 @@ func (p *PublicParams) Bytes() ([]byte, error) {
253253
}
254254

255255
func (p *PublicParams) Auditors() []driver.Identity {
256-
if len(p.Auditor) == 0 {
257-
return []driver.Identity{}
258-
}
259-
return []driver.Identity{p.Auditor}
256+
return p.AuditorIDs
260257
}
261258

262259
// Issuers returns the list of authorized issuers
@@ -285,6 +282,14 @@ func (p *PublicParams) Serialize() ([]byte, error) {
285282
if err != nil {
286283
return nil, errors.Wrapf(err, "failed to serialize issuer")
287284
}
285+
auditors, err := protos.ToProtosSliceFunc(p.AuditorIDs, func(id driver.Identity) (*pp.Identity, error) {
286+
return &pp.Identity{
287+
Raw: id,
288+
}, nil
289+
})
290+
if err != nil {
291+
return nil, errors.Wrapf(err, "failed to serialize auditor")
292+
}
288293
idemixIssuerPublicKeys, err := protos.ToProtosSlice[pp.IdemixIssuerPublicKey, *IdemixIssuerPublicKey](p.IdemixIssuerPublicKeys)
289294
if err != nil {
290295
return nil, errors.Wrapf(err, "failed to serialize idemix issuer public keys")
@@ -299,12 +304,10 @@ func (p *PublicParams) Serialize() ([]byte, error) {
299304
PedersenGenerators: pg,
300305
RangeProofParams: rpp,
301306
IdemixIssuerPublicKeys: idemixIssuerPublicKeys,
302-
Auditor: &pp.Identity{
303-
Raw: p.Auditor,
304-
},
305-
Issuers: issuers,
306-
MaxToken: p.MaxToken,
307-
QuantityPrecision: p.QuantityPrecision,
307+
Auditors: auditors,
308+
Issuers: issuers,
309+
MaxToken: p.MaxToken,
310+
QuantityPrecision: p.QuantityPrecision,
308311
}
309312
raw, err := proto.Marshal(publicParams)
310313
if err != nil {
@@ -353,15 +356,22 @@ func (p *PublicParams) Deserialize(raw []byte) error {
353356
return errors.Wrapf(err, "failed to deserialize issuers")
354357
}
355358
p.IssuerIDs = issuers
359+
auditors, err := protos.FromProtosSliceFunc2(publicParams.Auditors, func(id *pp.Identity) (driver.Identity, error) {
360+
if id == nil {
361+
return nil, nil
362+
}
363+
return id.Raw, nil
364+
})
365+
if err != nil {
366+
return errors.Wrapf(err, "failed to deserialize issuers")
367+
}
368+
p.AuditorIDs = auditors
356369

357370
p.IdemixIssuerPublicKeys = slices.GenericSliceOfPointers[IdemixIssuerPublicKey](len(publicParams.IdemixIssuerPublicKeys))
358371
err = protos.FromProtosSlice[pp.IdemixIssuerPublicKey, *IdemixIssuerPublicKey](publicParams.IdemixIssuerPublicKeys, p.IdemixIssuerPublicKeys)
359372
if err != nil {
360373
return errors.Wrapf(err, "failed to deserialize idemix issuer public keys")
361374
}
362-
if publicParams.Auditor != nil {
363-
p.Auditor = publicParams.Auditor.Raw
364-
}
365375

366376
p.RangeProofParams = &RangeProofParams{}
367377
if err := p.RangeProofParams.FromProto(publicParams.RangeProofParams); err != nil {
@@ -406,7 +416,7 @@ func (p *PublicParams) GenerateRangeProofParameters(bitLength uint64) error {
406416
}
407417

408418
func (p *PublicParams) AddAuditor(auditor driver.Identity) {
409-
p.Auditor = auditor
419+
p.AuditorIDs = append(p.AuditorIDs, auditor)
410420
}
411421

412422
func (p *PublicParams) AddIssuer(id driver.Identity) {
@@ -420,7 +430,7 @@ func (p *PublicParams) SetIssuers(ids []driver.Identity) {
420430

421431
// SetAuditors sets the auditors to the passed identities
422432
func (p *PublicParams) SetAuditors(ids []driver.Identity) {
423-
p.Auditor = ids[0]
433+
p.AuditorIDs = ids
424434
}
425435

426436
func (p *PublicParams) ComputeHash() ([]byte, error) {

token/core/zkatdlog/nogh/v1/validator/validator_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ var _ = Describe("validator", func() {
9292
auditor = audit.NewAuditor(logging.MustGetLogger("auditor"), &noop.Tracer{}, des, pp.PedersenGenerators, asigner, c)
9393
araw, err := asigner.Serialize()
9494
Expect(err).NotTo(HaveOccurred())
95-
pp.Auditor = araw
95+
pp.AuditorIDs = []driver.Identity{araw}
9696

9797
// initialize enginw with pp
9898
deserializer, err := zkatdlog.NewDeserializer(pp)

0 commit comments

Comments
 (0)