Skip to content

Commit

Permalink
feat: VID take iterator instead of slice (#381)
Browse files Browse the repository at this point in the history
* derive common bounds for VidDisperse

* more downstream-friendly derivations for VidDisperse

* make itertools a workspace dep

* WIP can't use itertools because rust-itertools/itertools#499

* BytesToField and FieldToBytes iterators pass tests, lots of cleanup todo

* add large test length 5000, separate test for bytes_field_elems2, remove println

* make bytes_to_field2 generic over Borrow<u8>

* rename bytes_to_field2 -> bytes_to_field, etc

* cargo fmt, cargo clippy

* comments

* test for zero-length input

* 0-length input -> 0-length output

* refactor elem_to_usize

* refactor elem_to_bytes_iter

* make bytes_from_field generic over Borrow<F>

* test for iterators over both (u8, F) and (&u8, &F)

* fix infallibility test for bytes_from_field

* WIP disperse() take iterator, tests fail because commit() still does not

* WIP commit() take iterator, tests fail because recover() still does not

* WIP recover_payload() use bytes_from_field, tests fail due to a bug

* rename: add 'invertible'

* new alternate simpler bytes_to_field

* fix: add elems_len to common so as to discard excess elements returned by RS decoding

* remove simpler bytes_to_field (boo)

* rename: remove invertible from bytes_to_field name

* update CHANGELOG

* update flake.lock, fix flake.nix

* clippy appeasement

* iterate elems directly into polynomials in commit_only

* iterate elems directly into polynomials in disperse_from_elems
  • Loading branch information
ggutoski committed Oct 9, 2023
1 parent 1626a84 commit c0b8842
Show file tree
Hide file tree
Showing 13 changed files with 464 additions and 78 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -35,6 +35,7 @@ and follow [semantic versioning](https://semver.org/) for our releases.
- [#341](https://github.com/EspressoSystems/jellyfish/pull/341) Port VDF from another repo
- [#343](https://github.com/EspressoSystems/jellyfish/pull/343) Rescue parameter for `ark_bn254::Fq`
- [#362](https://github.com/EspressoSystems/jellyfish/pull/362) Derive Eq, Hash at a bunch of places
- [#381](https://github.com/EspressoSystems/jellyfish/pull/381) VID take iterator instead of slice

### Changed

Expand Down
10 changes: 4 additions & 6 deletions Cargo.toml
@@ -1,10 +1,5 @@
[workspace]
members = [
"plonk",
"primitives",
"relation",
"utilities",
]
members = ["plonk", "primitives", "relation", "utilities"]

[workspace.package]
version = "0.4.0-pre.0"
Expand All @@ -15,3 +10,6 @@ rust-version = "1.64.0"
homepage = "https://github.com/EspressoSystems/jellyfish"
documentation = "https://jellyfish.docs.espressosys.com"
repository = "https://github.com/EspressoSystems/jellyfish"

[workspace.dependencies]
itertools = { version = "0.10.1", default-features = false }
30 changes: 15 additions & 15 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion flake.nix
Expand Up @@ -70,7 +70,7 @@
buildInputs = [
argbash
openssl
pkgconfig
pkg-config
git

stableToolchain
Expand Down
32 changes: 24 additions & 8 deletions plonk/Cargo.toml
Expand Up @@ -11,7 +11,7 @@ rust-version = { workspace = true }

[dependencies]
ark-ec = "0.4.0"
ark-ff = { version = "0.4.0", features = [ "asm" ] }
ark-ff = { version = "0.4.0", features = ["asm"] }
ark-poly = "0.4.0"
ark-serialize = "0.4.0"
ark-std = { version = "0.4.0", default-features = false }
Expand All @@ -21,7 +21,7 @@ downcast-rs = { version = "1.2.0", default-features = false }
dyn-clone = "^1.0"
espresso-systems-common = { git = "https://github.com/espressosystems/espresso-systems-common", tag = "0.4.0" }
hashbrown = "0.13.2"
itertools = { version = "0.10.1", default-features = false }
itertools = { workspace = true }
jf-primitives = { path = "../primitives", default-features = false }
jf-relation = { path = "../relation", default-features = false }
jf-utils = { path = "../utilities" }
Expand Down Expand Up @@ -52,14 +52,30 @@ harness = false
[features]
default = ["parallel"]
std = [
"ark-std/std", "ark-serialize/std", "ark-ff/std", "ark-ec/std", "ark-poly/std",
"downcast-rs/std", "itertools/use_std", "jf-primitives/std", "jf-relation/std",
"jf-utils/std", "num-bigint/std", "rand_chacha/std", "sha3/std"
"ark-std/std",
"ark-serialize/std",
"ark-ff/std",
"ark-ec/std",
"ark-poly/std",
"downcast-rs/std",
"itertools/use_std",
"jf-primitives/std",
"jf-relation/std",
"jf-utils/std",
"num-bigint/std",
"rand_chacha/std",
"sha3/std",
]
test_apis = [] # exposing apis for testing purpose
parallel = ["ark-ff/parallel", "ark-ec/parallel", "ark-poly/parallel",
"jf-utils/parallel", "jf-relation/parallel", "jf-primitives/parallel",
"dep:rayon" ]
parallel = [
"ark-ff/parallel",
"ark-ec/parallel",
"ark-poly/parallel",
"jf-utils/parallel",
"jf-relation/parallel",
"jf-primitives/parallel",
"dep:rayon",
]
test-srs = []

[[example]]
Expand Down
2 changes: 1 addition & 1 deletion plonk/src/circuit/plonk_verifier/gadgets.rs
Expand Up @@ -177,7 +177,7 @@ where
}
// ensure all the buffer has been consumed
if v_and_uv_basis.next().is_some() {
return Err(PlonkError::IteratorOutOfRange)?;
Err(PlonkError::IteratorOutOfRange)?;
}
Ok(result)
}
Expand Down
6 changes: 3 additions & 3 deletions plonk/src/circuit/plonk_verifier/poly.rs
Expand Up @@ -340,7 +340,7 @@ where
let pi = public_inputs[0];
for &pi_i in public_inputs.iter().skip(1) {
if pi != pi_i {
return Err(PlonkError::PublicInputsDoNotMatch)?;
Err(PlonkError::PublicInputsDoNotMatch)?;
}
}

Expand Down Expand Up @@ -462,7 +462,7 @@ where
}
// ensure all the buffer has been consumed
if alpha_bases_elem_var.next().is_some() {
return Err(PlonkError::IteratorOutOfRange)?;
Err(PlonkError::IteratorOutOfRange)?;
}
// =====================================================
// second statement
Expand Down Expand Up @@ -690,7 +690,7 @@ where

// ensure all the buffer has been consumed
if alpha_bases_elem_var.next().is_some() {
return Err(PlonkError::IteratorOutOfRange)?;
Err(PlonkError::IteratorOutOfRange)?;
}
// ============================================
// Add splitted quotient commitments
Expand Down
4 changes: 1 addition & 3 deletions primitives/Cargo.toml
Expand Up @@ -36,9 +36,7 @@ digest = { version = "0.10.1", default-features = false, features = ["alloc"] }
displaydoc = { version = "0.2.3", default-features = false }
espresso-systems-common = { git = "https://github.com/espressosystems/espresso-systems-common", tag = "0.4.0" }
hashbrown = "0.13.1"
itertools = { version = "0.10.1", default-features = false, features = [
"use_alloc",
] }
itertools = { workspace = true, features = ["use_alloc"] }
jf-relation = { path = "../relation", default-features = false }
jf-utils = { path = "../utilities" }
merlin = { version = "3.0.0", default-features = false }
Expand Down
4 changes: 4 additions & 0 deletions primitives/src/merkle_tree/hasher.rs
Expand Up @@ -35,6 +35,10 @@
//! Use [`GenericHasherMerkleTree`] if you prefer to specify your own `Arity`
//! and node [`Index`] types.

// clippy is freaking out about `HasherNode` and this is the only thing I
// could do to stop it
#![allow(clippy::incorrect_partial_ord_impl_on_ord_type)]

use crate::errors::PrimitivesError;

use super::{append_only::MerkleTree, DigestAlgorithm, Element, Index};
Expand Down

0 comments on commit c0b8842

Please sign in to comment.