diff --git a/.license-header b/.license-header new file mode 100644 index 000000000..9181edff9 --- /dev/null +++ b/.license-header @@ -0,0 +1,5 @@ +Copyright (c) 2022 Espresso Systems (espressosys.com) +This file is part of the Jellyfish library. + +You should have received a copy of the MIT License +along with the Jellyfish library. If not, see . diff --git a/Cargo.toml b/Cargo.toml index 5c3c6e55b..3ada0e7db 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,8 +1,8 @@ [workspace] members = [ "plonk", - "relation", "primitives", + "relation", "utilities", "utilities_derive", ] diff --git a/README.md b/README.md index 2675554d8..650d4b2ed 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # Jellyfish cryptographic library + ![example workflow](https://github.com/EspressoSystems/jellyfish/actions/workflows/build.yml/badge.svg) ![Crates.io (version)](https://img.shields.io/crates/dv/jf-plonk/0.1.0) ![GitHub](https://img.shields.io/github/license/EspressoSystems/jellyfish) @@ -8,7 +9,7 @@ **DISCLAIMER:** This software is provided "as is" and its security has not been externally audited. Use at your own risk. ## Chatroom - + For general discussions on Jellyfish PLONK, please join our [Discord channel](https://discord.gg/GJa4gznGfU). ## Development environment setup @@ -100,15 +101,12 @@ To format your code run ### Updating non-cargo dependencies -- To update the [nix packages](https://github.com/NixOS/nixpkgs) run `./nix/update-nix`. -- To update the [rust overlay](https://github.com/oxalica/rust-overlay) run - `./nix/update-rust-overlay`. - -To use the updates enter a new `nix-shell`. +Run `nix flake update` if you would like to pin other version edit `flake.nix` +beforehand. Commit the lock file when happy. -### Testing the nix-shell dev environment on other platforms +To update only a single input specify it as argument, for example -Refer to the [nix/vagrant](./nix/vagrant/) directory. + nix flake update github:oxalica/rust-overlay ### Benchmarks diff --git a/flake.lock b/flake.lock new file mode 100644 index 000000000..c929f91d9 --- /dev/null +++ b/flake.lock @@ -0,0 +1,160 @@ +{ + "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1650374568, + "narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "b4a34015c698c7793d592d66adbab377907a2be8", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "locked": { + "lastModified": 1644229661, + "narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_3": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1666109165, + "narHash": "sha256-BMLyNVkr0oONuq3lKlFCRVuYqF75CO68Z8EoCh81Zdk=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "32096899af23d49010bd8cf6a91695888d9d9e73", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1645655918, + "narHash": "sha256-ZfbEFRW7o237+A1P7eTKhXje435FCAoe0blj2n20Was=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "77a7a4197740213879b9a1d2e1788c6c8ade4274", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1665296151, + "narHash": "sha256-uOB0oxqxN9K7XGF1hcnY+PQnlQJ+3bP2vCn/+Ru/bbc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "14ccaaedd95a488dd7ae142757884d8e125b3363", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1666160137, + "narHash": "sha256-8bQu+6poMzUyS2n3C1v3hkO6ZhRzj8Pf3CDCNckqQE4=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "e6c8efee1c108bb27522b9fd25b1cd0eb3288681", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "pre-commit-hooks": "pre-commit-hooks", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": "flake-utils_3", + "nixpkgs": "nixpkgs_3" + }, + "locked": { + "lastModified": 1666148516, + "narHash": "sha256-pFgSJzUFsnCTulIzhn3HHImaZpqlMxAvXTrhg0qlMOE=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "3e41700ab6f585b9569112ee7516c74f8d072989", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 000000000..789f931df --- /dev/null +++ b/flake.nix @@ -0,0 +1,98 @@ +# Copyright (c) 2022 Espresso Systems (espressosys.com) +# This file is part of the Jellyfish library. + +# You should have received a copy of the MIT License +# along with the Jellyfish library. If not, see . + +{ + description = "Jellyfish dev env"; + + inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + inputs.flake-utils.url = "github:numtide/flake-utils"; # for dedup + + # allow shell.nix alongside flake.nix + inputs.flake-compat.url = "github:edolstra/flake-compat"; + inputs.flake-compat.flake = false; + + inputs.rust-overlay.url = "github:oxalica/rust-overlay"; + inputs.pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix"; + + outputs = { self, nixpkgs, flake-utils, flake-compat, rust-overlay, pre-commit-hooks, ... }: + flake-utils.lib.eachDefaultSystem (system: + let + overlays = [ (import rust-overlay) ]; + pkgs = import nixpkgs { inherit system overlays; }; + nightlyToolchain = pkgs.rust-bin.selectLatestNightlyWith + (toolchain: toolchain.minimal.override { extensions = [ "rustfmt" ]; }); + + stableToolchain = pkgs.rust-bin.stable.latest.minimal.override { + extensions = [ "clippy" "llvm-tools-preview" "rust-src" ]; + }; + in with pkgs; + { + check = { + pre-commit-check = pre-commit-hooks.lib.${system}.run { + src = ./.; + hooks = { + check-format = { + enable = true; + files = "\\.rs$"; + entry = "cargo fmt -- --check"; + }; + doctest = { + enable = true; + entry = "cargo test --doc"; + files = "\\.rs$"; + pass_filenames = false; + }; + cargo-clippy = { + enable = true; + description = "Lint Rust code."; + entry = "cargo-clippy --workspace -- -D warnings"; + files = "\\.rs$"; + pass_filenames = false; + }; + cargo-sort = { + enable = true; + description = "Ensure Cargo.toml are sorted"; + entry = "cargo sort -w"; + pass_filenames = false; + }; + license-header-c-style = { + enable = true; + description = + "Ensure files with c-style comments have license header"; + entry = '' + insert_license --license-filepath .license-header --comment-style "//"''; + types_or = [ "rust" ]; + pass_filenames = true; + }; + }; + }; + }; + devShell = mkShell { + buildInputs = [ + argbash + openssl + pkgconfig + git + + stableToolchain + nightlyToolchain + cargo-sort + + ] ++ lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Security ]; + + shellHook = '' + export RUST_BACKTRACE=full + export PATH="$PATH:$(pwd)/target/debug:$(pwd)/target/release" + + # Ensure `cargo fmt` uses `rustfmt` from nightly. + export RUSTFMT="${nightlyToolchain}/bin/rustfmt" + '' + # install pre-commit hooks + + self.check.${system}.pre-commit-check.shellHook; + }; + } + ); +} diff --git a/nix/grcov/default.nix b/nix/grcov/default.nix deleted file mode 100644 index 51cb4f6f1..000000000 --- a/nix/grcov/default.nix +++ /dev/null @@ -1,28 +0,0 @@ -{ lib, rustToolchain, rustPlatform, fetchFromGitHub }: - -rustPlatform.buildRustPackage rec { - pname = "grcov"; - version = "v0.8.2"; - - # See https://nixos.org/manual/nixpkgs/stable/#using-community-rust-overlays - nativeBuildInputs = [ - rustToolchain - ]; - - doCheck = false; - - src = fetchFromGitHub { - owner = "mozilla"; - repo = pname; - rev = version; - sha256 = "t1Gj5u4MmXPbQ5jmO9Sstn7aXJ6Ge+AnsmmG2GiAGKE="; - }; - - cargoSha256 = "DRAUeDzNUMg0AGrqU1TdrqBZJw4A2o3YJB0MdwwzefQ="; - - meta = with lib; { - description = "grcov collects and aggregates code coverage information for multiple source files."; - homepage = "https://github.com/mozilla/grcov"; - license = licenses.mpl20; - }; -} diff --git a/nix/nightly.nix b/nix/nightly.nix deleted file mode 100644 index a054b8e45..000000000 --- a/nix/nightly.nix +++ /dev/null @@ -1,25 +0,0 @@ -let - basePkgs = import ./nixpkgs.nix { }; - - rust_overlay = with basePkgs; import (fetchFromGitHub - (lib.importJSON ./oxalica_rust_overlay.json)); - - pkgs = import ./nixpkgs.nix { overlays = [ rust_overlay ]; }; - - nightlyToolchain = pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.minimal); - grcov = with pkgs; callPackage ./grcov { rustToolchain = nightlyToolchain; }; -in -with pkgs; - -mkShell { - buildInputs = [ - nightlyToolchain - grcov - ] ++ lib.optionals stdenv.isDarwin [ - darwin.apple_sdk.frameworks.Security - ]; - - shellHook = '' - export RUST_BACKTRACE=full - ''; -} diff --git a/nix/nixpkgs.json b/nix/nixpkgs.json deleted file mode 100644 index 3cd4c582f..000000000 --- a/nix/nixpkgs.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "url": "https://github.com/nixos/nixpkgs/archive/6f38b43c8c84c800f93465b2241156419fd4fd52.tar.gz", - "sha256": "0xw3y3jx1bcnwsc0imacbp5m8f51b66s9h8kk8qnfbckwv67dhgd" -} diff --git a/nix/nixpkgs.nix b/nix/nixpkgs.nix deleted file mode 100644 index ddfbdc4b0..000000000 --- a/nix/nixpkgs.nix +++ /dev/null @@ -1,10 +0,0 @@ -# Behaves like `` but pinned. Like ``, requires attrset for opt overlays. -attrs: -let - hostpkgs = import {}; - pinnedNixpkgs = hostpkgs.lib.importJSON ./nixpkgs.json; - nixpkgs = builtins.fetchTarball { - url = pinnedNixpkgs.url; - sha256 = pinnedNixpkgs.sha256; - }; -in import nixpkgs attrs diff --git a/nix/oxalica_rust_overlay.json b/nix/oxalica_rust_overlay.json deleted file mode 100644 index 3081ab7c1..000000000 --- a/nix/oxalica_rust_overlay.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "owner": "oxalica", - "repo": "rust-overlay", - "rev": "53f8467a9ef7a49c8729b28660bb83d1a75da508", - "sha256": "aeno3vAJm5ReC2ZCOQoZHDoNsBsqM64HgSWgqhzF6yk=", - "fetchSubmodules": true -} \ No newline at end of file diff --git a/nix/pre-commit.nix b/nix/pre-commit.nix deleted file mode 100644 index 8d3552b8c..000000000 --- a/nix/pre-commit.nix +++ /dev/null @@ -1,34 +0,0 @@ -{ pkgs, ... }: - -let - nix-pre-commit-hooks = import (pkgs.fetchFromGitHub { - owner = "cachix"; - repo = "pre-commit-hooks.nix"; - rev = "ff9c0b459ddc4b79c06e19d44251daa8e9cd1746"; - sha256 = "jlsQb2y6A5dB1R0wVPLOfDGM0wLyfYqEJNzMtXuzCXw="; - }); -in -nix-pre-commit-hooks.run { - src = ./.; - hooks = { - check-format = { - enable = true; - files = "\\.rs$"; - entry = "cargo fmt -- --check"; - }; - doctest = { - enable = true; - entry = "cargo test --doc"; - files = "\\.rs$"; - pass_filenames = false; - }; - # The hook "clippy" that ships with nix-precommit-hooks is outdated. - cargo-clippy = { - enable = true; - description = "Lint Rust code."; - entry = "cargo-clippy"; - files = "\\.rs$"; - pass_filenames = false; - }; - }; -} diff --git a/nix/update-nix b/nix/update-nix deleted file mode 100755 index e25d6d823..000000000 --- a/nix/update-nix +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env nix-shell -#! nix-shell -i bash -p curl jq nix -# -# Updates nixpkgs.json to the latest or chosen nixpkgs revision -# -# Usage: ./update-nix -# ./update-nix $rev -# ./update-nix $owner $rev -# -# Arguments default to owner=nixos and rev=master and refer -# to the github owner of a nixpkgs fork and a git revision. -# -set -exo pipefail - -owner="nixos" - -if [ ! -z "$2" ]; then - owner="$1" - rev="$2" -else - rev="${1:-master}" -fi - -resolved_rev=$(curl "https://api.github.com/repos/${owner}/nixpkgs/commits?sha=${rev}" | jq -r 'first.sha') -url="https://github.com/${owner}/nixpkgs/archive/${resolved_rev}.tar.gz" -digest=$(nix-prefetch-url --unpack "$url") -echo "{\"url\": \"${url}\", \"sha256\": \"${digest}\"}" | jq '.' > nix/nixpkgs.json diff --git a/nix/update-rust-overlay b/nix/update-rust-overlay deleted file mode 100755 index df2349cc1..000000000 --- a/nix/update-rust-overlay +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env nix-shell -#! nix-shell -i bash -p nix-prefetch-github -set -exo pipefail - -nix-prefetch-github oxalica rust-overlay | tee nix/oxalica_rust_overlay.json diff --git a/nix/vagrant/.gitignore b/nix/vagrant/.gitignore deleted file mode 100644 index 0d0559a8e..000000000 --- a/nix/vagrant/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -jellyfish/ -.vagrant diff --git a/nix/vagrant/README.md b/nix/vagrant/README.md deleted file mode 100644 index 606e47bdd..000000000 --- a/nix/vagrant/README.md +++ /dev/null @@ -1,66 +0,0 @@ -# Test nix-shell in vagrant VMs - -Set up a vagrant guest VM, and test the dev environment inside the guest. - -- Only tested on nixos host with _libvirt_ virtualization provider. -- Assumes that the host has an SSH agent. The agent is used for SSH auth inside - the guest. -- Upon creation (`vagrant up`) a copy of this local repo is rsynced to the - `/jellyfish` directory in the guest. The tests are run against these files. To - see changes made to the code on the host run `vagrant reload` to re-sync the - source code from host to guest. - -## Available vagrant boxes -The following boxes are available: - - - `ubuntu`: `ubuntu20.04` + `nix` - - `ubuntu_rustup`: `ubuntu20.04` + `nix` + `rustup` - -More OSes/VMs can be added in the `Vagrantfile`. - -Append name of box after vagrant command to apply to a single box only - - vagrant up ubuntu_rustup - vagrant ssh ubuntu_rustup - -## Usage -Enable `libvrtd` on your host: -[ubuntu](https://ubuntu.com/server/docs/virtualization-libvirt), -[nixos](https://nixos.wiki/wiki/Libvirt). - -Make sure we are in the `libvirtd` group. - -Install `libvirt` vagrant plugin (not needed on nixos): - - vagrant plugin install vagrant-libvirt - -Activate nix-shell in this directory (or ensure vagrant is installed): - - nix-shell - -Start vm: - - vagrant up ubuntu - -There is a password prompt to add the insecure vagrant key to the agent. One can -supply an empty password once or cancel the prompt each time one runs `vagrant -ssh`. - -Run formatter, linter, tests inside a nix-shell environment inside the `ubuntu` -guest: - - vagrant ssh ubuntu -- -t /vagrant/test-nix-shell-guest - -This runs the `test-nix-shell-guest` script in this directory inside the vagrant -guest. - -Clean up with - - vagrant destroy ubuntu - -## Notes - -- After editing the Vagrantfile, `vagrant reload` will apply the changes. -- When making substantial changes or changing names of vagrant boxes I usually - have more luck with running `vagrant destroy` with the previous `Vagrantfile` - and then `vagrant up` again with the new `Vagrantfile`. diff --git a/nix/vagrant/Vagrantfile b/nix/vagrant/Vagrantfile deleted file mode 100644 index 8ce45e133..000000000 --- a/nix/vagrant/Vagrantfile +++ /dev/null @@ -1,36 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -Vagrant.configure("2") do |config| - - config.vm.define "ubuntu" do |ubuntu| - ubuntu.vm.box = "generic/ubuntu2004" - $script = <<~SCRIPT - set -euxo pipefail - curl -L https://nixos.org/nix/install | sh - SCRIPT - ubuntu.vm.provision "shell", inline: $script, privileged: false - end - - config.vm.define "ubuntu_rustup" do |ubuntu| - ubuntu.vm.box = "generic/ubuntu2004" - $script = <<~SCRIPT - set -euxo pipefail - curl -L https://nixos.org/nix/install | sh - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y - source $HOME/.cargo/env - rustup default stable-2021-06-17 - SCRIPT - ubuntu.vm.provision "shell", inline: $script, privileged: false - end - - config.ssh.forward_agent = true - config.vm.synced_folder ".", "/vagrant", disabled: false - config.vm.synced_folder "../..", "/jellyfish", disabled: false, rsync__exclude: [".git/", "target"] - - - config.vm.provider "libvirt" do |v| - v.cpus = 4 - end - -end diff --git a/nix/vagrant/shell.nix b/nix/vagrant/shell.nix deleted file mode 100644 index 0a6b6cb0a..000000000 --- a/nix/vagrant/shell.nix +++ /dev/null @@ -1,7 +0,0 @@ -with import ../nixpkgs.nix { }; - -mkShell { - buildInputs = [ - vagrant - ]; -} diff --git a/nix/vagrant/test-nix-shell-guest b/nix/vagrant/test-nix-shell-guest deleted file mode 100755 index ce0dc9b21..000000000 --- a/nix/vagrant/test-nix-shell-guest +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash -set -euxo pipefail - -# vagrant "ssh + command" does not source, adding -- -t does not help -. $HOME/.nix-profile/etc/profile.d/nix.sh -if [ -f $HOME/.carg/env ]; then - source $HOME/.cargo/env -fi - -ssh-keyscan gitlab.com >> ~/.ssh/known_hosts -ssh -T git@gitlab.com - -cd /jellyfish - -nix-shell --run "cargo-clippy" -nix-shell --run "cargo fmt -- --check" -nix-shell --run "cargo test --doc" -nix-shell --run "cargo test --release" - -echo "Ok!" diff --git a/plonk/Cargo.toml b/plonk/Cargo.toml index 200928f22..1586c1db4 100644 --- a/plonk/Cargo.toml +++ b/plonk/Cargo.toml @@ -7,40 +7,38 @@ edition = "2018" license = "MIT" [dependencies] -jf-utils = { path = "../utilities" } -jf-relation = { path = "../relation", default-features = false } -jf-primitives = { path = "../primitives", default-features = false } - -ark-std = { version = "0.3.0", default-features = false } -ark-serialize = "0.3.0" -ark-ff = { version = "0.3.0", features = [ "asm" ] } -ark-ec = "0.3.0" -ark-poly = "0.3.0" -ark-bn254 = "0.3.0" ark-bls12-377 = { git = "https://github.com/arkworks-rs/curves", rev = "677b4ae751a274037880ede86e9b6f30f62635af" } ark-bls12-381 = "0.3.0" +ark-bn254 = "0.3.0" ark-bw6-761 = { git = "https://github.com/arkworks-rs/curves", rev = "677b4ae751a274037880ede86e9b6f30f62635af" } - -merlin = { version = "3.0.0", default-features = false } -rayon = { version = "1.5.0", optional = true } -itertools = { version = "0.10.1", default-features = false } -downcast-rs = { version = "1.2.0", default-features = false } -serde = { version = "1.0", default-features = false, features = ["derive"] } -displaydoc = { version = "0.2.3", default-features = false } +ark-ec = "0.3.0" +ark-ff = { version = "0.3.0", features = [ "asm" ] } +ark-poly = "0.3.0" +ark-serialize = "0.3.0" +ark-std = { version = "0.3.0", default-features = false } derivative = { version = "2", features = ["use_core"] } +displaydoc = { version = "0.2.3", default-features = false } +downcast-rs = { version = "1.2.0", default-features = false } +dyn-clone = "^1.0" +espresso-systems-common = { git = "https://github.com/espressosystems/espresso-systems-common", branch = "main" } +hashbrown = "0.12.3" +itertools = { version = "0.10.1", default-features = false } +jf-primitives = { path = "../primitives", default-features = false } +jf-relation = { path = "../relation", default-features = false } +jf-utils = { path = "../utilities" } +merlin = { version = "3.0.0", default-features = false } num-bigint = { version = "0.4", default-features = false } rand_chacha = { version = "0.3.1" } +rayon = { version = "1.5.0", optional = true } +serde = { version = "1.0", default-features = false, features = ["derive"] } sha3 = "^0.10" -espresso-systems-common = { git = "https://github.com/espressosystems/espresso-systems-common", branch = "main" } -hashbrown = "0.12.3" -dyn-clone = "^1.0" [dev-dependencies] -bincode = "1.0" -ark-ed-on-bls12-381 = "0.3.0" ark-ed-on-bls12-377 = { git = "https://github.com/arkworks-rs/curves", rev = "677b4ae751a274037880ede86e9b6f30f62635af" } +ark-ed-on-bls12-381 = "0.3.0" ark-ed-on-bls12-381-bandersnatch = { git = "https://github.com/arkworks-rs/curves", rev = "677b4ae751a274037880ede86e9b6f30f62635af" } ark-ed-on-bn254 = "0.3.0" +bincode = "1.0" hex = "^0.4.3" # Benchmarks @@ -50,9 +48,9 @@ path = "benches/bench.rs" harness = false [features] -default = [ "parallel" ] -std = [ "ark-std/std", "ark-serialize/std", "ark-ff/std", "ark-ec/std", "ark-poly/std"] +default = ["parallel"] +std = ["ark-std/std", "ark-serialize/std", "ark-ff/std", "ark-ec/std", "ark-poly/std"] test_apis = [] # exposing apis for testing purpose -parallel = [ "ark-ff/parallel", "ark-ec/parallel", "ark-poly/parallel", +parallel = ["ark-ff/parallel", "ark-ec/parallel", "ark-poly/parallel", "jf-utils/parallel", "jf-relation/parallel", "jf-primitives/parallel", "rayon" ] diff --git a/primitives/Cargo.toml b/primitives/Cargo.toml index bcb809df0..afb45b5d8 100644 --- a/primitives/Cargo.toml +++ b/primitives/Cargo.toml @@ -7,60 +7,46 @@ edition = "2018" license = "MIT" [dependencies] - -# ark -ark-ff = "0.3.0" -ark-std = { version = "0.3.0", default-features = false } -ark-ec = "0.3.0" -ark-serialize = "0.3.0" -ark-poly = "0.3.0" - -# ark curves -ark-bls12-381 = "0.3.0" ark-bls12-377 = { git = "https://github.com/arkworks-rs/curves", rev = "677b4ae751a274037880ede86e9b6f30f62635af" } -ark-ed-on-bls12-377 = { git = "https://github.com/arkworks-rs/curves", rev = "677b4ae751a274037880ede86e9b6f30f62635af"} -ark-ed-on-bls12-381 = "0.3.0" -ark-ed-on-bn254 = "0.3.0" +ark-bls12-381 = "0.3.0" ark-bn254 = "0.3.0" ark-bw6-761 = { git = "https://github.com/arkworks-rs/curves", rev = "677b4ae751a274037880ede86e9b6f30f62635af" } - -# jellyfish -jf-utils = { path = "../utilities" } -jf-relation = { path = "../relation", default-features = false } - -# blst +ark-ec = "0.3.0" +ark-ed-on-bls12-377 = { git = "https://github.com/arkworks-rs/curves", rev = "677b4ae751a274037880ede86e9b6f30f62635af" } +ark-ed-on-bls12-381 = "0.3.0" +ark-ed-on-bn254 = "0.3.0" +ark-ff = "0.3.0" +ark-poly = "0.3.0" +ark-serialize = "0.3.0" +ark-std = { version = "0.3.0", default-features = false } blst = "0.3.10" - -# merlin -merlin = { version = "3.0.0", default-features = false } - -# others -rayon = { version = "1.5.0", optional = true } -zeroize = { version = "1.3", default-features = false } -itertools = { version = "0.10.1", default-features = false, features = [ "use_alloc" ] } -serde = { version = "1.0", default-features = false, features = ["derive"] } -generic-array = { version = "^0.14", default-features = false } crypto_box = "0.8.1" -displaydoc = { version = "0.2.3", default-features = false } derivative = { version = "2", features = ["use_core"] } -rand_chacha = { version = "0.3.1", default-features = false } -sha2 = { version = "0.10.1", default-features = false } digest = { version = "0.10.1", default-features = false } +displaydoc = { version = "0.2.3", default-features = false } espresso-systems-common = { git = "https://github.com/espressosystems/espresso-systems-common", branch = "main" } +generic-array = { version = "^0.14", default-features = false } +itertools = { version = "0.10.1", default-features = false, features = [ "use_alloc" ] } +jf-relation = { path = "../relation", default-features = false } +jf-utils = { path = "../utilities" } +merlin = { version = "3.0.0", default-features = false } +rand_chacha = { version = "0.3.1", default-features = false } +rayon = { version = "1.5.0", optional = true } +serde = { version = "1.0", default-features = false, features = ["derive"] } +sha2 = { version = "0.10.1", default-features = false } +zeroize = { version = "1.3", default-features = false } [dev-dependencies] -bincode = "1.0" -quickcheck = "1.0.0" -criterion = "0.3.1" - -# ark curves ark-bls12-377 = { git = "https://github.com/arkworks-rs/curves", rev = "677b4ae751a274037880ede86e9b6f30f62635af" } ark-bls12-381 = "0.3.0" -ark-ed-on-bls12-377 = { git = "https://github.com/arkworks-rs/curves", rev = "677b4ae751a274037880ede86e9b6f30f62635af"} -ark-ed-on-bls12-381-bandersnatch = { git = "https://github.com/arkworks-rs/curves", rev = "677b4ae751a274037880ede86e9b6f30f62635af" } -ark-ed-on-bn254 = "0.3.0" ark-bn254 = "0.3.0" ark-bw6-761 = { git = "https://github.com/arkworks-rs/curves", rev = "677b4ae751a274037880ede86e9b6f30f62635af" } +ark-ed-on-bls12-377 = { git = "https://github.com/arkworks-rs/curves", rev = "677b4ae751a274037880ede86e9b6f30f62635af" } +ark-ed-on-bls12-381-bandersnatch = { git = "https://github.com/arkworks-rs/curves", rev = "677b4ae751a274037880ede86e9b6f30f62635af" } +ark-ed-on-bn254 = "0.3.0" +bincode = "1.0" +criterion = "0.3.1" +quickcheck = "1.0.0" [[bench]] name = "merkle_path" @@ -71,8 +57,8 @@ name = "pcs" harness = false [features] -default = [ "parallel" ] +default = ["parallel"] std = [] -print-trace = [ "ark-std/print-trace" ] -parallel = [ "ark-ff/parallel", "ark-ec/parallel", "jf-utils/parallel", +print-trace = ["ark-std/print-trace"] +parallel = ["ark-ff/parallel", "ark-ec/parallel", "jf-utils/parallel", "jf-relation/parallel", "rayon" ] diff --git a/relation/Cargo.toml b/relation/Cargo.toml index 2f01d2596..806192a6c 100644 --- a/relation/Cargo.toml +++ b/relation/Cargo.toml @@ -7,39 +7,37 @@ authors = ["Espresso Systems "] license = "MIT" [dependencies] -jf-utils = { path = "../utilities" } - -ark-std = { version = "0.3.0", default-features = false } -ark-serialize = "0.3.0" -ark-ff = { version = "0.3.0", features = [ "asm" ] } -ark-ec = "0.3.0" -ark-poly = "0.3.0" -ark-bn254 = "0.3.0" ark-bls12-377 = { git = "https://github.com/arkworks-rs/curves", rev = "677b4ae751a274037880ede86e9b6f30f62635af" } ark-bls12-381 = "0.3.0" +ark-bn254 = "0.3.0" ark-bw6-761 = { git = "https://github.com/arkworks-rs/curves", rev = "677b4ae751a274037880ede86e9b6f30f62635af" } - -num-bigint = { version = "0.4", default-features = false } -rayon = { version = "1.5.0", optional = true } -hashbrown = "0.12.3" -rand_chacha = { version = "0.3.1" } +ark-ec = "0.3.0" +ark-ff = { version = "0.3.0", features = [ "asm" ] } +ark-poly = "0.3.0" +ark-serialize = "0.3.0" +ark-std = { version = "0.3.0", default-features = false } +derivative = { version = "2", features = ["use_core"] } displaydoc = { version = "0.2.3", default-features = false } downcast-rs = { version = "1.2.0", default-features = false } -derivative = { version = "2", features = ["use_core"] } dyn-clone = "^1.0" +hashbrown = "0.12.3" itertools = { version = "0.10.1", default-features = false } +jf-utils = { path = "../utilities" } +num-bigint = { version = "0.4", default-features = false } +rand_chacha = { version = "0.3.1" } +rayon = { version = "1.5.0", optional = true } [dev-dependencies] -bincode = "1.0" -ark-ed-on-bls12-381 = "0.3.0" ark-ed-on-bls12-377 = { git = "https://github.com/arkworks-rs/curves", rev = "677b4ae751a274037880ede86e9b6f30f62635af" } +ark-ed-on-bls12-381 = "0.3.0" ark-ed-on-bls12-381-bandersnatch = { git = "https://github.com/arkworks-rs/curves", rev = "677b4ae751a274037880ede86e9b6f30f62635af" } ark-ed-on-bn254 = "0.3.0" +bincode = "1.0" hex = "^0.4.3" [features] -default = [ "parallel" ] -std = [ "ark-std/std", "ark-serialize/std", "ark-ff/std", +default = ["parallel"] +std = ["ark-std/std", "ark-serialize/std", "ark-ff/std", "ark-ec/std", "ark-poly/std"] -parallel = [ "ark-ff/parallel", "ark-ec/parallel", "ark-poly/parallel", +parallel = ["ark-ff/parallel", "ark-ec/parallel", "ark-poly/parallel", "jf-utils/parallel", "rayon" ] diff --git a/shell.nix b/shell.nix index 6a99444c6..006cc45c0 100644 --- a/shell.nix +++ b/shell.nix @@ -1,41 +1,20 @@ -let - basePkgs = import ./nix/nixpkgs.nix { }; - - rust_overlay = with basePkgs; - import (fetchFromGitHub (lib.importJSON ./nix/oxalica_rust_overlay.json)); - - pkgs = import ./nix/nixpkgs.nix { overlays = [ rust_overlay ]; }; - - nightlyToolchain = pkgs.rust-bin.selectLatestNightlyWith - (toolchain: toolchain.minimal.override { extensions = [ "rustfmt" ]; }); - - stableToolchain = pkgs.rust-bin.stable.latest.minimal.override { - extensions = [ "clippy" "llvm-tools-preview" "rust-src" ]; - }; - - pre-commit-check = pkgs.callPackage ./nix/pre-commit.nix { }; -in with pkgs; - -mkShell { - buildInputs = [ - argbash - openssl - pkgconfig - git - - stableToolchain - nightlyToolchain - - ] ++ lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Security ]; - - shellHook = '' - export RUST_BACKTRACE=full - export PATH="$PATH:$(pwd)/target/debug:$(pwd)/target/release" - - # Ensure `cargo fmt` uses `rustfmt` from nightly. - export RUSTFMT="${nightlyToolchain}/bin/rustfmt" - - # install pre-commit hooks - ${pre-commit-check.shellHook} - ''; -} +# Copyright (c) 2022 Espresso Systems (espressosys.com) +# This file is part of the Configurable Asset Privacy for Ethereum (CAPE) library. +# +# This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# You should have received a copy of the GNU General Public License along with this program. If not, see . + +(import + ( + let + lock = builtins.fromJSON (builtins.readFile ./flake.lock); + in + fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; + sha256 = lock.nodes.flake-compat.locked.narHash; + } + ) + { + src = ./.; + }).shellNix diff --git a/utilities/Cargo.toml b/utilities/Cargo.toml index 1d1fb52b5..2afa9c5f7 100644 --- a/utilities/Cargo.toml +++ b/utilities/Cargo.toml @@ -7,34 +7,31 @@ edition = "2018" license = "MIT" [dependencies] -jf-utils-derive = { path = "../utilities_derive" } -tagged-base64 = { git = "https://github.com/EspressoSystems/tagged-base64", tag = "0.2.0" } - -ark-std = { version = "0.3.0", default-features = false } -ark-ff = { version = "0.3.0", default-features = false, features = [ "asm" ] } +anyhow = { version = "^1.0", default-features = false } ark-ec = { version = "0.3.0", default-features = false } +ark-ff = { version = "0.3.0", default-features = false, features = [ "asm" ] } ark-serialize = { version = "0.3.0", default-features = false } - -serde = { version = "1.0", default-features = false, features = ["derive"] } -anyhow = { version = "^1.0", default-features = false } +ark-std = { version = "0.3.0", default-features = false } +digest = { version = "0.10.1", default-features = false } displaydoc = { version = "0.2.3", default-features = false } +jf-utils-derive = { path = "../utilities_derive" } rayon = { version = "1.5.0", optional = true } - +serde = { version = "1.0", default-features = false, features = ["derive"] } sha2 = { version = "0.10.1", default-features = false } -digest = { version = "0.10.1", default-features = false } +tagged-base64 = { git = "https://github.com/EspressoSystems/tagged-base64", tag = "0.2.0" } [dev-dependencies] -ark-ed-on-bn254 = "0.3.0" +ark-bls12-377 = { git = "https://github.com/arkworks-rs/curves", rev = "677b4ae751a274037880ede86e9b6f30f62635af" } +ark-bls12-381 = "0.3.0" +ark-bn254 = "0.3.0" ark-ed-on-bls12-377 = { git = "https://github.com/arkworks-rs/curves", rev = "677b4ae751a274037880ede86e9b6f30f62635af" } ark-ed-on-bls12-381 = "0.3.0" ark-ed-on-bls12-381-bandersnatch = { git = "https://github.com/arkworks-rs/curves", rev = "677b4ae751a274037880ede86e9b6f30f62635af" } -ark-bn254 = "0.3.0" -ark-bls12-377 = { git = "https://github.com/arkworks-rs/curves", rev = "677b4ae751a274037880ede86e9b6f30f62635af" } -ark-bls12-381 = "0.3.0" +ark-ed-on-bn254 = "0.3.0" ark-serialize = { version = "0.3.0", features = ["derive"] } serde_json = "1.0" [features] default = [] -std = [ "ark-ff/std", "ark-std/std", "ark-ec/std", "ark-serialize/std" ] -parallel = [ "ark-ff/parallel", "ark-std/parallel", "ark-ec/parallel", "rayon" ] +std = ["ark-ff/std", "ark-std/std", "ark-ec/std", "ark-serialize/std"] +parallel = ["ark-ff/parallel", "ark-std/parallel", "ark-ec/parallel", "rayon"] diff --git a/utilities_derive/Cargo.toml b/utilities_derive/Cargo.toml index 0c34cbf3e..cfc51f4f3 100644 --- a/utilities_derive/Cargo.toml +++ b/utilities_derive/Cargo.toml @@ -11,12 +11,12 @@ proc-macro = true [dependencies] ark-std = { version = "0.3.0", default-features = false } -syn = "1.0" quote = "1.0" +syn = "1.0" [dev-dependencies] -ark-serialize = { version = "0.3.0", default-features = false, features = ["derive"] } ark-bls12-381 = { version = "0.3.0", default-features = false, features = ["curve"] } +ark-serialize = { version = "0.3.0", default-features = false, features = ["derive"] } bincode = { version = "1.3.3", default-features = false } jf-utils = { path = "../utilities" } rand_chacha = { version = "0.3.1" }