remove extra dependency and rename error

This commit is contained in:
collin 2020-06-01 18:05:24 -07:00
parent 01cc8e3066
commit 887e374e28
5 changed files with 5 additions and 9 deletions

1
Cargo.lock generated
View File

@ -479,7 +479,6 @@ dependencies = [
"pest-ast",
"pest_derive",
"rand",
"rand_xorshift",
"sha2",
"snarkos-algorithms",
"snarkos-curves",

View File

@ -21,5 +21,4 @@ pest = { version = "2.0" }
pest-ast = { version = "0.3.3" }
pest_derive = { version = "2.0" }
rand = { version = "0.7" }
rand_xorshift = { version = "0.2" }
sha2 = { version = "0.8" }

View File

@ -16,7 +16,7 @@ pub(crate) fn group_from_input<F: Field + PrimeField, G: GroupType<F>, CS: Const
if let InputValue::Group(group_string) = input {
Some(group_string)
} else {
return Err(GroupError::InvalidGroup(input.to_string()));
return Err(GroupError::Invalid(input.to_string()));
}
}
None => None,

View File

@ -2,8 +2,8 @@ use snarkos_errors::gadgets::SynthesisError;
#[derive(Debug, Error)]
pub enum GroupError {
#[error("Expected group element parameter, got {}", _0)]
InvalidGroup(String),
#[error("Expected affine point, got {}", _0)]
Invalid(String),
#[error("{}", _0)]
SynthesisError(SynthesisError),

View File

@ -88,10 +88,8 @@ impl EdwardsGroupType {
pub fn edwards_affine_from_str(string: String) -> Result<EdwardsAffine, GroupError> {
// 0 or (0, 1)
match Fq::from_str(&string).ok() {
Some(x) => {
EdwardsAffine::get_point_from_x(x, false).ok_or(GroupError::InvalidGroup(string))
}
None => EdwardsAffine::from_str(&string).map_err(|_| GroupError::InvalidGroup(string)),
Some(x) => EdwardsAffine::get_point_from_x(x, false).ok_or(GroupError::Invalid(string)),
None => EdwardsAffine::from_str(&string).map_err(|_| GroupError::Invalid(string)),
}
}