Skip to content

Commit f7552f7

Browse files
jannikluhnulope
authored andcommitted
Rename identity to identity preimage
1 parent de0d90a commit f7552f7

File tree

13 files changed

+112
-111
lines changed

13 files changed

+112
-111
lines changed

rolling-shutter/gnosisaccessnode/decryptionkeyshandler.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,15 @@ func (handler *DecryptionKeysHandler) validateCommonFields(keys *p2pmsg.Decrypti
7373
if err != nil {
7474
return pubsub.ValidationReject, err
7575
}
76-
ok, err := shcrypto.VerifyEpochSecretKey(epochSecretKey, eonKey, k.Identity)
76+
ok, err := shcrypto.VerifyEpochSecretKey(epochSecretKey, eonKey, k.IdentityPreimage)
7777
if err != nil {
78-
return pubsub.ValidationReject, errors.Wrapf(err, "error while checking epoch secret key for identity %x", k.Identity)
78+
return pubsub.ValidationReject, errors.Wrapf(err, "error while checking epoch secret key for identity %x", k.IdentityPreimage)
7979
}
8080
if !ok {
81-
return pubsub.ValidationReject, errors.Errorf("epoch secret key for identity %x is not valid", k.Identity)
81+
return pubsub.ValidationReject, errors.Errorf("epoch secret key for identity %x is not valid", k.IdentityPreimage)
8282
}
8383

84-
if i > 0 && bytes.Compare(k.Identity, keys.Keys[i-1].Identity) < 0 {
84+
if i > 0 && bytes.Compare(k.IdentityPreimage, keys.Keys[i-1].IdentityPreimage) < 0 {
8585
return pubsub.ValidationReject, errors.Errorf("keys not ordered")
8686
}
8787
}

rolling-shutter/keyper/database/extend.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (bc *TendermintBatchConfig) KeyperIndex(addr common.Address) (uint64, bool)
3030

3131
func (q *Queries) InsertDecryptionKeysMsg(ctx context.Context, msg *p2pmsg.DecryptionKeys) error {
3232
for _, key := range msg.Keys {
33-
identityPreimage := identitypreimage.IdentityPreimage(key.Identity)
33+
identityPreimage := identitypreimage.IdentityPreimage(key.IdentityPreimage)
3434
tag, err := q.InsertDecryptionKey(ctx, InsertDecryptionKeyParams{
3535
Eon: int64(msg.Eon),
3636
EpochID: identityPreimage.Bytes(),

rolling-shutter/keyper/epochkghandler/benchmark_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ func prepareKeysBenchmark(ctx context.Context, b *testing.B, dbpool *pgxpool.Poo
5353
decryptionKeys := []*p2pmsg.Key{}
5454
for i, identityPreimage := range identityPreimages {
5555
key := &p2pmsg.Key{
56-
Identity: identityPreimage.Bytes(),
57-
Key: encodedDecryptionKeys[i],
56+
IdentityPreimage: identityPreimage.Bytes(),
57+
Key: encodedDecryptionKeys[i],
5858
}
5959
decryptionKeys = append(decryptionKeys, key)
6060
}

rolling-shutter/keyper/epochkghandler/key.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func checkKeysErrors(
9797
if err != nil {
9898
return pubsub.ValidationReject, err
9999
}
100-
if i > 0 && bytes.Compare(k.Identity, decryptionKeys.Keys[i-1].Identity) < 0 {
100+
if i > 0 && bytes.Compare(k.IdentityPreimage, decryptionKeys.Keys[i-1].IdentityPreimage) < 0 {
101101
return pubsub.ValidationReject, errors.Errorf("keys not ordered")
102102
}
103103

@@ -107,21 +107,21 @@ func checkKeysErrors(
107107
}
108108
existingDecryptionKey, err := queries.GetDecryptionKey(ctx, database.GetDecryptionKeyParams{
109109
Eon: eon,
110-
EpochID: k.GetIdentity(),
110+
EpochID: k.GetIdentityPreimage(),
111111
})
112112
if err != nil && !errors.Is(err, pgx.ErrNoRows) {
113-
return pubsub.ValidationReject, errors.Wrapf(err, "failed to get decryption key for identity %x from db", k.Identity)
113+
return pubsub.ValidationReject, errors.Wrapf(err, "failed to get decryption key for identity %x from db", k.IdentityPreimage)
114114
}
115115
if !errors.Is(err, pgx.ErrNoRows) && bytes.Equal(k.Key, existingDecryptionKey.DecryptionKey) {
116116
continue
117117
}
118118

119-
ok, err := shcrypto.VerifyEpochSecretKey(epochSecretKey, pureDKGResult.PublicKey, k.Identity)
119+
ok, err := shcrypto.VerifyEpochSecretKey(epochSecretKey, pureDKGResult.PublicKey, k.IdentityPreimage)
120120
if err != nil {
121-
return pubsub.ValidationReject, errors.Wrapf(err, "error while checking epoch secret key for identity %x", k.Identity)
121+
return pubsub.ValidationReject, errors.Wrapf(err, "error while checking epoch secret key for identity %x", k.IdentityPreimage)
122122
}
123123
if !ok {
124-
return pubsub.ValidationReject, errors.Errorf("epoch secret key for identity %x is not valid", k.Identity)
124+
return pubsub.ValidationReject, errors.Errorf("epoch secret key for identity %x is not valid", k.IdentityPreimage)
125125
}
126126
}
127127
return pubsub.ValidationAccept, nil

rolling-shutter/keyper/epochkghandler/key_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ func TestHandleDecryptionKeyIntegration(t *testing.T) {
5151
decryptionKeys := []*p2pmsg.Key{}
5252
for i, identityPreimage := range identityPreimages {
5353
key := &p2pmsg.Key{
54-
Identity: identityPreimage.Bytes(),
55-
Key: encodedDecryptionKeys[i],
54+
IdentityPreimage: identityPreimage.Bytes(),
55+
Key: encodedDecryptionKeys[i],
5656
}
5757
decryptionKeys = append(decryptionKeys, key)
5858
}
@@ -106,8 +106,8 @@ func TestDecryptionKeyValidatorIntegration(t *testing.T) {
106106
Eon: keyperConfigIndex,
107107
Keys: []*p2pmsg.Key{
108108
{
109-
Identity: identityPreimage.Bytes(),
110-
Key: secretKey.Marshal(),
109+
IdentityPreimage: identityPreimage.Bytes(),
110+
Key: secretKey.Marshal(),
111111
},
112112
},
113113
},
@@ -120,8 +120,8 @@ func TestDecryptionKeyValidatorIntegration(t *testing.T) {
120120
Eon: keyperConfigIndex,
121121
Keys: []*p2pmsg.Key{
122122
{
123-
Identity: wrongIdentityPreimage.Bytes(),
124-
Key: secretKey.Marshal(),
123+
IdentityPreimage: wrongIdentityPreimage.Bytes(),
124+
Key: secretKey.Marshal(),
125125
},
126126
},
127127
},
@@ -134,8 +134,8 @@ func TestDecryptionKeyValidatorIntegration(t *testing.T) {
134134
Eon: keyperConfigIndex,
135135
Keys: []*p2pmsg.Key{
136136
{
137-
Identity: identityPreimage.Bytes(),
138-
Key: secretKey.Marshal(),
137+
IdentityPreimage: identityPreimage.Bytes(),
138+
Key: secretKey.Marshal(),
139139
},
140140
},
141141
},
@@ -157,12 +157,12 @@ func TestDecryptionKeyValidatorIntegration(t *testing.T) {
157157
Eon: keyperConfigIndex,
158158
Keys: []*p2pmsg.Key{
159159
{
160-
Identity: secondIdentityPreimage.Bytes(),
161-
Key: secondSecretKey.Marshal(),
160+
IdentityPreimage: secondIdentityPreimage.Bytes(),
161+
Key: secondSecretKey.Marshal(),
162162
},
163163
{
164-
Identity: identityPreimage.Bytes(),
165-
Key: secretKey.Marshal(),
164+
IdentityPreimage: identityPreimage.Bytes(),
165+
Key: secretKey.Marshal(),
166166
},
167167
},
168168
},

rolling-shutter/keyper/epochkghandler/keyshare.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ func (handler *DecryptionKeyShareHandler) HandleMessage(ctx context.Context, m p
184184
}
185185

186186
keys = append(keys, &p2pmsg.Key{
187-
Identity: identityPreimage.Bytes(),
188-
Key: decryptionKey.Marshal(),
187+
IdentityPreimage: identityPreimage.Bytes(),
188+
Key: decryptionKey.Marshal(),
189189
})
190190
}
191191
message := &p2pmsg.DecryptionKeys{

rolling-shutter/keyper/epochkghandler/keyshare_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func TestHandleDecryptionKeyShareIntegration(t *testing.T) {
8282
assert.Check(t, msg.InstanceId == config.GetInstanceID())
8383
assert.Check(t, len(msg.Keys) == len(identityPreimages))
8484
for i, key := range msg.Keys {
85-
assert.Check(t, bytes.Equal(key.Identity, identityPreimages[i].Bytes()))
85+
assert.Check(t, bytes.Equal(key.IdentityPreimage, identityPreimages[i].Bytes()))
8686
assert.Check(t, bytes.Equal(key.Key, encodedDecryptionKeys[i]))
8787
}
8888
}

rolling-shutter/keyperimpl/gnosis/handlers.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ func (h *DecryptionKeySharesHandler) HandleMessage(ctx context.Context, msg p2pm
142142
return []p2pmsg.Message{}, nil
143143
}
144144
key := &p2pmsg.Key{
145-
Identity: share.IdentityPreimage,
146-
Key: decryptionKeyDB.DecryptionKey,
145+
IdentityPreimage: share.IdentityPreimage,
146+
Key: decryptionKeyDB.DecryptionKey,
147147
}
148148
keys = append(keys, key)
149149
}
@@ -240,7 +240,7 @@ func ValidateDecryptionKeysSignatures(
240240

241241
identityPreimages := []identitypreimage.IdentityPreimage{}
242242
for _, key := range keys.Keys {
243-
identityPreimage := identitypreimage.IdentityPreimage(key.Identity)
243+
identityPreimage := identitypreimage.IdentityPreimage(key.IdentityPreimage)
244244
identityPreimages = append(identityPreimages, identityPreimage)
245245
}
246246
slotDecryptionSignatureData, err := gnosisssztypes.NewSlotDecryptionSignatureData(
@@ -319,7 +319,7 @@ func (h *DecryptionKeysHandler) HandleMessage(ctx context.Context, msg p2pmsg.Me
319319

320320
identityPreimages := []identitypreimage.IdentityPreimage{}
321321
for _, key := range keys.Keys {
322-
identityPreimage := identitypreimage.IdentityPreimage(key.Identity)
322+
identityPreimage := identitypreimage.IdentityPreimage(key.IdentityPreimage)
323323
identityPreimages = append(identityPreimages, identityPreimage)
324324
}
325325
identitiesHash := computeIdentitiesHash(identityPreimages)

0 commit comments

Comments
 (0)