packages feed

bulletproofs 1.0.0 → 1.0.1

raw patch · 5 files changed

+25/−70 lines, 5 filesdep −pairingdep ~arithmoidep ~galois-field

Dependencies removed: pairing

Dependency ranges changed: arithmoi, galois-field

Files

Bulletproofs/Curve.hs view
@@ -12,6 +12,7 @@ ) where  import Protolude hiding (hash)+import Data.Maybe (fromJust)  import Crypto.Hash import qualified Crypto.PubKey.ECC.Generate as Crypto@@ -20,7 +21,8 @@  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@@ -98,11 +100,10 @@ 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)))
Bulletproofs/Fq.hs view
@@ -1,68 +1,18 @@ {-# LANGUAGE TypeFamilies #-}--- | Prime field with characteristic _q, over which the elliptic curve--- is defined and the other finite field extensions.------   * Fq---   * Fq2 := Fq[u]/u^2 + 1---   * Fq6 := Fq2[v]/v^3 - (9 + u)---   * Fq12 := Fq6[w]/w^2 - v  module Bulletproofs.Fq   ( Fq   , PF-  , fqRandom-  , fqPow-  , fqSqrt-  , toInt   ) where  import Protolude -import Crypto.Random (MonadRandom)-import Crypto.Number.Generate (generateMax)-import Math.NumberTheory.Moduli.Class (powMod)-import PrimeField (PrimeField(..), toInt)-import Pairing.Modular+import PrimeField (PrimeField(..)) import Bulletproofs.Curve ------------------------------------------------------------------------------------ Types--------------------------------------------------------------------------------- -- | Prime field @Fq@ with characteristic @_q@ type Fq = PrimeField 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141  -- | Type family to extract the characteristic of the prime field type family PF a where   PF (PrimeField k) = k------------------------------------------------------------------------------------ Instances----------------------------------------------------------------------------------instance Ord Fq where-  compare = on compare toInt------------------------------------------------------------------------------------ Random----------------------------------------------------------------------------------fqRandom :: MonadRandom m => m Fq-fqRandom = fromInteger <$> generateMax _q------------------------------------------------------------------------------------ Y for X----------------------------------------------------------------------------------fqPow :: Integral e => Fq -> e -> Fq-fqPow a b = fromInteger (withQ (modUnOp (toInt a) (flip powMod b)))-{-# INLINE fqPow #-}--fqSqrt :: Bool -> Fq -> Maybe Fq-fqSqrt largestY a = do-  (y1, y2) <- withQM (modUnOpMTup (toInt a) bothSqrtOf)-  return (fromInteger ((if largestY then max else min) y1 y2))--fqYforX :: Fq -> Bool -> Maybe Fq-fqYforX x largestY = fqSqrt largestY (x `fqPow` 3 + fromInteger _b)
ChangeLog.md view
@@ -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
bulletproofs.cabal view
@@ -1,11 +1,13 @@--- This file has been generated from package.yaml by hpack version 0.28.2.+cabal-version: 1.12++-- This file has been generated from package.yaml by hpack version 0.31.2. -- -- see: https://github.com/sol/hpack ----- hash: c3039f817828e381dba02b51b3dd24480614dfa32254ebae4b12992e2d2a126e+-- hash: 8d64db9eb665557111c118de02a106cc7b0671597707d1314eba6f33cfbe9dd6  name:           bulletproofs-version:        1.0.0+version:        1.0.1 description:    Please see the README on GitHub at <https://github.com/adjoint-io/bulletproofs#readme> category:       Cryptography homepage:       https://github.com/adjoint-io/bulletproofs#readme@@ -14,10 +16,9 @@ license:        Apache license-file:   LICENSE build-type:     Simple-cabal-version:  >= 1.10 extra-source-files:-    ChangeLog.md     README.md+    ChangeLog.md  source-repository head   type: git@@ -51,13 +52,12 @@   build-depends:       MonadRandom     , QuickCheck-    , arithmoi+    , arithmoi >=0.8     , base >=4.7 && <5     , containers     , cryptonite-    , galois-field+    , galois-field ==0.4.0     , memory-    , pairing     , protolude >=0.2     , random-shuffle     , text@@ -78,14 +78,13 @@   build-depends:       MonadRandom     , QuickCheck-    , arithmoi+    , arithmoi >=0.8     , base     , bulletproofs     , containers     , cryptonite-    , galois-field+    , galois-field ==0.4.0     , memory-    , pairing     , protolude >=0.2     , random-shuffle     , tasty@@ -105,15 +104,14 @@   build-depends:       MonadRandom     , QuickCheck-    , arithmoi+    , arithmoi >=0.8     , base >=4.7 && <5     , bulletproofs     , containers     , criterion >=1.5.1.0     , cryptonite-    , galois-field+    , galois-field ==0.4.0     , memory-    , pairing     , protolude >=0.2     , random-shuffle     , tasty
tests/TestProtocol.hs view
@@ -15,6 +15,7 @@ import qualified Crypto.PubKey.ECC.Prim as Crypto import qualified Crypto.PubKey.ECC.Types as Crypto import GaloisField (GaloisField(..))+import PrimeField (toInt)  import Bulletproofs.Curve import qualified Bulletproofs.RangeProof as RP