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

refactor: divide proof operations to subroutines #164

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ sha2 = "0.9"
sha3 = "0.9"

[dev-dependencies]
criterion = { version = "0.4.0", features = ["html_reports"] }
criterion = { version = "0.5.1", features = ["html_reports"] }
hex = "0.4"
rand_xorshift = "0.3"
bbs-fixtures-generator = {version = "0.1.0", path = "tools/bbs-fixtures-generator"}
Expand Down
20 changes: 20 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::usize;

/// Error enumerates all possible errors occuring in this library.
/// An error returned by the crypto component.
#[derive(Clone, PartialEq, Eq, Hash)]
Expand Down Expand Up @@ -68,6 +70,14 @@ pub enum Error {
messages: usize,
},

/// Not enough random scalars during Proof initialization.
UndisclosedIndexesRandomScalarsLengthMismatch {
/// Number of random scalars.
random_scalars: usize,
/// Number of messages.
undisclosed_indexes: usize,
},

/// The given point(from `G1` or `G2`) is an `Identity` element of
/// respective subgroup.
PointIsIdentity,
Expand Down Expand Up @@ -135,6 +145,16 @@ impl core::fmt::Debug for Error {
#messages: {messages}."
)
}
Error::UndisclosedIndexesRandomScalarsLengthMismatch {
random_scalars,
undisclosed_indexes,
} => {
write!(
f,
"length mismatch #random_scalars: {random_scalars}, \
#undisclosed_indexes: {undisclosed_indexes}."
)
}
Error::PointIsIdentity => {
write!(f, "unexpected `Identity` element.")
}
Expand Down
1 change: 0 additions & 1 deletion src/schemes/bbs/api/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ where
request.presentation_header.as_ref(),
&generators,
&messages,
Some(total_message_count),
)
}

Expand Down
2 changes: 1 addition & 1 deletion src/schemes/bbs/core/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub(crate) trait Generators: Debug + Clone {
/// Note - `MessageGenerators` is zero indexed, so passed `index` value
/// should be in [0, `length`) range. In case of an invalid `index`, `None`
/// value is returned.
fn get_message_generator(&mut self, index: usize) -> Option<G1Projective>;
fn get_message_generator(&self, index: usize) -> Option<G1Projective>;

/// Get a `Iterator` for message generators.
fn message_generators_iter(&self) -> MessageGeneratorsIter<Self> {
Expand Down
2 changes: 1 addition & 1 deletion src/schemes/bbs/core/generator/memory_cached_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl<C: BbsCiphersuiteParameters + Debug + Clone> Generators
/// Note `MessageGenerators` is zero indexed, so passed `index` value should
/// be in [0, `length`) range. In case of invalid `index`, `None` value
/// is returned.
fn get_message_generator(&mut self, index: usize) -> Option<G1Projective> {
fn get_message_generator(&self, index: usize) -> Option<G1Projective> {
if index >= self.H_list.len() {
return None;
}
Expand Down
Loading