Skip to content

Commit

Permalink
Fix galois field and number theory dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
sdiehl committed Aug 13, 2019
1 parent ca31452 commit d466ad3
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 7 deletions.
11 changes: 6 additions & 5 deletions Bulletproofs/Curve.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module Bulletproofs.Curve (
) where

import Protolude hiding (hash)
import Data.Maybe (fromJust)

import Crypto.Hash
import qualified Crypto.PubKey.ECC.Generate as Crypto
Expand All @@ -20,7 +21,8 @@ import qualified Crypto.PubKey.ECC.Types as Crypto

import qualified Data.ByteArray as BA
import Crypto.Number.Serialize (os2ip)
import Math.NumberTheory.Moduli.Sqrt (sqrtModP)
import Math.NumberTheory.Moduli.Sqrt (sqrtsModPrime)
import Math.NumberTheory.UniqueFactorisation (isPrime)

import Numeric
import qualified Data.List as L
Expand Down Expand Up @@ -98,11 +100,10 @@ _p = Crypto.ecc_p cp
generateH :: Crypto.Point -> [Char] -> Crypto.Point
generateH basePoint extra =
case yM of
Nothing -> generateH basePoint (toS $ '1':extra)
Just y -> if Crypto.isPointValid curve (Crypto.Point x y)
[] -> generateH basePoint (toS $ '1':extra)
(y:_) -> if Crypto.isPointValid curve (Crypto.Point x y)
then Crypto.Point x y
else generateH basePoint (toS $ '1':extra)
where
x = oracle (pointToBS basePoint <> toS extra) `mod` _p
yM = sqrtModP (x ^ 3 + 7) _p

yM = sqrtsModPrime (fromInteger (x ^ 3 + 7)) ((fromJust (isPrime _p)))
5 changes: 5 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog for bulletproofs

## 1.0.1

* Fix arithmoi dependency.
* Fix galois-field dependency.

## 1.0

* Use galois-field library as dependency
Expand Down
4 changes: 2 additions & 2 deletions package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: bulletproofs
version: 1.0.0
version: 1.0.1
github: "adjoint-io/bulletproofs"
license: Apache
maintainer: Adjoint Inc ([email protected])
Expand All @@ -23,7 +23,7 @@ dependencies:
- text
- cryptonite
- memory
- arithmoi
- arithmoi >= 0.8
- containers
- random-shuffle
- MonadRandom
Expand Down
40 changes: 40 additions & 0 deletions stack.yaml.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This file was autogenerated by Stack.
# You should not edit this file by hand.
# For more information, please see the documentation at:
# https://docs.haskellstack.org/en/stable/lock_files

packages:
- completed:
hackage: criterion-1.5.2.0@sha256:7ba73119322c7f481e93214853d208f1f9331e45d8b3b070da5a1d21c440826c,5324
pantry-tree:
size: 2213
sha256: 99737e889407fac08849d30554cc2fba49f2aa8e8683004563e092de18d8f008
original:
hackage: criterion-1.5.2.0
- completed:
hackage: galois-field-0.4.0@sha256:7f8aed0c11f6afc720685c2ede6bdbea3ce8dbd738dacd8fbf722168863d4dd1,3190
pantry-tree:
size: 1130
sha256: e68a2fb1731fc4cdf5f0ae4dd718f8bd2e128eb6285be3d602a209e5430812ba
original:
hackage: galois-field-0.4.0
- completed:
hackage: poly-0.3.1.0@sha256:3e015e84d304c4197a2cff4a78400ed619eb850922d566028edb6c7254f2095f,1875
pantry-tree:
size: 1466
sha256: ee6b1de208cdd7a621e3138fe3507f4a97d26ce3c47fe20021c1de75d3fddf29
original:
hackage: poly-0.3.1.0
- completed:
hackage: semirings-0.4.2@sha256:7803a3bd8add49c375da59d456b59e32ea02a88ac1a1d71132420e4c976333f3,3750
pantry-tree:
size: 555
sha256: dcf5c467c4005b567d409c3fe74aa233a6a9313a3693716eeee9ddafbd953f87
original:
hackage: semirings-0.4.2
snapshots:
- completed:
size: 499889
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/13/26.yaml
sha256: ecb02ee16829df8d7219e7d7fe6c310819820bf335b0b9534bce84d3ea896684
original: lts-13.26

0 comments on commit d466ad3

Please sign in to comment.