From 54410d2b826060fc67776e0aa5ea06d3a2fd93c0 Mon Sep 17 00:00:00 2001 From: vks4git Date: Fri, 26 Jul 2024 11:29:26 +0000 Subject: [PATCH] stylish-haskell auto-commit --- bench/BenchDiv.hs | 9 +++++---- src/ZkFold/Base/Algebra/Basic/Number.hs | 2 +- .../Algebra/Polynomials/Multivariate/Polynomial.hs | 10 +++++----- src/ZkFold/Base/Protocol/ARK/Protostar/Lookup.hs | 3 ++- .../Base/Protocol/ARK/Protostar/Permutation.hs | 2 +- .../Base/Protocol/ARK/Protostar/SpecialSound.hs | 12 ++++++------ 6 files changed, 20 insertions(+), 18 deletions(-) diff --git a/bench/BenchDiv.hs b/bench/BenchDiv.hs index d263db3a8..1d9eb3112 100644 --- a/bench/BenchDiv.hs +++ b/bench/BenchDiv.hs @@ -12,7 +12,8 @@ import Control.DeepSeq (force) import Control.Exception (evaluate) import qualified Data.Map as M import Data.Time.Clock (getCurrentTime) -import Prelude hiding (not, sum, (&&), (*), (+), (-), (/), (^), (||), divMod) +import Prelude hiding (divMod, not, sum, (&&), (*), (+), (-), (/), (^), + (||)) import System.Random (randomIO) import Test.Tasty.Bench @@ -22,15 +23,15 @@ import ZkFold.Base.Algebra.Basic.Number import ZkFold.Base.Algebra.EllipticCurve.BLS12_381 import ZkFold.Base.Data.Vector import ZkFold.Symbolic.Compiler -import ZkFold.Symbolic.Data.UInt import ZkFold.Symbolic.Data.Combinators +import ZkFold.Symbolic.Data.UInt evalUInt :: forall a n . UInt n ArithmeticCircuit a -> Vector (NumberOfRegisters a n) a evalUInt (UInt xs) = eval xs M.empty -- | Generate random addition circuit of given size -- -divisionCircuit +divisionCircuit :: forall n p r . KnownNat n => PrimeField (Zp p) @@ -47,7 +48,7 @@ divisionCircuit = do let acX = fromConstant (x :: Integer) :: UInt n ArithmeticCircuit (Zp p) acY = fromConstant (y :: Integer) :: UInt n ArithmeticCircuit (Zp p) - acZ = acX `divMod` acY + acZ = acX `divMod` acY evaluate . force $ acZ diff --git a/src/ZkFold/Base/Algebra/Basic/Number.hs b/src/ZkFold/Base/Algebra/Basic/Number.hs index 5a3d4487d..6a3dbee54 100644 --- a/src/ZkFold/Base/Algebra/Basic/Number.hs +++ b/src/ZkFold/Base/Algebra/Basic/Number.hs @@ -4,7 +4,7 @@ {-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-} -module ZkFold.Base.Algebra.Basic.Number +module ZkFold.Base.Algebra.Basic.Number ( Natural , KnownNat , Prime diff --git a/src/ZkFold/Base/Algebra/Polynomials/Multivariate/Polynomial.hs b/src/ZkFold/Base/Algebra/Polynomials/Multivariate/Polynomial.hs index 7d2cafd2c..505cc41dc 100644 --- a/src/ZkFold/Base/Algebra/Polynomials/Multivariate/Polynomial.hs +++ b/src/ZkFold/Base/Algebra/Polynomials/Multivariate/Polynomial.hs @@ -38,13 +38,13 @@ newtype Poly c i j = P [(c, Mono i j)] polynomial :: Polynomial c i j => [(c, Mono i j)] -> Poly c i j polynomial = foldr (\(c, m) x -> if c == zero then x else P [(c, m)] + x) zero -evalPolynomial - :: forall c i j b +evalPolynomial + :: forall c i j b . AdditiveMonoid b => Scale c b - => ((i -> b) -> Mono i j -> b) - -> (i -> b) - -> Poly c i j + => ((i -> b) -> Mono i j -> b) + -> (i -> b) + -> Poly c i j -> b evalPolynomial e f (P p) = foldr (\(c, m) x -> x + scale c (e f m)) zero p diff --git a/src/ZkFold/Base/Protocol/ARK/Protostar/Lookup.hs b/src/ZkFold/Base/Protocol/ARK/Protostar/Lookup.hs index e40dd9708..c72349d42 100644 --- a/src/ZkFold/Base/Protocol/ARK/Protostar/Lookup.hs +++ b/src/ZkFold/Base/Protocol/ARK/Protostar/Lookup.hs @@ -14,7 +14,8 @@ import ZkFold.Base.Algebra.Basic.Field (Zp) import ZkFold.Base.Algebra.Basic.Number import ZkFold.Base.Data.Sparse.Vector (SVector (..)) import ZkFold.Base.Data.Vector (Vector) -import ZkFold.Base.Protocol.ARK.Protostar.SpecialSound (SpecialSoundProtocol (..), SpecialSoundTranscript, LMap) +import ZkFold.Base.Protocol.ARK.Protostar.SpecialSound (LMap, SpecialSoundProtocol (..), + SpecialSoundTranscript) import ZkFold.Symbolic.Compiler (Arithmetic) data ProtostarLookup (l :: Natural) (sizeT :: Natural) diff --git a/src/ZkFold/Base/Protocol/ARK/Protostar/Permutation.hs b/src/ZkFold/Base/Protocol/ARK/Protostar/Permutation.hs index 173734d1a..a07dd64d9 100644 --- a/src/ZkFold/Base/Protocol/ARK/Protostar/Permutation.hs +++ b/src/ZkFold/Base/Protocol/ARK/Protostar/Permutation.hs @@ -7,7 +7,7 @@ import ZkFold.Base.Algebra.Basic.Class import ZkFold.Base.Algebra.Basic.Number import ZkFold.Base.Algebra.Basic.Permutations (Permutation, applyPermutation) import ZkFold.Base.Algebra.Polynomials.Multivariate (var) -import ZkFold.Base.Data.Vector as V +import ZkFold.Base.Data.Vector as V import ZkFold.Base.Protocol.ARK.Protostar.SpecialSound (LMap, SpecialSoundProtocol (..), SpecialSoundTranscript) import ZkFold.Symbolic.Compiler (Arithmetic) diff --git a/src/ZkFold/Base/Protocol/ARK/Protostar/SpecialSound.hs b/src/ZkFold/Base/Protocol/ARK/Protostar/SpecialSound.hs index e3f5185e8..a75488e60 100644 --- a/src/ZkFold/Base/Protocol/ARK/Protostar/SpecialSound.hs +++ b/src/ZkFold/Base/Protocol/ARK/Protostar/SpecialSound.hs @@ -40,13 +40,13 @@ class Arithmetic f => SpecialSoundProtocol f a where prover :: a -> Witness f a -> Input f a -> SpecialSoundTranscript f a -> ProverMessage f a - algebraicMap - :: a - -> Input f a - -> [ProverMessage Natural a] - -> [VerifierMessage Natural a] + algebraicMap + :: a + -> Input f a + -> [ProverMessage Natural a] + -> [VerifierMessage Natural a] -> LMap f - -- ^ the algebraic map V_sps computed by the verifier. + -- ^ the algebraic map V_sps computed by the verifier. -- The j-th element of the vector is a homogeneous degree-j algebraic map that outputs a vector of @Dimension a@ field elements. -- Variables have natural indices from @0@ to @2k@: -- Variable @0@ is public input