Skip to content

Commit e1f4805

Browse files
hdevalencecathieyun
andcommitted
Add extra checks on party capacity to the MPC protocol
Co-authored-by: Cathie Yun <[email protected]>
1 parent 1d55442 commit e1f4805

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

src/errors.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ impl From<MPCError> for ProofError {
3939
match e {
4040
MPCError::InvalidBitsize => ProofError::InvalidBitsize,
4141
MPCError::InvalidAggregation => ProofError::InvalidAggregation,
42+
MPCError::InvalidGeneratorsLength => ProofError::InvalidGeneratorsLength,
4243
_ => ProofError::ProvingError(e),
4344
}
4445
}
@@ -65,6 +66,9 @@ pub enum MPCError {
6566
/// proof with non-power-of-two aggregation size.
6667
#[fail(display = "Invalid aggregation size, m must be a power of 2")]
6768
InvalidAggregation,
69+
/// This error occurs when the generators are of the wrong length.
70+
#[fail(display = "Invalid generators length, must be equal to n.")]
71+
InvalidGeneratorsLength,
6872
/// This error occurs when the dealer is given the wrong number of
6973
/// value commitments.
7074
#[fail(display = "Wrong number of value commitments")]

src/range_proof/dealer.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ impl Dealer {
3636
if !m.is_power_of_two() {
3737
return Err(MPCError::InvalidAggregation);
3838
}
39+
if gens.gens_capacity < n {
40+
return Err(MPCError::InvalidGeneratorsLength);
41+
}
42+
if gens.party_capacity < m {
43+
return Err(MPCError::InvalidGeneratorsLength);
44+
}
3945

4046
// At the end of the protocol, the dealer will attempt to
4147
// verify the proof, and if it fails, determine which party's

src/range_proof/mod.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ impl RangeProof {
8585
if generators.gens_capacity < n {
8686
return Err(ProofError::InvalidGeneratorsLength);
8787
}
88+
if generators.party_capacity < values.len() {
89+
return Err(ProofError::InvalidGeneratorsLength);
90+
}
8891

8992
let dealer = Dealer::new(generators, n, values.len(), transcript)?;
9093

@@ -150,6 +153,8 @@ impl RangeProof {
150153
rng: &mut R,
151154
n: usize,
152155
) -> Result<(), ProofError> {
156+
let m = value_commitments.len();
157+
153158
// First, replay the "interactive" protocol using the proof
154159
// data to recompute all challenges.
155160
if !(n == 8 || n == 16 || n == 32 || n == 64) {
@@ -158,8 +163,9 @@ impl RangeProof {
158163
if gens.gens_capacity < n {
159164
return Err(ProofError::InvalidGeneratorsLength);
160165
}
161-
162-
let m = value_commitments.len();
166+
if gens.party_capacity < m {
167+
return Err(ProofError::InvalidGeneratorsLength);
168+
}
163169

164170
// XXX check n, m parameters
165171

0 commit comments

Comments
 (0)