Skip to content

Commit d466ad3

Browse files
committed
Fix galois field and number theory dependencies
1 parent ca31452 commit d466ad3

File tree

4 files changed

+53
-7
lines changed

4 files changed

+53
-7
lines changed

Bulletproofs/Curve.hs

+6-5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ module Bulletproofs.Curve (
1212
) where
1313

1414
import Protolude hiding (hash)
15+
import Data.Maybe (fromJust)
1516

1617
import Crypto.Hash
1718
import qualified Crypto.PubKey.ECC.Generate as Crypto
@@ -20,7 +21,8 @@ import qualified Crypto.PubKey.ECC.Types as Crypto
2021

2122
import qualified Data.ByteArray as BA
2223
import Crypto.Number.Serialize (os2ip)
23-
import Math.NumberTheory.Moduli.Sqrt (sqrtModP)
24+
import Math.NumberTheory.Moduli.Sqrt (sqrtsModPrime)
25+
import Math.NumberTheory.UniqueFactorisation (isPrime)
2426

2527
import Numeric
2628
import qualified Data.List as L
@@ -98,11 +100,10 @@ _p = Crypto.ecc_p cp
98100
generateH :: Crypto.Point -> [Char] -> Crypto.Point
99101
generateH basePoint extra =
100102
case yM of
101-
Nothing -> generateH basePoint (toS $ '1':extra)
102-
Just y -> if Crypto.isPointValid curve (Crypto.Point x y)
103+
[] -> generateH basePoint (toS $ '1':extra)
104+
(y:_) -> if Crypto.isPointValid curve (Crypto.Point x y)
103105
then Crypto.Point x y
104106
else generateH basePoint (toS $ '1':extra)
105107
where
106108
x = oracle (pointToBS basePoint <> toS extra) `mod` _p
107-
yM = sqrtModP (x ^ 3 + 7) _p
108-
109+
yM = sqrtsModPrime (fromInteger (x ^ 3 + 7)) ((fromJust (isPrime _p)))

ChangeLog.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog for bulletproofs
22

3+
## 1.0.1
4+
5+
* Fix arithmoi dependency.
6+
* Fix galois-field dependency.
7+
38
## 1.0
49

510
* Use galois-field library as dependency

package.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: bulletproofs
2-
version: 1.0.0
2+
version: 1.0.1
33
github: "adjoint-io/bulletproofs"
44
license: Apache
55
maintainer: Adjoint Inc ([email protected])
@@ -23,7 +23,7 @@ dependencies:
2323
- text
2424
- cryptonite
2525
- memory
26-
- arithmoi
26+
- arithmoi >= 0.8
2727
- containers
2828
- random-shuffle
2929
- MonadRandom

stack.yaml.lock

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# This file was autogenerated by Stack.
2+
# You should not edit this file by hand.
3+
# For more information, please see the documentation at:
4+
# https://docs.haskellstack.org/en/stable/lock_files
5+
6+
packages:
7+
- completed:
8+
hackage: criterion-1.5.2.0@sha256:7ba73119322c7f481e93214853d208f1f9331e45d8b3b070da5a1d21c440826c,5324
9+
pantry-tree:
10+
size: 2213
11+
sha256: 99737e889407fac08849d30554cc2fba49f2aa8e8683004563e092de18d8f008
12+
original:
13+
hackage: criterion-1.5.2.0
14+
- completed:
15+
hackage: galois-field-0.4.0@sha256:7f8aed0c11f6afc720685c2ede6bdbea3ce8dbd738dacd8fbf722168863d4dd1,3190
16+
pantry-tree:
17+
size: 1130
18+
sha256: e68a2fb1731fc4cdf5f0ae4dd718f8bd2e128eb6285be3d602a209e5430812ba
19+
original:
20+
hackage: galois-field-0.4.0
21+
- completed:
22+
hackage: poly-0.3.1.0@sha256:3e015e84d304c4197a2cff4a78400ed619eb850922d566028edb6c7254f2095f,1875
23+
pantry-tree:
24+
size: 1466
25+
sha256: ee6b1de208cdd7a621e3138fe3507f4a97d26ce3c47fe20021c1de75d3fddf29
26+
original:
27+
hackage: poly-0.3.1.0
28+
- completed:
29+
hackage: semirings-0.4.2@sha256:7803a3bd8add49c375da59d456b59e32ea02a88ac1a1d71132420e4c976333f3,3750
30+
pantry-tree:
31+
size: 555
32+
sha256: dcf5c467c4005b567d409c3fe74aa233a6a9313a3693716eeee9ddafbd953f87
33+
original:
34+
hackage: semirings-0.4.2
35+
snapshots:
36+
- completed:
37+
size: 499889
38+
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/13/26.yaml
39+
sha256: ecb02ee16829df8d7219e7d7fe6c310819820bf335b0b9534bce84d3ea896684
40+
original: lts-13.26

0 commit comments

Comments
 (0)