Skip to content

Commit 3025d3a

Browse files
authored
Update lc (#6)
* update lc * update readme * ci
1 parent dc8fced commit 3025d3a

File tree

8 files changed

+102
-13
lines changed

8 files changed

+102
-13
lines changed

Diff for: .github/workflows/cabal.yml

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Cabal CI
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
branches: [main, master]
8+
9+
# INFO: The following configuration block ensures that only one build runs per branch,
10+
# which may be desirable for projects with a costly build process.
11+
# Remove this block from the CI workflow to let each CI job run to completion.
12+
concurrency:
13+
group: build-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
build:
18+
name: GHC ${{ matrix.ghc-version }} on ${{ matrix.os }}
19+
runs-on: ${{ matrix.os }}
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
os: [ubuntu-latest]
24+
ghc-version: ['9.8', '9.6']
25+
26+
steps:
27+
- uses: actions/checkout@v4
28+
29+
- name: Set up GHC ${{ matrix.ghc-version }}
30+
uses: haskell-actions/setup@v2
31+
id: setup
32+
with:
33+
ghc-version: ${{ matrix.ghc-version }}
34+
# Defaults, added for clarity:
35+
cabal-version: 'latest'
36+
cabal-update: true
37+
38+
- name: Configure the build
39+
run: |
40+
cabal configure --enable-tests --enable-benchmarks --disable-documentation
41+
cabal build all --dry-run
42+
# The last step generates dist-newstyle/cache/plan.json for the cache key.
43+
44+
- name: Restore cached dependencies
45+
uses: actions/cache/restore@v3
46+
id: cache
47+
env:
48+
key: ${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}-cabal-${{ steps.setup.outputs.cabal-version }}
49+
with:
50+
path: ${{ steps.setup.outputs.cabal-store }}
51+
key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }}
52+
restore-keys: ${{ env.key }}-
53+
54+
- name: Install dependencies
55+
# If we had an exact cache hit, the dependencies will be up to date.
56+
if: steps.cache.outputs.cache-hit != 'true'
57+
run: cabal build all --only-dependencies
58+
59+
# Cache dependencies already here, so that we do not have to rebuild them should the subsequent steps fail.
60+
- name: Save cached dependencies
61+
uses: actions/cache/save@v3
62+
# If we had an exact cache hit, trying to save the cache would error because of key clash.
63+
if: steps.cache.outputs.cache-hit != 'true'
64+
with:
65+
path: ${{ steps.setup.outputs.cabal-store }}
66+
key: ${{ steps.cache.outputs.cache-primary-key }}
67+
68+
- name: Build
69+
run: cabal build all
70+
71+
- name: Test
72+
run: cabal test all

Diff for: .github/workflows/ormolu.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Ormolu CI
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
branches: [main, master]
8+
9+
jobs:
10+
ormolu:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: haskell-actions/run-ormolu@v15
15+
with:
16+
version: "0.7.2.0"

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ trusted-setup/
1717
!trusted-setup/pot14_final.ptau
1818
src/Contracts
1919
contracts
20+
circuit.dot

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ A ZK program written in a Haskell DSL that expresses a factorization of a public
3131
You can produce a circom compatible `r1cs` file for this program by running
3232

3333
```
34-
> cabal run factors-cli -- compile --output-dir trusted-setup
34+
> cabal run factors -- compile --r1cs trusted-setup/circuit.r1cs --constraints trusted-setup/circuit.bin
3535
```
3636

3737
You should see the artifacts

Diff for: cabal.project

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ source-repository-package
2525
source-repository-package
2626
type: git
2727
location: https://github.com/l-adic/arithmetic-circuits.git
28-
tag: 77415e01245ff6cc3cc60e9062dcf3e986b9811f
29-
--sha256: jI3tAEGwOBqiCr6JqQfAws3X2RIp1eYbI9fXWutTMuE=
28+
tag: 7d06e2b5df24237d8d694ca842ff1cd7e6609b34
29+
--sha256: ldjPgZN7M+hsD6S7kx0QsVJsK8FbCl0d7oSyPHQRoaw=
3030

3131
index-state: 2024-05-21T06:16:08Z

Diff for: factors/test/Main.hs

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import Circom.R1CS (witnessFromCircomWitness)
44
import Circom.Solver (CircomProgram (..), mkCircomProgram, nativeGenWitness)
55
import Circuit
66
import Circuit.Language
7+
import Data.Binary (decode, encode)
78
import qualified Data.Map as Map
89
import Protolude
910
import R1CS (Witness (..))
1011
import Test.Hspec
1112
import Test.QuickCheck
1213
import ZK.Factors (Fr, factors)
13-
import Data.Binary (encode, decode)
1414

1515
main :: IO ()
1616
main = hspec $ do
@@ -21,19 +21,19 @@ main = hspec $ do
2121
it "can serialize/deserialize the program" $ do
2222
let a = decode (encode program)
2323
cpCircuit a `shouldBe` cpCircuit program
24-
24+
2525
it "should accept valid factorizations" $
2626
property $
2727
\x y ->
2828
(x /= 1 && y /= 1) ==>
29-
let inputs = Map.fromList [("n", x * y), ("a", x), ("b", y)]
29+
let inputs = Map.fromList [("n", Simple $ x * y), ("a", Simple x), ("b", Simple y)]
3030
Witness w =
3131
witnessFromCircomWitness $
3232
nativeGenWitness program inputs
3333
in lookupVar vars "out" w === Just 1
3434
it "shouldn't accept trivial factorizations" $
3535
property $ \x ->
36-
let inputs = Map.fromList [("n", x), ("a", 1), ("b", x)]
36+
let inputs = Map.fromList [("n", Simple x), ("a", Simple 1), ("b", Simple x)]
3737
Witness w =
3838
witnessFromCircomWitness $
3939
nativeGenWitness program inputs
@@ -42,7 +42,7 @@ main = hspec $ do
4242
property $
4343
\x y z ->
4444
(x * y /= z) ==>
45-
let inputs = Map.fromList [("n", z), ("a", x), ("b", y)]
45+
let inputs = Map.fromList [("n", Simple z), ("a", Simple x), ("b", Simple y)]
4646
Witness w =
4747
witnessFromCircomWitness $
4848
nativeGenWitness program inputs

Diff for: wasm-solver/app/Main.hs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Main where
22

3-
import Data.Binary (decodeFile)
43
import Circom.Solver qualified as Circom
4+
import Data.Binary (decodeFile)
55
import Data.IORef (IORef, newIORef)
66
import Protolude
77
import System.IO.Unsafe (unsafePerformIO)
@@ -70,7 +70,7 @@ getInputSize = Circom._getInputSize env
7070
foreign export ccall getInputSignalSize :: Word32 -> Word32 -> IO Int
7171

7272
getInputSignalSize :: Word32 -> Word32 -> IO Int
73-
getInputSignalSize = Circom._getInputSignalSize
73+
getInputSignalSize = Circom._getInputSignalSize env
7474

7575
foreign export ccall getWitnessSize :: Int
7676

@@ -80,4 +80,4 @@ getWitnessSize = Circom._getWitnessSize env
8080
foreign export ccall getWitness :: Int -> IO ()
8181

8282
getWitness :: Int -> IO ()
83-
getWitness = Circom._getWitness env stateRef
83+
getWitness = Circom._getWitness env stateRef

Diff for: wasm-solver/cabal.project

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ source-repository-package
3535
source-repository-package
3636
type: git
3737
location: https://github.com/l-adic/arithmetic-circuits.git
38-
tag: 77415e01245ff6cc3cc60e9062dcf3e986b9811f
39-
--sha256: jI3tAEGwOBqiCr6JqQfAws3X2RIp1eYbI9fXWutTMuE=
38+
tag: 7d06e2b5df24237d8d694ca842ff1cd7e6609b34
39+
--sha256: ldjPgZN7M+hsD6S7kx0QsVJsK8FbCl0d7oSyPHQRoaw=

0 commit comments

Comments
 (0)