cabal-version:      3.0

name:               symbolic-base
version:            0.1.0.0
tested-with:        GHC == 9.12.1
synopsis:           ZkFold Symbolic compiler and zero-knowledge proof protocols
homepage:           https://zkfold.io/
category:           Cryptography, DSL, Math, Symbolic Computation
author:             Vladimir Sinyakov, Pavel Sokolov, Vladimir Morozov, Eitan Chatav, Ilya Baryshnikov, Anna Hovanskaya, Evgenii Samodelov, Murat Kasimov, Maxim Churilov
maintainer:         vlasin@zkfold.io
license:            MIT
license-file:       LICENSE
build-type:         Simple
Data-Files:
    test/data/shabittestvectors/*.rsp

description:
  This package contains the zkFold Symbolic framework base library. It includes the zkFold Symbolic compiler and a number of zero knowledge proof protocols.
  The compiler translates code written using the zkFold Symbolic framework into arithmetic circuits. The zero knowledge proof protocols are used to verify statements about the circuits.

Flag Pedantic
    Description: Enable pedantic build with -Werror
    Manual: True
    Default: False

common options
    default-language: Haskell2010
    ghc-options:
      -fwarn-redundant-constraints
      -Wall
      -Wcompat
      -Widentities
      -Wincomplete-record-updates
      -Wincomplete-uni-patterns
      -Wnoncanonical-monad-instances
      -Wpartial-fields
      -Wredundant-constraints
      -Wunused-packages
      -Wno-x-partial
      -O2
      -threaded
    if flag(pedantic)
      ghc-options:
        -Werror
    default-extensions:
      BangPatterns,
      BinaryLiterals,
      ConstraintKinds,
      DataKinds,
      DefaultSignatures,
      DeriveDataTypeable,
      DeriveFoldable,
      DeriveFunctor,
      DeriveGeneric,
      DeriveTraversable,
      ExistentialQuantification,
      FlexibleContexts,
      FlexibleInstances,
      FunctionalDependencies,
      GADTs,
      GeneralizedNewtypeDeriving,
      InstanceSigs,
      KindSignatures,
      LambdaCase,
      MultiParamTypeClasses,
      MultiWayIf,
      NamedFieldPuns,
      NoImplicitPrelude,
      NoStarIsType,
      NumericUnderscores,
      OverloadedStrings,
      OverloadedLabels,
      PolyKinds,
      RankNTypes,
      RecordWildCards,
      ScopedTypeVariables,
      StandaloneDeriving,
      StandaloneKindSignatures,
      TupleSections,
      TypeApplications,
      TypeFamilies,
      ViewPatterns

common options-exe
    import: options
    ghc-options:
      -rtsopts
    ghc-prof-options:
      -with-rtsopts=-pj

library
    import: options
    exposed-modules:
      ZkFold.Base.Algebra.Basic.Class
      ZkFold.Base.Algebra.Basic.Field
      ZkFold.Base.Algebra.Basic.Number
      ZkFold.Base.Algebra.Basic.Permutations
      ZkFold.Base.Algebra.Basic.DFT
      ZkFold.Base.Algebra.Basic.VectorSpace
      ZkFold.Base.Algebra.EllipticCurve.BLS12_381
      ZkFold.Base.Algebra.EllipticCurve.BN254
      ZkFold.Base.Algebra.EllipticCurve.Pasta
      ZkFold.Base.Algebra.EllipticCurve.Class
      ZkFold.Base.Algebra.EllipticCurve.Ed25519
      ZkFold.Base.Algebra.EllipticCurve.Pairing
      ZkFold.Base.Algebra.EllipticCurve.PlutoEris
      ZkFold.Base.Algebra.EllipticCurve.Secp256k1
      ZkFold.Base.Algebra.Polynomials.Multivariate
      ZkFold.Base.Algebra.Polynomials.Multivariate.Groebner
      ZkFold.Base.Algebra.Polynomials.Multivariate.Monomial
      ZkFold.Base.Algebra.Polynomials.Multivariate.Polynomial
      ZkFold.Base.Algebra.Polynomials.Multivariate.Substitution
      ZkFold.Base.Algebra.Polynomials.Univariate
      ZkFold.Base.Algorithm.ReedSolomon
      ZkFold.Base.Control.HApplicative
      ZkFold.Base.Data.ByteString
      ZkFold.Base.Data.HFunctor
      ZkFold.Base.Data.List.Infinite
      ZkFold.Base.Data.Matrix
      ZkFold.Base.Data.Orphans
      ZkFold.Base.Data.Package
      ZkFold.Base.Data.Product
      ZkFold.Base.Data.Sparse.Matrix
      ZkFold.Base.Data.Sparse.Vector
      ZkFold.Base.Data.Type
      ZkFold.Base.Data.Utils
      ZkFold.Base.Data.Vector
      ZkFold.Base.Protocol.IVC
      ZkFold.Base.Protocol.IVC.Accumulator
      ZkFold.Base.Protocol.IVC.AccumulatorScheme
      ZkFold.Base.Protocol.IVC.AlgebraicMap
      ZkFold.Base.Protocol.IVC.CommitOpen
      ZkFold.Base.Protocol.IVC.Commit
      ZkFold.Base.Protocol.IVC.FiatShamir
      ZkFold.Base.Protocol.IVC.Internal
      ZkFold.Base.Protocol.IVC.NARK
      ZkFold.Base.Protocol.IVC.Oracle
      ZkFold.Base.Protocol.IVC.Predicate
      ZkFold.Base.Protocol.IVC.RecursiveFunction
      ZkFold.Base.Protocol.IVC.SpecialSound
      ZkFold.Base.Protocol.IVC.StepFunction
      ZkFold.Base.Protocol.IVC.VerifierCircuit
      ZkFold.Base.Protocol.KZG
      ZkFold.Base.Protocol.Plonk
      ZkFold.Base.Protocol.Plonk.Prover
      ZkFold.Base.Protocol.Plonk.Verifier
      ZkFold.Base.Protocol.Plonkup
      ZkFold.Base.Protocol.Plonkup.LookupConstraint
      ZkFold.Base.Protocol.Plonkup.PlonkConstraint
      ZkFold.Base.Protocol.Plonkup.PlonkupConstraint
      ZkFold.Base.Protocol.Plonkup.Input
      ZkFold.Base.Protocol.Plonkup.Internal
      ZkFold.Base.Protocol.Plonkup.Proof
      ZkFold.Base.Protocol.Plonkup.Prover
      ZkFold.Base.Protocol.Plonkup.Prover.Polynomials
      ZkFold.Base.Protocol.Plonkup.Prover.Secret
      ZkFold.Base.Protocol.Plonkup.Prover.Setup
      ZkFold.Base.Protocol.Plonkup.Relation
      ZkFold.Base.Protocol.Plonkup.Setup
      ZkFold.Base.Protocol.Plonkup.Testing
      ZkFold.Base.Protocol.Plonkup.Utils
      ZkFold.Base.Protocol.Plonkup.Verifier
      ZkFold.Base.Protocol.Plonkup.Verifier.Commitments
      ZkFold.Base.Protocol.Plonkup.Verifier.Setup
      ZkFold.Base.Protocol.Plonkup.Witness
      ZkFold.Base.Protocol.NonInteractiveProof
      ZkFold.Base.Protocol.NonInteractiveProof.Internal
      ZkFold.Base.Protocol.NonInteractiveProof.Prover
      ZkFold.Base.Protocol.NonInteractiveProof.Testing
      ZkFold.Prelude
      ZkFold.Symbolic.Algorithms.ECDSA.ECDSA
      ZkFold.Symbolic.Algorithms.Hash.Blake2b
      ZkFold.Symbolic.Algorithms.Hash.Blake2b.Constants
      ZkFold.Symbolic.Algorithms.Hash.MiMC
      ZkFold.Symbolic.Algorithms.Hash.MiMC.Constants
      ZkFold.Symbolic.Algorithms.Hash.SHA2
      ZkFold.Symbolic.Algorithms.Hash.SHA2.Constants
      ZkFold.Symbolic.Algorithms.RSA
      ZkFold.Symbolic.Algorithms.FFT
      ZkFold.Symbolic.Class
      ZkFold.Symbolic.Compiler
      ZkFold.Symbolic.Compiler.ArithmeticCircuit
      ZkFold.Symbolic.Compiler.ArithmeticCircuit.Instance
      ZkFold.Symbolic.Compiler.ArithmeticCircuit.Internal
      ZkFold.Symbolic.Compiler.ArithmeticCircuit.Lookup
      ZkFold.Symbolic.Compiler.ArithmeticCircuit.Map
      ZkFold.Symbolic.Compiler.ArithmeticCircuit.MerkleHash
      ZkFold.Symbolic.Compiler.ArithmeticCircuit.Optimization
      ZkFold.Symbolic.Compiler.ArithmeticCircuit.Var
      ZkFold.Symbolic.Compiler.ArithmeticCircuit.Witness
      ZkFold.Symbolic.Compiler.ArithmeticCircuit.WitnessEstimation
      ZkFold.Symbolic.Data.Bool
      ZkFold.Symbolic.Data.ByteString
      ZkFold.Symbolic.Data.Class
      ZkFold.Symbolic.Data.Combinators
      ZkFold.Symbolic.Data.Conditional
      ZkFold.Symbolic.Data.DiscreteField
      ZkFold.Symbolic.Data.EllipticCurve.BLS12_381
      ZkFold.Symbolic.Data.EllipticCurve.BN254
      ZkFold.Symbolic.Data.EllipticCurve.Ed25519
      ZkFold.Symbolic.Data.EllipticCurve.Pasta
      ZkFold.Symbolic.Data.EllipticCurve.PlutoEris
      ZkFold.Symbolic.Data.EllipticCurve.Secp256k1
      ZkFold.Symbolic.Data.Eq
      ZkFold.Symbolic.Data.FFA
      ZkFold.Symbolic.Data.FieldElement
      ZkFold.Symbolic.Data.Hash
      ZkFold.Symbolic.Data.Input
      ZkFold.Symbolic.Data.Int
      ZkFold.Symbolic.Data.JWT
      ZkFold.Symbolic.Data.JWT.Google
      ZkFold.Symbolic.Data.JWT.RS256
      ZkFold.Symbolic.Data.JWT.Twitch
      ZkFold.Symbolic.Data.JWT.Utils
      ZkFold.Symbolic.Data.List
      ZkFold.Symbolic.Data.Maybe
      ZkFold.Symbolic.Data.Morph
      ZkFold.Symbolic.Data.Ord
      ZkFold.Symbolic.Data.Payloaded
      ZkFold.Symbolic.Data.Switch
      ZkFold.Symbolic.Data.UInt
      ZkFold.Symbolic.Data.UTCTime
      ZkFold.Symbolic.Data.VarByteString
      ZkFold.Symbolic.Fold
      ZkFold.Symbolic.Interpreter
      ZkFold.Symbolic.MonadCircuit
    if arch(javascript)
      js-sources:
        js-src/blake2b.js

    if arch(javascript)
      build-depends:
        base                          >= 4.9 && < 5,
        adjunctions                           < 4.5,
        aeson                               ^>= 2.2,
        aeson-casing                          < 0.3,
        base64-bytestring                          ,
        binary                               < 0.11,
        bytestring                           < 0.12,
        containers                            < 0.7,
        constraints                                ,
        cryptohash-sha256                    < 0.12,
        deepseq                          <= 1.5.0.0,
        distributive                               ,
        generic-random                        < 1.6,
        infinite-list                              ,
        lens                                       ,
        monoidal-containers                        ,
        mtl                                   < 2.4,
        optics                                < 0.5,
        pretty-simple                         < 4.2,
        QuickCheck                           < 2.15,
        random                                < 1.3,
        scientific                            < 0.4,
        semialign                             < 1.4,
        semigroups                                 ,
        split                               < 0.2.6,
        text                                       ,
        these                                 < 1.3,
        transformers                               ,
        type-errors                         < 0.2.1,
        vector                               < 0.14,
        vector-binary-instances               < 0.3,
        vector-split                          < 1.1,
    else
      build-depends:
        base                          >= 4.9 && < 5,
        adjunctions                           < 4.5,
        aeson                               ^>= 2.2,
        aeson-casing                          < 0.3,
        base64-bytestring                          ,
        binary                               < 0.11,
        -- TODO: remove `blake2` after refactoring of ZK protocols
        blake2                                < 0.4,
        bytestring                           < 0.12,
        containers                            < 0.7,
        constraints                                ,
        cryptohash-sha256                    < 0.12,
        deepseq                          <= 1.5.0.0,
        distributive                               ,
        generic-random                        < 1.6,
        infinite-list                              ,
        lens                                       ,
        monoidal-containers                        ,
        mtl                                   < 2.4,
        optics                                < 0.5,
        pretty-simple                         < 4.2,
        QuickCheck                           < 2.15,
        random                                < 1.3,
        scientific                            < 0.4,
        semialign                             < 1.4,
        semigroups                                 ,
        split                               < 0.2.6,
        text                                       ,
        these                                 < 1.3,
        transformers                               ,
        type-errors                         < 0.2.1,
        vector                               < 0.14,
        vector-binary-instances               < 0.3,
        vector-split                          < 1.1,
    hs-source-dirs: src

test-suite symbolic-base-test
    import: options-exe
    type: exitcode-stdio-1.0
    ghc-options: 
        -threaded
        "-with-rtsopts=-A128M -AL256m -qb0 -qn4 -N"
    main-is: Main.hs
    other-modules:
      Tests.Algebra.EllipticCurve
      Tests.Algebra.Field
      Tests.Algebra.GroebnerBasis
      Tests.Algebra.Group
      Tests.Algebra.Pairing
      Tests.Algebra.Permutations
      Tests.Algebra.ReedSolomon
      Tests.Algebra.Univariate
      Tests.Algebra.Univariate.Poly
      Tests.Algebra.Univariate.PolyVec
      Tests.Data.Binary
      Tests.Protocol.IVC
      Tests.Protocol.NonInteractiveProof
      Tests.Protocol.Plonkup
      Tests.Symbolic.Algorithm.Blake2b
      Tests.Symbolic.Algorithm.JWT
      Tests.Symbolic.Algorithm.RSA
      Tests.Symbolic.Algorithm.SHA2
      Tests.Symbolic.ArithmeticCircuit
      Tests.Symbolic.Compiler
      Tests.Symbolic.Compiler.CompileWith
      Tests.Symbolic.Compiler.Optimization
      Tests.Symbolic.Compiler.Test1
      Tests.Symbolic.Compiler.Test2
      Tests.Symbolic.Compiler.Test3
      Tests.Symbolic.Compiler.Test4
      Tests.Symbolic.Data.ByteString
      Tests.Symbolic.Data.FFA
      Tests.Symbolic.Data.Hash
      Tests.Symbolic.Data.Int
      Tests.Symbolic.Data.List
      Tests.Symbolic.Data.UInt
    build-depends:
      base                          >= 4.9 && < 5,
      adjunctions                           < 4.5,
      binary                               < 0.11,
      bytestring                                 ,
      blake2                                     ,
      constraints                                ,
      containers                                 ,
      random                                     ,
      directory                        <= 1.3.8.4,
      filepath                         <= 1.5.2.0,
      hspec                                < 2.12,
      QuickCheck                                 ,
      regex-tdfa                       <= 1.3.2.2,
      RSA                                   < 1.1,
      split                               < 0.2.6,
      symbolic-base                              ,
      transformers                               ,
      vector                                     ,
      vector-algorithms                          ,
      aeson
    hs-source-dirs: test

benchmark bench-poly-mul
    import:           options-exe
    main-is:          BenchPolyMul.hs
    hs-source-dirs:   bench
    type:             exitcode-stdio-1.0
    ghc-options:
      -O3
    build-depends:
      base,
      deepseq,
      random,
      symbolic-base,
      tasty-bench,
      vector,

benchmark bench-in-circuit-ec 
    import:           options-exe
    main-is:          BenchEC.hs
    hs-source-dirs:   bench
    type:             exitcode-stdio-1.0
    ghc-options:
      -O3
    build-depends:
      base,
      deepseq,
      tasty-bench,
      random,
      symbolic-base,