Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batch verification for range proofs #86

Open
wants to merge 233 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
233 commits
Select commit Hold shift + click to select a range
98b2c9a
create readme
cathieyun Feb 2, 2018
223bf90
Fix merge conflict whoops
Feb 2, 2018
e745b83
Added comments, some more progress on generating t
Feb 2, 2018
327d21b
add helper functions
Feb 3, 2018
f1087fc
syntax fix
oleganza Feb 3, 2018
79a701a
Generate t1, t2
Feb 5, 2018
d1a385d
fmt
Feb 5, 2018
242e5c6
generate x
Feb 5, 2018
5c096e3
Output range proof
Feb 6, 2018
75bd9f1
generate l, r
Feb 6, 2018
58e3b24
Use the crates.io version of dalek, now that it's released.
hdevalence Feb 6, 2018
cae7675
Add tests
Feb 6, 2018
1c25edd
Merge branch 'master' of github.com:chain/ristretto-bulletproofs
Feb 6, 2018
78d6e26
Starting verification
Feb 7, 2018
df128e3
messy but working proof
Feb 8, 2018
481ac92
implement last verification check
Feb 8, 2018
e0577a3
Switch to efficient proof gen
Feb 8, 2018
03ccaf8
speeding up verification
Feb 9, 2018
af66f59
it compiles now
Feb 10, 2018
84eade7
added fiatshamir api
oleganza Feb 12, 2018
a57bee5
Feature: random oracle API (#2)
oleganza Feb 12, 2018
103e9e7
Remove alternative ways of calculating t0, t1, t2
Feb 13, 2018
aa9cf89
Adding scalar invert func & test
Feb 13, 2018
02dc9b5
move range proofs to a separate file (#3)
oleganza Feb 13, 2018
dad7d59
fix merge conflict
Feb 13, 2018
bbffac1
added testfile
oleganza Feb 13, 2018
1a17370
Merge pull request #4 from chain/scalar-batch-invert
cathieyun Feb 13, 2018
e30ddf0
merge testfile
oleganza Feb 13, 2018
b142b05
Change calculation for t0, t1, t2
Feb 14, 2018
ce9dd2a
Merge pull request #5 from chain/karatsuba
cathieyun Feb 14, 2018
411481f
add ipp outline
Feb 14, 2018
3c9dbef
Work on recurse function
Feb 14, 2018
65cc1e8
change to loop instead of recursive call
Feb 14, 2018
1bd3cb6
first pass on proving
Feb 15, 2018
f27d212
assuming nightly, so we dont need a bench feature (#7)
oleganza Feb 15, 2018
d2d774d
Finish prover for inner product proof
Feb 15, 2018
b63b0f5
rename variables in range proof to match new symbols
Feb 15, 2018
5d91fcc
update comments
Feb 15, 2018
a466494
fix errors
Feb 15, 2018
198d837
Update test names, add more tests
Feb 16, 2018
0b5977d
merge conflict fix
Feb 16, 2018
2833314
Merge pull request #8 from chain/ipp-2
cathieyun Feb 16, 2018
bf4def0
replace arrays with bytestrings for test vectors
hdevalence Feb 17, 2018
24b2dc8
apply rustfmt
hdevalence Feb 17, 2018
07b023e
remove feature not in crate root
hdevalence Feb 17, 2018
7581fa0
Merge branch 'rename-rp'
hdevalence Feb 21, 2018
3ee343f
rearrange terms to get vertical alignment
hdevalence Feb 17, 2018
eda44af
remove unnecessary P computation
hdevalence Feb 17, 2018
1a0a381
Move proof creation into impl Proof
hdevalence Feb 17, 2018
2fccb80
factor out common test code into helper functions
hdevalence Feb 17, 2018
e8a0895
use _L, _R to match notation in the paper
hdevalence Feb 17, 2018
4aaf375
Rename a_final, b_final to just a,b
hdevalence Feb 17, 2018
13b6dc4
Pass P,Q as borrows
hdevalence Feb 17, 2018
72f097b
Use random oracle API for proof creation
hdevalence Feb 17, 2018
58b4dfc
Check that all inputs to innerproduct proof have the same len
hdevalence Feb 17, 2018
8a9e1ab
oops, the scalar module wasn't included in lib.rs
hdevalence Feb 17, 2018
fe7fe84
add (failing) verify method
hdevalence Feb 17, 2018
bf8fa35
add benchmark stubs for (still broken) verification
hdevalence Feb 20, 2018
9cb78fc
Test proof creation with valid proofs
hdevalence Feb 21, 2018
4e78d4f
Add minimal test cases for proofs
hdevalence Feb 21, 2018
962b354
fix challenge ordering
hdevalence Feb 21, 2018
34ecfb0
Use vartime multiscalar mult since the inner-product proof works on p…
hdevalence Feb 21, 2018
aab7bd0
Rename to `ProofTranscript` (#13)
hdevalence Mar 12, 2018
bafba49
rust-toolchain = nightly-2018-03-05
oleganza Mar 12, 2018
9f9d110
proof_transcript: switch to Keccak with half-duplex support (#16)
oleganza Mar 14, 2018
48d884c
Add API for generators (#15)
oleganza Mar 14, 2018
843635f
cleanup some warnings in scalar.rs and generators.rs (#18)
oleganza Mar 14, 2018
a1e5ac5
temporarily use dalek develop
hdevalence Mar 12, 2018
180c887
Add adjustment factor for H bases to IPP API
hdevalence Mar 12, 2018
6651b13
The point P is not used in proof creation
hdevalence Mar 13, 2018
48b8372
Add a util module, with an iterator for scalar powers.
hdevalence Mar 13, 2018
cd341af
Test IPP generation with RHS adjustment exponents
hdevalence Mar 13, 2018
0990a2b
Use iterators to remove allocs from IPP verification
hdevalence Mar 13, 2018
59934f3
Use the inner-product proof for range proofs.
hdevalence Mar 13, 2018
6364840
Use generators API
hdevalence Mar 14, 2018
d7175d6
Benchmark proof creation and verification correctly.
hdevalence Mar 15, 2018
f9f1f96
fix tests
oleganza Mar 15, 2018
29e70cb
Eliminate a loop by bit-twiddling hacks
hdevalence Mar 16, 2018
ccfe36e
Split IPP verification scalars into helper function
hdevalence Mar 16, 2018
6827a5f
Perform verification using a single multiscalar multiplication.
hdevalence Mar 16, 2018
9b7284f
Minor fixups
hdevalence Mar 16, 2018
505101a
Merge branch 'use-ipp_r3'
hdevalence Mar 19, 2018
258f4a6
Update to dalek v0.16.
hdevalence Mar 23, 2018
f58021b
Merge branch 'update-dalek'
hdevalence Mar 23, 2018
2d16bb1
Replace existing libtest benchmarks with Criterion benchmarks.
hdevalence Mar 23, 2018
5766424
Merge pull request #20 from chain/feature/criterion
hdevalence Mar 28, 2018
0338abf
Import some of the TeX notes into Markdown+KaTeX.
hdevalence Mar 28, 2018
f2cdfe4
Move IPP protocol description to inner_product_proof module
hdevalence Mar 29, 2018
242913b
Import IPP notes from TeX
hdevalence Mar 29, 2018
5b36238
Update README and use it for the crate docs
hdevalence Mar 29, 2018
a8e4b73
Move inner_product and add_vec into util
hdevalence Mar 29, 2018
e03b685
Hide internal modules
hdevalence Mar 29, 2018
fbe1a84
fix an IPP compression formula
oleganza Mar 30, 2018
e993849
fixed another formula
oleganza Mar 30, 2018
c0de269
one more fix
oleganza Mar 30, 2018
8c63637
more edits
oleganza Mar 30, 2018
bbd00d7
more fixes to the eqn references
oleganza Mar 30, 2018
46d72fe
another formula fix
oleganza Mar 30, 2018
5d5f79b
add a link to 1066.pdf
oleganza Mar 30, 2018
666d7a8
Change from 'Decoder Ring' to just 'variable renaming'
hdevalence Mar 30, 2018
6b0538e
Add note on cargo doc --open
hdevalence Mar 30, 2018
6f65bc8
Fix missing export
hdevalence Mar 30, 2018
bc05003
Merge pull request #21 from chain/add-docs
hdevalence Mar 30, 2018
9e7b0cd
rustfmt
hdevalence Apr 9, 2018
3e60403
Add dalek logo
hdevalence Apr 9, 2018
edc9256
Make prover constant time
hdevalence Apr 9, 2018
945717a
Remove the `scalar` module
hdevalence Apr 9, 2018
aee68f0
Merge pull request #41 from chain/feature/consttime-prover
hdevalence Apr 9, 2018
ec130fa
Merge pull request #42 from chain/feature/remove-scalar-module
hdevalence Apr 10, 2018
a85b162
Add and test Serde support.
hdevalence Apr 10, 2018
28e1007
Merge pull request #45 from chain/feature/serde
hdevalence Apr 10, 2018
337d95c
Add warning note to transcript
hdevalence Apr 10, 2018
68ea56e
Merge pull request #46 from chain/feature/add-note-to-proof-transcript
hdevalence Apr 11, 2018
3a2c534
fix imports on benchmarks
hdevalence Apr 11, 2018
877c4b7
Merge pull request #47 from chain/fix-benchmarks
hdevalence Apr 11, 2018
09f6ce3
Bump rust version to 2018-04-03 to compile dalek 0.16.3 (#48)
oleganza Apr 11, 2018
52a34a0
Add notes on range proof protocol, closes #43
oleganza Apr 11, 2018
b40a1bb
Generators API accepts arbitrary pair of generators via PedersenGener…
oleganza Apr 12, 2018
19c47ef
Refine API (#49)
oleganza Apr 12, 2018
5bd976c
Add n to the transcript to domain-separate rangeproofs of different s…
oleganza Apr 12, 2018
a4ca3f9
Refine API docs (#51)
oleganza Apr 12, 2018
5f7f81d
Fix typo in the rangeproof notes: z*V -> z^2*V
oleganza Apr 13, 2018
f1a82a0
Fix typo in the rangeproof docs: x->u
oleganza Apr 13, 2018
7d40ccf
Add MIT license
hdevalence Apr 13, 2018
ba6de4c
tweak readme
hdevalence Apr 13, 2018
30ac2db
computers are bad
hdevalence Apr 13, 2018
17a28fe
Merge pull request #52 from chain/licence
hdevalence Apr 13, 2018
534f43f
update cargo.toml
hdevalence Apr 13, 2018
bf37530
Rename remaining x -> u in the IPP implementation (#53)
oleganza Apr 16, 2018
3cadefe
Clarify notes on how rangeproof is built up (#56)
oleganza Apr 20, 2018
634d28a
Squashed commit of the following:
Apr 24, 2018
e9f876e
Squashed commit of the following:
Apr 24, 2018
26cd867
Merge branch 'main' of github.com:chain/ristretto-bulletproofs into main
Apr 24, 2018
aaa130b
add error checks for m parties on dealer state
Apr 19, 2018
a8f7d48
setup for doing per-share validation on proof shares
Apr 19, 2018
d7bf5d5
Adding proof share validation math - only passes for the first proof …
Apr 20, 2018
f5b7032
Fixed math, validity check works for all proof shares now
Apr 20, 2018
7248e9d
add ProofBlame struct
Apr 24, 2018
0e93297
rustfmt
hdevalence Apr 24, 2018
38c2f04
add error checking for size of m, n
Apr 24, 2018
0b7e3b5
fmt
Apr 24, 2018
5b33666
add n>64 checking
Apr 24, 2018
a86268f
lib fixup
Apr 24, 2018
fcf40dd
rustfmt
Apr 25, 2018
fc9df98
Add tests for ProofBlame
Apr 25, 2018
81f6760
rename ProofBlame to ProofShareVerifier
Apr 25, 2018
82988a0
add fast sum_of_powers func to utils
Apr 25, 2018
071c749
Merge pull request #57 from chain/aggregated_proof
hdevalence Apr 25, 2018
737d52c
Rename Proof to AggregatedProof
hdevalence Apr 26, 2018
c370ba5
create a SinglePartyAggregator
hdevalence Apr 26, 2018
e77b368
use standard tiny-keccak with duplex construction
oleganza Apr 24, 2018
3dc6595
test vectors updated
oleganza Apr 24, 2018
b4e21ff
improved documentation
oleganza Apr 25, 2018
8bdb1c8
Fix missing Serialize impl on AggregatedProof
hdevalence Apr 26, 2018
0909ddb
Refactor aggregated proof testing code to do a full round trip.
hdevalence Apr 26, 2018
f92406f
Use a tmp u128 for computing an upper bound in test code
hdevalence Apr 26, 2018
e82f53c
Merge pull request #58 from chain/oleg/keccak-duplex
hdevalence Apr 26, 2018
de83342
Move transcript state inside of the Dealer state
hdevalence Apr 26, 2018
4484ba3
Move generator view into the dealer state
hdevalence Apr 26, 2018
7638b2f
tweak: take &[T] instead of &Vec<T>
hdevalence Apr 26, 2018
a3ebc01
Merge pull request #61 from chain/single-party-aggregator
hdevalence Apr 26, 2018
c2c9b56
add aggregated range proof notes to notes doc
Apr 26, 2018
5135e69
Merge pull request #63 from chain/keep-dealer-params-internal
hdevalence Apr 26, 2018
cd76c27
fixup! use standard tiny-keccak with duplex construction
oleganza Apr 26, 2018
b56d2bf
first try at travis
hdevalence Apr 26, 2018
f55a90b
Merge pull request #66 from chain/travis
hdevalence Apr 26, 2018
62854e6
Refactor aggregation logic to allow choice in validation
hdevalence Apr 26, 2018
8a7d6a9
Add a test that dishonest aggregation fails
hdevalence Apr 26, 2018
da9b59b
Change the dishonest test to four parties so we can test multidetection
hdevalence Apr 27, 2018
4d922a2
Pinpoint which shares were invalid.
hdevalence Apr 27, 2018
ff5aee8
Fix warnings
hdevalence Apr 27, 2018
f30dcb3
Merge pull request #67 from chain/feature/dealer-verify-shares
hdevalence Apr 27, 2018
bcb944a
Add aggregate proof benchmarks
hdevalence Apr 27, 2018
a65e422
Pass generators into the aggregated proof code and shorten proofs
hdevalence Apr 28, 2018
1fe5338
Merge pull request #72 from chain/feature/aggregation-benchmarks
hdevalence Apr 30, 2018
2f47dfc
update Rust nightly
hdevalence Apr 30, 2018
ffdd2a5
try using travis's rust cargo cache
hdevalence Apr 30, 2018
cd21598
Merge branch 'main' into cache-cargo-in-travis
hdevalence Apr 30, 2018
3bc14d1
Merge branch 'main' into fix/aggregate_proof_generators
hdevalence Apr 30, 2018
7f7fd2c
Merge pull request #76 from chain/fix/aggregate_proof_generators
hdevalence Apr 30, 2018
affa6b7
Fix the build and add benches to CI
hdevalence Apr 30, 2018
c5e85bf
Merge branch 'main' into cache-cargo-in-travis
hdevalence Apr 30, 2018
45e9b82
Merge branch 'main' into update-rust-nightly
hdevalence Apr 30, 2018
ddd8076
Merge pull request #79 from chain/fix-the-build-and-add-benches-to-ci
hdevalence Apr 30, 2018
aa79d9d
Merge branch 'main' into cache-cargo-in-travis
hdevalence Apr 30, 2018
30f22fb
convert _j to _(j) notation, and de-duplicate writing between single-…
Apr 30, 2018
9d4f7ba
Merge pull request #78 from chain/cache-cargo-in-travis
hdevalence Apr 30, 2018
46a80e2
Merge branch 'main' into update-rust-nightly
hdevalence Apr 30, 2018
1d8d43f
fixing up to l(x), r(x)
Apr 30, 2018
4ccc66f
some fix-ups and debugging
May 1, 2018
55ea35e
add some more clarifying steps for summation
May 1, 2018
f907677
Merge branch 'main' into agg_notes
cathieyun May 1, 2018
6f4c3fb
clarify wording
May 1, 2018
c79c096
Merge branch 'agg_notes' of github.com:chain/ristretto-bulletproofs i…
May 1, 2018
11234aa
Merge pull request #77 from chain/update-rust-nightly
hdevalence May 1, 2018
78eb032
Merge branch 'main' into agg_notes
cathieyun May 1, 2018
b5f7c94
touchups
May 1, 2018
5556e35
Merge branch 'agg_notes' of github.com:chain/ristretto-bulletproofs i…
May 1, 2018
adeb744
Revert nightly version
hdevalence May 1, 2018
7a0cee5
Merge pull request #81 from chain/revert-nightly
hdevalence May 1, 2018
3928380
[fmt] cargo fmt
hdevalence May 1, 2018
f796308
Unify aggregated and non-aggregated range proofs.
hdevalence May 1, 2018
7454933
Keep V in the ValueCommitment per GitHub discussion
hdevalence May 1, 2018
f92ce80
Unify proof creation by using self-MPC for single-prover.
hdevalence May 1, 2018
1f6be81
Rearrange source tree.
hdevalence May 1, 2018
9770a79
Keep RangeProof fields private now that aggregation code is part of t…
hdevalence May 1, 2018
7da3ea7
Merge pull request #83 from chain/unify-single-and-aggregate-rangeproofs
hdevalence May 2, 2018
99479bc
Simplify API by reading m from the length of value_commitments
hdevalence May 2, 2018
b6ead1e
change to latex form
May 2, 2018
ee40de6
change _(j)L to _L, (j) for L/R/0/1/2
May 2, 2018
a6705e2
add explanation for subscripts
May 2, 2018
36e0046
touchups
May 2, 2018
0caee1a
Merge pull request #84 from chain/rearrange-src-tree
hdevalence May 2, 2018
7bdb4f9
better explanation in intro
May 2, 2018
ee33c5f
change H to H' to make exponential ys less confusing
May 2, 2018
30b1c67
change indexing to use pythonic notation, add agg proof notation section
May 2, 2018
b4c7c29
move definitions of z_j and y_j to the notation section
May 2, 2018
193b592
aligned concatenation for l/r/G/H
oleganza May 3, 2018
e7eb7a5
Merge branch 'main' into agg_notes
cathieyun May 3, 2018
28e84a2
Merge pull request #64 from chain/agg_notes
cathieyun May 4, 2018
ada5481
Prevent a malicious dealer from retrieving the party's secrets
hdevalence May 4, 2018
1dfa781
Merge pull request #87 from chain/ensure-evaluation-point-is-nonzero
hdevalence May 4, 2018
04a885a
generalize and factor out batch verification of range proofs
oleganza May 3, 2018
ed6b0f2
allow rangeproofs with different n,m to be batched
oleganza May 3, 2018
ae0239f
refactor batch verification tests
oleganza May 3, 2018
87fc9f5
make sure Verification type is not dropped w/o verification
oleganza May 3, 2018
44f23d9
cargo fmt
oleganza May 3, 2018
692cedc
simplify impl
oleganza May 8, 2018
647a421
move test_delta back
oleganza May 8, 2018
b7ceab5
debugging batch logic
oleganza May 8, 2018
d33dc23
bug fix: take only necessary number of generator points
oleganza May 8, 2018
7e61002
remove obsolete test
oleganza May 8, 2018
7295a16
remove unnecessary vec allocations
oleganza May 8, 2018
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
21 changes: 21 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
language: rust
cache: cargo

rust:
- nightly

env:
- TEST_COMMAND=test EXTRA_FLAGS='' FEATURES=''
- TEST_COMMAND=test EXTRA_FLAGS='' FEATURES='yolocrypto'
# run cargo bench with a filter that matches no benchmarks.
# this ensures the benchmarks build but doesn't run them on the CI server.
- TEST_COMMAND=bench EXTRA_FLAGS='"DONTRUNBENCHMARKS"' FEATURES='yolocrypto'

script:
- cargo $TEST_COMMAND --features="$FEATURES" $EXTRA_FLAGS

# enable this integration if we upstream the repo
#notifications:
# slack:
# rooms:
# - dalek-cryptography:Xxv9WotKYWdSoKlgKNqXiHoD#dalek-bots
35 changes: 30 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,35 @@
[package]
name = "ristretto-bp"
name = "ristretto-bulletproofs"
version = "0.1.0"
authors = ["Cathie <[email protected]>"]
authors = ["Cathie Yun <[email protected]>",
"Henry de Valence <[email protected]>",
"Oleg Andreev <[email protected]>"]
readme = "README.md"
license = "MIT"
repository = "https://github.com/chain/ristretto-bulletproofs"
categories = ["cryptography"]
keywords = ["cryptography", "ristretto", "zero-knowledge", "bulletproofs"]
description = "A pure-Rust implementation of Bulletproofs using Ristretto"

[dependencies]
#curve25519-dalek = "^0.14"
curve25519-dalek = { git = "https://github.com/dalek-cryptography/curve25519-dalek", branch = "develop", features = ["nightly"]}
curve25519-dalek = { version = "^0.16", features = ["serde", "nightly"] }
subtle = "0.6"
sha2 = "^0.7"
rand = "^0.4"
rand = "^0.4"
byteorder = "1.2.1"
serde = "1"
serde_derive = "1"
tiny-keccak = "1.4.1"

[dev-dependencies]
hex = "^0.3"
criterion = "0.2"
bincode = "1"

[features]
yolocrypto = ["curve25519-dalek/yolocrypto"]

[[bench]]
name = "bulletproofs"
harness = false

21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 Chain, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FEATURES :=

doc:
cargo rustdoc --features "$(FEATURES)" -- --html-in-header docs/assets/rustdoc-include-katex-header.html

doc-internal:
cargo rustdoc --features "$(FEATURES)" -- --html-in-header docs/assets/rustdoc-include-katex-header.html --document-private-items

74 changes: 73 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,73 @@
# ristretto-bulletproofs
# Ristretto Bulletproofs

A pure-Rust implementation of [Bulletproofs][bp_website] using [Ristretto][ristretto].

This crate contains both an implementation and a set of notes on how and why
Bulletproofs work. The [external documentation][doc_external] describes how to use this
crate’s API, while the [internal documentation][doc_internal] contains the notes.

## WARNING

This code is still research-quality. It is not (yet) suitable for deployment.

## Documentation

* [Public API documentation][doc_external]
* [Internal documentation][doc_internal]
* [Notes on how Bulletproofs work][bp_notes] (located in the internal `notes` module)
* [Range proof protocol description][rp_notes]
* [Inner product protocol description][ipp_notes]


Unfortunately, `cargo doc` does not yet have support for custom HTML injection
and for documenting private members, so the documentation is built using:

```text
make doc # Builds external documentation
make doc-internal # Builds internal documentation
```

Note: `cargo doc --open` rebuilds the docs without the custom
invocation, so it may be necessary to rerun `make`.

## Tests

Run tests with `cargo test`.

## Benchmarks

This crate uses [criterion.rs][criterion] for benchmarks. Run benchmarks with
`cargo bench`.

## Features

The `yolocrypto` feature enables the `yolocrypto` feature in
`curve25519-dalek`, which enables the experimental AVX2 backend. To use it for
Bulletproofs, the `target_cpu` must support AVX2:

```text
RUSTFLAGS="-C target_cpu=skylake" cargo bench --features "yolocrypto"
```

Skylake-X CPUs have double the AVX2 registers. To use them, try

```text
RUSTFLAGS="-C target_cpu=skylake-avx512" cargo bench --features "yolocrypto"
```

This prevents spills in the AVX2 parallel field multiplication code, but causes
worse code generation elsewhere ¯\\\_(ツ)\_/¯

## About

This is a research project being built for Chain, Inc, by Henry de Valence,
Cathie Yun, and Oleg Andreev.

[bp_website]: https://crypto.stanford.edu/bulletproofs/
[ristretto]: https://doc.dalek.rs/curve25519_dalek/ristretto/index.html
[doc_external]: https://doc.dalek.rs/ristretto_bulletproofs/index.html
[doc_internal]: https://doc-internal.dalek.rs/ristretto_bulletproofs/index.html
[bp_notes]: https://doc-internal.dalek.rs/ristretto_bulletproofs/notes/index.html
[rp_notes]: https://doc-internal.dalek.rs/ristretto_bulletproofs/range_proof/index.html
[ipp_notes]: https://doc-internal.dalek.rs/ristretto_bulletproofs/inner_product_proof/index.html
[criterion]: https://github.com/japaric/criterion.rs
2 changes: 2 additions & 0 deletions Testfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rustfmt: rustfmt --version && cargo fmt -- --write-mode=diff
cargotest: cargo test
150 changes: 150 additions & 0 deletions benches/bulletproofs.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
#![allow(non_snake_case)]
#[macro_use]
extern crate criterion;
use criterion::Criterion;

extern crate rand;
use rand::{OsRng, Rng};

extern crate curve25519_dalek;
use curve25519_dalek::scalar::Scalar;

extern crate ristretto_bulletproofs;
use ristretto_bulletproofs::ProofTranscript;
use ristretto_bulletproofs::RangeProof;
use ristretto_bulletproofs::{Generators, PedersenGenerators};

static AGGREGATION_SIZES: [usize; 6] = [1, 2, 4, 8, 16, 32];

fn create_aggregated_rangeproof_helper(n: usize, c: &mut Criterion) {
let label = format!("Aggregated {}-bit rangeproof creation", n);

c.bench_function_over_inputs(
&label,
move |b, &&m| {
let generators = Generators::new(PedersenGenerators::default(), n, m);
let mut rng = OsRng::new().unwrap();

let (min, max) = (0u64, ((1u128 << n) - 1) as u64);
let values: Vec<u64> = (0..m).map(|_| rng.gen_range(min, max)).collect();
let blindings: Vec<Scalar> = (0..m).map(|_| Scalar::random(&mut rng)).collect();

b.iter(|| {
// Each proof creation requires a clean transcript.
let mut transcript = ProofTranscript::new(b"AggregateRangeProofBenchmark");

RangeProof::prove_multiple(
&generators,
&mut transcript,
&mut rng,
&values,
&blindings,
n,
)
})
},
&AGGREGATION_SIZES,
);
}

fn create_aggregated_rangeproof_n_8(c: &mut Criterion) {
create_aggregated_rangeproof_helper(8, c);
}

fn create_aggregated_rangeproof_n_16(c: &mut Criterion) {
create_aggregated_rangeproof_helper(16, c);
}

fn create_aggregated_rangeproof_n_32(c: &mut Criterion) {
create_aggregated_rangeproof_helper(32, c);
}

fn create_aggregated_rangeproof_n_64(c: &mut Criterion) {
create_aggregated_rangeproof_helper(64, c);
}

fn verify_aggregated_rangeproof_helper(n: usize, c: &mut Criterion) {
let label = format!("Aggregated {}-bit rangeproof verification", n);

c.bench_function_over_inputs(
&label,
move |b, &&m| {
let generators = Generators::new(PedersenGenerators::default(), n, m);
let mut rng = OsRng::new().unwrap();

let (min, max) = (0u64, ((1u128 << n) - 1) as u64);
let values: Vec<u64> = (0..m).map(|_| rng.gen_range(min, max)).collect();
let blindings: Vec<Scalar> = (0..m).map(|_| Scalar::random(&mut rng)).collect();

let mut transcript = ProofTranscript::new(b"AggregateRangeProofBenchmark");
let proof = RangeProof::prove_multiple(
&generators,
&mut transcript,
&mut rng,
&values,
&blindings,
n,
).unwrap();

// XXX would be nice to have some convenience API for this
let pg = &generators.all().pedersen_generators;
let value_commitments: Vec<_> = values
.iter()
.zip(blindings.iter())
.map(|(&v, &v_blinding)| pg.commit(Scalar::from_u64(v), v_blinding))
.collect();

b.iter(|| {
// Each proof creation requires a clean transcript.
let mut transcript = ProofTranscript::new(b"AggregateRangeProofBenchmark");

proof.verify(
&value_commitments,
generators.all(),
&mut transcript,
&mut rng,
n,
)
});
},
&AGGREGATION_SIZES,
);
}

fn verify_aggregated_rangeproof_n_8(c: &mut Criterion) {
verify_aggregated_rangeproof_helper(8, c);
}

fn verify_aggregated_rangeproof_n_16(c: &mut Criterion) {
verify_aggregated_rangeproof_helper(16, c);
}

fn verify_aggregated_rangeproof_n_32(c: &mut Criterion) {
verify_aggregated_rangeproof_helper(32, c);
}

fn verify_aggregated_rangeproof_n_64(c: &mut Criterion) {
verify_aggregated_rangeproof_helper(64, c);
}

criterion_group!{
name = create_rp;
config = Criterion::default().sample_size(10);
targets =
create_aggregated_rangeproof_n_8,
create_aggregated_rangeproof_n_16,
create_aggregated_rangeproof_n_32,
create_aggregated_rangeproof_n_64,
}

criterion_group!{
name = verify_rp;
config = Criterion::default();
targets =
verify_aggregated_rangeproof_n_8,
verify_aggregated_rangeproof_n_16,
verify_aggregated_rangeproof_n_32,
verify_aggregated_rangeproof_n_64,
}

criterion_main!(create_rp, verify_rp);
17 changes: 17 additions & 0 deletions docs/assets/rustdoc-include-katex-header.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<link rel="stylesheet" href="https://doc.dalek.rs/assets/katex/katex.min.css">
<script src="https://doc.dalek.rs/assets/katex/katex.min.js"></script>
<script src="https://doc.dalek.rs/assets/katex/contrib/auto-render.min.js"></script>
<script>
document.addEventListener("DOMContentLoaded", function() {
renderMathInElement(document.body, {
macros: {
"\\lo": "\\text{lo}",
"\\hi": "\\text{hi}"
}
});
});
</script>
<style>
.katex { font-size: 1em !important; }
pre.rust, .docblock code, .docblock-short code { font-size: 0.85em !important; }
</style>
Loading