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

GPU implementation for multiexp and fft #35

Open
wants to merge 327 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
327 commits
Select commit Hold shift + click to select a range
a7cbb00
start testing on large circuits
shamatar Oct 1, 2019
4aedc02
finished test on a large circut. Now optimize t-poly
shamatar Oct 1, 2019
343a7c1
40% lde speedup
shamatar Oct 4, 2019
c28d7c8
cleanup and few experiments
shamatar Oct 4, 2019
3856029
chunked prover
shamatar Oct 4, 2019
563c345
copy-paste partial reduction from experimental repo
shamatar Nov 17, 2019
2f4c15d
some cleanup and functions for bitreversed forms
shamatar Nov 17, 2019
6163879
change FRI definisions to port coset combining FRI from experimental
shamatar Nov 17, 2019
c864ac1
some draft redshift implementation
shamatar Nov 19, 2019
03ae5a4
fix/check correctness
shamatar Nov 21, 2019
400a07a
redshift and plonk with optimizatioins
shamatar Nov 26, 2019
0c58688
place benchmarks, remove verbosity
shamatar Nov 28, 2019
4195dde
move blake2 locally
shamatar Nov 28, 2019
9e47d2c
push blake2
shamatar Nov 28, 2019
2850109
fix path
shamatar Nov 28, 2019
5f42378
fix circuit sizes
shamatar Nov 28, 2019
e6cf658
fix benchmark sizes
shamatar Nov 28, 2019
d6c7430
fix coset schedule
shamatar Nov 28, 2019
b7b999c
don't test too large sizes
shamatar Nov 28, 2019
75c15ab
use required number of bases
shamatar Nov 28, 2019
305efcb
remove more verbosity
shamatar Nov 28, 2019
3a13d0a
unchecked transpiler
Konstantce Dec 26, 2019
63fb68e
unchecked transpiler (right version)
Konstantce Dec 26, 2019
c2b5d5f
start implementing alternative approach to transpiling
shamatar Jan 16, 2020
da9089a
initial transpiler routines
shamatar Jan 16, 2020
d93e048
push initial transpiler
shamatar Jan 16, 2020
9cd10b6
polish and fix
shamatar Jan 16, 2020
b41ab3a
succesfully transpiles XOR circuit
shamatar Jan 23, 2020
24f5915
proving on XOR must also work
shamatar Jan 23, 2020
673becb
make some parts public
shamatar Jan 27, 2020
a3f403b
transpiler is working on some real-world circuits
shamatar Jan 29, 2020
3a88ea6
build pairing from git
shamatar Jan 29, 2020
786536d
some verbosity
shamatar Jan 31, 2020
7e8c1f2
try to implement cleaner adaptor for modified proof system
shamatar Feb 6, 2020
e7d7227
improve edge cases
shamatar Feb 6, 2020
1b36a9a
fixes
shamatar Feb 13, 2020
a8edb32
commit the indexer
shamatar Feb 18, 2020
a05c0e1
little bit of the prover
shamatar Feb 19, 2020
b57fe20
tmp
shamatar Feb 22, 2020
b759b97
draft if the prover is complete
shamatar Feb 25, 2020
7dfc529
fix 1st sumcheck
shamatar Mar 2, 2020
8e93fd1
initial
shamatar Mar 9, 2020
2aee9e3
read ignition transcript
shamatar Mar 10, 2020
59d03c2
fix ignition ceremony
shamatar Mar 10, 2020
932b6aa
explicitly test crs serialization
shamatar Mar 10, 2020
fea5602
make test assembly simpler
shamatar Mar 11, 2020
00e8c39
keep one-shot checker too
shamatar Mar 16, 2020
c5468b1
transform ignition setup into lagrange basis
shamatar Mar 18, 2020
a6541d8
implement verification key serialization
shamatar Mar 19, 2020
c369f24
fix verfication key deserialization
shamatar Mar 19, 2020
e619ece
change structure of transpiler hints to simpler one
shamatar Mar 20, 2020
27394ca
some cleanup
shamatar Mar 20, 2020
e88a63a
fix transpilation of single variables
shamatar Mar 20, 2020
06f2568
also implement copy now
shamatar Mar 20, 2020
15a4df3
change ethereum transcript. Make proof write/read
shamatar Mar 23, 2020
ddcabe3
write num inputs only once
shamatar Mar 23, 2020
0f12d9b
extra asserts in deserialization
shamatar Mar 23, 2020
d82c4ea
update ethereum transcript
shamatar Mar 25, 2020
dea6f05
merge master
shamatar Mar 25, 2020
fed2730
Merge branch 'plonk_release' of https://github.com/matter-labs/bellma…
shamatar Mar 25, 2020
3b62c5d
remove duplicate
shamatar Mar 25, 2020
1aa039a
some cleanups
shamatar Mar 25, 2020
e633c5d
try to make FMA gates in transpiler
shamatar Mar 25, 2020
f11183c
Merge branch 'plonk_release' of github.com:matter-labs/bellman into p…
dvush Mar 25, 2020
8f4ab80
add serialization for precomputed polynomials
dvush Mar 26, 2020
a5165e7
allow to expose LC as mutable
shamatar Mar 28, 2020
0e500f6
Merge branch 'plonk_release' of https://github.com/matter-labs/bellma…
shamatar Mar 28, 2020
a961358
make gates counter
shamatar Mar 29, 2020
e0d64d7
count gates in all the implementations
shamatar Mar 29, 2020
d05937b
fix gate counting
shamatar Mar 29, 2020
31c92e5
cleanup
shamatar Mar 29, 2020
16d1747
create uniform prover with or without precomputations
shamatar Apr 2, 2020
d62dc2d
migrate to new pairing
shamatar Apr 7, 2020
6320c6a
draft universal compiler for custom gates
shamatar Apr 7, 2020
465bd1b
perform synthesis
shamatar Apr 8, 2020
2f23ae6
experiment with CS definitions
shamatar Apr 9, 2020
b90cfd4
try another approach
shamatar Apr 9, 2020
6b355c9
play how custom gates workflow may look like
shamatar Apr 10, 2020
012b40b
custom gate synthesis seems to work, now rework complex assignments
shamatar Apr 13, 2020
36788c9
Some cleanup, continue work in gadget library
shamatar Apr 13, 2020
8c532c5
access next gate linear term
shamatar Apr 13, 2020
4b22042
add constants in gate equation
shamatar Apr 15, 2020
83e15af
implement basic compiler and satisfiability check
shamatar Apr 15, 2020
a07439b
perform setup
shamatar Apr 17, 2020
cd7214a
prepare tree for recursion
shamatar Apr 18, 2020
85e6567
make setup multioracle
shamatar Apr 19, 2020
6b278f3
only multiopening left
shamatar Apr 20, 2020
60e7ade
draft of recursive friendly redshift with custom gates
shamatar Apr 21, 2020
865d542
expose bn+rescue prover for tests
shamatar Apr 21, 2020
579d303
some verbosity
shamatar Apr 21, 2020
c911ec4
save
shamatar Apr 23, 2020
65f9a13
another approach on custom gates
shamatar May 14, 2020
2996ca2
return hash counting
shamatar May 14, 2020
b84e6fa
draft some lookup tables interface
shamatar May 22, 2020
6c96863
test along the gadgets
shamatar May 26, 2020
3af9a5d
make a prover stub for initial testing
shamatar Jun 4, 2020
4520a04
continue writing prover stub
shamatar Jun 8, 2020
83c3ae0
integrate main gate
shamatar Jun 9, 2020
201f127
handle custom gates too
shamatar Jun 9, 2020
c16e573
compute quotient poly
shamatar Jun 10, 2020
4334d3e
add logging of individual stages
shamatar Jun 11, 2020
e9ba6d5
also log individual commitments
shamatar Jun 11, 2020
05112e8
commit
shamatar Jun 11, 2020
16f27fd
different CPUs set
shamatar Jun 11, 2020
76fcaec
try another strategy
shamatar Jun 11, 2020
d2b6123
try another strategy
shamatar Jun 11, 2020
1f8171f
use subworker
shamatar Jun 11, 2020
7f98b8b
try manual unroll and prefetch
shamatar Jun 11, 2020
e652028
fix
shamatar Jun 11, 2020
5e3ff99
add lde bencher
shamatar Jun 11, 2020
9875af5
add long division test
shamatar Jun 11, 2020
ed6ba55
try to debug
shamatar Jun 11, 2020
f213b1b
whoops
shamatar Jun 11, 2020
d9d4312
unrolling is not that beneficial
shamatar Jun 11, 2020
02f1019
stay on dense multiexp without unroll
shamatar Jun 11, 2020
aa3b6bd
almost linearized
shamatar Jun 17, 2020
ea70740
many todos, but to the sanity check first
shamatar Jun 22, 2020
409fdf4
tmp
shamatar Jun 23, 2020
84313d6
test for custom gates
shamatar Jun 23, 2020
951bb67
lookup part before mergin divisions
shamatar Jun 25, 2020
734f164
merge all quotient parts under single division
shamatar Jun 25, 2020
ab813e0
various updates
shamatar Jul 2, 2020
5b951a7
remove debug statements
shamatar Jul 2, 2020
be6476a
works with recursion
shamatar Jul 14, 2020
931c227
also make test data
shamatar Jul 14, 2020
7cafa60
merge start merging generator and prover
shamatar Jul 15, 2020
ce946ac
rewrite to uniform storages
shamatar Jul 15, 2020
93c4303
create setup
shamatar Jul 16, 2020
d3d5ef8
tmp
shamatar Jul 21, 2020
4fede99
fix prng
shamatar Jul 21, 2020
0d6f726
add standalone prover and verifier
shamatar Jul 22, 2020
de85e2a
optional features
shamatar Jul 22, 2020
6239f5b
move out tree hashes
shamatar Jul 22, 2020
4e4f540
implement read/write
shamatar Jul 23, 2020
d9dcbc9
write n to proof
shamatar Jul 23, 2020
2e63d7c
polish
shamatar Jul 24, 2020
e9d2d5e
small cleanup and speedup
shamatar Jul 27, 2020
8f4e25d
fix synthesis error
shamatar Jul 31, 2020
ec55a81
check few other options
shamatar Aug 11, 2020
871550e
synthesize for different windows
shamatar Aug 11, 2020
78cbd74
set comments
shamatar Aug 11, 2020
c8be468
uniform log
shamatar Aug 11, 2020
9941275
also try larger windows
shamatar Aug 11, 2020
81d85a1
fix
shamatar Aug 11, 2020
6a086d5
try alternative strategy for sizing
shamatar Aug 13, 2020
8972cab
try producer-consumer pattern
shamatar Aug 13, 2020
4fe8fe6
add verbosity
shamatar Aug 13, 2020
0bf73d1
oops
shamatar Aug 13, 2020
5685c74
use larger capacity
shamatar Aug 13, 2020
0935248
some more debug
shamatar Aug 13, 2020
20f3482
try another one
shamatar Aug 13, 2020
9e053ef
check against byte size
shamatar Aug 13, 2020
1cd2b75
try no copy
shamatar Aug 13, 2020
18816bb
scan over windows
shamatar Aug 13, 2020
5d0050f
stricter check
shamatar Aug 13, 2020
76e1927
batch normalize
shamatar Aug 13, 2020
6be524a
more mixed additions
shamatar Aug 13, 2020
49b8bc4
perform full scan
shamatar Aug 13, 2020
d6ef7ee
try asm backend
shamatar Aug 13, 2020
c5e866a
log number of CPUs
shamatar Aug 13, 2020
8d19fe6
test wider set
shamatar Aug 13, 2020
9779433
test full interesting space
shamatar Aug 17, 2020
c1e398f
remove produce-consumer variant
shamatar Aug 18, 2020
8961651
Merge branch 'circuit_description' into insane_size_benches
shamatar Aug 18, 2020
6a4ac2e
merge
shamatar Aug 18, 2020
83f1ce7
Merge pull request #28 from matter-labs/insane_size_benches
shamatar Aug 18, 2020
635f714
backport x86 build
shamatar Aug 18, 2020
86ce5bd
make special case for BN254
shamatar Aug 18, 2020
9c5e85b
non-degenerate normal case
shamatar Aug 18, 2020
d764501
test with prefetches
shamatar Aug 18, 2020
775c59c
disable some features for now
shamatar Aug 18, 2020
e0fad74
remove LLVM prefetch
shamatar Aug 18, 2020
bd31b7e
extend search space
shamatar Aug 18, 2020
3a63cb5
also try with virtual cores
shamatar Aug 18, 2020
b0dcbec
try job based approach
shamatar Aug 18, 2020
b415942
inclusive range
shamatar Aug 18, 2020
c33201f
test same base
shamatar Aug 18, 2020
2a64ca4
more exhaustive test
shamatar Aug 18, 2020
b62f976
check if cache line matters
shamatar Aug 20, 2020
6e562dd
try L3 sharing
shamatar Aug 20, 2020
27c4bb5
also compare to non-sharing variant
shamatar Aug 20, 2020
66eba05
prefer deterministic spinning instead of sleep
shamatar Aug 20, 2020
fc35b66
try to be branchless
shamatar Aug 20, 2020
eb1d6c5
fix
shamatar Aug 20, 2020
6bb97df
check if L3 prefetch matters
shamatar Aug 20, 2020
d30a1ff
check if size matters
shamatar Aug 20, 2020
1d71973
run everything using asm backend
shamatar Aug 20, 2020
e57cb65
test how non-uniform access matters
shamatar Aug 20, 2020
50f0a1a
rename
shamatar Aug 20, 2020
a3a454f
rename again
shamatar Aug 20, 2020
0423e08
fix test
shamatar Aug 20, 2020
754cab0
try strange options
shamatar Aug 20, 2020
b0d0b94
check consistency
shamatar Aug 20, 2020
64db88c
revert
shamatar Aug 20, 2020
079963b
try buffered approach
shamatar Aug 20, 2020
ce8476d
oops
shamatar Aug 20, 2020
0b17679
fix
shamatar Aug 20, 2020
5c436de
some verbosity
shamatar Aug 20, 2020
f500d47
remove debug log
shamatar Aug 20, 2020
3867cd6
change other buffer sizes
shamatar Aug 20, 2020
538b0dd
partially revert sparse multiexp
shamatar Aug 20, 2020
c228a62
test buffering for futures based case
shamatar Aug 20, 2020
bc53858
fix signature
shamatar Aug 20, 2020
74a6841
test dense
shamatar Aug 20, 2020
027bc30
revert to the standard options
shamatar Aug 20, 2020
9983792
test two options simultaneously
shamatar Aug 20, 2020
89857be
smaller search range
shamatar Aug 20, 2020
1cd12c0
check if wider parallelism makes sense
shamatar Aug 21, 2020
d877f1a
check against single op
shamatar Aug 21, 2020
5328c9d
remove restrictions
shamatar Aug 21, 2020
f972e88
fix logging
shamatar Aug 21, 2020
c868212
fft benchmark
shamatar Aug 21, 2020
1797f7d
check with explicit sync
shamatar Aug 21, 2020
5f2d103
problem with sync
shamatar Aug 21, 2020
c3d68dd
silly mistake
shamatar Aug 21, 2020
a6df946
properly reflect hardcoded window size
shamatar Aug 21, 2020
185f90e
remove redundant test
shamatar Aug 21, 2020
c226765
also check 4
shamatar Aug 21, 2020
2661a0f
create default config with custom gates
shamatar Sep 2, 2020
af37a71
handle deduplication
shamatar Sep 9, 2020
5386214
expose a/b coeffs
shamatar Sep 23, 2020
703efb1
add helper
shamatar Sep 24, 2020
a274af2
separate into aggregation and verification
shamatar Oct 5, 2020
7f80de5
better debug, faster lookup
shamatar Oct 6, 2020
34d038b
prettier message
shamatar Oct 19, 2020
58614fc
use constant names
shamatar Oct 20, 2020
1ec11ec
make verification function panic free
shamatar Oct 20, 2020
f1f129c
some cleanup
shamatar Oct 23, 2020
89b28d0
streamline features
shamatar Oct 23, 2020
1948501
remove experimental code
shamatar Oct 23, 2020
d13dd33
fix worker imports
shamatar Oct 23, 2020
4eb8ff6
fix multicore feature
shamatar Oct 26, 2020
2f3fd02
with_traits
Konstantce Oct 26, 2020
6a966d6
with_traits2
Konstantce Oct 26, 2020
5e38cc4
Merge pull request #31 from matter-labs/with_traits
Konstantce Oct 26, 2020
c8ccf38
have multicore and plonk by default in dev
shamatar Nov 11, 2020
2b233f6
Merge branch 'dev' of https://github.com/matter-labs/bellman into dev
shamatar Nov 11, 2020
15e17f7
make fpga test vectors for full tests
shamatar Nov 24, 2020
4844115
fix edge case of transpilation
shamatar Nov 24, 2020
5d9f8aa
GPU v0.1
chenhuan14 Dec 1, 2020
5ddccba
implement dense_multiexp_gpu
chenhuan14 Dec 2, 2020
ad34ba5
commit_using_monomials(gpu)
chenhuan14 Dec 2, 2020
5f26e80
implement fft_gpu for Engine
chenhuan14 Dec 7, 2020
c4db2fd
fft gpu acceration
chenhuan14 Dec 9, 2020
b3d69ff
implement best_ct_ntt_2_best_fft_gpu
chenhuan14 Dec 9, 2020
25dc473
add some test
chenhuan14 Dec 9, 2020
a9b7e40
Phase1: change ntt to fft for using gpu
chenhuan14 Dec 10, 2020
35d7c41
phase 2: ntt_2_fft for using gpu
chenhuan14 Dec 10, 2020
6e8c1d4
phase3: change ntt to fft for using gpu
chenhuan14 Dec 10, 2020
527eb0e
change println to log.info
chenhuan14 Dec 10, 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
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
target
Cargo.lock
pkg
pkg
*.key
*.proof
*.data
.idea/
45 changes: 35 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,55 @@ crate-type = ["cdylib", "lib", "staticlib"]
[dependencies]
rand = "0.4"
bit-vec = "0.6"
cfg-if = "0.1"
cfg-if = "1.*"

#pairing = {package = "pairing_ce", version = "0.24.*" }
pairing = {path = "../pairing", package = "pairing_ce"}

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

futures= {package = "futures", version = "0.3", default_features = false, features = ["executor"]}
futures = {package = "futures", version = "0.3", default_features = false, features = ["executor"]}
num_cpus = "1"
crossbeam = {version = "0.7", optional = true}

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

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

tiny-keccak = {version = "1.4.2", optional = true}
tiny-keccak = {version = "1.5", optional = true}
blake2-rfc = {version = "0.2.18", optional = true}

blake2s_simd = {version = "0.5"}
lazy_static = {version = "1", optional = true}

blake2s_const = {version = "0.6", optional = true, path = "./src/plonk/blake2_const/blake2s/"}

# rescue_hash = {git = "https://github.com/shamatar/rescue_hash.git", optional = true }
# rescue_hash = {path = "../rescue_hash", optional = true }
# poseidon_hash = {path = "../poseidon_hash", optional = true }

hex = "*"


# add GPU
thiserror = "1.0.10"
rand_core = "0.5"
ocl = { version = "0.19.4", package = "fil-ocl", optional = true }
ff-cl-gen = { path = "../ff-cl-gen", optional = true }
fs2 = { version = "0.4.3", optional = true }
log = "0.4.8"
#futures_01 = {package = "futures", version = "0.1"}


[features]
# default = []
default = ["multicore"]
#default = ["wasm"]
#default = ["multicore", "plonk"]
default = ["multicore", "plonk", "gpu"]
multicore = ["crossbeam", "futures/thread-pool"]
sonic = ["tiny-keccak", "blake2-rfc"]
gm17 = []
nolog = []
plonk = ["lazy_static", "tiny-keccak", "blake2s_const"]
# redshift = ["plonk", "rescue_hash", "poseidon_hash"]
marlin = ["tiny-keccak", "blake2s_const"]
wasm = ["web-sys"]
nightly = ["prefetch"]
asm = ["pairing/asm"]
gpu = ["ocl", "ff-cl-gen", "fs2"]
3 changes: 3 additions & 0 deletions run_buffered_multiexp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

RUSTFLAGS="-C target-cpu=native -C target_feature=+bmi2,+adx,+sse4.1" cargo +nightly test --release --features "asm" -- --ignored --nocapture test_large_data_buffered_multiexp
3 changes: 3 additions & 0 deletions run_diff_windows.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

cargo test --release -- --ignored --nocapture test_large_data_different_windows_multiexp
3 changes: 3 additions & 0 deletions run_diff_windows_nightly.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

RUSTFLAGS="-C target-cpu=native -C target_feature=+bmi2,+adx,+sse4.1" cargo +nightly test --release --features "asm" -- --ignored --nocapture test_large_data_different_windows_multiexp
3 changes: 3 additions & 0 deletions run_diff_windows_nightly_futures.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

RUSTFLAGS="-C target-cpu=native -C target_feature=+bmi2,+adx,+sse4.1" cargo +nightly test --release --features "asm" -- --ignored --nocapture future_based_test_large_data_different_windows
3 changes: 3 additions & 0 deletions run_insane_fft.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

RUSTFLAGS="-C target-cpu=native -C target_feature=+bmi2,+adx,+sse4.1" cargo +nightly test --release --features "asm" -- --ignored --nocapture test_fft_scaling
3 changes: 3 additions & 0 deletions run_insane_lde.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

RUSTFLAGS="-C target-cpu=native -C target_feature=+bmi2,+adx,+sse4.1" cargo +nightly test --release --features "asm" -- --ignored --nocapture test_insane_size_lde
4 changes: 4 additions & 0 deletions run_insane_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

# cargo test --release -- --ignored --nocapture test_multiexp_performance_on_large_data
RUSTFLAGS="-C target-cpu=native -C target_feature=+bmi2,+adx,+sse4.1" cargo +nightly test --release --features "asm" -- --ignored --nocapture test_large_data_different_multiexps
3 changes: 3 additions & 0 deletions run_insane_test_with_futures.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

RUSTFLAGS="-C target-cpu=native -C target_feature=+bmi2,+adx,+sse4.1" cargo +nightly test --release --features "asm" -- --ignored --nocapture test_future_based_multiexp_performance_on_large_data
3 changes: 3 additions & 0 deletions run_long_division.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

cargo test --release -- --ignored --nocapture test_long_naive_division
3 changes: 3 additions & 0 deletions run_parallel_jobs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

RUSTFLAGS="-C target-cpu=native -C target_feature=+bmi2,+adx,+sse4.1" cargo +nightly test --release --features "asm" -- --ignored --nocapture test_optimal_bn254_multiexp
3 changes: 3 additions & 0 deletions run_shared_l3.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

RUSTFLAGS="-C target-cpu=native -C target_feature=+bmi2,+adx,+sse4.1" cargo +nightly test --release --features "asm" -- --ignored --nocapture test_l3_shared_multiexp_bn254
6 changes: 6 additions & 0 deletions run_test_on_nightly.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

# RUSTFLAGS="-C target-cpu=native -C target_feature=+bmi2,+adx,+sse4.1" cargo +nightly test --release -- --nocapture test_valid_bn254_multiexp
# RUSTFLAGS="-C target-cpu=native -C target_feature=+bmi2,+adx,+sse4.1" cargo +nightly test --release -- --nocapture test_dense_multiexp_vs_new_multiexp
RUSTFLAGS="-C target-cpu=native -C target_feature=+bmi2,+adx,+sse4.1" cargo +nightly test --release --features "asm" -- --nocapture test_valid_bn254_multiexp
RUSTFLAGS="-C target-cpu=native -C target_feature=+bmi2,+adx,+sse4.1" cargo +nightly test --release --features "asm" -- --nocapture test_dense_multiexp_vs_new_multiexp
48 changes: 48 additions & 0 deletions src/constants.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
pub const ETH_BLOCK_10_000_000_HASH: &'static str
= "aa20f7bde5be60603f11a45fc4923aab7552be775403fc00c2e6b805e6297dbe";

use crate::pairing::{Engine, CurveProjective};
use crate::byteorder::{BigEndian, ReadBytesExt};

pub fn make_random_points_with_unknown_discrete_log_from_seed<E: Engine>(
dst: &[u8],
seed: &[u8],
num_points: usize
) -> Vec<E::G1Affine> {
let mut result = vec![];

use rand::{Rng, SeedableRng};
use rand::chacha::ChaChaRng;
// Create an RNG based on the outcome of the random beacon
let mut rng = {
// if we use Blake hasher
let input: Vec<u8> = dst.iter().chain(seed.iter()).cloned().collect();
let h = blake2s_simd::blake2s(&input);
assert!(h.as_bytes().len() == 32);
let mut seed = [0u32; 8];
for (i, chunk) in h.as_bytes().chunks_exact(8).enumerate() {
seed[i] = (&chunk[..]).read_u32::<BigEndian>().expect("digest is large enough for this to work");
}

ChaChaRng::from_seed(&seed)
};

for _ in 0..num_points {
let point: E::G1 = rng.gen();

result.push(point.into_affine());
}

result
}

pub fn make_random_points_with_unknown_discrete_log<E: Engine>(
dst: &[u8],
num_points: usize
) -> Vec<E::G1Affine> {
make_random_points_with_unknown_discrete_log_from_seed::<E>(
dst,
&hex::decode(crate::constants::ETH_BLOCK_10_000_000_HASH).unwrap(),
num_points
)
}
19 changes: 16 additions & 3 deletions src/cs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ impl<E: Engine> AsRef<[(Variable, E::Fr)]> for LinearCombination<E> {
}
}

impl<E: Engine> AsMut<Vec<(Variable, E::Fr)>> for LinearCombination<E> {
fn as_mut(&mut self) -> &mut Vec<(Variable, E::Fr)> {
&mut self.0
}
}

impl<E: Engine> LinearCombination<E> {
pub fn zero() -> LinearCombination<E> {
LinearCombination(vec![])
Expand Down Expand Up @@ -178,8 +184,9 @@ impl From<io::Error> for SynthesisError {
}
}

impl Error for SynthesisError {
fn description(&self) -> &str {

impl SynthesisError {
pub fn self_description(&self) -> &str {
match *self {
SynthesisError::AssignmentMissing => "an assignment for a variable could not be computed",
SynthesisError::DivisionByZero => "division by zero",
Expand All @@ -193,13 +200,19 @@ impl Error for SynthesisError {
}
}

impl Error for SynthesisError {
fn description(&self) -> &str {
self.self_description()
}
}

impl fmt::Display for SynthesisError {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
if let &SynthesisError::IoError(ref e) = self {
write!(f, "I/O error: ")?;
e.fmt(f)
} else {
write!(f, "{}", self.description())
write!(f, "{}", self.self_description())
}
}
}
Expand Down
Loading