diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 4feaa2e0f..4ce000607 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -4,9 +4,11 @@ on:
push:
branches:
- main
+ - release-*
pull_request:
branches:
- main
+ - release-*
schedule:
- cron: '0 0 * * 1'
workflow_dispatch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index eeecfeb24..1fbdd2f42 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,13 @@
## Pending
+## v0.1.3
+
+- Update dependencies
+ - `crypto_box` from `0.7.1` to `0.8.1`
+ - `zeroize` from `1.3` to `^1.5`
+- Use nix flake instead, bump rust version to the latest
+
## v0.1.2
### Improvements
diff --git a/Cargo.toml b/Cargo.toml
index d5c5bbd9f..cedf030b9 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,8 +1,8 @@
[workspace]
members = [
"plonk",
- "rescue",
"primitives",
+ "rescue",
"utilities",
"utilities_derive",
]
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 000000000..d9aa2c3c4
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,204 @@
+{
+ "nodes": {
+ "flake-compat": {
+ "flake": false,
+ "locked": {
+ "lastModified": 1668681692,
+ "narHash": "sha256-Ht91NGdewz8IQLtWZ9LCeNXMSXHUss+9COoqu6JLmXU=",
+ "owner": "edolstra",
+ "repo": "flake-compat",
+ "rev": "009399224d5e398d03b22badca40a37ac85412a1",
+ "type": "github"
+ },
+ "original": {
+ "owner": "edolstra",
+ "repo": "flake-compat",
+ "type": "github"
+ }
+ },
+ "flake-compat_2": {
+ "flake": false,
+ "locked": {
+ "lastModified": 1668681692,
+ "narHash": "sha256-Ht91NGdewz8IQLtWZ9LCeNXMSXHUss+9COoqu6JLmXU=",
+ "owner": "edolstra",
+ "repo": "flake-compat",
+ "rev": "009399224d5e398d03b22badca40a37ac85412a1",
+ "type": "github"
+ },
+ "original": {
+ "owner": "edolstra",
+ "repo": "flake-compat",
+ "type": "github"
+ }
+ },
+ "flake-utils": {
+ "locked": {
+ "lastModified": 1667395993,
+ "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "type": "github"
+ }
+ },
+ "flake-utils_2": {
+ "locked": {
+ "lastModified": 1667395993,
+ "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
+ "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"
+ }
+ },
+ "gitignore": {
+ "inputs": {
+ "nixpkgs": [
+ "pre-commit-hooks",
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1660459072,
+ "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=",
+ "owner": "hercules-ci",
+ "repo": "gitignore.nix",
+ "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73",
+ "type": "github"
+ },
+ "original": {
+ "owner": "hercules-ci",
+ "repo": "gitignore.nix",
+ "type": "github"
+ }
+ },
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1669542132,
+ "narHash": "sha256-DRlg++NJAwPh8io3ExBJdNW7Djs3plVI5jgYQ+iXAZQ=",
+ "owner": "nixos",
+ "repo": "nixpkgs",
+ "rev": "a115bb9bd56831941be3776c8a94005867f316a7",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nixos",
+ "ref": "nixos-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "nixpkgs-stable": {
+ "locked": {
+ "lastModified": 1668984258,
+ "narHash": "sha256-0gDMJ2T3qf58xgcSbYoXiRGUkPWmKyr5C3vcathWhKs=",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "cf63ade6f74bbc9d2a017290f1b2e33e8fbfa70a",
+ "type": "github"
+ },
+ "original": {
+ "owner": "NixOS",
+ "ref": "nixos-22.05",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "nixpkgs_2": {
+ "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-compat": "flake-compat_2",
+ "flake-utils": "flake-utils_2",
+ "gitignore": "gitignore",
+ "nixpkgs": [
+ "nixpkgs"
+ ],
+ "nixpkgs-stable": "nixpkgs-stable"
+ },
+ "locked": {
+ "lastModified": 1669152228,
+ "narHash": "sha256-FEDReoTLWJHXcNso7aaAlAUU7uOqIR6Hc/C/nqlfooE=",
+ "owner": "cachix",
+ "repo": "pre-commit-hooks.nix",
+ "rev": "078b0dee35e2da01334af682ec347463b70a9986",
+ "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_2"
+ },
+ "locked": {
+ "lastModified": 1669689198,
+ "narHash": "sha256-YsWu3C9IGbH3+xguTzEDyQorFe/igr6FGZ+Q5T2ocxE=",
+ "owner": "oxalica",
+ "repo": "rust-overlay",
+ "rev": "4e093ce661a63aca4bcbace33695225eae4ef4e4",
+ "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..b81694f97
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,89 @@
+# 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";
+ inputs.pre-commit-hooks.inputs.nixpkgs.follows = "nixpkgs";
+
+ 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;
+ };
+ };
+ };
+ };
+ 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 cc5cf5156..000000000
--- a/nix/nixpkgs.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "url": "https://github.com/nixos/nixpkgs/archive/db8ab32efd3a4ad59044848d889480954e458f25.tar.gz",
- "sha256": "1i7ayivjm3rx62qq263jjj55m0nzhn4b99wax25kw6a8zhhwcwjb"
-}
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 98b023744..000000000
--- a/nix/oxalica_rust_overlay.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "owner": "oxalica",
- "repo": "rust-overlay",
- "rev": "9d7c777625640b70a4d211f62711fa316bca7176",
- "sha256": "025bw59nl12jqf4nrvbn0a8xn03aj9bz54nvf1rb25zl2l1nkrnd",
- "fetchSubmodules": true
-}
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 2d5d52414..eec715cc7 100644
--- a/plonk/Cargo.toml
+++ b/plonk/Cargo.toml
@@ -1,37 +1,34 @@
[package]
name = "jf-plonk"
description = "UltraPlonk implementation"
-version = "0.1.2"
+version = "0.1.3"
authors = ["Espresso Systems "]
edition = "2018"
license = "MIT"
[dependencies]
-jf-utils = { path = "../utilities" }
-jf-rescue = { path = "../rescue" }
-
-ark-std = { version = "0.3.0", default-features = false }
-ark-serialize = { version = "0.3.0", default-features = false }
-ark-ff = { version = "0.3.0", default-features = false, features = ["asm", "parallel"] }
-ark-ec = { version = "0.3.0", default-features = false, features = ["parallel"] }
-ark-poly = { version = "0.3.0", default-features = false, features = ["parallel"] }
-ark-bn254 = { version = "0.3.0", default-features = false, features = ["curve"] }
ark-bls12-377 = { git = "https://github.com/arkworks-rs/curves", features = ["curve"], rev = "677b4ae751a274037880ede86e9b6f30f62635af" }
ark-bls12-381 = { version = "0.3.0", default-features = false, features = ["curve"] }
+ark-bn254 = { version = "0.3.0", default-features = false, features = ["curve"] }
ark-bw6-761 = { git = "https://github.com/arkworks-rs/curves", rev = "677b4ae751a274037880ede86e9b6f30f62635af" }
-
+ark-ec = { version = "0.3.0", default-features = false, features = ["parallel"] }
+ark-ff = { version = "0.3.0", default-features = false, features = ["asm", "parallel"] }
+ark-poly = { version = "0.3.0", default-features = false, features = ["parallel"] }
+ark-serialize = { version = "0.3.0", default-features = false }
+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 }
+espresso-systems-common = { git = "https://github.com/espressosystems/espresso-systems-common", tag = "0.1.1" }
+itertools = { version = "0.10.1", default-features = false }
+jf-rescue = { path = "../rescue" }
+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", default-features = false }
-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 }
-derivative = { version = "2", features = ["use_core"] }
-num-bigint = { version = "0.4", default-features = false}
-rand_chacha = { version = "0.3.1" }
sha3 = "^0.10"
-espresso-systems-common = { git = "https://github.com/espressosystems/espresso-systems-common", tag = "0.1.1" }
-
[dependencies.ark-poly-commit]
git = "https://github.com/arkworks-rs/poly-commit/"
@@ -39,11 +36,11 @@ rev = "cafc05e39692bbc5c383990063ad851f0b94a553"
default-features = false
[dev-dependencies]
-bincode = "1.0"
-ark-ed-on-bls12-381 = { version = "0.3.0", default-features = false }
ark-ed-on-bls12-377 = { git = "https://github.com/arkworks-rs/curves", rev = "677b4ae751a274037880ede86e9b6f30f62635af" }
+ark-ed-on-bls12-381 = { version = "0.3.0", default-features = false }
ark-ed-on-bls12-381-bandersnatch = { git = "https://github.com/arkworks-rs/curves", default-features = false, rev = "677b4ae751a274037880ede86e9b6f30f62635af" }
ark-ed-on-bn254 = { version = "0.3.0", default-features = false }
+bincode = "1.0"
hex = "^0.4.3"
# Benchmarks
diff --git a/plonk/src/circuit/basic.rs b/plonk/src/circuit/basic.rs
index c7c72bab8..1f581d777 100644
--- a/plonk/src/circuit/basic.rs
+++ b/plonk/src/circuit/basic.rs
@@ -630,10 +630,10 @@ impl PlonkCircuit {
+ q_mul[0] * w_vals[0] * w_vals[1]
+ q_mul[1] * w_vals[2] * w_vals[3]
+ q_ecc * w_vals[0] * w_vals[1] * w_vals[2] * w_vals[3] * w_vals[4]
- + q_hash[0] * w_vals[0].pow(&[5])
- + q_hash[1] * w_vals[1].pow(&[5])
- + q_hash[2] * w_vals[2].pow(&[5])
- + q_hash[3] * w_vals[3].pow(&[5])
+ + q_hash[0] * w_vals[0].pow([5])
+ + q_hash[1] * w_vals[1].pow([5])
+ + q_hash[2] * w_vals[2].pow([5])
+ + q_hash[3] * w_vals[3].pow([5])
+ q_c;
let gate_output = q_o * w_vals[4];
if expected_gate_output != gate_output {
diff --git a/plonk/src/circuit/customized/ecc/mod.rs b/plonk/src/circuit/customized/ecc/mod.rs
index 1c741c4c0..f973c8762 100644
--- a/plonk/src/circuit/customized/ecc/mod.rs
+++ b/plonk/src/circuit/customized/ecc/mod.rs
@@ -29,7 +29,7 @@ mod msm;
pub use conversion::*;
pub use msm::*;
-#[derive(Debug, Copy, Clone, PartialEq)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq)]
/// An elliptic curve point in twisted Edwards affine form (x, y).
pub struct Point(F, F);
diff --git a/plonk/src/circuit/customized/mod.rs b/plonk/src/circuit/customized/mod.rs
index 32468452a..57bade926 100644
--- a/plonk/src/circuit/customized/mod.rs
+++ b/plonk/src/circuit/customized/mod.rs
@@ -437,7 +437,7 @@ where
// now we prove that x^11 = x_to_11
let x_val = self.witness(x)?;
- let x_to_5_val = x_val.pow(&[5]);
+ let x_to_5_val = x_val.pow([5]);
let x_to_5 = self.create_variable(x_to_5_val)?;
let wire_vars = &[x, 0, 0, 0, x_to_5];
self.insert_gate(wire_vars, Box::new(FifthRootGate))?;
@@ -454,7 +454,7 @@ where
// now we prove that x^11 = x_to_11
let x_val = self.witness(x)?;
- let x_to_5_val = x_val.pow(&[5]);
+ let x_to_5_val = x_val.pow([5]);
let x_to_5 = self.create_variable(x_to_5_val)?;
let wire_vars = &[x, 0, 0, 0, x_to_5];
self.insert_gate(wire_vars, Box::new(FifthRootGate))?;
@@ -470,7 +470,7 @@ where
self.check_var_bound(a)?;
let a_val = self.witness(a)?;
let a_uint: BigUint = a_val.into();
- let modulus = F::from(2u8).pow(&[bit_length as u64]);
+ let modulus = F::from(2u8).pow([bit_length as u64]);
let modulus_uint: BigUint = modulus.into();
let res = F::from(a_uint % modulus_uint);
let b = self.create_variable(res)?;
@@ -498,7 +498,7 @@ where
let a_val = self.witness(a)?;
let b_val = self.witness(b)?;
- let modulus = F::from(2u8).pow(&[bit_length as u64]);
+ let modulus = F::from(2u8).pow([bit_length as u64]);
let modulus_uint: BigUint = modulus.into();
if b_val >= modulus {
@@ -555,12 +555,12 @@ where
// step 1. setup the constants
let two_to_bit_length_lookup_component =
- F::from(2u8).pow(&[bit_length_lookup_component as u64]);
+ F::from(2u8).pow([bit_length_lookup_component as u64]);
let two_to_bit_length_lookup_component_uint: BigUint =
two_to_bit_length_lookup_component.into();
let two_to_delta_length_lookup_component =
- F::from(2u8).pow(&[delta_length_lookup_component as u64]);
+ F::from(2u8).pow([delta_length_lookup_component as u64]);
let two_to_delta_length_lookup_component_uint: BigUint =
two_to_delta_length_lookup_component.into();
@@ -1486,7 +1486,7 @@ pub(crate) mod test {
let mut rng = test_rng();
let x = F::rand(&mut rng);
let y = F::rand(&mut rng);
- let x11 = x.pow(&[11]);
+ let x11 = x.pow([11]);
// Create a satisfied circuit
let mut circuit: PlonkCircuit = PlonkCircuit::new_turbo_plonk();
@@ -1531,7 +1531,7 @@ pub(crate) mod test {
let mut rng = test_rng();
let x = F::rand(&mut rng);
let y = F::rand(&mut rng);
- let x11 = x.pow(&[11]);
+ let x11 = x.pow([11]);
// Create a satisfied circuit
let mut circuit: PlonkCircuit = PlonkCircuit::new_turbo_plonk();
@@ -1576,7 +1576,7 @@ pub(crate) mod test {
for len in [80, 100, 201, 248] {
let mut circuit: PlonkCircuit = PlonkCircuit::new_ultra_plonk(16);
let x_var = circuit.create_variable(x)?;
- let modulus = F::from(2u8).pow(&[len as u64]);
+ let modulus = F::from(2u8).pow([len as u64]);
let modulus_uint: BigUint = modulus.into();
let y_var = circuit.truncate(x_var, len)?;
assert!(circuit.check_circuit_satisfiability(&[]).is_ok());
@@ -1590,7 +1590,7 @@ pub(crate) mod test {
let len = F::size_in_bits() - minus_len;
let mut circuit: PlonkCircuit = PlonkCircuit::new_ultra_plonk(16);
let x_var = circuit.create_variable(x)?;
- let modulus = F::from(2u8).pow(&[len as u64]);
+ let modulus = F::from(2u8).pow([len as u64]);
let modulus_uint: BigUint = modulus.into();
let y_var = circuit.truncate(x_var, len)?;
assert!(circuit.check_circuit_satisfiability(&[]).is_ok());
diff --git a/plonk/src/circuit/customized/rescue/native.rs b/plonk/src/circuit/customized/rescue/native.rs
index f0d8ec14b..e862aff07 100644
--- a/plonk/src/circuit/customized/rescue/native.rs
+++ b/plonk/src/circuit/customized/rescue/native.rs
@@ -600,7 +600,7 @@ where
// generate the `power 11 vector` and its wires
let mut input_power_11_vars = RescueStateVar([Variable::default(); STATE_SIZE]);
for (e, f) in input_var.0.iter().zip(input_power_11_vars.0.iter_mut()) {
- let val = self.witness(*e)?.pow(&[11]);
+ let val = self.witness(*e)?.pow([11]);
let var = self.create_variable(val)?;
self.power_11_gate(*e, var)?;
*f = var;
@@ -618,7 +618,7 @@ where
self.check_var_bound(input_var)?;
let input_val = self.witness(input_var)?;
- let output_val = input_val.pow(&F::A_INV);
+ let output_val = input_val.pow(F::A_INV);
let output_var = self.create_variable(output_val)?;
if F::A == 5 {
let wire_vars = &[output_var, 0, 0, 0, input_var];
@@ -765,7 +765,7 @@ mod tests {
let out_var = circuit.pow_alpha_inv_state(&input_var).unwrap();
let out_value: Vec = (0..STATE_SIZE)
- .map(|i| state.elems()[i].pow(&F::A_INV))
+ .map(|i| state.elems()[i].pow(F::A_INV))
.collect();
check_state(
diff --git a/plonk/src/circuit/customized/rescue/non_native.rs b/plonk/src/circuit/customized/rescue/non_native.rs
index b578897b1..d08a51e47 100644
--- a/plonk/src/circuit/customized/rescue/non_native.rs
+++ b/plonk/src/circuit/customized/rescue/non_native.rs
@@ -586,7 +586,7 @@ where
modulus: input_var.modulus,
};
for i in 0..STATE_SIZE {
- let power_eleventh_t = input_val_fields_elems_t[i].pow(&[T::A]);
+ let power_eleventh_t = input_val_fields_elems_t[i].pow([T::A]);
let power_eleventh_f = field_switching::(&power_eleventh_t);
let power_eleventh_fp_elem_var = FpElemVar::new_from_field_element(
self,
diff --git a/plonk/src/circuit/customized/ultraplonk/mod_arith.rs b/plonk/src/circuit/customized/ultraplonk/mod_arith.rs
index 91b526652..6a503fedd 100644
--- a/plonk/src/circuit/customized/ultraplonk/mod_arith.rs
+++ b/plonk/src/circuit/customized/ultraplonk/mod_arith.rs
@@ -20,7 +20,7 @@ macro_rules! to_big_int {
};
}
-#[derive(Debug, Clone, PartialEq, Default, Copy)]
+#[derive(Debug, Clone, PartialEq, Eq, Default, Copy)]
/// A field element represented by:
/// p = p.0 + 2^m * p.1.
/// The struct is useful in modular multiplication
@@ -51,7 +51,7 @@ where
}
let two_power_m = match two_power_m {
Some(p) => p,
- None => F::from(2u8).pow(&[m as u64]),
+ None => F::from(2u8).pow([m as u64]),
};
let (p1, p0) = div_rem(p, &two_power_m);
Ok(Self {
@@ -162,7 +162,7 @@ impl FpElemVar {
m,
two_power_m: match two_power_m {
Some(p) => p,
- None => F::from(2u8).pow(&[m as u64]),
+ None => F::from(2u8).pow([m as u64]),
},
})
}
@@ -203,7 +203,7 @@ impl FpElemVar {
m,
two_power_m: match two_power_m {
Some(p) => p,
- None => F::from(2u8).pow(&[m as u64]),
+ None => F::from(2u8).pow([m as u64]),
},
}
}
@@ -215,7 +215,7 @@ impl FpElemVar {
m,
two_power_m: match two_power_m {
Some(p) => p,
- None => F::from(2u8).pow(&[m as u64]),
+ None => F::from(2u8).pow([m as u64]),
},
}
}
@@ -926,7 +926,7 @@ mod test {
// case 1: m = len(|F|) / 2
let m = F::size_in_bits() / 2;
- let two_power_m = F::from(2u8).pow(&[m as u64]);
+ let two_power_m = F::from(2u8).pow([m as u64]);
let fp_elem = FpElem::new(&p, m, Some(two_power_m))?;
assert!(fp_elem.p.0 < two_power_m, "p0 larger than 2^m");
assert!(fp_elem.p.1 < two_power_m, "p1 larger than 2^m");
@@ -1018,7 +1018,7 @@ mod test {
assert!(circuit.check_circuit_satisfiability(&[]).is_ok());
// larger modulus: l_p = 10, p = 2^{160}
- let p = F::from(RANGE_SIZE_FOR_TEST as u32).pow(&[10u64]);
+ let p = F::from(RANGE_SIZE_FOR_TEST as u32).pow([10u64]);
let mut rng = test_rng();
let vars: Vec = (0..12)
.map(|_| {
@@ -1092,7 +1092,7 @@ mod test {
test_mod_mul_helper::()
}
fn test_mod_mul_helper() -> Result<(), PlonkError> {
- let p = F::from(RANGE_SIZE_FOR_TEST as u32).pow(&[10u64]);
+ let p = F::from(RANGE_SIZE_FOR_TEST as u32).pow([10u64]);
let m = 80;
let p_split = FpElem::new(&p, m, None)?;
let mut rng = test_rng();
@@ -1205,7 +1205,7 @@ mod test {
test_mod_mul_constant_helper::()
}
fn test_mod_mul_constant_helper() -> Result<(), PlonkError> {
- let p = F::from(RANGE_SIZE_FOR_TEST as u32).pow(&[10u64]);
+ let p = F::from(RANGE_SIZE_FOR_TEST as u32).pow([10u64]);
let m = 80;
let p_split = FpElem::new(&p, m, None)?;
let mut rng = test_rng();
@@ -1301,7 +1301,7 @@ mod test {
test_mod_add_helper::()
}
fn test_mod_add_helper() -> Result<(), PlonkError> {
- let p = F::from(RANGE_SIZE_FOR_TEST as u32).pow(&[10u64]);
+ let p = F::from(RANGE_SIZE_FOR_TEST as u32).pow([10u64]);
let m = 80;
let p_split = FpElem::new(&p, m, None)?;
let mut rng = test_rng();
@@ -1413,7 +1413,7 @@ mod test {
test_mod_add_constant_helper::()
}
fn test_mod_add_constant_helper() -> Result<(), PlonkError> {
- let p = F::from(RANGE_SIZE_FOR_TEST as u32).pow(&[10u64]);
+ let p = F::from(RANGE_SIZE_FOR_TEST as u32).pow([10u64]);
let m = 80;
let p_split = FpElem::new(&p, m, None)?;
let mut rng = test_rng();
diff --git a/plonk/src/circuit/customized/ultraplonk/non_native_gates.rs b/plonk/src/circuit/customized/ultraplonk/non_native_gates.rs
index f7ce0438d..6c2211f1a 100644
--- a/plonk/src/circuit/customized/ultraplonk/non_native_gates.rs
+++ b/plonk/src/circuit/customized/ultraplonk/non_native_gates.rs
@@ -222,7 +222,7 @@ mod test {
let mut rng = test_rng();
let x_t = T::rand(&mut rng);
- let y_t = x_t.pow(&[11]);
+ let y_t = x_t.pow([11]);
let x_p = F::from_le_bytes_mod_order(x_t.into_repr().to_bytes_le().as_ref());
let y_p = F::from_le_bytes_mod_order(y_t.into_repr().to_bytes_le().as_ref());
@@ -266,7 +266,7 @@ mod test {
let mut rng = test_rng();
let x_t = T::rand(&mut rng);
- let y_t = x_t.pow(&[5]);
+ let y_t = x_t.pow([5]);
let x_p = F::from_le_bytes_mod_order(x_t.into_repr().to_bytes_le().as_ref());
let y_p = F::from_le_bytes_mod_order(y_t.into_repr().to_bytes_le().as_ref());
@@ -310,7 +310,7 @@ mod test {
let mut rng = test_rng();
let x_t = T::rand(&mut rng);
- let y_t = x_t.pow(&[11]);
+ let y_t = x_t.pow([11]);
let x_p = F::from_le_bytes_mod_order(x_t.into_repr().to_bytes_le().as_ref());
let y_p = F::from_le_bytes_mod_order(y_t.into_repr().to_bytes_le().as_ref());
diff --git a/plonk/src/circuit/customized/ultraplonk/plonk_verifier/gadgets.rs b/plonk/src/circuit/customized/ultraplonk/plonk_verifier/gadgets.rs
index f6242852e..55f0bcbed 100644
--- a/plonk/src/circuit/customized/ultraplonk/plonk_verifier/gadgets.rs
+++ b/plonk/src/circuit/customized/ultraplonk/plonk_verifier/gadgets.rs
@@ -554,7 +554,7 @@ mod test {
// constants
let m = 128;
- let two_power_m = Some(E::Fq::from(2u8).pow(&[m as u64]));
+ let two_power_m = Some(E::Fq::from(2u8).pow([m as u64]));
let fr_modulus_bits = ::Params::MODULUS.to_bytes_le();
let modulus_in_f = F::from_le_bytes_mod_order(&fr_modulus_bits);
diff --git a/plonk/src/circuit/customized/ultraplonk/plonk_verifier/mod.rs b/plonk/src/circuit/customized/ultraplonk/plonk_verifier/mod.rs
index 8b271be9e..9b486cccc 100644
--- a/plonk/src/circuit/customized/ultraplonk/plonk_verifier/mod.rs
+++ b/plonk/src/circuit/customized/ultraplonk/plonk_verifier/mod.rs
@@ -192,7 +192,7 @@ impl VerifyingKeyVar {
let m = (m2 - 1) / range_bit_len * range_bit_len + range_bit_len;
// constants
- let two_power_m = Some(E::Fq::from(2u8).pow(&[m as u64]));
+ let two_power_m = Some(E::Fq::from(2u8).pow([m as u64]));
let fr_modulus_bits = ::Params::MODULUS.to_bytes_le();
let modulus_in_f = F::from_le_bytes_mod_order(&fr_modulus_bits);
@@ -701,7 +701,7 @@ mod test {
// constants
let m = 128;
- let two_power_m = Some(E::Fq::from(2u8).pow(&[m as u64]));
+ let two_power_m = Some(E::Fq::from(2u8).pow([m as u64]));
// public inputs
let shared_public_input_var =
diff --git a/plonk/src/circuit/customized/ultraplonk/plonk_verifier/poly.rs b/plonk/src/circuit/customized/ultraplonk/plonk_verifier/poly.rs
index a8af4aa00..23cc8643b 100644
--- a/plonk/src/circuit/customized/ultraplonk/plonk_verifier/poly.rs
+++ b/plonk/src/circuit/customized/ultraplonk/plonk_verifier/poly.rs
@@ -769,7 +769,7 @@ mod test {
// compute the variables
let m = 128;
// constants
- let two_power_m = Some(E::Fq::from(2u8).pow(&[m as u64]));
+ let two_power_m = Some(E::Fq::from(2u8).pow([m as u64]));
let fr_modulus_bits = ::Params::MODULUS.to_bytes_le();
let modulus_in_f = E::Fq::from_le_bytes_mod_order(&fr_modulus_bits);
diff --git a/plonk/src/proof_system/prover.rs b/plonk/src/proof_system/prover.rs
index 43d59994d..41fc9955f 100644
--- a/plonk/src/proof_system/prover.rs
+++ b/plonk/src/proof_system/prover.rs
@@ -326,7 +326,7 @@ impl Prover {
zeta: E::Fr,
quot_polys: &[DensePolynomial],
) -> Result, PlonkError> {
- let vanish_eval = zeta.pow(&[domain_size as u64]) - E::Fr::one();
+ let vanish_eval = zeta.pow([domain_size as u64]) - E::Fr::one();
let zeta_to_n_plus_2 = (vanish_eval + E::Fr::one()) * zeta * zeta;
let mut r_quot = quot_polys.first().ok_or(PlonkError::IndexError)?.clone();
let mut coeff = E::Fr::one();
@@ -705,10 +705,10 @@ impl Prover {
+ q_mul[0] * w[0] * w[1]
+ q_mul[1] * w[2] * w[3]
+ q_ecc * w[0] * w[1] * w[2] * w[3] * w[4]
- + q_hash[0] * w[0].pow(&[5])
- + q_hash[1] * w[1].pow(&[5])
- + q_hash[2] * w[2].pow(&[5])
- + q_hash[3] * w[3].pow(&[5])
+ + q_hash[0] * w[0].pow([5])
+ + q_hash[1] * w[1].pow([5])
+ + q_hash[2] * w[2].pow([5])
+ + q_hash[3] * w[3].pow([5])
- q_o * w[4]
}
@@ -944,10 +944,10 @@ impl Prover {
+ Self::mul_poly(&q_lc[3], &w_evals[3])
+ Self::mul_poly(&q_mul[0], &(w_evals[0] * w_evals[1]))
+ Self::mul_poly(&q_mul[1], &(w_evals[2] * w_evals[3]))
- + Self::mul_poly(&q_hash[0], &w_evals[0].pow(&[5]))
- + Self::mul_poly(&q_hash[1], &w_evals[1].pow(&[5]))
- + Self::mul_poly(&q_hash[2], &w_evals[2].pow(&[5]))
- + Self::mul_poly(&q_hash[3], &w_evals[3].pow(&[5]))
+ + Self::mul_poly(&q_hash[0], &w_evals[0].pow([5]))
+ + Self::mul_poly(&q_hash[1], &w_evals[1].pow([5]))
+ + Self::mul_poly(&q_hash[2], &w_evals[2].pow([5]))
+ + Self::mul_poly(&q_hash[3], &w_evals[3].pow([5]))
+ Self::mul_poly(
q_ecc,
&(w_evals[0] * w_evals[1] * w_evals[2] * w_evals[3] * w_evals[4]),
@@ -963,7 +963,7 @@ impl Prover {
poly_evals: &ProofEvaluations,
prod_perm_poly: &DensePolynomial,
) -> DensePolynomial {
- let dividend = challenges.zeta.pow(&[pk.domain_size() as u64]) - E::Fr::one();
+ let dividend = challenges.zeta.pow([pk.domain_size() as u64]) - E::Fr::one();
let divisor = E::Fr::from(pk.domain_size() as u32) * (challenges.zeta - E::Fr::one());
let lagrange_1_eval = dividend / divisor;
@@ -1010,7 +1010,7 @@ impl Prover {
let alpha_6 = alpha_4 * alpha_2;
let n = pk.domain_size();
let one = E::Fr::one();
- let vanish_eval = challenges.zeta.pow(&[n as u64]) - one;
+ let vanish_eval = challenges.zeta.pow([n as u64]) - one;
// compute lagrange_1 and lagrange_n
let divisor = E::Fr::from(n as u32) * (challenges.zeta - one);
diff --git a/plonk/src/proof_system/structs.rs b/plonk/src/proof_system/structs.rs
index 4849d8558..537ac6eb9 100644
--- a/plonk/src/proof_system/structs.rs
+++ b/plonk/src/proof_system/structs.rs
@@ -42,7 +42,7 @@ use jf_rescue::RescueParameter;
use jf_utils::{field_switching, fq_to_fr, fr_to_fq, tagged_blob};
/// Universal Structured Reference String for PlonkKzgSnark
-#[derive(Debug, Clone, PartialEq, CanonicalSerialize, CanonicalDeserialize)]
+#[derive(Debug, Clone, PartialEq, Eq, CanonicalSerialize, CanonicalDeserialize)]
pub struct UniversalSrs(pub(crate) UniversalParams);
impl UniversalSrs {
@@ -570,7 +570,7 @@ pub struct ProvingKey<'a, E: PairingEngine> {
/// Preprocessed prover parameters used to compute Plookup proofs for a certain
/// circuit.
-#[derive(Debug, Clone, PartialEq, CanonicalSerialize, CanonicalDeserialize)]
+#[derive(Debug, Clone, PartialEq, Eq, CanonicalSerialize, CanonicalDeserialize)]
pub struct PlookupProvingKey {
/// Range table polynomial.
pub(crate) range_table_poly: DensePolynomial,
@@ -657,7 +657,7 @@ impl<'a, E: PairingEngine> ProvingKey<'a, E> {
/// Preprocessed verifier parameters used to verify Plonk proofs for a certain
/// circuit.
-#[derive(Debug, Clone, PartialEq, CanonicalSerialize, CanonicalDeserialize)]
+#[derive(Debug, Clone, PartialEq, Eq, CanonicalSerialize, CanonicalDeserialize)]
pub struct VerifyingKey {
/// The size of the evaluation domain. Should be a power of two.
pub(crate) domain_size: usize,
@@ -746,7 +746,7 @@ where
/// Preprocessed verifier parameters used to verify Plookup proofs for a certain
/// circuit.
-#[derive(Debug, Clone, PartialEq, CanonicalSerialize, CanonicalDeserialize)]
+#[derive(Debug, Clone, PartialEq, Eq, CanonicalSerialize, CanonicalDeserialize)]
pub struct PlookupVerifyingKey {
/// Range table polynomial commitment. The commitment is not hiding.
pub(crate) range_table_comm: Commitment,
diff --git a/primitives/Cargo.toml b/primitives/Cargo.toml
index c7750ffbf..ae97c4397 100644
--- a/primitives/Cargo.toml
+++ b/primitives/Cargo.toml
@@ -1,55 +1,45 @@
[package]
name = "jf-primitives"
description = "Cryptographic primitives"
-version = "0.1.2"
+version = "0.1.3"
authors = ["Espresso Systems "]
edition = "2018"
license = "MIT"
[dependencies]
-
-# ark
-ark-ff = { version = "0.3.0", default-features = false }
-ark-std = { version = "0.3.0", default-features = false }
-ark-ec = { version = "0.3.0", default-features = false }
-ark-serialize = { version = "0.3.0", default-features = false }
-
-# ark curves
-ark-bls12-381 = { version = "0.3.0", default-features = false, features = ["curve"] }
ark-bls12-377 = { git = "https://github.com/arkworks-rs/curves", default-features = false, features = ["curve"], rev = "677b4ae751a274037880ede86e9b6f30f62635af" }
-ark-ed-on-bls12-377 = { git = "https://github.com/arkworks-rs/curves", default-features = false, rev = "677b4ae751a274037880ede86e9b6f30f62635af"}
+ark-bls12-381 = { version = "0.3.0", default-features = false, features = ["curve"] }
+ark-ec = { version = "0.3.0", default-features = false }
+ark-ed-on-bls12-377 = { git = "https://github.com/arkworks-rs/curves", default-features = false, rev = "677b4ae751a274037880ede86e9b6f30f62635af" }
ark-ed-on-bls12-381 = { version = "0.3.0", default-features = false }
-
-# jellyfish
+ark-ff = { version = "0.3.0", default-features = false }
+ark-serialize = { version = "0.3.0", default-features = false }
+ark-std = { version = "0.3.0", default-features = false }
+crypto_box = "0.8.1"
+derivative = { version = "2", features = ["use_core"] }
+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", tag = "0.1.1" }
+generic-array = { version = "^0.14", default-features = false }
+itertools = { version = "0.10.1", default-features = false, features = [ "use_alloc" ] }
jf-plonk = { path = "../plonk" }
jf-rescue = { path = "../rescue" }
jf-utils = { path = "../utilities" }
-
-# others
+rand_chacha = { version = "0.3.1", default-features = false }
rayon = { version = "1.5.0", default-features = false }
-zeroize = { version = "1.3", default-features = false }
-itertools = { version = "0.10.1", default-features = false, features = [ "use_alloc" ] }
serde = { version = "1.0", features = ["derive"] }
-generic-array = { version = "^0.14", default-features = false }
-crypto_box = { version = "0.7.1", default-features = false, features = [ "u64_backend", "alloc" ] }
-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 }
-espresso-systems-common = { git = "https://github.com/espressosystems/espresso-systems-common", tag = "0.1.1" }
+zeroize = { version = "^1.5", default-features = false }
[dev-dependencies]
-rand_chacha = "^0.3"
-bincode = "1.0"
-quickcheck = "1.0.0"
-criterion = "0.3.1"
-
-# ark curves
-ark-ed-on-bls12-381-bandersnatch = { git = "https://github.com/arkworks-rs/curves", default-features = false, rev = "677b4ae751a274037880ede86e9b6f30f62635af" }
-ark-ed-on-bn254 = { version = "0.3.0", default-features = false }
ark-bn254 = { version = "0.3.0", default-features = false, features = ["curve"] }
ark-bw6-761 = { git = "https://github.com/arkworks-rs/curves", default-features = false, rev = "677b4ae751a274037880ede86e9b6f30f62635af" }
+ark-ed-on-bls12-381-bandersnatch = { git = "https://github.com/arkworks-rs/curves", default-features = false, rev = "677b4ae751a274037880ede86e9b6f30f62635af" }
+ark-ed-on-bn254 = { version = "0.3.0", default-features = false }
+bincode = "1.0"
+criterion = "0.3.1"
+quickcheck = "1.0.0"
+rand_chacha = "^0.3"
[[bench]]
name = "merkle_path"
diff --git a/primitives/src/aead.rs b/primitives/src/aead.rs
index 6e6d17b7b..2e9dfe7e2 100644
--- a/primitives/src/aead.rs
+++ b/primitives/src/aead.rs
@@ -15,7 +15,7 @@ use ark_std::{
vec::Vec,
};
use crypto_box::{
- aead::{Aead, Nonce, Payload},
+ aead::{Aead, AeadCore, Nonce, Payload},
ChaChaBox,
};
use generic_array::{typenum::U24, GenericArray};
@@ -82,19 +82,16 @@ impl EncKey {
/// during encryption will cause decryption to fail, which is useful if you
/// would like to "bind" the ciphertext to some identifier, like a
/// digital signature key.
- pub fn encrypt(
+ pub fn encrypt(
&self,
- rng: &mut R,
+ mut rng: impl RngCore + CryptoRng,
message: &[u8],
aad: &[u8],
- ) -> Result
- where
- R: RngCore + CryptoRng,
- {
- let nonce = crypto_box::generate_nonce(rng);
+ ) -> Result {
+ let nonce = ChaChaBox::generate_nonce(&mut rng);
// generate an ephemeral key pair as the virtual sender to derive the crypto box
- let ephemeral_sk = crypto_box::SecretKey::generate(rng);
+ let ephemeral_sk = crypto_box::SecretKey::generate(&mut rng);
let ephemeral_pk = EncKey(crypto_box::PublicKey::from(&ephemeral_sk));
let my_box = ChaChaBox::new(&self.0, &ephemeral_sk);
diff --git a/primitives/src/signatures/schnorr.rs b/primitives/src/signatures/schnorr.rs
index bb543925e..61edc796c 100644
--- a/primitives/src/signatures/schnorr.rs
+++ b/primitives/src/signatures/schnorr.rs
@@ -97,7 +97,7 @@ where
// Signing key
// =====================================================
#[derive(
- Clone, Hash, Default, Zeroize, PartialEq, CanonicalSerialize, CanonicalDeserialize, Debug,
+ Clone, Hash, Default, Zeroize, PartialEq, Eq, CanonicalSerialize, CanonicalDeserialize, Debug,
)]
/// Signing key for Schnorr signature.
pub struct SignKey(pub(crate) F);
diff --git a/rescue/Cargo.toml b/rescue/Cargo.toml
index e591a854a..7a8840474 100644
--- a/rescue/Cargo.toml
+++ b/rescue/Cargo.toml
@@ -1,45 +1,36 @@
[package]
name = "jf-rescue"
description = "Rescue hash function"
-version = "0.1.2"
+version = "0.1.3"
authors = ["Espresso Systems "]
edition = "2018"
license = "MIT"
[dependencies]
-
-# ark
-ark-ff = { version = "0.3.0", default-features = false }
-ark-std = { version = "0.3.0", default-features = false }
-ark-ec = { version = "0.3.0", default-features = false }
-ark-serialize = { version = "0.3.0", default-features = false }
-
-# ark cruves
-ark-ed-on-bls12-377 = { git = "https://github.com/arkworks-rs/curves", default-features = false, rev = "677b4ae751a274037880ede86e9b6f30f62635af"}
-ark-ed-on-bls12-381 = { version = "0.3.0", default-features = false }
-ark-ed-on-bn254 = { version = "0.3.0", default-features = false }
ark-bls12-377 = { git = "https://github.com/arkworks-rs/curves", default-features = false, features = ["curve"], rev = "677b4ae751a274037880ede86e9b6f30f62635af" }
ark-bls12-381 = { version = "0.3.0", default-features = false, features = ["curve"] }
ark-bn254 = { version = "0.3.0", default-features = false, features = ["curve"] }
ark-bw6-761 = { git = "https://github.com/arkworks-rs/curves", default-features = false, rev = "677b4ae751a274037880ede86e9b6f30f62635af" }
-
-# jellyfish
+ark-ec = { version = "0.3.0", default-features = false }
+ark-ed-on-bls12-377 = { git = "https://github.com/arkworks-rs/curves", default-features = false, rev = "677b4ae751a274037880ede86e9b6f30f62635af" }
+ark-ed-on-bls12-381 = { version = "0.3.0", default-features = false }
+ark-ed-on-bn254 = { version = "0.3.0", default-features = false }
+ark-ff = { version = "0.3.0", default-features = false }
+ark-serialize = { version = "0.3.0", default-features = false }
+ark-std = { version = "0.3.0", default-features = false }
+derivative = { version = "2", features = ["use_core"] }
+displaydoc = { version = "0.2.3", default-features = false }
+generic-array = { version = "^0.14", default-features = false }
jf-utils = { path = "../utilities" }
-
-# others
rayon = { version = "1.5.0", default-features = false }
-zeroize = { version = "1.3", default-features = false }
serde = { version = "1.0", features = ["derive"] }
-generic-array = { version = "^0.14", default-features = false }
-displaydoc = { version = "0.2.3", default-features = false }
-derivative = { version = "2", features = ["use_core"] }
+zeroize = { version = "^1.5", default-features = false }
[dev-dependencies]
-rand_chacha = "^0.3"
bincode = "1.0"
-quickcheck = "1.0.0"
criterion = "0.3.1"
-
+quickcheck = "1.0.0"
+rand_chacha = "^0.3"
[features]
std = []
diff --git a/rescue/src/errors.rs b/rescue/src/errors.rs
index 2bd78b8a9..fdd1ce81c 100644
--- a/rescue/src/errors.rs
+++ b/rescue/src/errors.rs
@@ -14,7 +14,7 @@ use ark_std::string::String;
use displaydoc::Display;
/// Various error modes.
-#[derive(Debug, Display, PartialEq)]
+#[derive(Debug, Display, PartialEq, Eq)]
pub enum RescueError {
/// Bad parameter in function call, {0}
ParameterError(String),
diff --git a/rescue/src/lib.rs b/rescue/src/lib.rs
index f14c2c456..a8dc72182 100644
--- a/rescue/src/lib.rs
+++ b/rescue/src/lib.rs
@@ -91,7 +91,7 @@ pub trait RescueParameter: PrimeField {
const PERMUTATION_ROUND_KEYS: [[&'static [u8]; 4]; 25];
}
-#[derive(Clone, Debug, PartialEq, Copy)]
+#[derive(Clone, Debug, PartialEq, Eq, Copy)]
/// Data type for rescue prp inputs, keys and internal data
pub struct RescueVector {
pub(crate) vec: [F; STATE_SIZE],
diff --git a/shell.nix b/shell.nix
index 993c4be7a..006cc45c0 100644
--- a/shell.nix
+++ b/shell.nix
@@ -1,45 +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."1.56.1".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 ddf33fbc7..0a6707bae 100644
--- a/utilities/Cargo.toml
+++ b/utilities/Cargo.toml
@@ -1,35 +1,32 @@
[package]
name = "jf-utils"
description = "Utilities for Jellyfish cryptographic library"
-version = "0.1.2"
+version = "0.1.3"
authors = ["Espresso Systems "]
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", "parallel"] }
+anyhow = { version = "^1.0", default-features = false }
ark-ec = { version = "0.3.0", default-features = false, features = ["parallel"] }
+ark-ff = { version = "0.3.0", default-features = false, features = ["asm", "parallel"] }
ark-serialize = { version = "0.3.0", default-features = false }
-
+ark-std = { version = "0.3.0", default-features = false }
+digest = { version = "0.10.1", default-features = false }
+jf-utils-derive = { path = "../utilities_derive" }
serde = { version = "1.0", features = ["derive"] }
-anyhow = { version = "^1.0", default-features = false }
-snafu = { version = "0.7", features = ["backtraces"] }
-
sha2 = { version = "0.10.1", default-features = false }
-digest = { version = "0.10.1", default-features = false }
+snafu = { version = "0.7", features = ["backtraces"] }
+tagged-base64 = { git = "https://github.com/EspressoSystems/tagged-base64", tag = "0.2.0" }
[dev-dependencies]
-ark-ed-on-bn254 = { version = "0.3.0", default-features = false }
+ark-bls12-377 = { git = "https://github.com/arkworks-rs/curves", rev = "677b4ae751a274037880ede86e9b6f30f62635af" }
+ark-bls12-381 = { version = "0.3.0", default-features = false, features = ["curve"] }
+ark-bn254 = { version = "0.3.0", default-features = false, features = ["curve"] }
ark-ed-on-bls12-377 = { git = "https://github.com/arkworks-rs/curves", default-features = false, rev = "677b4ae751a274037880ede86e9b6f30f62635af" }
ark-ed-on-bls12-381 = { version = "0.3.0", default-features = false }
ark-ed-on-bls12-381-bandersnatch = { git = "https://github.com/arkworks-rs/curves", default-features = false, rev = "677b4ae751a274037880ede86e9b6f30f62635af" }
-ark-bn254 = { version = "0.3.0", default-features = false, features = ["curve"] }
-ark-bls12-377 = { git = "https://github.com/arkworks-rs/curves", rev = "677b4ae751a274037880ede86e9b6f30f62635af" }
-ark-bls12-381 = { version = "0.3.0", default-features = false, features = ["curve"] }
+ark-ed-on-bn254 = { version = "0.3.0", default-features = false }
ark-serialize = { version = "0.3.0", default-features = false, features = ["derive"] }
serde_json = "1.0"
diff --git a/utilities_derive/Cargo.toml b/utilities_derive/Cargo.toml
index 0c34cbf3e..051803923 100644
--- a/utilities_derive/Cargo.toml
+++ b/utilities_derive/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "jf-utils-derive"
description = "Procedural macros for deriving serialization code for Jellyfish types"
-version = "0.1.2"
+version = "0.1.3"
authors = ["Espresso Systems "]
edition = "2018"
license = "MIT"
@@ -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" }