mirror of https://github.com/zcash/halo2.git
Compare commits
7 Commits
affcfff839
...
b04cfa80de
Author | SHA1 | Date |
---|---|---|
Carlos Pérez | b04cfa80de | |
Daira-Emma Hopwood | 7df93fd855 | |
adria0 | daaa638966 | |
CPerezz | 580d982a64 | |
CPerezz | a4cc9f60e0 | |
CPerezz | e49cf60f59 | |
CPerezz | 36899251cc |
|
@ -12,7 +12,7 @@ jobs:
|
|||
- uses: actions/checkout@v3
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: nightly
|
||||
toolchain: '1.76.0'
|
||||
override: true
|
||||
|
||||
# - name: Setup mdBook
|
||||
|
@ -26,7 +26,7 @@ jobs:
|
|||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: install
|
||||
args: mdbook --git https://github.com/HollowMan6/mdBook.git --rev 62e01b34c23b957579c04ee1b24b57814ed8a4d5
|
||||
args: mdbook --git https://github.com/HollowMan6/mdBook.git --rev 5830c9555a4dc051675d17f1fcb04dd0920543e8
|
||||
|
||||
- name: Install mdbook-katex and mdbook-pdf
|
||||
uses: actions-rs/cargo@v1
|
||||
|
@ -40,6 +40,11 @@ jobs:
|
|||
- name: Build halo2 book
|
||||
run: mdbook build book/
|
||||
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: nightly-2023-10-05
|
||||
override: true
|
||||
|
||||
- name: Build latest rustdocs
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
|
|
|
@ -14,8 +14,6 @@ title = "The halo2 Book"
|
|||
macros = "macros.txt"
|
||||
renderers = ["html"]
|
||||
|
||||
[output.katex]
|
||||
|
||||
[output.html]
|
||||
|
||||
[output.html.print]
|
||||
|
|
|
@ -52,6 +52,7 @@ rand_core = { version = "0.6", default-features = false }
|
|||
tracing = "0.1"
|
||||
blake2b_simd = "1"
|
||||
maybe-rayon = {version = "0.1.0", default-features = false}
|
||||
rand_chacha = { version = "0.3", optional = true }
|
||||
|
||||
# Developer tooling dependencies
|
||||
plotters = { version = "0.3.0", default-features = false, optional = true }
|
||||
|
@ -77,7 +78,7 @@ getrandom = { version = "0.2", features = ["js"] }
|
|||
|
||||
[features]
|
||||
default = ["batch", "multicore"]
|
||||
multicore = ["maybe-rayon/threads"]
|
||||
multicore = ["maybe-rayon/threads", "rand_chacha"]
|
||||
dev-graph = ["plotters", "tabbycat"]
|
||||
test-dev-graph = [
|
||||
"dev-graph",
|
||||
|
|
|
@ -4,6 +4,13 @@ use ff::Field;
|
|||
use group::Curve;
|
||||
use rand_core::RngCore;
|
||||
|
||||
#[cfg(feature = "multicore")]
|
||||
use maybe_rayon::{current_num_threads, prelude::*};
|
||||
#[cfg(feature = "multicore")]
|
||||
use rand_chacha::ChaCha20Rng;
|
||||
#[cfg(feature = "multicore")]
|
||||
use rand_core::SeedableRng;
|
||||
|
||||
use super::Argument;
|
||||
use crate::{
|
||||
arithmetic::{eval_polynomial, CurveAffine},
|
||||
|
@ -42,10 +49,43 @@ impl<C: CurveAffine> Argument<C> {
|
|||
transcript: &mut T,
|
||||
) -> Result<Committed<C>, Error> {
|
||||
// Sample a random polynomial of degree n - 1
|
||||
let mut random_poly = domain.empty_coeff();
|
||||
for coeff in random_poly.iter_mut() {
|
||||
*coeff = C::Scalar::random(&mut rng);
|
||||
}
|
||||
#[cfg(feature = "multicore")]
|
||||
let random_poly = {
|
||||
let n_threads = current_num_threads();
|
||||
let n = 1usize << domain.k as usize;
|
||||
let n_chunks = n_threads + if n % n_threads != 0 { 1 } else { 0 };
|
||||
let mut rand_vec = vec![C::Scalar::ZERO; n];
|
||||
|
||||
let mut thread_seeds: Vec<ChaCha20Rng> = (0..n_chunks)
|
||||
.into_iter()
|
||||
.map(|_| {
|
||||
let mut seed = [0u8; 32];
|
||||
rng.fill_bytes(&mut seed);
|
||||
ChaCha20Rng::from_seed(seed)
|
||||
})
|
||||
.collect();
|
||||
|
||||
thread_seeds
|
||||
.par_iter_mut()
|
||||
.zip_eq(rand_vec.par_chunks_mut(n / n_threads))
|
||||
.for_each(|(mut rng, chunk)| {
|
||||
chunk
|
||||
.iter_mut()
|
||||
.for_each(|v| *v = C::Scalar::random(&mut rng))
|
||||
});
|
||||
|
||||
domain.coeff_from_vec(rand_vec)
|
||||
};
|
||||
|
||||
#[cfg(not(feature = "multicore"))]
|
||||
let random_poly = {
|
||||
let mut random_poly = domain.empty_coeff();
|
||||
for coeff in random_poly.iter_mut() {
|
||||
*coeff = C::Scalar::random(&mut rng);
|
||||
}
|
||||
random_poly
|
||||
};
|
||||
|
||||
// Sample a random blinding factor
|
||||
let random_blind = Blind(C::Scalar::random(rng));
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ use std::marker::PhantomData;
|
|||
#[derive(Clone, Debug)]
|
||||
pub struct EvaluationDomain<F: Field> {
|
||||
n: u64,
|
||||
k: u32,
|
||||
pub(crate) k: u32,
|
||||
extended_k: u32,
|
||||
omega: F,
|
||||
omega_inv: F,
|
||||
|
|
Loading…
Reference in New Issue