Skip to content

Commit

Permalink
Merge pull request #545 from NoCtrlZ/master
Browse files Browse the repository at this point in the history
Fix typo and change to match statement
  • Loading branch information
CPerezz authored Jul 6, 2021
2 parents cb5a917 + ba02c08 commit d3412ce
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Fix the document references and typos [#533](https://github.com/dusk-network/plonk/pull/533)
- Fix if condition to match [#545](https://github.com/dusk-network/plonk/pull/545)

## [0.8.1] - 07-06-21

Expand Down
32 changes: 14 additions & 18 deletions src/commitment_scheme/kzg10/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,29 +116,25 @@ impl CommitKey {
/// Truncates the commit key to a lower max degree.
/// Returns an error if the truncated degree is zero or if the truncated
/// degree is larger than the max degree of the commit key.
// FIXME: Use a match maybe?
pub(crate) fn truncate(
&self,
mut truncated_degree: usize,
) -> Result<CommitKey, Error> {
if truncated_degree == 1 {
truncated_degree += 1;
match truncated_degree {
// Check that the truncated degree is not zero
0 => Err(Error::TruncatedDegreeIsZero),
// Check that max degree is less than truncated degree
i if i > self.max_degree() => Err(Error::TruncatedDegreeTooLarge),
i => {
if i == 1 {
truncated_degree += 1
};
let truncated_powers = Self {
powers_of_g: self.powers_of_g[..=truncated_degree].to_vec(),
};
Ok(truncated_powers)
}
}
// Check that the truncated degree is not zero
if truncated_degree == 0 {
return Err(Error::TruncatedDegreeIsZero);
}

// Check that max degree is less than truncated degree
if truncated_degree > self.max_degree() {
return Err(Error::TruncatedDegreeTooLarge);
}

let truncated_powers = Self {
powers_of_g: self.powers_of_g[..=truncated_degree].to_vec(),
};

Ok(truncated_powers)
}

/// Checks whether the polynomial we are committing to:
Expand Down
4 changes: 2 additions & 2 deletions src/commitment_scheme/kzg10/srs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ impl PublicParameters {

/// Setup generates the public parameters using a random number generator.
/// This method will in most cases be used for testing and exploration.
/// In reality, a `Trusted party` or a `Multiparty Computation` will used to
/// generate the SRS. Returns an error if the configured degree is less
/// In reality, a `Trusted party` or a `Multiparty Computation` will be used
/// to generate the SRS. Returns an error if the configured degree is less
/// than one.
pub fn setup<R: RngCore + CryptoRng>(
max_degree: usize,
Expand Down

0 comments on commit d3412ce

Please sign in to comment.