Skip to content

Commit 4b1aeb1

Browse files
authored
Merge pull request #216 from dalek-cryptography/feature-gate-r1cs
Feature-gate R1CS code behind 'yoloproofs' feature
2 parents b01ef96 + 7463335 commit 4b1aeb1

File tree

6 files changed

+18
-9
lines changed

6 files changed

+18
-9
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ rust:
66

77
env:
88
- TEST_COMMAND=test EXTRA_FLAGS='' FEATURES=''
9-
- TEST_COMMAND=test EXTRA_FLAGS='' FEATURES='avx2_backend'
9+
- TEST_COMMAND=test EXTRA_FLAGS='' FEATURES='yoloproofs'
1010
# run cargo bench with a filter that matches no benchmarks.
1111
# this ensures the benchmarks build but doesn't run them on the CI server.
12-
- TEST_COMMAND=bench EXTRA_FLAGS='"DONTRUNBENCHMARKS"' FEATURES='avx2_backend'
12+
- TEST_COMMAND=bench EXTRA_FLAGS='"DONTRUNBENCHMARKS"' FEATURES=''
1313

1414
before_script:
1515
- rustup component add rustfmt-preview

Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,12 @@ bincode = "1"
3131

3232
[features]
3333
avx2_backend = ["curve25519-dalek/avx2_backend"]
34+
yoloproofs = []
3435

3536
[[bench]]
3637
name = "range_proof"
3738
harness = false
3839

39-
[[bench]]
40-
name = "r1cs"
41-
harness = false
40+
#[[bench]]
41+
#name = "r1cs"
42+
#harness = false

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ This library provides implementations of:
2828

2929
* A programmable constraint system API for expressing rank-1
3030
constraint systems, and proving and verifying proofs of arbitrary
31-
statements (under development in the `circuit` branch);
31+
statements (unstable, under development with the `yoloproofs` feature);
3232

33-
* Online multi-party computation for aggregated circuit proofs
33+
* Online multi-party computation for aggregated constraint system proofs
3434
(planned future work).
3535

3636
These proofs are implemented using [Merlin transcripts][doc_merlin],
@@ -48,9 +48,9 @@ the library's [internal documentation][doc_internal]:
4848
* how [the range proof protocol works][rp_notes];
4949
* how [the inner product proof protocol works][ipp_notes];
5050
* how [the aggregation protocol works][agg_notes];
51-
* how the Bulletproof circuit proofs work (under development);
51+
* how the Bulletproof constraint system proofs work (under development);
5252
* how the constraint system reduction works (under development);
53-
* how the aggregated circuit proofs work (future work).
53+
* how the aggregated constraint system proofs work (future work).
5454

5555
## Comparative Performance
5656

src/errors.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ pub enum MPCError {
9494
}
9595

9696
/// Represents an error during the proving or verifying of a constraint system.
97+
#[cfg(feature = "yoloproofs")]
9798
#[derive(Fail, Copy, Clone, Debug, Eq, PartialEq)]
9899
pub enum R1CSError {
99100
/// Occurs when there are insufficient generators for the proof.

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,5 @@ pub mod range_proof_mpc {
5555
pub use range_proof::party;
5656
}
5757

58+
#[cfg(feature = "yoloproofs")]
5859
pub mod r1cs;

src/util.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pub struct VecPoly1(pub Vec<Scalar>, pub Vec<Scalar>);
1010

1111
/// Represents a degree-3 vector polynomial
1212
/// \\(\mathbf{a} + \mathbf{b} \cdot x + \mathbf{c} \cdot x^2 + \mathbf{d} \cdot x^3 \\).
13+
#[cfg(feature = "yoloproofs")]
1314
pub struct VecPoly3(
1415
pub Vec<Scalar>,
1516
pub Vec<Scalar>,
@@ -22,6 +23,7 @@ pub struct Poly2(pub Scalar, pub Scalar, pub Scalar);
2223

2324
/// Represents a degree-6 scalar polynomial, without the zeroth degree
2425
/// \\(a \cdot x + b \cdot x^2 + c \cdot x^3 + d \cdot x^4 + e \cdot x^5 + f \cdot x^6\\)
26+
#[cfg(feature = "yoloproofs")]
2527
pub struct Poly6 {
2628
pub t1: Scalar,
2729
pub t2: Scalar,
@@ -102,6 +104,7 @@ impl VecPoly1 {
102104
}
103105
}
104106

107+
#[cfg(feature = "yoloproofs")]
105108
impl VecPoly3 {
106109
pub fn zero(n: usize) -> Self {
107110
VecPoly3(
@@ -152,6 +155,7 @@ impl Poly2 {
152155
}
153156
}
154157

158+
#[cfg(feature = "yoloproofs")]
155159
impl Poly6 {
156160
pub fn eval(&self, x: Scalar) -> Scalar {
157161
x * (self.t1 + x * (self.t2 + x * (self.t3 + x * (self.t4 + x * (self.t5 + x * self.t6)))))
@@ -177,6 +181,7 @@ impl Drop for Poly2 {
177181
}
178182
}
179183

184+
#[cfg(feature = "yoloproofs")]
180185
impl Drop for VecPoly3 {
181186
fn drop(&mut self) {
182187
for e in self.0.iter_mut() {
@@ -194,6 +199,7 @@ impl Drop for VecPoly3 {
194199
}
195200
}
196201

202+
#[cfg(feature = "yoloproofs")]
197203
impl Drop for Poly6 {
198204
fn drop(&mut self) {
199205
self.t1.clear();

0 commit comments

Comments
 (0)