Skip to content

Commit

Permalink
Merge pull request #286 from zkFold/vlasin-monorepo-refactor
Browse files Browse the repository at this point in the history
Monorepo refactor
  • Loading branch information
vlasin authored Oct 8, 2024
2 parents e4cb70d + 3d40db9 commit 58cc6e6
Show file tree
Hide file tree
Showing 232 changed files with 508 additions and 129 deletions.
1 change: 1 addition & 0 deletions .github/workflows/main-pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:

- name: Configure Cabal
run: |
cabal update
cabal configure --enable-tests --enable-benchmarks --enable-documentation
- name: Generate cache key
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/main-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ jobs:
shell: bash
run: |
cabal update
cabal new-build all -f Pedantic
cabal build all -f Pedantic
- name: Upload package
env:
HACKAGE_PASSWORD: ${{ secrets.HACKAGE_PASSWORD }}
shell: bash
run: |
cabal sdist
cabal sdist symbolic-base
cabal upload --username=VladimirSinyakov --password="$HACKAGE_PASSWORD" dist-newstyle/sdist/*.tar.gz
cabal v2-haddock --haddock-for-hackage --enable-doc
cabal v2-haddock symbolic-base --haddock-for-hackage --enable-doc
cabal upload --documentation --username=VladimirSinyakov --password="$HACKAGE_PASSWORD" dist-newstyle/*-docs.tar.gz
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,5 @@ cabal.project.local
cabal.project.local~
.HTF/
.ghc.environment.*
compiled_scripts/*
stack.yaml*
.DS_Store
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
# zkFold Base library
This repository contains the base library for the ZkFold project. It includes the zkFold Symbolic compiler and a number of zero knowledge proof protocols. The compiler translates a subset of Haskell into arithmetic circuits, which can be used to generate zero knowledge proofs.
# zkFold Symbolic framework
This repository contains the zkFold Symbolic framework base library as well as additional packages written using the framework.

# Documentation
The zkFold Symbolic language can be utilized to create zero-knowledge smart contracts and privacy-preserving applications.
The zkFold Symbolic framework can be utilized to create zero-knowledge smart contracts and privacy-preserving applications.

User documentation can be found at [docs.zkfold.io](https://docs.zkfold.io "zkFold Symbolic User Documentation").
User documentation can be found at [docs.zkfold.io](https://docs.zkfold.io/symbolic/introduction/ "zkFold Symbolic User Documentation").

If you want to contribute to the project or find out how it works "under the hood", check out [package documentation](https://hackage.haskell.org/package/zkfold-base-0.1.0.0/candidate "zkFold Base package") on Hackage.

# Build
The package compiles with GHC 9.6.3 and Cabal 3.10.2.1.
The package compiles with GHC 9.6.3 and Cabal 3.10.2.1. To build all packages, execute
```bash
cabal build all
```

# Tests
To run the tests, execute
```bash
cabal run -- zkfold-base-test
cabal test all
```

# Examples
The `examples` folder contains several code examples of arithmetizable pure functions. These examples can be compiled into the arithmetic circuits with the zkFold Symbolic compiler. In order to do it, execute
# Benchmarks
To run the benchmarks, execute
```bash
cabal run -- zkfold-base-examples
```
The output is placed into the `compiled_scripts` folder.
cabal bench all
```
6 changes: 5 additions & 1 deletion cabal.project
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
index-state: 2023-10-29T16:11:26Z

packages: .
packages:
symbolic-base
symbolic-cardano
symbolic-examples
zkfold-ledger

optimization: 2

Expand Down
16 changes: 0 additions & 16 deletions hie.yaml

This file was deleted.

21 changes: 21 additions & 0 deletions symbolic-base/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 zkFold SA

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 2 additions & 0 deletions symbolic-base/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# zkFold Symbolic Base package
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.
File renamed without changes.
10 changes: 10 additions & 0 deletions symbolic-base/hie.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cradle:
cabal:
- path: "./src"
component: "lib:symbolic-base"

- path: "./test"
component: "symbolic-base:test:symbolic-base-test"

- path: "./bench/BenchPolyMul.hs"
component: "symbolic-base:bench:bench-poly-mul"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
107 changes: 12 additions & 95 deletions zkfold-base.cabal → symbolic-base/symbolic-base.cabal
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
cabal-version: 3.0

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

description:
This package contains the base library for the ZkFold project. It includes zkFold Symbolic compiler and a number of zero knowledge proof protocols.
The compiler translates a subset of Haskell into arithmetic circuits, which can be used to generate zero knowledge proofs.
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
Expand All @@ -35,6 +35,7 @@ common options
-Wnoncanonical-monad-instances
-Wpartial-fields
-Wredundant-constraints
-Wunused-packages
-O2
-threaded
if flag(pedantic)
Expand Down Expand Up @@ -166,24 +167,6 @@ library
ZkFold.Symbolic.Algorithms.Hash.MiMC.Constants
ZkFold.Symbolic.Algorithms.Hash.SHA2
ZkFold.Symbolic.Algorithms.Hash.SHA2.Constants
ZkFold.Symbolic.Cardano.Wrapper
ZkFold.Symbolic.Cardano.Contracts.BatchTransfer
ZkFold.Symbolic.Cardano.Contracts.RandomOracle
ZkFold.Symbolic.Cardano.Types
ZkFold.Symbolic.Cardano.Types.Address
ZkFold.Symbolic.Cardano.Types.Basic
ZkFold.Symbolic.Cardano.Types.Input
ZkFold.Symbolic.Cardano.Types.Output
ZkFold.Symbolic.Cardano.Types.Output.Datum
ZkFold.Symbolic.Cardano.Types.OutputRef
ZkFold.Symbolic.Cardano.Types.Transaction
ZkFold.Symbolic.Cardano.Types.Value
ZkFold.Symbolic.Cardano.UPLC
ZkFold.Symbolic.Cardano.UPLC.Builtins
ZkFold.Symbolic.Cardano.UPLC.Inference
ZkFold.Symbolic.Cardano.UPLC.Inference.Internal
ZkFold.Symbolic.Cardano.UPLC.Term
ZkFold.Symbolic.Cardano.UPLC.Type
ZkFold.Symbolic.Class
ZkFold.Symbolic.Compiler
ZkFold.Symbolic.Compiler.ArithmeticCircuit
Expand All @@ -208,25 +191,6 @@ library
ZkFold.Symbolic.Data.UTCTime
ZkFold.Symbolic.Data.FieldElement
ZkFold.Symbolic.Interpreter
ZkFold.Symbolic.Ledger.Types
ZkFold.Symbolic.Ledger.Types.Address
ZkFold.Symbolic.Ledger.Types.Basic
ZkFold.Symbolic.Ledger.Types.Bridge
ZkFold.Symbolic.Ledger.Types.Contract
ZkFold.Symbolic.Ledger.Types.Hash
ZkFold.Symbolic.Ledger.Types.Input
ZkFold.Symbolic.Ledger.Types.Output
ZkFold.Symbolic.Ledger.Types.OutputRef
ZkFold.Symbolic.Ledger.Types.Transaction
ZkFold.Symbolic.Ledger.Types.Update
ZkFold.Symbolic.Ledger.Types.Value
ZkFold.Symbolic.Ledger.Validation.Bridge
ZkFold.Symbolic.Ledger.Validation.Contract
ZkFold.Symbolic.Ledger.Validation.Common
ZkFold.Symbolic.Ledger.Validation.PrivateInput
ZkFold.Symbolic.Ledger.Validation.PublicInput
ZkFold.Symbolic.Ledger.Validation.Transaction
ZkFold.Symbolic.Ledger.Validation.Update
ZkFold.Symbolic.MonadCircuit
build-depends:
base >= 4.9 && < 5,
Expand All @@ -244,7 +208,6 @@ library
lens ,
mtl < 2.4,
optics < 0.5,
parallel < 3.2.3.0,
pretty-simple < 4.2,
QuickCheck < 2.15,
random < 1.3,
Expand All @@ -254,38 +217,14 @@ library
-- TODO: remove `swagger2` after moving the related code to `zkfold-prover`
swagger2 ,
text ,
tfp < 1.1,
these < 1.3,
type-errors < 0.2.1,
vector < 0.14,
vector-binary-instances < 0.3,
vector-split < 1.1,
hs-source-dirs: src

library zkfold-symbolic-examples
import: options
exposed-modules:
ZkFold.Symbolic.Examples
other-modules:
Examples.BatchTransfer
Examples.ByteString
Examples.Conditional
Examples.Constant
Examples.Eq
Examples.FFA
Examples.Fibonacci
Examples.LEQ
Examples.MiMCHash
Examples.ReverseList
Examples.UInt
build-depends:
base,
containers,
deepseq,
zkfold-base,
hs-source-dirs: examples

test-suite zkfold-base-test
test-suite symbolic-base-test
import: options-exe
type: exitcode-stdio-1.0
ghc-options:
Expand Down Expand Up @@ -322,20 +261,19 @@ test-suite zkfold-base-test
bytestring ,
blake2 ,
containers ,
deepseq ,
containers ,
directory <= 1.3.8.4,
filepath <= 1.5.2.0,
hspec < 2.12,
QuickCheck ,
regex-tdfa <= 1.3.2.2,
split < 0.2.6,
symbolic-base ,
vector ,
vector-algorithms ,
zkfold-base ,
hs-source-dirs: tests
hs-source-dirs: test

benchmark polynomial-multiplication
benchmark bench-poly-mul
import: options-exe
main-is: BenchPolyMul.hs
hs-source-dirs: bench
Expand All @@ -344,29 +282,8 @@ benchmark polynomial-multiplication
-O3
build-depends:
base,
array,
deepseq,
random,
symbolic-base,
tasty-bench,
vector,
zkfold-base

benchmark compiler-benchmark
import: options-exe
main-is: BenchCompiler.hs
hs-source-dirs: bench
type: exitcode-stdio-1.0
ghc-options:
-fprof-auto
-fprof-cafs
-O3
build-depends:
adjunctions,
base,
bytestring,
containers,
deepseq,
tasty-bench,
tasty-golden,
zkfold-base,
zkfold-symbolic-examples
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/Tests/SHA2.hs → symbolic-base/test/Tests/SHA2.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import ZkFold.Symbolic.Interpreter (Interpreter (Inter
-- https://csrc.nist.gov/Projects/Cryptographic-Algorithm-Validation-Program/Secure-Hashing#shavs
--
dataDir :: FilePath
dataDir = "tests/data/shabittestvectors/"
dataDir = "test/data/shabittestvectors/"

getTestFiles :: forall (algorithm :: Symbol) . KnownSymbol algorithm => IO [FilePath]
getTestFiles = Haskell.filter isAlgoFile <$> listDirectory dataDir
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
21 changes: 21 additions & 0 deletions symbolic-cardano/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 zkFold SA

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 2 additions & 0 deletions symbolic-cardano/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# zkFold Symbolic Cardano package
This package contains the library for integration of the zkFold Symbolic framework with the Cardano blockchain. It provides the types and functions for verifying statements about Cardano transactions.
4 changes: 4 additions & 0 deletions symbolic-cardano/hie.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
cradle:
cabal:
- path: "./src"
component: "lib:symbolic-cardano"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 58cc6e6

Please sign in to comment.