Skip to content

Commit

Permalink
Make Rust main code in the repository
Browse files Browse the repository at this point in the history
This inverts the relationship between Rust and Haskell in this repo:
The Rust code is the primary code, and Haskell code moves to a
subdirectory.
  • Loading branch information
abailly committed Sep 18, 2024
1 parent c9240f2 commit 5ebf71a
Show file tree
Hide file tree
Showing 19 changed files with 95 additions and 84 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ jobs:
cabal-version: '3.10.1.0'

- name: 🧊 Freeze
run: >
cabal freeze
--builddir=${{ env.cabal-build-dir }}
working-directory: haskell
run: |
cabal freeze --builddir=${{ env.cabal-build-dir }}
- name: 🚪 Cache
uses: actions/cache@v4
Expand All @@ -44,6 +44,7 @@ jobs:
${{ env.cabal-build-dir }}
- name: ❄ Install libsodium
working-directory: haskell
run: |
git clone https://github.com/input-output-hk/libsodium
cd libsodium
Expand All @@ -54,17 +55,20 @@ jobs:
sudo make install
- name: 🪨 Install dependencies
working-directory: haskell
run: |
cabal update
cabal build --only-dependencies --enable-tests --enable-benchmarks
- name: 🏠 Build
working-directory: haskell
env:
LD_LIBRARY_PATH: "/usr/local/lib:$LD_LIBRARY_PATH"
PKG_CONFIG_PATH: "/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"
run: cabal build --enable-tests --enable-benchmarks --extra-include-dirs=/usr/local/include --extra-lib-dirs=/usr/local/lib all

- name: 🧪 Run tests
working-directory: haskell
run: cabal test --extra-include-dirs=/usr/local/include --extra-lib-dirs=/usr/local/lib all

docs:
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/rust-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,24 @@ jobs:
- name: Build
run: cargo build --verbose
working-directory: caledonia

- name: Verify target directory exists
run: |
echo "Checking if target directory exists and is not empty"
ls -la caledonia/target
ls -la target
- name: Run tests
run: cargo test --verbose
working-directory: caledonia

# - name: Run Clippy
# run: cargo clippy -- -D warnings
# working-directory: caledonia

- name: Check format
run: cargo fmt -- --check
working-directory: caledonia

- name: Build and test documentation
run: cargo doc --no-deps --verbose
working-directory: caledonia

- name: Cache Cargo registry
uses: actions/cache@v3
Expand Down
File renamed without changes.
76 changes: 1 addition & 75 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ALBA

Prototype implementation of _Approximate Lower Bound Arguments_ from the [paper](https://iohk.io/en/research/library/papers/approximate-lower-bound-arguments/) published by IOG Research:
Implementation of _Approximate Lower Bound Arguments_ from the [paper](https://iohk.io/en/research/library/papers/approximate-lower-bound-arguments/) published by IOG Research:

> **Approximate Lower Bound Arguments**, _Pyrros Chaidos, Prof Aggelos Kiayias, Leonid Reyzin, Anatoliy Zinovyev_, May 2024, Eurocrypt'24
Expand All @@ -10,77 +10,3 @@ Prototype implementation of _Approximate Lower Bound Arguments_ from the [paper]
👉 Checkout documentation on https://alba.cardano-scaling.org

## Build

This code is written in Haskell with some native libraries dependencies for faster hashing. It requires the following software to be built:

* GHC
* Cabal
* [libsodium](https://doc.libsodium.org/)

To install sodium, you can follow instructions for [cardano-node](https://developers.cardano.org/docs/get-started/installing-cardano-node/#downloading--compiling) but please not ALBA does not depend (yet) on Cardano-specific sodium extensions.

GHC and Cabal can be installed through [GHCUp](https://www.haskell.org/ghcup/).

To build all components, assuming pkg-config is propertly configured and `libsodium` is installed:

```
cabal build all
```

To run tests:

```
cabal test
```
## Run

This package provides a small executable, unsurprisingly called `alba`, one can use to generate random data and proofs from those. It can also verify a given proof.

Help is available from the command-line:

```
$ cabal run alba -- --help
alba: Command-line utility for creating and verifying ALBA proofs
...
```

Here are a few examples use:

* Generate a proof for a set of size 900 from a maximum bound of 1000, assuming 80% honest ratio, with each item of length 256 bytes, in a file called `alba.proof`:

```
$ cabal run alba -- prove --bound 1000 --size 900 --len 500 --output alba.proof
Generating proof Options {size = 900, bound = 1000, len = 500, params = Params {λ_sec = 128, λ_rel = 128, n_p = 800, n_f = 200}, output = "alba.proof"}
Written proof to 'alba.proof' (34557 bytes)
```

* Verifying the above generated proof with same parameters:

```
$ cabal run alba -- verify --bound 1000 --size 900 --len 500 --output alba.proof
Verifying proof with Options {size = 900, bound = 1000, len = 500, params = Params {λ_sec = 128, λ_rel = 128, n_p = 800, n_f = 200}, output = "alba.proof"}
Verified proof Proof (6,["df5fd475c65f745cf63dc2705f33f8a9190460ffc97a0eaa9...
```

A textual representation of the proof is dumped on the standard output.

* Generate a proof for a subset of elements smaller than $n_p$ blows up:

```
$ cabal run alba -- prove --bound 1000 --size 700 --len 500 --output alba.proof
```

## Benchmarks

### Running benchmarks

This package comes with [criterion](http://www.serpentine.com/criterion/)-based benchmarks defined in the [ALBABench](bench/ALBABench.hs) module.
To run benchmarks and generate a nice HTML page:

```
cabal bench --benchmark-options '-o bench.html'
```

It should be relatively straightforward to tweak the benchmarks for different figures, see the [documentation](https:/alba.cardano-scaling.org/benchmarks) for latest results.
1 change: 0 additions & 1 deletion caledonia/.gitignore

This file was deleted.

86 changes: 86 additions & 0 deletions haskell/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# ALBA

Prototype Haskell implementation of _Approximate Lower Bound Arguments_ from the [paper](https://iohk.io/en/research/library/papers/approximate-lower-bound-arguments/) published by IOG Research:

> **Approximate Lower Bound Arguments**, _Pyrros Chaidos, Prof Aggelos Kiayias, Leonid Reyzin, Anatoliy Zinovyev_, May 2024, Eurocrypt'24
> [!IMPORTANT]
> This code is NOT fit for production, it's not been optimised, thoroughly tested, nor audited by competent cryptographers.
> Its one and only purpose is to help people who are more familiar with code than equations to have a better understanding of ALBAs
👉 Checkout documentation on https://alba.cardano-scaling.org

## Build

This code is written in Haskell with some native libraries dependencies for faster hashing. It requires the following software to be built:

* GHC
* Cabal
* [libsodium](https://doc.libsodium.org/)

To install sodium, you can follow instructions for [cardano-node](https://developers.cardano.org/docs/get-started/installing-cardano-node/#downloading--compiling) but please not ALBA does not depend (yet) on Cardano-specific sodium extensions.

GHC and Cabal can be installed through [GHCUp](https://www.haskell.org/ghcup/).

To build all components, assuming pkg-config is propertly configured and `libsodium` is installed:

```
cabal build all
```

To run tests:

```
cabal test
```
## Run

This package provides a small executable, unsurprisingly called `alba`, one can use to generate random data and proofs from those. It can also verify a given proof.

Help is available from the command-line:

```
$ cabal run alba -- --help
alba: Command-line utility for creating and verifying ALBA proofs
...
```

Here are a few examples use:

* Generate a proof for a set of size 900 from a maximum bound of 1000, assuming 80% honest ratio, with each item of length 256 bytes, in a file called `alba.proof`:

```
$ cabal run alba -- prove --bound 1000 --size 900 --len 500 --output alba.proof
Generating proof Options {size = 900, bound = 1000, len = 500, params = Params {λ_sec = 128, λ_rel = 128, n_p = 800, n_f = 200}, output = "alba.proof"}
Written proof to 'alba.proof' (34557 bytes)
```

* Verifying the above generated proof with same parameters:

```
$ cabal run alba -- verify --bound 1000 --size 900 --len 500 --output alba.proof
Verifying proof with Options {size = 900, bound = 1000, len = 500, params = Params {λ_sec = 128, λ_rel = 128, n_p = 800, n_f = 200}, output = "alba.proof"}
Verified proof Proof (6,["df5fd475c65f745cf63dc2705f33f8a9190460ffc97a0eaa9...
```

A textual representation of the proof is dumped on the standard output.

* Generate a proof for a subset of elements smaller than $n_p$ blows up:

```
$ cabal run alba -- prove --bound 1000 --size 700 --len 500 --output alba.proof
```

## Benchmarks

### Running benchmarks

This package comes with [criterion](http://www.serpentine.com/criterion/)-based benchmarks defined in the [ALBABench](bench/ALBABench.hs) module.
To run benchmarks and generate a nice HTML page:

```
cabal bench --benchmark-options '-o bench.html'
```

It should be relatively straightforward to tweak the benchmarks for different figures, see the [documentation](https:/alba.cardano-scaling.org/benchmarks) for latest results.
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.

0 comments on commit 5ebf71a

Please sign in to comment.