Skip to content

Commit

Permalink
Merge pull request #8 from jtraglia/a-better-int
Browse files Browse the repository at this point in the history
Remove to_string from Scalar::__int__ method
  • Loading branch information
kevaundray authored Aug 30, 2024
2 parents 0a0f979 + 4872051 commit 02e1049
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
1 change: 1 addition & 0 deletions examples/scalar.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@
assert scalar == deserialised_scalar

# Conversion to int
assert int(Scalar(0)) == 0
assert int(Scalar(12345)) == 12345
3 changes: 1 addition & 2 deletions src/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,7 @@ impl Scalar {
}
}
fn __int__(&self) -> BigUint {
// Bug, Fr::to_string will print nothing if the value is zero
BigUint::from_str(&*self.0.to_string()).unwrap_or(BigUint::ZERO)
BigUint::from(self.0.into_bigint())
}

fn pow(&self, exp: Scalar) -> Scalar {
Expand Down

0 comments on commit 02e1049

Please sign in to comment.