mirror of
https://github.com/pezkuwichain/bizinikiwi-bn.git
synced 2026-06-22 06:51:07 +00:00
remove rustc-serialize feature and bump version (#22)
* remove rustc-serialize * bump version to 0.6.0 * remove bincode
This commit is contained in:
+1
-20
@@ -4,9 +4,6 @@ use rand::Rng;
|
||||
use crate::fields::FieldElement;
|
||||
use crate::arith::{U256, U512};
|
||||
|
||||
#[cfg(feature = "rustc-serialize")]
|
||||
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
|
||||
|
||||
macro_rules! field_impl {
|
||||
($name:ident, $modulus:expr, $rsquared:expr, $rcubed:expr, $one:expr, $inv:expr) => {
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
||||
@@ -22,22 +19,6 @@ macro_rules! field_impl {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "rustc-serialize")]
|
||||
impl Encodable for $name {
|
||||
fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
|
||||
let normalized = U256::from(*self);
|
||||
|
||||
normalized.encode(s)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "rustc-serialize")]
|
||||
impl Decodable for $name {
|
||||
fn decode<S: Decoder>(s: &mut S) -> Result<$name, S::Error> {
|
||||
$name::new(U256::decode(s)?).ok_or_else(|| s.error("integer is not less than modulus"))
|
||||
}
|
||||
}
|
||||
|
||||
impl $name {
|
||||
pub fn from_str(s: &str) -> Option<Self> {
|
||||
let ints: Vec<_> = {
|
||||
@@ -240,7 +221,7 @@ field_impl!(
|
||||
0x9ede7d651eca6ac987d20782e4866389
|
||||
);
|
||||
|
||||
lazy_static! {
|
||||
lazy_static::lazy_static! {
|
||||
|
||||
static ref FQ: U256 = U256::from([
|
||||
0x3c208c16d87cfd47,
|
||||
|
||||
+1
-26
@@ -3,9 +3,6 @@ use rand::Rng;
|
||||
use crate::fields::{const_fq, FieldElement, Fq};
|
||||
use crate::arith::{U256, U512};
|
||||
|
||||
#[cfg(feature = "rustc-serialize")]
|
||||
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
|
||||
|
||||
#[inline]
|
||||
fn fq_non_residue() -> Fq {
|
||||
// (q - 1) is a quadratic nonresidue in Fq
|
||||
@@ -43,28 +40,6 @@ pub struct Fq2 {
|
||||
c1: Fq,
|
||||
}
|
||||
|
||||
#[cfg(feature = "rustc-serialize")]
|
||||
impl Encodable for Fq2 {
|
||||
fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
|
||||
let c0: U256 = self.c0.into();
|
||||
let c1: U256 = self.c1.into();
|
||||
|
||||
U512::new(&c1, &c0, &Fq::modulus()).encode(s)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "rustc-serialize")]
|
||||
impl Decodable for Fq2 {
|
||||
fn decode<S: Decoder>(s: &mut S) -> Result<Fq2, S::Error> {
|
||||
let combined = U512::decode(s)?;
|
||||
|
||||
match combined.divrem(&Fq::modulus()) {
|
||||
(Some(c1), c0) => Ok(Fq2::new(Fq::new(c0).unwrap(), Fq::new(c1).unwrap())),
|
||||
_ => Err(s.error("integer not less than modulus squared")),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Fq2 {
|
||||
pub fn new(c0: Fq, c1: Fq) -> Self {
|
||||
Fq2 { c0: c0, c1: c1 }
|
||||
@@ -206,7 +181,7 @@ impl Neg for Fq2 {
|
||||
}
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
lazy_static::lazy_static! {
|
||||
static ref FQ: U256 = U256::from([
|
||||
0x3c208c16d87cfd47,
|
||||
0x97816a916871ca8d,
|
||||
|
||||
Reference in New Issue
Block a user