Skip to content

Commit 1374e26

Browse files
adecaroalexandrosfilios
authored andcommitted
remove the use of math.Pow
Signed-off-by: Angelo De Caro <adc@zurich.ibm.com>
1 parent 2dfb67f commit 1374e26

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

token/core/zkatdlog/crypto/rp/bulletproof_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ SPDX-License-Identifier: Apache-2.0
77
package rp_test
88

99
import (
10-
math2 "math"
1110
"strconv"
1211

1312
math "github.com/IBM/mathlib"
@@ -23,7 +22,7 @@ var _ = Describe("Range Proof", func() {
2322
It("Succeeds", func() {
2423
curve := math.Curves[1]
2524
nr := uint64(3)
26-
l := uint64(math2.Pow(2, float64(nr)))
25+
l := uint64(1 << nr)
2726
leftGens := make([]*math.G1, l)
2827
rightGens := make([]*math.G1, l)
2928

token/core/zkatdlog/crypto/rp/ipa_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ SPDX-License-Identifier: Apache-2.0
66
package rp_test
77

88
import (
9-
math2 "math"
109
"strconv"
1110

1211
math "github.com/IBM/mathlib"
@@ -22,7 +21,7 @@ var _ = Describe("Inner Product Argument", func() {
2221
It("Succeeds", func() {
2322
curve := math.Curves[0]
2423
nr := uint64(6)
25-
l := uint64(math2.Pow(2, float64(nr)))
24+
l := uint64(1 << nr)
2625
leftGens := make([]*math.G1, l)
2726
rightGens := make([]*math.G1, l)
2827
left := make([]*math.Zr, l)

token/core/zkatdlog/crypto/setup.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,11 @@ func (rpp *RangeProofParams) Validate() error {
3939
if rpp.NumberOfRounds == 0 {
4040
return errors.New("invalid range proof parameters: number of rounds is zero")
4141
}
42-
if rpp.BitLength != uint64(math.Pow(2, float64(rpp.NumberOfRounds))) {
43-
return errors.Errorf("invalid range proof parameters: bit length should be %d\n", int(math.Pow(2, float64(rpp.NumberOfRounds))))
42+
if rpp.NumberOfRounds > 64 {
43+
return errors.New("invalid range proof parameters: number of rounds must be smaller or equal to 64")
44+
}
45+
if rpp.BitLength != uint64(1<<rpp.NumberOfRounds) {
46+
return errors.Errorf("invalid range proof parameters: bit length should be %d\n", uint64(1<<rpp.NumberOfRounds))
4447
}
4548
if len(rpp.LeftGenerators) != len(rpp.RightGenerators) {
4649
return errors.Errorf("invalid range proof parameters: the size of the left generators does not match the size of the right generators [%d vs, %d]", len(rpp.LeftGenerators), len(rpp.RightGenerators))

0 commit comments

Comments
 (0)