packages feed

bulletproofs 0.1.0 → 0.2.0

raw patch · 13 files changed

+104/−44 lines, 13 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Bulletproofs.Curve: curveName :: CurveName
- Bulletproofs.Curve: generateH :: Point -> [Char] -> Point
- Bulletproofs.Curve: p :: Integer
- Bulletproofs.Curve: sha256 :: ByteString -> ByteString
- Bulletproofs.Fq: asInteger :: Fq -> Integer
- Bulletproofs.Fq: fqAdd :: Fq -> Fq -> Fq
- Bulletproofs.Fq: fqDiv :: Fq -> Fq -> Fq
- Bulletproofs.Fq: fqMul :: Fq -> Fq -> Fq
- Bulletproofs.Fq: fqMulV :: [Fq] -> [Fq] -> [Fq]
- Bulletproofs.Fq: fqNeg :: Fq -> Fq
- Bulletproofs.Fq: inv' :: (Integral a) => a -> a -> (a, a)
- Bulletproofs.Fq: norm :: Fq -> Fq
- Bulletproofs.RangeProof.Internal: encodeBit :: Integer -> Fq -> [Fq]
- Bulletproofs.RangeProof.Internal: fillWithZeros :: Integer -> [Fq] -> [Fq]
- Bulletproofs.RangeProof.Prover: computeLRPolys :: Integer -> [Fq] -> [Fq] -> [Fq] -> [Fq] -> Fq -> Fq -> LRPolys
- Bulletproofs.RangeProof.Prover: computeTPoly :: LRPolys -> TPoly
- Bulletproofs.Utils: isLogBase2 :: Integer -> Bool

Files

Bulletproofs/Curve.hs view
@@ -1,4 +1,13 @@-module Bulletproofs.Curve where+module Bulletproofs.Curve (+  q,+  g,+  h,+  gs,+  hs,+  curve,+  oracle,+  pointToBS,+) where  import Protolude hiding (hash) @@ -11,7 +20,6 @@ import Crypto.Number.Serialize (os2ip) import Math.NumberTheory.Moduli.Sqrt (sqrtModP) --- TEST import Numeric import qualified Data.List as L 
Bulletproofs/Fq.hs view
@@ -1,6 +1,19 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} -module Bulletproofs.Fq where+module Bulletproofs.Fq (+  Fq(..),+  new,+  inv,+  fqInv,+  fqZero,+  fqOne,+  fqSquare,+  fqCube,+  fqSubV,+  fqAddV,+  euclidean,+  random+) where  import Protolude 
Bulletproofs/InnerProductProof.hs view
@@ -1,12 +1,10 @@-module Bulletproofs.InnerProductProof-( generateProof-, verifyProof--, InnerProductProof(..)-, InnerProductBase(..)-, InnerProductWitness(..)+module Bulletproofs.InnerProductProof ( +  generateProof,+  verifyProof,+  InnerProductProof(..),+  InnerProductBase(..),+  InnerProductWitness(..), ) where-  import Bulletproofs.InnerProductProof.Internal import Bulletproofs.InnerProductProof.Prover
Bulletproofs/InnerProductProof/Internal.hs view
@@ -1,4 +1,8 @@-module Bulletproofs.InnerProductProof.Internal where+module Bulletproofs.InnerProductProof.Internal (+  InnerProductProof(..),+  InnerProductWitness(..),+  InnerProductBase(..),+) where  import Protolude 
Bulletproofs/InnerProductProof/Prover.hs view
@@ -1,7 +1,7 @@ {-# LANGUAGE NamedFieldPuns, MultiWayIf #-} -module Bulletproofs.InnerProductProof.Prover-( generateProof+module Bulletproofs.InnerProductProof.Prover ( +  generateProof, ) where  import Protolude
Bulletproofs/InnerProductProof/Verifier.hs view
@@ -1,8 +1,8 @@ {-# LANGUAGE RecordWildCards, NamedFieldPuns, MultiWayIf #-} -module Bulletproofs.InnerProductProof.Verifier-  ( verifyProof-  ) where+module Bulletproofs.InnerProductProof.Verifier ( +  verifyProof,+) where  import Protolude 
Bulletproofs/RangeProof.hs view
@@ -1,13 +1,11 @@-module Bulletproofs.RangeProof-( RangeProof(..)-, RangeProofError(..)+module Bulletproofs.RangeProof ( +    RangeProof(..)+  , RangeProofError(..) -, generateProof-, generateProofUnsafe-, verifyProof+  , generateProof+  , generateProofUnsafe+  , verifyProof ) where--  import Bulletproofs.RangeProof.Internal import Bulletproofs.RangeProof.Prover
Bulletproofs/RangeProof/Internal.hs view
@@ -1,4 +1,18 @@-module Bulletproofs.RangeProof.Internal where+module Bulletproofs.RangeProof.Internal (+  RangeProof(..),+  RangeProofError(..),+  LRPolys(..),+  TPoly(..),+  delta,+  checkRange,+  reversedEncodeBit,+  complementaryVector,+  chooseBlindingVectors,+  commitBitVectors,+  computeLRCommitment,+  obfuscateEncodedBits,+  obfuscateEncodedBitsSingle,+) where  import Protolude 
Bulletproofs/RangeProof/Prover.hs view
@@ -1,6 +1,9 @@ {-# LANGUAGE RecordWildCards, MultiWayIf #-} -module Bulletproofs.RangeProof.Prover where+module Bulletproofs.RangeProof.Prover (+  generateProof,+  generateProofUnsafe,+) where  import Protolude @@ -14,7 +17,8 @@ import Bulletproofs.Fq as Fq import Bulletproofs.RangeProof.Internal -import Bulletproofs.InnerProductProof as IPP+import Bulletproofs.InnerProductProof as IPP hiding (generateProof)+import qualified Bulletproofs.InnerProductProof as IPP  -- | Prove that a value lies in a specific range generateProof
Bulletproofs/RangeProof/Verifier.hs view
@@ -1,6 +1,10 @@ {-# LANGUAGE RecordWildCards, MultiWayIf, NamedFieldPuns, ViewPatterns #-} -module Bulletproofs.RangeProof.Verifier where+module Bulletproofs.RangeProof.Verifier (+  verifyProof,+  verifyTPoly,+  verifyLRCommitment,+) where  import Protolude import Prelude (zipWith3)@@ -14,7 +18,8 @@ import Bulletproofs.Utils import Bulletproofs.Fq as Fq -import Bulletproofs.InnerProductProof as IPP+import Bulletproofs.InnerProductProof as IPP hiding (verifyProof)+import qualified Bulletproofs.InnerProductProof as IPP  -- | Verify that a commitment was computed from a value in a given range verifyProof
Bulletproofs/Utils.hs view
@@ -1,4 +1,19 @@-module Bulletproofs.Utils where+module Bulletproofs.Utils (+  dotp,+  addP,+  subP,+  mulP,+  shamirU,+  shamirX,+  shamirX',+  shamirY,+  shamirZ,+  commit,+  hadamardp,+  powerVector,+  logBase2,+  logBase2M,+) where  import Protolude 
README.md view
@@ -2,7 +2,8 @@   <a href="http://www.adjoint.io"><img src="https://www.adjoint.io/assets/img/adjoint-logo@2x.png" width="250"/></a> </p> -[![CircleCI](https://circleci.com/gh/adjoint-io/bulletproofs.svg?style=svg)](https://circleci.com/gh/adjoint-io/bulletproofs)+[![CircleCI](http://circleci.com/gh/adjoint-io/bulletproofs.svg?style=shield)](https://circleci.com/gh/adjoint-io/bulletproofs)+[![Hackage](https://img.shields.io/hackage/v/bulletproofs.svg)](http://hackage.haskell.org/package/bulletproofs)  Bulletproofs are short zero-knowledge arguments of knowledge that do not require a trusted setup. Argument systems are proof systems with computational soundness.@@ -36,32 +37,32 @@  - **P -> V : A, S** - where A and S are blinded Pedersen commitments to **a<sub>L</sub>** and **a<sub>R</sub>**. -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ![equation](https://latex.codecogs.com/gif.latex?\\&space;$&space;A&space;=&space;h&space;\cdot&space;\alpha&space;&plus;&space;\textbf{g}&space;\cdot&space;\textbf{a}_L&space;&plus;&space;\textbf{h}&space;\cdot&space;\textbf{a}_R&space;\in&space;\mathcal{G}&space;$)+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ![equation](https://latex.codecogs.com/gif.latex?\\&space;$&space;A&space;=&space;h&space;\cdot&space;\alpha&space;&plus;&space;\textbf{g}&space;\cdot&space;\textbf{a}_L&space;&plus;&space;\textbf{h}&space;\cdot&space;\textbf{a}_R&space;\in&space;\mathbb{G}&space;$) -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ![equation](https://latex.codecogs.com/gif.latex?\\&space;$&space;S&space;=&space;h&space;\cdot&space;\rho&space;&plus;&space;\textbf{g}&space;\cdot&space;\textbf{s}_L&space;&plus;&space;\textbf{h}&space;\cdot&space;\textbf{s}_R&space;\in&space;\mathcal{G}&space;$)+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ![equation](https://latex.codecogs.com/gif.latex?\\&space;$&space;S&space;=&space;h&space;\cdot&space;\rho&space;&plus;&space;\textbf{g}&space;\cdot&space;\textbf{s}_L&space;&plus;&space;\textbf{h}&space;\cdot&space;\textbf{s}_R&space;\in&space;\mathbb{G}&space;$)  - **V -> P : y, z** - Verifier sends challenges _y_ and _z_ to fix **A** and **S**.  - **P -> V : T<sub>1</sub>, T<sub>2</sub>** - where T<sub>1</sub> and T<sub>2</sub> are commitments to the coefficients t<sub>1</sub>, of a polynomial t constructed from the existing values in the protocol. -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ![equation](https://latex.codecogs.com/gif.latex?\\&space;$&space;\textbf{l}&space;=&space;l(x)&space;=&space;\textbf{a}_L&space;-&space;z&space;\cdot&space;\textbf{1}^n&space;&plus;&space;\textbf{s}_L&space;\cdot&space;x&space;\in&space;\mathcal{Z}^n_p$)+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ![equation](https://latex.codecogs.com/gif.latex?\\&space;$&space;\textbf{l}&space;=&space;l(x)&space;=&space;\textbf{a}_L&space;-&space;z&space;\cdot&space;\textbf{1}^n&space;&plus;&space;\textbf{s}_L&space;\cdot&space;x&space;\in&space;\mathbb{Z}^n_p$) -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ![equation](https://latex.codecogs.com/gif.latex?\\&space;$&space;\textbf{r}&space;=&space;r(x)&space;=&space;\textbf{y}^n&space;\circ&space;(\textbf{a}_R&space;&plus;&space;z&space;\cdot&space;\textbf{1}^n&space;&plus;&space;\textbf{s}_R&space;\cdot&space;x&space;)&space;&plus;&space;z^2&space;\cdot&space;\textbf{2}^n&space;\in&space;\mathcal{Z}^n_p&space;$)+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ![equation](https://latex.codecogs.com/gif.latex?\\&space;$&space;\textbf{r}&space;=&space;r(x)&space;=&space;\textbf{y}^n&space;\circ&space;(\textbf{a}_R&space;&plus;&space;z&space;\cdot&space;\textbf{1}^n&space;&plus;&space;\textbf{s}_R&space;\cdot&space;x&space;)&space;&plus;&space;z^2&space;\cdot&space;\textbf{2}^n&space;\in&space;\mathbb{Z}^n_p&space;$) -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ![equation](https://latex.codecogs.com/gif.latex?\\&space;$&space;t&space;=&space;\langle&space;\textbf{l},&space;\textbf{r}&space;\rangle&space;\in&space;\mathcal{Z}_p$)+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ![equation](https://latex.codecogs.com/gif.latex?\\&space;$&space;t&space;=&space;\langle&space;\textbf{l},&space;\textbf{r}&space;\rangle&space;\in&space;\mathbb{Z}_p$) -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ![equation](https://latex.codecogs.com/gif.latex?\\&space;$T_i&space;=&space;g&space;\cdot&space;t_i&space;&plus;&space;h&space;\cdot&space;\tau_i&space;\in&space;\mathcal{G},&space;\hspace{3em}&space;i&space;=&space;\{1,&space;2\}&space;$)+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ![equation](https://latex.codecogs.com/gif.latex?\\&space;$T_i&space;=&space;g&space;\cdot&space;t_i&space;&plus;&space;h&space;\cdot&space;\tau_i&space;\in&space;\mathbb{G},&space;\hspace{3em}&space;i&space;=&space;\{1,&space;2\}&space;$)  - **V -> P : x** - Verifier challenges Prover with value _x_.  - **P -> V : tau, mu, t, l, r** - Prover sends several commitments that the verifier will then check. -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ![equation](https://latex.codecogs.com/gif.latex?\\&space;$&space;\tau_x&space;=&space;\tau_2&space;\cdot&space;x^2&space;&plus;&space;\tau_1&space;\cdot&space;x&space;&plus;&space;z^2&space;\cdot&space;\gamma&space;\in&space;\mathcal{Z}_p&space;$)+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ![equation](https://latex.codecogs.com/gif.latex?\\&space;$&space;\tau_x&space;=&space;\tau_2&space;\cdot&space;x^2&space;&plus;&space;\tau_1&space;\cdot&space;x&space;&plus;&space;z^2&space;\cdot&space;\gamma&space;\in&space;\mathbb{Z}_p&space;$) -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ![equation](https://latex.codecogs.com/gif.latex?\\&space;$&space;\mu&space;=&space;\alpha&space;&plus;&space;\rho&space;\cdot&space;x&space;\in&space;\mathcal{Z}_p&space;$)+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ![equation](https://latex.codecogs.com/gif.latex?\\&space;$&space;\mu&space;=&space;\alpha&space;&plus;&space;\rho&space;\cdot&space;x&space;\in&space;\mathbb{Z}_p&space;$) -See [Prover.hs](https://github.com/adjoint-io/bulletproofs/blob/master/src/RangeProof/Prover.hs "Prover.hs") for implementation details.+See [Prover.hs](https://github.com/adjoint-io/bulletproofs/blob/master/Bulletproofs/RangeProof/Prover.hs "Prover.hs") for implementation details.  The interaction described is made non-interactive using the Fiat-Shamir Transform wherein all the random challenges made by V are replaced with a hash of the transcript up until that point.@@ -109,7 +110,7 @@  **References**: -1.  Bunz B., Bootle J., Boneh J., Poelstra A., Wuille P., Maxwell G.+1.  Bunz B., Bootle J., Boneh D., Poelstra A., Wuille P., Maxwell G.     "Bulletproofs: Short Proofs for Confidential Transactions and More". Stanford, UCL, Blockstream, 2017  2. Groth J. "Linear Algebra with Sub-linear Zero-Knowledge Arguments". University College London, 2009
bulletproofs.cabal view
@@ -2,10 +2,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 3b89183974f949f3c27e1427d8945ec87f154533ac162d13451c5e50045d5d78+-- hash: b1527afdaf3310a51701ef0c756ab6e3cd6ed3606bc52e74b6a0a744bbbf5426  name:           bulletproofs-version:        0.1.0+version:        0.2.0 description:    Please see the README on GitHub at <https://github.com/githubuser/bulletproofs#readme> category:       Cryptography homepage:       https://github.com/adjoint-io/bulletproofs#readme