Skip to content
This repository has been archived by the owner on Aug 15, 2024. It is now read-only.

Recursive Redshift #20

Open
wants to merge 122 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
f98bac9
initial draft, no zk
shamatar Sep 19, 2019
d9df818
some cleanup
shamatar Sep 19, 2019
2e857b6
backport IOP and FRI
shamatar Sep 24, 2019
6c07a6f
add precomputations before we start
shamatar Sep 24, 2019
f0ce6b4
initial transparent commitment completed
shamatar Sep 25, 2019
5619d4f
implement and test blake2s commitment
shamatar Sep 25, 2019
ec2627d
initial plonk without public inputs for transparent scheme
shamatar Sep 30, 2019
5fe138a
start some benchmarking and optimizations
shamatar Oct 1, 2019
4034ad0
start testing on large circuits
shamatar Oct 1, 2019
fa77d38
finished test on a large circut. Now optimize t-poly
shamatar Oct 1, 2019
e8a9f31
40% lde speedup
shamatar Oct 4, 2019
603ba5f
cleanup and few experiments
shamatar Oct 4, 2019
4f01fbd
chunked prover
shamatar Oct 4, 2019
f4081f6
copy-paste partial reduction from experimental repo
shamatar Nov 17, 2019
237dc16
some cleanup and functions for bitreversed forms
shamatar Nov 17, 2019
6f1094a
change FRI definisions to port coset combining FRI from experimental
shamatar Nov 17, 2019
44b06b1
some draft redshift implementation
shamatar Nov 19, 2019
eaeecfb
fix/check correctness
shamatar Nov 21, 2019
1ace312
redshift and plonk with optimizatioins
shamatar Nov 26, 2019
7098ce7
place benchmarks, remove verbosity
shamatar Nov 28, 2019
21bd85b
move blake2 locally
shamatar Nov 28, 2019
440564e
push blake2
shamatar Nov 28, 2019
7628e92
fix path
shamatar Nov 28, 2019
f31d595
fix circuit sizes
shamatar Nov 28, 2019
5e23863
fix benchmark sizes
shamatar Nov 28, 2019
18dc414
fix coset schedule
shamatar Nov 28, 2019
5d2dd3e
don't test too large sizes
shamatar Nov 28, 2019
18e5ff8
use required number of bases
shamatar Nov 28, 2019
792bf2e
remove more verbosity
shamatar Nov 28, 2019
4206d72
unchecked transpiler
Konstantce Dec 26, 2019
4fe3f19
unchecked transpiler (right version)
Konstantce Dec 26, 2019
9991a11
Merge branch 'plonk' of https://github.com/matter-labs/bellman into p…
shamatar Jan 16, 2020
ad18aae
start implementing alternative approach to transpiling
shamatar Jan 16, 2020
734b241
initial transpiler routines
shamatar Jan 16, 2020
6e81f2e
push initial transpiler
shamatar Jan 16, 2020
e497255
polish and fix
shamatar Jan 16, 2020
57b9173
succesfully transpiles XOR circuit
shamatar Jan 23, 2020
37ce786
proving on XOR must also work
shamatar Jan 23, 2020
1c88588
make some parts public
shamatar Jan 27, 2020
a5f6d4c
transpiler is working on some real-world circuits
shamatar Jan 29, 2020
f04a5df
build pairing from git
shamatar Jan 29, 2020
a547f52
some verbosity
shamatar Jan 31, 2020
29fa34c
try to implement cleaner adaptor for modified proof system
shamatar Feb 6, 2020
cce51ee
improve edge cases
shamatar Feb 6, 2020
b8b5ef4
fixes
shamatar Feb 13, 2020
aa961ed
commit the indexer
shamatar Feb 18, 2020
1d30515
little bit of the prover
shamatar Feb 19, 2020
8c898bf
tmp
shamatar Feb 22, 2020
67e6dc7
draft if the prover is complete
shamatar Feb 25, 2020
d37b053
init
Konstantce Feb 26, 2020
a0beeb7
new genrators
Konstantce Feb 28, 2020
2f158ea
bits of refactoring
Konstantce Feb 28, 2020
01ab9c4
new prover: WiP
Konstantce Feb 28, 2020
fbc8f3c
rescue: WiP
Konstantce Mar 2, 2020
e01b7c1
rescue finished
Konstantce Mar 4, 2020
40ca0fe
rescue tree finished
Konstantce Mar 4, 2020
6facab8
FRI refactoring
Konstantce Mar 4, 2020
e11d977
FRI refactoring2
Konstantce Mar 4, 2020
92bc75d
significant cleaning
Konstantce Mar 5, 2020
2b5a42c
more cleaning
Konstantce Mar 6, 2020
d329be8
fixed dependency errors
Konstantce Mar 6, 2020
7b005ee
channel class
Konstantce Mar 6, 2020
f1f2407
new attempt to refactor FRI
Konstantce Mar 6, 2020
197db4d
FRI - FRI - FRI
Konstantce Mar 6, 2020
d1c5d20
combining all together
Konstantce Mar 9, 2020
c10b63e
more understanding of FRI
Konstantce Mar 10, 2020
ddc33d9
final FRI refactor: WiP
Konstantce Mar 11, 2020
5133c58
final FRI refactor: almost done
Konstantce Mar 11, 2020
dd1f9ea
new coset Combiner
Konstantce Mar 11, 2020
35fd607
new query producer
Konstantce Mar 11, 2020
2316385
FRI verifier: WiP
Konstantce Mar 11, 2020
ae93dc4
generation of constants in rescue
Konstantce Mar 13, 2020
ae75558
FRI verifier: WiP
Konstantce Mar 13, 2020
4dd277a
FRI verifier: almost done
Konstantce Mar 13, 2020
659b663
FRI done
Konstantce Mar 16, 2020
976c2a9
batched_oracle_required
Konstantce Mar 17, 2020
4b17889
batched oracle and FRI support
Konstantce Mar 17, 2020
ae9aaa4
batched oracle and FRI support2
Konstantce Mar 17, 2020
67d5d83
Redshift: prover works
Konstantce Mar 17, 2020
7541a89
Redshift: almost final rework
Konstantce Mar 17, 2020
a17de3d
Redshift: almost final rework2
Konstantce Mar 20, 2020
02b18ef
Redshift: almost final rework3
Konstantce Mar 20, 2020
6449719
with labeled oracles
Konstantce Mar 20, 2020
d4bb800
verifier: final WiP
Konstantce Mar 20, 2020
21ab328
verifier: almost done
Konstantce Mar 20, 2020
3daac72
should modify coset combiner: WiP
Konstantce Mar 23, 2020
863ff7a
verifier: almost done
Konstantce Mar 23, 2020
f2acdee
verifier: done
Konstantce Mar 23, 2020
7306476
verifier: done finally all
Konstantce Mar 26, 2020
cec7a5b
verifying circuit: WiP
Konstantce Mar 30, 2020
b007540
reworking hashes
Konstantce Mar 30, 2020
ebaee8b
with BN256 Rescue params
Konstantce Mar 31, 2020
7dd20cf
with modified channel and oracle, suitable for BN256
Konstantce Mar 31, 2020
eb7ea01
with fixed FRI
Konstantce Mar 31, 2020
8be39b9
final modifications to work with BN256
Konstantce Mar 31, 2020
62132a8
all is done to debug and test BN256-based redshift
Konstantce Apr 1, 2020
6e50dc4
Pred-release
Konstantce Apr 1, 2020
b8046e2
some minor changes in cs
Konstantce Apr 2, 2020
c0ed561
some minor changes2
Konstantce Apr 2, 2020
26d160a
some minor changes2
Konstantce Apr 2, 2020
f202024
some minor changes3
Konstantce Apr 4, 2020
93eab59
some minor changes4
Konstantce Apr 5, 2020
364fdf0
code style PR
Konstantce Apr 9, 2020
44f9c82
debugging FRI
Konstantce Apr 15, 2020
4b762ad
localizing problem
Konstantce Apr 16, 2020
c7880c4
localizing problem2
Konstantce Apr 19, 2020
cb4cd3b
FRI is fixed
Konstantce Apr 19, 2020
6217c2d
before merging changes
Konstantce Apr 19, 2020
15222f7
before merging changes2
Konstantce Apr 19, 2020
7071422
fixed annoying bug
Konstantce Apr 20, 2020
fb3c5e3
fixed annoying bug2
Konstantce Apr 23, 2020
1881538
with debug output
Konstantce Apr 23, 2020
8562a5a
with debug output2
Konstantce Apr 23, 2020
5f8f0e9
final version
Konstantce Apr 24, 2020
c6216e2
final version2
Konstantce Apr 24, 2020
a72c79e
final version3
Konstantce Apr 24, 2020
5f1de5a
final version4
Konstantce Apr 24, 2020
0db6f5d
final version4
Konstantce Apr 24, 2020
e8046c4
some minor compatibility changes
Konstantce Apr 28, 2020
7450c10
some minor compatibility changes
Konstantce Apr 29, 2020
279f35f
adjust fri_params final degree
Konstantce Apr 30, 2020
1b83447
with poseidon
Konstantce Apr 30, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

{
"version": "0.2.0",
"configurations": [
{
"name": "Run Test Debugger",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/target/debug/buggin-70708b3916187eeb.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"preLaunchTask": "cargo test build",
},

{
"type": "lldb",
"request": "launch",
"name": "Launch",
"args": [],
"program": "${workspaceFolder}/target/debug/boa",
"cwd": "${workspaceFolder}",
"stopOnEntry": false,
"sourceLanguages": ["rust"],
"sourceMap": {
"/rustc/*": "${env:HOME}/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust"
}
},
{
"name": "(Windows) Launch",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/target/debug/boa.exe",
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"sourceFileMap": {
"/rustc/5e1a799842ba6ed4a57e91f7ab9435947482f7d8": "${env:USERPROFILE}/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust"
},
"symbolSearchPath": "https://msdl.microsoft.com/download/symbols",
"environment": []
}
]
}
31 changes: 20 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,38 @@ crate-type = ["cdylib", "lib", "staticlib"]
rand = "0.4"
bit-vec = "0.4.4"
futures = "0.1"
cfg-if = "0.1.7"
cfg-if = "0.1"

# pairing = {package = "pairing_ce", path = "../pairing" }
#pairing = {package = "pairing_ce", version = "0.19" }
pairing = {package = "pairing_ce", git = "https://github.com/matter-labs/pairing.git"}


#pairing = {package = "pairing_ce", path = "../pairing" }
pairing = {package = "pairing_ce", version = "0.18.0" }
byteorder = "1"

futures-cpupool = {version = "0.1", optional = true}
num_cpus = {version = "1", optional = true}
crossbeam = {version = "0.7.1", optional = true}
crossbeam = {version = "0.7", optional = true}

prefetch = {version = "0.2", optional = true}

web-sys = {version = "0.3.17", optional = true, features = ["console", "Performance", "Window"]}
web-sys = {version = "0.3", optional = true, features = ["console", "Performance", "Window"]}

tiny-keccak = {version = "1.5"}
blake2-rfc = {version = "0.2.18"}

lazy_static = {version = "1", optional = true}
num = {package = "num", version = "0.2.1"}

tiny-keccak = {version = "1.4.2", optional = true}
blake2-rfc = {version = "0.2.18", optional = true}
blake2s_simd = {version = "0.5", optional = true}
blake2s_const = {version = "0.6", optional = true, path = "./src/redshift/IOP/hashes/blake2_const/blake2s"}

[features]
default = ["multicore"]
#default = ["multicore", "nightly"]
#default = ["wasm"]
default = ["multicore", "redshift"]
multicore = ["futures-cpupool", "num_cpus", "crossbeam"]
sonic = ["tiny-keccak", "blake2-rfc"]
sonic = []
gm17 = []
redshift = ["lazy_static", "blake2s_simd", "blake2s_const"]
wasm = ["web-sys"]
nightly = ["prefetch"]
#derive_serde = ["pairing/derive_serde"]
30 changes: 27 additions & 3 deletions src/cs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub trait Circuit<E: Engine> {
}

/// Represents a variable in our constraint system.
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
pub struct Variable(pub(crate) Index);

impl Variable {
Expand Down Expand Up @@ -50,6 +50,12 @@ pub enum Index {
#[derive(Clone)]
pub struct LinearCombination<E: Engine>(pub(crate) Vec<(Variable, E::Fr)>);

impl<E: Engine> Default for LinearCombination<E> {
fn default() -> Self {
LinearCombination(vec![])
}
}

impl<E: Engine> AsRef<[(Variable, E::Fr)]> for LinearCombination<E> {
fn as_ref(&self) -> &[(Variable, E::Fr)] {
&self.0
Expand All @@ -60,6 +66,21 @@ impl<E: Engine> LinearCombination<E> {
pub fn zero() -> LinearCombination<E> {
LinearCombination(vec![])
}

pub fn is_empty(&self) -> bool {
self.0.is_empty()
}

/// returns true if this linear combination
/// consists of exactly one element with coefficient 1
pub fn is_simple(&self) -> Option<Variable> {
let res = match self.0.len() == 1 && self.0[0].1 == E::Fr::one() {
true => Some(self.0[0].0),
false => None,
};

res
}
}

impl<E: Engine> Add<(E::Fr, Variable)> for LinearCombination<E> {
Expand Down Expand Up @@ -169,7 +190,9 @@ pub enum SynthesisError {
/// During verification, our verifying key was malformed.
MalformedVerifyingKey,
/// During CRS generation, we observed an unconstrained auxillary variable
UnconstrainedVariable
UnconstrainedVariable,
/// Error that should never happen under normal circumstances
Unknown,
}

impl From<io::Error> for SynthesisError {
Expand All @@ -188,7 +211,8 @@ impl Error for SynthesisError {
SynthesisError::UnexpectedIdentity => "encountered an identity element in the CRS",
SynthesisError::IoError(_) => "encountered an I/O error",
SynthesisError::MalformedVerifyingKey => "malformed verifying key",
SynthesisError::UnconstrainedVariable => "auxillary variable was unconstrained"
SynthesisError::UnconstrainedVariable => "auxillary variable was unconstrained",
SynthesisError::Unknown => "unknown error",
}
}
}
Expand Down
22 changes: 22 additions & 0 deletions src/domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,28 @@ impl<E: Engine, G: Group<E>> EvaluationDomain<E, G> {
self.distribute_powers(worker, geninv);
}

pub fn transform_powers_of_tau_into_lagrange_basis(&mut self, worker: &Worker) {
self.ifft(&worker);
}

pub fn transform_powers_of_tau_into_lagrange_basis_on_coset(&mut self, worker: &Worker)
{
let geninv = self.geninv;
self.distribute_powers(worker, geninv);

// worker.scope(self.coeffs.len(), |scope, chunk| {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, annotate why it is commented out.

// for v in self.coeffs.chunks_mut(chunk) {
// scope.spawn(move |_| {
// for v in v.iter_mut() {
// v.group_mul_assign(&geninv);
// }
// });
// }
// });

self.ifft(worker);
}

/// This evaluates t(tau) for this domain, which is
/// tau^m - 1 for these radix-2 domains.
pub fn z(&self, tau: &E::Fr) -> E::Fr {
Expand Down
2 changes: 0 additions & 2 deletions src/groth16/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ use std::io::{self, Read, Write};
use std::sync::Arc;
use byteorder::{BigEndian, WriteBytesExt, ReadBytesExt};

#[cfg(test)]
mod tests;

mod generator;
mod prover;
Expand Down
Loading