5
5
6
6
"github.com/shutter-network/shutter/shlib/shcrypto"
7
7
8
- "github.com/shutter-network/rolling-shutter/rolling-shutter/medley/epochid "
8
+ "github.com/shutter-network/rolling-shutter/rolling-shutter/medley/identitypreimage "
9
9
)
10
10
11
11
// KeyGenerator is a helper tool to generate secret and public eon and epoch keys and key
@@ -28,15 +28,15 @@ func NewKeyGenerator(numKeypers uint64, threshold uint64) *KeyGenerator {
28
28
29
29
// getEonIndex computes the index of the EON key to be used for the given epochID. We generate a new
30
30
// eon key every eonInterval epochs.
31
- func (kg * KeyGenerator ) getEonIndex (epochID epochid. EpochID ) uint64 {
31
+ func (kg * KeyGenerator ) getEonIndex (epochID identitypreimage. IdentityPreimage ) uint64 {
32
32
if kg .eonInterval == 0 {
33
33
return 0
34
34
}
35
35
36
36
return epochID .Big ().Uint64 () / kg .eonInterval
37
37
}
38
38
39
- func (kg * KeyGenerator ) EonKeysForEpoch (epochID epochid. EpochID ) * EonKeys {
39
+ func (kg * KeyGenerator ) EonKeysForEpoch (epochID identitypreimage. IdentityPreimage ) * EonKeys {
40
40
eonIndex := kg .getEonIndex (epochID )
41
41
res , ok := kg .eonKeyGen [eonIndex ]
42
42
var err error
@@ -54,40 +54,37 @@ func (kg *KeyGenerator) EonKeysForEpoch(epochID epochid.EpochID) *EonKeys {
54
54
return res
55
55
}
56
56
57
- func (kg * KeyGenerator ) EonPublicKeyShare (epochID epochid. EpochID , keyperIndex uint64 ) * shcrypto.EonPublicKeyShare {
57
+ func (kg * KeyGenerator ) EonPublicKeyShare (epochID identitypreimage. IdentityPreimage , keyperIndex uint64 ) * shcrypto.EonPublicKeyShare {
58
58
return kg .EonKeysForEpoch (epochID ).keyperShares [keyperIndex ].eonPublicKeyShare
59
59
}
60
60
61
- func (kg * KeyGenerator ) EonPublicKey (epochID epochid. EpochID ) * shcrypto.EonPublicKey {
61
+ func (kg * KeyGenerator ) EonPublicKey (epochID identitypreimage. IdentityPreimage ) * shcrypto.EonPublicKey {
62
62
return kg .EonKeysForEpoch (epochID ).publicKey
63
63
}
64
64
65
- func (kg * KeyGenerator ) EonSecretKeyShare (epochID epochid. EpochID , keyperIndex uint64 ) * shcrypto.EonSecretKeyShare {
65
+ func (kg * KeyGenerator ) EonSecretKeyShare (epochID identitypreimage. IdentityPreimage , keyperIndex uint64 ) * shcrypto.EonSecretKeyShare {
66
66
return kg .EonKeysForEpoch (epochID ).keyperShares [keyperIndex ].eonSecretKeyShare
67
67
}
68
68
69
- func (kg * KeyGenerator ) EpochSecretKeyShare (epochID epochid. EpochID , keyperIndex uint64 ) * shcrypto.EpochSecretKeyShare {
69
+ func (kg * KeyGenerator ) EpochSecretKeyShare (epochID identitypreimage. IdentityPreimage , keyperIndex uint64 ) * shcrypto.EpochSecretKeyShare {
70
70
return kg .EonKeysForEpoch (epochID ).keyperShares [keyperIndex ].ComputeEpochSecretKeyShare (epochID )
71
71
}
72
72
73
- func (kg * KeyGenerator ) EpochSecretKey (epochID epochid. EpochID ) * shcrypto.EpochSecretKey {
73
+ func (kg * KeyGenerator ) EpochSecretKey (epochID identitypreimage. IdentityPreimage ) * shcrypto.EpochSecretKey {
74
74
epochSecretKey , err := kg .EonKeysForEpoch (epochID ).EpochSecretKey (epochID )
75
75
if err != nil {
76
76
panic (err )
77
77
}
78
78
return epochSecretKey
79
79
}
80
80
81
- func (kg * KeyGenerator ) RandomEpochID (epochbytes []byte ) epochid. EpochID {
81
+ func (kg * KeyGenerator ) RandomEpochID (epochbytes []byte ) identitypreimage. IdentityPreimage {
82
82
_ , err := rand .Read (epochbytes )
83
83
if err != nil {
84
84
panic (err )
85
85
}
86
86
87
- epochID , err := epochid .BytesToEpochID (epochbytes )
88
- if err != nil {
89
- panic (err )
90
- }
87
+ epochID := identitypreimage .IdentityPreimage (epochbytes )
91
88
return epochID
92
89
}
93
90
0 commit comments