@@ -8,33 +8,33 @@ import (
8
8
"math/rand"
9
9
)
10
10
11
- func GeneratePairsFromVrfHash (hash [32 ]byte , dictionarySize , pairCount int ) (nums []int ) {
11
+ func GeneratePairsFromVrfHash (hash [32 ]byte , firstIndex , dictionarySize , pairCount int ) (nums []int ) {
12
12
rnd := rand .New (rand .NewSource (int64 (getWordsRnd (hash ))))
13
13
pairs := mapset .NewSet ()
14
14
for i := 0 ; i < pairCount ; i ++ {
15
15
var num1 , num2 int
16
- num1 , num2 = nextPair (rnd , dictionarySize , pairCount , pairs )
16
+ num1 , num2 = nextPair (rnd , firstIndex , dictionarySize , pairCount , pairs )
17
17
nums = append (nums , num1 , num2 )
18
18
}
19
19
return nums
20
20
}
21
21
22
- func (vc * ValidationCeremony ) GeneratePairs (seed []byte , dictionarySize , pairCount int ) (nums []int , proof []byte ) {
22
+ func (vc * ValidationCeremony ) GeneratePairs (seed []byte , firstIndex , dictionarySize , pairCount int ) (nums []int , proof []byte ) {
23
23
hash , p := vc .secStore .VrfEvaluate (seed )
24
- nums = GeneratePairsFromVrfHash (hash , dictionarySize , pairCount )
24
+ nums = GeneratePairsFromVrfHash (hash , firstIndex , dictionarySize , pairCount )
25
25
return nums , p
26
26
}
27
27
28
28
func getWordsRnd (hash [32 ]byte ) uint64 {
29
29
return binary .LittleEndian .Uint64 (hash [:])
30
30
}
31
31
32
- func GetWords (authorRnd uint64 , dictionarySize , pairCount , pairIndex int ) (word1 , word2 int , err error ) {
32
+ func GetWords (authorRnd uint64 , firstIndex , dictionarySize , pairCount , pairIndex int ) (word1 , word2 int , err error ) {
33
33
rnd := rand .New (rand .NewSource (int64 (authorRnd )))
34
34
pairs := mapset .NewSet ()
35
35
for i := 0 ; i < pairCount ; i ++ {
36
36
var val1 , val2 int
37
- val1 , val2 = nextPair (rnd , dictionarySize , pairCount , pairs )
37
+ val1 , val2 = nextPair (rnd , firstIndex , dictionarySize , pairCount , pairs )
38
38
if i == pairIndex {
39
39
return val1 , val2 , nil
40
40
}
@@ -46,11 +46,11 @@ func maxUniquePairs(dictionarySize int) int {
46
46
return (dictionarySize - 1 ) * dictionarySize / 2
47
47
}
48
48
49
- func nextPair (rnd * rand.Rand , dictionarySize , pairCount int , pairs mapset.Set ) (num1 , num2 int ) {
50
- num1 , num2 = rnd .Intn (dictionarySize ), rnd .Intn (dictionarySize )
49
+ func nextPair (rnd * rand.Rand , firstIndex , dictionarySize , pairCount int , pairs mapset.Set ) (num1 , num2 int ) {
50
+ num1 , num2 = rnd .Intn (dictionarySize )+ firstIndex , rnd .Intn (dictionarySize )+ firstIndex
51
51
maxPairs := maxUniquePairs (dictionarySize )
52
52
for pairCount <= maxPairs && ! checkPair (num1 , num2 , pairs ) {
53
- num1 , num2 = rnd .Intn (dictionarySize ), rnd .Intn (dictionarySize )
53
+ num1 , num2 = rnd .Intn (dictionarySize )+ firstIndex , rnd .Intn (dictionarySize )+ firstIndex
54
54
}
55
55
56
56
pairs .Add (pairToString (num1 , num2 ))
0 commit comments