diff --git a/examples/scalar.py b/examples/scalar.py index fcd7cc0..308ec86 100644 --- a/examples/scalar.py +++ b/examples/scalar.py @@ -41,4 +41,5 @@ assert scalar == deserialised_scalar # Conversion to int +assert int(Scalar(0)) == 0 assert int(Scalar(12345)) == 12345 \ No newline at end of file diff --git a/src/wrapper.rs b/src/wrapper.rs index 7fc5e16..1bb9ded 100644 --- a/src/wrapper.rs +++ b/src/wrapper.rs @@ -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 {