Skip to content

Commit de0d90a

Browse files
jannikluhnulope
authored andcommitted
Rename epoch_id to identity_preimage
1 parent 1e3565e commit de0d90a

File tree

15 files changed

+163
-157
lines changed

15 files changed

+163
-157
lines changed

rolling-shutter/keyper/database/extend.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func (q *Queries) InsertDecryptionKeySharesMsg(ctx context.Context, msg *p2pmsg.
5151
for _, share := range msg.GetShares() {
5252
err := q.InsertDecryptionKeyShare(ctx, InsertDecryptionKeyShareParams{
5353
Eon: int64(msg.Eon),
54-
EpochID: share.EpochId,
54+
EpochID: share.IdentityPreimage,
5555
KeyperIndex: int64(msg.KeyperIndex),
5656
DecryptionKeyShare: share.Share,
5757
})

rolling-shutter/keyper/epochkghandler/benchmark_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ func prepareKeySharesBenchmark(
8585
keyperIndex := 0
8686
for _, identityPreimage := range identityPreimages {
8787
share := &p2pmsg.KeyShare{
88-
EpochId: identityPreimage.Bytes(),
89-
Share: keys.EpochSecretKeyShare(identityPreimage, keyperIndex).Marshal(),
88+
IdentityPreimage: identityPreimage.Bytes(),
89+
Share: keys.EpochSecretKeyShare(identityPreimage, keyperIndex).Marshal(),
9090
}
9191
shares = append(shares, share)
9292
}
@@ -107,8 +107,8 @@ func prepareKeySharesBenchmark(
107107
shares := []*p2pmsg.KeyShare{}
108108
for _, identityPreimage := range identityPreimages {
109109
share := &p2pmsg.KeyShare{
110-
EpochId: identityPreimage.Bytes(),
111-
Share: keys.EpochSecretKeyShare(identityPreimage, keyperIndex).Marshal(),
110+
IdentityPreimage: identityPreimage.Bytes(),
111+
Share: keys.EpochSecretKeyShare(identityPreimage, keyperIndex).Marshal(),
112112
}
113113
shares = append(shares, share)
114114
}

rolling-shutter/keyper/epochkghandler/keyshare.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,12 @@ func checkKeyShares(keyShare *p2pmsg.DecryptionKeyShares, pureDKGResult *puredkg
9595
if !shcrypto.VerifyEpochSecretKeyShare(
9696
epochSecretKeyShare,
9797
pureDKGResult.PublicKeyShares[keyShare.KeyperIndex],
98-
shcrypto.ComputeEpochID(share.EpochId),
98+
shcrypto.ComputeEpochID(share.IdentityPreimage),
9999
) {
100100
return pubsub.ValidationReject, errors.Errorf("cannot verify secret key share")
101101
}
102102

103-
if i > 0 && bytes.Compare(share.EpochId, shares[i-1].EpochId) < 0 {
103+
if i > 0 && bytes.Compare(share.IdentityPreimage, shares[i-1].IdentityPreimage) < 0 {
104104
return pubsub.ValidationReject, errors.Errorf("keyshares not ordered")
105105
}
106106
}
@@ -124,7 +124,7 @@ func (handler *DecryptionKeyShareHandler) HandleMessage(ctx context.Context, m p
124124
}
125125
allKeysExist := true
126126
for _, share := range msg.GetShares() {
127-
identityPreimage := identitypreimage.IdentityPreimage(share.EpochId)
127+
identityPreimage := identitypreimage.IdentityPreimage(share.IdentityPreimage)
128128
keyExists, err := db.ExistsDecryptionKey(ctx, database.ExistsDecryptionKeyParams{
129129
Eon: eon,
130130
EpochID: identityPreimage.Bytes(),
@@ -159,7 +159,7 @@ func (handler *DecryptionKeyShareHandler) HandleMessage(ctx context.Context, m p
159159
// aggregate epoch secret keys
160160
keys := []*p2pmsg.Key{}
161161
for _, share := range msg.GetShares() {
162-
identityPreimage := identitypreimage.IdentityPreimage(share.EpochId)
162+
identityPreimage := identitypreimage.IdentityPreimage(share.IdentityPreimage)
163163

164164
epochKG, err := handler.aggregateDecryptionKeySharesFromDB(
165165
ctx,

rolling-shutter/keyper/epochkghandler/keyshare_test.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ func TestHandleDecryptionKeyShareIntegration(t *testing.T) {
4747
shares := []*p2pmsg.KeyShare{}
4848
for _, identityPreimage := range identityPreimages {
4949
share := &p2pmsg.KeyShare{
50-
EpochId: identityPreimage.Bytes(),
51-
Share: keys.EpochSecretKeyShare(identityPreimage, 0).Marshal(),
50+
IdentityPreimage: identityPreimage.Bytes(),
51+
Share: keys.EpochSecretKeyShare(identityPreimage, 0).Marshal(),
5252
}
5353
shares = append(shares, share)
5454
}
@@ -65,8 +65,8 @@ func TestHandleDecryptionKeyShareIntegration(t *testing.T) {
6565
shares = []*p2pmsg.KeyShare{}
6666
for _, identityPreimage := range identityPreimages {
6767
share := &p2pmsg.KeyShare{
68-
EpochId: identityPreimage.Bytes(),
69-
Share: keys.EpochSecretKeyShare(identityPreimage, 2).Marshal(),
68+
IdentityPreimage: identityPreimage.Bytes(),
69+
Share: keys.EpochSecretKeyShare(identityPreimage, 2).Marshal(),
7070
}
7171
shares = append(shares, share)
7272
}
@@ -121,12 +121,12 @@ func TestDecryptionKeyshareValidatorIntegration(t *testing.T) {
121121
KeyperIndex: keyperIndex,
122122
Shares: []*p2pmsg.KeyShare{
123123
{
124-
EpochId: identityPreimage.Bytes(),
125-
Share: keyshare,
124+
IdentityPreimage: identityPreimage.Bytes(),
125+
Share: keyshare,
126126
},
127127
{
128-
EpochId: secondIdentityPreimage.Bytes(),
129-
Share: secondKeyshare,
128+
IdentityPreimage: secondIdentityPreimage.Bytes(),
129+
Share: secondKeyshare,
130130
},
131131
},
132132
},
@@ -140,8 +140,8 @@ func TestDecryptionKeyshareValidatorIntegration(t *testing.T) {
140140
KeyperIndex: keyperIndex,
141141
Shares: []*p2pmsg.KeyShare{
142142
{
143-
EpochId: wrongIdentityPreimage.Bytes(),
144-
Share: keyshare,
143+
IdentityPreimage: wrongIdentityPreimage.Bytes(),
144+
Share: keyshare,
145145
},
146146
},
147147
},
@@ -155,8 +155,8 @@ func TestDecryptionKeyshareValidatorIntegration(t *testing.T) {
155155
KeyperIndex: keyperIndex,
156156
Shares: []*p2pmsg.KeyShare{
157157
{
158-
EpochId: identityPreimage.Bytes(),
159-
Share: keyshare,
158+
IdentityPreimage: identityPreimage.Bytes(),
159+
Share: keyshare,
160160
},
161161
},
162162
},
@@ -170,8 +170,8 @@ func TestDecryptionKeyshareValidatorIntegration(t *testing.T) {
170170
KeyperIndex: keyperIndex + 1,
171171
Shares: []*p2pmsg.KeyShare{
172172
{
173-
EpochId: identityPreimage.Bytes(),
174-
Share: keyshare,
173+
IdentityPreimage: identityPreimage.Bytes(),
174+
Share: keyshare,
175175
},
176176
},
177177
},
@@ -195,12 +195,12 @@ func TestDecryptionKeyshareValidatorIntegration(t *testing.T) {
195195
KeyperIndex: keyperIndex,
196196
Shares: []*p2pmsg.KeyShare{
197197
{
198-
EpochId: secondIdentityPreimage.Bytes(),
199-
Share: secondKeyshare,
198+
IdentityPreimage: secondIdentityPreimage.Bytes(),
199+
Share: secondKeyshare,
200200
},
201201
{
202-
EpochId: identityPreimage.Bytes(),
203-
Share: keyshare,
202+
IdentityPreimage: identityPreimage.Bytes(),
203+
Share: keyshare,
204204
},
205205
},
206206
},

rolling-shutter/keyper/epochkghandler/sendkeyshare.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ func (ksh *KeyShareHandler) ConstructDecryptionKeyShares(
113113
share := epochKG.ComputeEpochSecretKeyShare(identityPreimage)
114114

115115
shares = append(shares, &p2pmsg.KeyShare{
116-
EpochId: identityPreimage.Bytes(),
117-
Share: share.Marshal(),
116+
IdentityPreimage: identityPreimage.Bytes(),
117+
Share: share.Marshal(),
118118
})
119119
}
120120

rolling-shutter/keyper/epochkghandler/trigger_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ func TestHandleDecryptionTriggerIntegration(t *testing.T) {
7575
assert.DeepEqual(t, msg.GetShares(),
7676
[]*p2pmsg.KeyShare{
7777
{
78-
EpochId: identityPreimage.Bytes(),
79-
Share: share.DecryptionKeyShare,
78+
IdentityPreimage: identityPreimage.Bytes(),
79+
Share: share.DecryptionKeyShare,
8080
},
8181
},
8282
cmpopts.IgnoreUnexported(p2pmsg.KeyShare{}),

rolling-shutter/keyperimpl/gnosis/handlers.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (h *DecryptionKeySharesHandler) ValidateMessage(ctx context.Context, msg p2
6969

7070
identityPreimages := []identitypreimage.IdentityPreimage{}
7171
for _, share := range keyShares.Shares {
72-
identityPreimage := identitypreimage.IdentityPreimage(share.EpochId)
72+
identityPreimage := identitypreimage.IdentityPreimage(share.IdentityPreimage)
7373
identityPreimages = append(identityPreimages, identityPreimage)
7474
}
7575
slotDecryptionSignatureData, err := gnosisssztypes.NewSlotDecryptionSignatureData(
@@ -136,13 +136,13 @@ func (h *DecryptionKeySharesHandler) HandleMessage(ctx context.Context, msg p2pm
136136
for _, share := range keyShares.GetShares() {
137137
decryptionKeyDB, err := keyperCoreDB.GetDecryptionKey(ctx, corekeyperdatabase.GetDecryptionKeyParams{
138138
Eon: int64(keyShares.Eon),
139-
EpochID: share.EpochId,
139+
EpochID: share.IdentityPreimage,
140140
})
141141
if err == pgx.ErrNoRows {
142142
return []p2pmsg.Message{}, nil
143143
}
144144
key := &p2pmsg.Key{
145-
Identity: share.EpochId,
145+
Identity: share.IdentityPreimage,
146146
Key: decryptionKeyDB.DecryptionKey,
147147
}
148148
keys = append(keys, key)

rolling-shutter/keyperimpl/gnosis/identitieshash.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func computeIdentitiesHash(identityPreimages []identitypreimage.IdentityPreimage
1818
func computeIdentitiesHashFromShares(shares []*p2pmsg.KeyShare) []byte {
1919
identityPreimges := []identitypreimage.IdentityPreimage{}
2020
for _, share := range shares {
21-
identityPreimges = append(identityPreimges, identitypreimage.IdentityPreimage(share.EpochId))
21+
identityPreimges = append(identityPreimges, identitypreimage.IdentityPreimage(share.IdentityPreimage))
2222
}
2323
return computeIdentitiesHash(identityPreimges)
2424
}

rolling-shutter/keyperimpl/gnosis/messagingmiddleware.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func (i *MessagingMiddleware) interceptDecryptionKeyShares(
141141

142142
identityPreimages := []identitypreimage.IdentityPreimage{}
143143
for _, share := range originalMsg.Shares {
144-
identityPreimages = append(identityPreimages, identitypreimage.IdentityPreimage(share.EpochId))
144+
identityPreimages = append(identityPreimages, identitypreimage.IdentityPreimage(share.IdentityPreimage))
145145
}
146146
slotDecryptionSignatureData, err := gnosisssztypes.NewSlotDecryptionSignatureData(
147147
i.config.InstanceID,

rolling-shutter/keyperimpl/snapshot/trigger.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,14 @@ func (handler *DecryptionTriggerHandler) ValidateMessage(ctx context.Context, ms
6767

6868
signatureValid, err := p2pmsg.VerifySignature(trigger, collator)
6969
if err != nil {
70-
return pubsub.ValidationReject, errors.Wrapf(err, "error while verifying decryption trigger signature for epoch: %x", trigger.EpochId)
70+
return pubsub.ValidationReject, errors.Wrapf(
71+
err,
72+
"error while verifying decryption trigger signature for epoch: %x",
73+
trigger.IdentityPreimage,
74+
)
7175
}
7276
if !signatureValid {
73-
return pubsub.ValidationReject, errors.Errorf("decryption trigger signature invalid for epoch: %x", trigger.EpochId)
77+
return pubsub.ValidationReject, errors.Errorf("decryption trigger signature invalid for epoch: %x", trigger.IdentityPreimage)
7478
}
7579
return pubsub.ValidationAccept, nil
7680
}
@@ -81,7 +85,7 @@ func (handler *DecryptionTriggerHandler) HandleMessage(ctx context.Context, m p2
8185
return nil, errors.New("Message type assertion mismatch")
8286
}
8387
log.Info().Str("message", msg.LogInfo()).Msg("received decryption trigger")
84-
identityPreimage := identitypreimage.IdentityPreimage(msg.EpochId)
88+
identityPreimage := identitypreimage.IdentityPreimage(msg.IdentityPreimage)
8589

8690
trig := &epochkghandler.DecryptionTrigger{
8791
BlockNumber: msg.BlockNumber,

0 commit comments

Comments
 (0)