Repository: dusk-network/bls12_381 (language: rust)

Issue:
Update `dusk-bytes`



Discussion / hints:

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4d5bdee8..8694e401 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ## [Unreleased]
 
+## [0.5.1] - 22-01-21
+### Changed
+- Update dusk-bytes and implement hex format tests
+
 ## [0.5.0] - 21-01-21
 ### Changed
 - to/from bytes methods of BlsScalar, G1Affine, G2Affine refactored in favor of dusk-bytes
diff --git a/Cargo.toml b/Cargo.toml
index 577cc881..66eaccd7 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -6,7 +6,7 @@ homepage = "https://github.com/dusk-network/bls12_381"
 license = "MIT/Apache-2.0"
 name = "dusk-bls12_381"
 repository = "https://github.com/dusk-network/bls12_381"
-version = "0.5.0"
+version = "0.5.1"
 keywords = ["cryptography", "bls12_381", "zk-snarks", "ecc", "elliptic-curve"]
 categories =["Algorithms", "Cryptography", "Development tools"]
 edition = "2018"
diff --git a/src/g1.rs b/src/g1.rs
index 9c040adb..85662c99 100644
--- a/src/g1.rs
+++ b/src/g1.rs
@@ -6,7 +6,7 @@ use crate::BlsScalar;
 use core::borrow::Borrow;
 use core::iter::Sum;
 use core::ops::{Add, AddAssign, Mul, MulAssign, Neg, Sub, SubAssign};
-use dusk_bytes::{DeserializableSlice, Error as BytesError, HexDebug, ParseHexStr, Serializable};
+use dusk_bytes::{Error as BytesError, HexDebug, Serializable};
 use subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption};
 
 #[cfg(feature = "canon")]
@@ -173,9 +173,6 @@ impl Serializable<48> for G1Affine {
     }
 }
 
-impl DeserializableSlice<48> for G1Affine {}
-impl ParseHexStr<48> for G1Affine {}
-
 #[cfg(feature = "serde_req")]
 impl Serialize for G1Affine {
     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
@@ -1545,6 +1542,8 @@ fn g1_affine_bytes_unchecked() {
 
 #[test]
 fn g1_affine_hex() {
+    use dusk_bytes::ParseHexStr;
+
     let gen = G1Affine::generator();
     let ident = G1Affine::identity();
 
diff --git a/src/g2.rs b/src/g2.rs
index eab3f904..4a6c77ee 100644
--- a/src/g2.rs
+++ b/src/g2.rs
@@ -7,7 +7,7 @@ use crate::BlsScalar;
 use core::borrow::Borrow;
 use core::iter::Sum;
 use core::ops::{Add, AddAssign, Mul, MulAssign, Neg, Sub, SubAssign};
-use dusk_bytes::{DeserializableSlice, Error as BytesError, HexDebug, ParseHexStr, Serializable};
+use dusk_bytes::{Error as BytesError, HexDebug, Serializable};
 use subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption};
 
 #[cfg(feature = "canon")]
@@ -224,9 +224,6 @@ impl Serializable<96> for G2Affine {
     }
 }
 
-impl DeserializableSlice<96> for G2Affine {}
-impl ParseHexStr<96> for G2Affine {}
-
 #[cfg(feature = "serde_req")]
 impl Serialize for G2Affine {
     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
@@ -1999,6 +1996,8 @@ fn g2_affine_bytes_unchecked() {
 
 #[test]
 fn g2_affine_hex() {
+    use dusk_bytes::ParseHexStr;
+
     let gen = G2Affine::generator();
     let ident = G2Affine::identity();
 
diff --git a/src/scalar.rs b/src/scalar.rs
index 6b1f2acb..8d24f900 100644
--- a/src/scalar.rs
+++ b/src/scalar.rs
@@ -11,7 +11,7 @@ use core::cmp::{Ord, Ordering, PartialOrd};
 use core::convert::TryFrom;
 use core::iter::{Product, Sum};
 use core::ops::{Add, AddAssign, BitAnd, BitXor, Mul, MulAssign, Neg, Sub, SubAssign};
-use dusk_bytes::{DeserializableSlice, Error as BytesError, HexDebug, ParseHexStr, Serializable};
+use dusk_bytes::{Error as BytesError, HexDebug, Serializable};
 use rand_core::{CryptoRng, RngCore};
 use subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption};
 
@@ -123,9 +123,6 @@ impl Serializable<32> for Scalar {
     }
 }
 
-impl DeserializableSlice<32> for Scalar {}
-impl ParseHexStr<32> for Scalar {}
-
 impl ConditionallySelectable for Scalar {
     fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self {
         Scalar([
@@ -916,6 +913,10 @@ fn test_debug() {
         format!("{:?}", R2),
         "feffffff0100000002480300fab78458f54fbcecef4f8c996f05c5ac59b12418"
     );
+    assert_eq!(
+        format!("{:#x}", R2),
+        "0xfeffffff0100000002480300fab78458f54fbcecef4f8c996f05c5ac59b12418"
+    );
 }
 
 #[test]
@@ -1421,6 +1422,8 @@ fn pow_of_two_test() {
 
 #[test]
 fn scalar_hex_serialization() {
+    use dusk_bytes::ParseHexStr;
+
     let scalar = -Scalar::one();
     let scalar_p = format!("{:x}", scalar);
     let scalar_p = Scalar::from_hex_str(scalar_p.as_str()).unwrap();


Test patch: