Skip to content

Commit

Permalink
update jf
Browse files Browse the repository at this point in the history
  • Loading branch information
mrain committed May 10, 2024
1 parent 8f46048 commit 7374076
Show file tree
Hide file tree
Showing 31 changed files with 348 additions and 396 deletions.
466 changes: 191 additions & 275 deletions Cargo.lock

Large diffs are not rendered by default.

45 changes: 29 additions & 16 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,39 +46,52 @@ dotenvy = "0.15"
ethers = { version = "2.0", features = ["solc"] }
futures = "0.3"

hotshot = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.50" }
hotshot = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.51" }
# Hotshot imports
hotshot-builder-api = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.50" }
hotshot-builder-core = { git = "https://github.com/EspressoSystems/hotshot-builder-core", tag = "0.1.18" }
hotshot-events-service = { git = "https://github.com/EspressoSystems/hotshot-events-service.git", tag = "0.1.19" }
hotshot-orchestrator = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.50" }
hotshot-query-service = { git = "https://github.com/EspressoSystems/hotshot-query-service", tag = "0.1.19" }
hotshot-stake-table = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.50" }
hotshot-builder-api = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.51" }
hotshot-builder-core = { git = "https://github.com/EspressoSystems/hotshot-builder-core", branch = "cl/jf-update" }
hotshot-events-service = { git = "https://github.com/EspressoSystems/hotshot-events-service.git", tag = "0.1.20" }
hotshot-orchestrator = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.51" }
hotshot-query-service = { git = "https://github.com/EspressoSystems/hotshot-query-service", tag = "0.1.20" }
hotshot-stake-table = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.51" }
hotshot-state-prover = { version = "0.1.0", path = "hotshot-state-prover" }
hotshot-task = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.50" }
hotshot-testing = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.50" }
hotshot-types = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.50" }
hotshot-task = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.51" }
hotshot-testing = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.51" }
hotshot-types = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.51" }

# Push CDN imports
cdn-broker = { git = "https://github.com/EspressoSystems/Push-CDN", features = [
"runtime-async-std",
"global-permits",
], tag = "0.3.2", package = "cdn-broker" }
], tag = "0.3.6", package = "cdn-broker" }
cdn-marshal = { git = "https://github.com/EspressoSystems/Push-CDN", features = [
"runtime-async-std",
"global-permits",
], tag = "0.3.2", package = "cdn-marshal" }
], tag = "0.3.6", package = "cdn-marshal" }

jf-plonk = { git = "https://github.com/EspressoSystems/jellyfish", tag = "0.4.4", features = [
jf-plonk = { git = "https://github.com/EspressoSystems/jellyfish", tag = "0.4.5", features = [
"test-apis",
] }
jf-primitives = { git = "https://github.com/EspressoSystems/jellyfish", tag = "0.4.4", features = [
jf-crhf = { version = "0.1.0", git = "https://github.com/EspressoSystems/jellyfish", tag = "0.4.5" }
jf-merkle-tree = { version = "0.1.0", git = "https://github.com/EspressoSystems/jellyfish", tag = "0.4.5", features = [
"std",
] }
jf-relation = { git = "https://github.com/EspressoSystems/jellyfish", tag = "0.4.4", features = [
jf-signature = { version = "0.1.0", git = "https://github.com/EspressoSystems/jellyfish", tag = "0.4.5", features = [
"std",
] }
jf-utils = { git = "https://github.com/EspressoSystems/jellyfish", tag = "0.4.4" }
jf-pcs = { version = "0.1.0", git = "https://github.com/EspressoSystems/jellyfish", tag = "0.4.5", features = [
"std", "parallel"
] }
jf-vid = { version = "0.1.0", git = "https://github.com/EspressoSystems/jellyfish", tag = "0.4.5", features = [
"std", "parallel"
] }
jf-rescue = { version = "0.1.0", git = "https://github.com/EspressoSystems/jellyfish", tag = "0.4.5", features = [
"std", "parallel"
] }
jf-relation = { git = "https://github.com/EspressoSystems/jellyfish", tag = "0.4.5", features = [
"std",
] }
jf-utils = { git = "https://github.com/EspressoSystems/jellyfish", tag = "0.4.5" }
snafu = "0.8"
strum = { version = "0.26", features = ["derive"] }
surf-disco = "0.6"
Expand Down
3 changes: 2 additions & 1 deletion builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ hotshot-orchestrator = { workspace = true }
hotshot-stake-table = { workspace = true }
hotshot-state-prover = { path = "../hotshot-state-prover" }
hotshot-types = { workspace = true }
jf-primitives = { workspace = true }
jf-signature = { workspace = true, features = ["bls"] }
jf-merkle-tree = { workspace = true }
portpicker = { workspace = true }
rand = "0.8.5"
sequencer = { path = "../sequencer", features = ["testing"] }
Expand Down
6 changes: 2 additions & 4 deletions builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@ use hotshot_builder_api::builder::{
BuildError, Error as BuilderApiError, Options as HotshotBuilderApiOptions,
};
use hotshot_builder_core::service::{GlobalState, ProxyGlobalState};
use jf_primitives::{
merkle_tree::{namespaced_merkle_tree::NamespacedMerkleTreeScheme, MerkleTreeScheme},
signatures::bls_over_bn254::VerKey,
};
use jf_merkle_tree::{namespaced_merkle_tree::NamespacedMerkleTreeScheme, MerkleTreeScheme};
use jf_signature::bls_over_bn254::VerKey;
use sequencer::catchup::mock::MockStateCatchup;
use sequencer::state_signature::StakeTableCommitmentType;
use sequencer::{
Expand Down
6 changes: 2 additions & 4 deletions builder/src/permissioned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,8 @@ use hotshot_builder_core::{
},
};
use hotshot_state_prover;
use jf_primitives::{
merkle_tree::{namespaced_merkle_tree::NamespacedMerkleTreeScheme, MerkleTreeScheme},
signatures::bls_over_bn254::VerKey,
};
use jf_merkle_tree::{namespaced_merkle_tree::NamespacedMerkleTreeScheme, MerkleTreeScheme};
use jf_signature::bls_over_bn254::VerKey;
use sequencer::state_signature::StakeTableCommitmentType;
use sequencer::{catchup::mock::MockStateCatchup, eth_signature_key::EthKeyPair, ChainConfig};
use sequencer::{
Expand Down
2 changes: 1 addition & 1 deletion contracts/rust/adapter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ diff-test-bn254 = { git = "https://github.com/EspressoSystems/solidity-bn254.git
ethers = { version = "2.0.4" }
hotshot-types = { workspace = true }
jf-plonk = { workspace = true }
jf-primitives = { workspace = true }
jf-pcs = { workspace = true }
jf-utils = { workspace = true }
num-bigint = { version = "0.4", default-features = false }
num-traits = { version = "0.2", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion contracts/rust/adapter/src/jellyfish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ use ethers::{
prelude::{AbiError, EthAbiCodec, EthAbiType},
types::{Bytes, H256, U256},
};
use jf_pcs::prelude::Commitment;
use jf_plonk::proof_system::structs::{OpenKey, Proof, ProofEvaluations, VerifyingKey};
use jf_plonk::testing_apis::Challenges;
use jf_plonk::{constants::KECCAK256_STATE_SIZE, transcript::SolidityTranscript};
use jf_primitives::pcs::prelude::Commitment;
use num_bigint::BigUint;
use num_traits::Num;

Expand Down
3 changes: 2 additions & 1 deletion contracts/rust/diff-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ hotshot-state-prover = { path = "../../../hotshot-state-prover" }
hotshot-types = { workspace = true }
itertools = { workspace = true }
jf-plonk = { workspace = true }
jf-primitives = { workspace = true }
jf-signature = { workspace = true }
jf-pcs = { workspace = true }
jf-relation = { workspace = true }
jf-utils = { workspace = true }
sha3 = { version = "0.10.8", default-features = false }
Expand Down
9 changes: 4 additions & 5 deletions contracts/rust/diff-test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,16 @@ use hotshot_state_prover::mock_ledger::{
gen_plonk_proof_for_test, MockLedger, MockSystemParam, STAKE_TABLE_CAPACITY,
};
use itertools::multiunzip;
use jf_pcs::prelude::Commitment;
use jf_plonk::proof_system::structs::{Proof, VerifyingKey};
use jf_plonk::proof_system::PlonkKzgSnark;
use jf_plonk::{
testing_apis::Verifier,
transcript::{PlonkTranscript, SolidityTranscript},
};
use jf_primitives::constants::CS_ID_BLS_BN254;
use jf_primitives::pcs::prelude::Commitment;
use jf_primitives::signatures::bls_over_bn254::Signature;
use jf_primitives::signatures::bls_over_bn254::{hash_to_curve, KeyPair as BLSKeyPair};
use jf_primitives::signatures::schnorr::KeyPair as SchnorrKeyPair;
use jf_signature::bls_over_bn254::{hash_to_curve, KeyPair as BLSKeyPair, Signature};
use jf_signature::constants::CS_ID_BLS_BN254;
use jf_signature::schnorr::KeyPair as SchnorrKeyPair;
use sha3::Keccak256;

#[derive(Parser)]
Expand Down
2 changes: 1 addition & 1 deletion contracts/rust/gen-vk-contract/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ ark-srs = { workspace = true }
hotshot-contract-adapter = { path = "../adapter" }
hotshot-stake-table = { workspace = true }
hotshot-state-prover = { path = "../../../hotshot-state-prover" }
jf-primitives = { workspace = true }
jf-pcs = { workspace = true }
2 changes: 1 addition & 1 deletion contracts/rust/gen-vk-contract/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::process::Command;

use hotshot_contract_adapter::jellyfish::ParsedVerifyingKey;
use hotshot_stake_table::config::STAKE_TABLE_CAPACITY;
use jf_primitives::pcs::prelude::UnivariateUniversalParams;
use jf_pcs::prelude::UnivariateUniversalParams;

fn main() {
let srs = {
Expand Down
9 changes: 6 additions & 3 deletions hotshot-state-prover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,18 @@ hotshot-stake-table = { workspace = true }
hotshot-types = { workspace = true }
itertools = { workspace = true }
jf-plonk = { workspace = true }
jf-primitives = { workspace = true }
jf-signature = { workspace = true, features = ["schnorr", "bls", "gadgets"] }
jf-rescue = { workspace = true, features = ["gadgets"] }
jf-pcs = { workspace = true }
jf-crhf = { workspace = true }
jf-relation = { workspace = true }
jf-utils = { workspace = true }
rand_chacha = { workspace = true }
sequencer-utils = { path = "../utils" }
serde = { workspace = true }
snafu = { workspace = true }
surf-disco = { workspace = true }
tagged-base64 = { git = "https://github.com/EspressoSystems/tagged-base64", tag = "0.3.4" }
tagged-base64 = { workspace = true }
tide-disco = { workspace = true }
time = { workspace = true }
toml = "0.8"
Expand All @@ -51,4 +54,4 @@ vbs = { workspace = true }
[features]
default = ["parallel"]
std = ["ark-std/std", "ark-ff/std"]
parallel = ["jf-primitives/parallel", "jf-utils/parallel", "ark-ff/parallel"]
parallel = ["jf-signature/parallel", "jf-utils/parallel", "ark-ff/parallel"]
31 changes: 15 additions & 16 deletions hotshot-state-prover/src/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@ use ark_ff::PrimeField;
use ark_std::borrow::Borrow;
use ethers::types::U256;
use hotshot_types::light_client::{GenericLightClientState, GenericPublicInput};
use jf_plonk::errors::PlonkError;
use jf_primitives::{
circuit::{
rescue::RescueNativeGadget,
signature::schnorr::{SignatureGadget, VerKeyVar},
},
rescue::RescueParameter,
signatures::schnorr::{Signature, VerKey as SchnorrVerKey},
use jf_plonk::PlonkError;
use jf_relation::{BoolVar, Circuit, CircuitError, PlonkCircuit, Variable};
use jf_rescue::{gadgets::RescueNativeGadget, RescueParameter};
use jf_signature::{
gadgets::schnorr::{SignatureGadget, VerKeyVar},
schnorr::{Signature, VerKey as SchnorrVerKey},
};
use jf_relation::{errors::CircuitError, BoolVar, Circuit, PlonkCircuit, Variable};

/// Lossy conversion of a U256 into a field element.
pub(crate) fn u256_to_field<F: PrimeField>(v: &U256) -> F {
Expand Down Expand Up @@ -380,11 +377,13 @@ mod tests {
use ark_ed_on_bn254::EdwardsConfig as Config;
use ethers::types::U256;
use hotshot_types::traits::stake_table::{SnapshotVersion, StakeTableScheme};
use jf_primitives::{
crhf::{VariableLengthRescueCRHF, CRHF},
errors::PrimitivesError,
signatures::{schnorr::Signature, SchnorrSignatureScheme, SignatureScheme},
use jf_crhf::CRHF;
use jf_rescue::crhf::VariableLengthRescueCRHF;
use jf_signature::{
schnorr::{SchnorrSignatureScheme, Signature},
SignatureScheme,
};

use jf_relation::Circuit;
use jf_utils::test_rng;

Expand Down Expand Up @@ -425,7 +424,7 @@ mod tests {
let sigs = state_keys
.iter()
.map(|(key, _)| SchnorrSignatureScheme::<Config>::sign(&(), key, state_msg, &mut prng))
.collect::<Result<Vec<_>, PrimitivesError>>()
.collect::<Result<Vec<_>, _>>()
.unwrap();

// bit vector with total weight 26
Expand Down Expand Up @@ -532,7 +531,7 @@ mod tests {
.map(|(key, _)| {
SchnorrSignatureScheme::<Config>::sign(&(), key, bad_state_msg, &mut prng)
})
.collect::<Result<Vec<_>, PrimitivesError>>()
.collect::<Result<Vec<_>, _>>()
.unwrap();
let (bad_circuit, public_inputs) = build(
&entries,
Expand All @@ -557,7 +556,7 @@ mod tests {
.map(|(key, _)| {
SchnorrSignatureScheme::<Config>::sign(&(), key, wrong_state_msg, &mut prng)
})
.collect::<Result<Vec<_>, PrimitivesError>>()
.collect::<Result<Vec<_>, _>>()
.unwrap();
let (bad_circuit, public_inputs) = build(
&entries,
Expand Down
15 changes: 8 additions & 7 deletions hotshot-state-prover/src/mock_ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,22 @@ use hotshot_types::{
traits::stake_table::SnapshotVersion,
};
use itertools::izip;
use jf_pcs::prelude::UnivariateUniversalParams;
use jf_plonk::proof_system::{PlonkKzgSnark, UniversalSNARK};
use jf_plonk::transcript::SolidityTranscript;
use jf_primitives::pcs::prelude::UnivariateUniversalParams;
use jf_primitives::signatures::schnorr::Signature;
use jf_primitives::signatures::{
use jf_relation::{Arithmetization, Circuit, PlonkCircuit};
use jf_signature::schnorr::Signature;
use jf_signature::{
bls_over_bn254::{BLSOverBN254CurveSignatureScheme, VerKey as BLSVerKey},
SchnorrSignatureScheme, SignatureScheme,
schnorr::SchnorrSignatureScheme,
SignatureScheme,
};
use jf_relation::{Arithmetization, Circuit, PlonkCircuit};
use jf_utils::test_rng;
use std::collections::HashMap;

type F = ark_ed_on_bn254::Fq;
type SchnorrVerKey = jf_primitives::signatures::schnorr::VerKey<EdwardsConfig>;
type SchnorrSignKey = jf_primitives::signatures::schnorr::SignKey<ark_ed_on_bn254::Fr>;
type SchnorrVerKey = jf_signature::schnorr::VerKey<EdwardsConfig>;
type SchnorrSignKey = jf_signature::schnorr::SignKey<ark_ed_on_bn254::Fr>;

/// Stake table capacity used for testing
pub const STAKE_TABLE_CAPACITY: usize = 10;
Expand Down
6 changes: 3 additions & 3 deletions hotshot-state-prover/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ use hotshot_types::{
traits::signature_key::StakeTableEntryType,
};

use jf_pcs::prelude::UnivariateUniversalParams;
use jf_plonk::errors::PlonkError;
use jf_primitives::constants::CS_ID_SCHNORR;
use jf_primitives::pcs::prelude::UnivariateUniversalParams;
use jf_relation::Circuit as _;
use jf_signature::constants::CS_ID_SCHNORR;
use std::{
iter,
time::{Duration, Instant},
Expand Down Expand Up @@ -484,7 +484,7 @@ mod test {
};
use hotshot_stake_table::vec_based::StakeTable;
use hotshot_types::light_client::StateSignKey;
use jf_primitives::signatures::{SchnorrSignatureScheme, SignatureScheme};
use jf_signature::{schnorr::SchnorrSignatureScheme, SignatureScheme};
use jf_utils::test_rng;
use sequencer_utils::deployer;

Expand Down
17 changes: 9 additions & 8 deletions hotshot-state-prover/src/snark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use jf_plonk::{
proof_system::{PlonkKzgSnark, UniversalSNARK},
transcript::SolidityTranscript,
};
use jf_primitives::signatures::schnorr::Signature;
use jf_signature::schnorr::Signature;

/// BLS verification key, base field and Schnorr verification key
pub use hotshot_stake_table::vec_based::config::QCVerKey;
Expand Down Expand Up @@ -113,16 +113,17 @@ mod tests {
light_client::GenericLightClientState,
traits::stake_table::{SnapshotVersion, StakeTableScheme},
};
use jf_crhf::CRHF;
use jf_plonk::{
proof_system::{PlonkKzgSnark, UniversalSNARK},
transcript::SolidityTranscript,
};
use jf_primitives::{
crhf::{VariableLengthRescueCRHF, CRHF},
errors::PrimitivesError,
signatures::{schnorr::Signature, SchnorrSignatureScheme, SignatureScheme},
};
use jf_relation::Circuit;
use jf_rescue::crhf::VariableLengthRescueCRHF;
use jf_signature::{
schnorr::{SchnorrSignatureScheme, Signature},
SignatureScheme,
};
use jf_utils::test_rng;

const ST_CAPACITY: usize = 20;
Expand All @@ -132,7 +133,7 @@ mod tests {
fn universal_setup_for_testing<R>(
max_degree: usize,
rng: &mut R,
) -> Result<UniversalSrs, PrimitivesError>
) -> anyhow::Result<UniversalSrs>
where
R: RngCore + CryptoRng,
{
Expand Down Expand Up @@ -219,7 +220,7 @@ mod tests {
let sigs = schnorr_keys
.iter()
.map(|(key, _)| SchnorrSignatureScheme::<Config>::sign(&(), key, state_msg, &mut prng))
.collect::<Result<Vec<_>, PrimitivesError>>()
.collect::<Result<Vec<_>, _>>()
.unwrap();

// bit vector with total weight 26
Expand Down
9 changes: 5 additions & 4 deletions hotshot-state-prover/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ use ark_std::rand::{CryptoRng, RngCore};
use ethers::types::U256;
use hotshot_stake_table::vec_based::StakeTable;
use hotshot_types::traits::stake_table::StakeTableScheme;
use jf_primitives::signatures::{
use jf_signature::{
bls_over_bn254::{BLSOverBN254CurveSignatureScheme, VerKey as BLSVerKey},
SchnorrSignatureScheme, SignatureScheme,
schnorr::SchnorrSignatureScheme,
SignatureScheme,
};

type F = ark_ed_on_bn254::Fq;
type SchnorrVerKey = jf_primitives::signatures::schnorr::VerKey<EdwardsConfig>;
type SchnorrSignKey = jf_primitives::signatures::schnorr::SignKey<ark_ed_on_bn254::Fr>;
type SchnorrVerKey = jf_signature::schnorr::VerKey<EdwardsConfig>;
type SchnorrSignKey = jf_signature::schnorr::SignKey<ark_ed_on_bn254::Fr>;

/// Helper function for test
pub(crate) fn key_pairs_for_testing<R: CryptoRng + RngCore>(
Expand Down
Loading

0 comments on commit 7374076

Please sign in to comment.