Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove canonical and canonical_derive #112

Merged
merged 1 commit into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions .github/workflows/dusk_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,6 @@ jobs:
command: test
args: --release --features serde_req

test_nightly_canon:
name: Nightly tests canon
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
- uses: actions-rs/cargo@v1
with:
command: test
args: --release --features canon

fmt:
name: Rustfmt
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Removed

- Remove scalar field generator [#100]
- Remove canonical and canonical_derive dependency [#108]

## [0.11.3] - 2023-05-17

Expand Down Expand Up @@ -185,6 +186,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Rename `S` to `TWO_ADACITY` and export it

<!-- Issues -->
[#108]: (https://github.com/dusk-network/bls12_381/issues/108)
[#100]: (https://github.com/dusk-network/bls12_381/issues/100)
[#93]: (https://github.com/dusk-network/bls12_381/issues/93)
[#75]: (https://github.com/dusk-network/bls12_381/issues/75)
Expand Down
3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ byteorder = {version = "1.0", default-features = false, optional = true}
rayon = {version = "1.3", optional = true}
serde = {version = "1.0", optional = true}
rand_core = {version = "0.6", default-features = false}
canonical = {version = "0.7", optional = true}
canonical_derive = {version = "0.7", optional = true}
rkyv = {version = "0.7", optional = true, default-features = false}
bytecheck = {version = "0.6", optional = true, default-features = false}
dusk-bytes = "0.1"
Expand Down Expand Up @@ -57,7 +55,6 @@ parallel = ["rayon"]
pairings = ["groups"]
alloc = []
nightly = ["subtle/nightly"]
canon = ["canonical", "canonical_derive"]
rkyv-impl = ["rkyv", "rkyv/alloc", "bytecheck"]
serde_req = ["serde", "std"]
endo = []
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ This crate provides an implementation of the BLS12-381 pairing-friendly elliptic
* `nightly`: Enables `subtle/nightly` which tries to prevent compiler optimizations that could jeopardize constant time operations. Requires the nightly Rust compiler.
* `endo`: Enables optimizations that leverage curve endomorphisms, which may run foul of patents US7110538B2 and US7995752B2 set to expire in September 2020.
* `parallel` (on by default): Enables `rayon` usage for higly parallelizable ops such as multiscalar multiplication.
* `canon`: Enables the usage of `canonical` for WASM-related serialization usages.

## [Documentation](https://docs.rs/dusk-bls12_381)

Expand Down
4 changes: 0 additions & 4 deletions src/choice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@ use core::convert::Infallible;
use dusk_bytes::{HexDebug, Serializable};
use subtle::ConditionallySelectable;

#[cfg(feature = "canon")]
use canonical_derive::Canon;

#[cfg(feature = "rkyv-impl")]
use bytecheck::CheckBytes;
#[cfg(feature = "rkyv-impl")]
use rkyv::{Archive, Deserialize as RkyvDeserialize, Serialize as RkyvSerialize};

/// Wrapper for a [`subtle::Choice`]
#[derive(Copy, Clone, HexDebug)]
#[cfg_attr(feature = "canon", derive(Canon))]
#[cfg_attr(feature = "rkyv-impl", derive(Archive, RkyvSerialize, RkyvDeserialize))]
#[cfg_attr(feature = "rkyv-impl", archive_attr(derive(CheckBytes)))]
pub struct Choice(u8);
Expand Down
3 changes: 0 additions & 3 deletions src/fp.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
//! This module provides an implementation of the BLS12-381 base field `GF(p)`
//! where `p = 0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab`

#[cfg(feature = "canon")]
use canonical_derive::Canon;
use core::convert::TryFrom;
use core::fmt;
use core::ops::{Add, AddAssign, Mul, MulAssign, Neg, Sub, SubAssign};
Expand All @@ -25,7 +23,6 @@ use crate::util::{adc, mac, sbb};
// integers in little-endian order. `Fp` values are always in
// Montgomery form; i.e., Scalar(a) = aR mod p, with R = 2^384.
#[derive(Copy, Clone)]
#[cfg_attr(feature = "canon", derive(Canon))]
#[cfg_attr(feature = "rkyv-impl", derive(Archive, RkyvSerialize, RkyvDeserialize))]
#[cfg_attr(feature = "rkyv-impl", archive_attr(derive(CheckBytes)))]
pub struct Fp([u64; 6]);
Expand Down
3 changes: 0 additions & 3 deletions src/fp12.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ use crate::fp::*;
use crate::fp2::*;
use crate::fp6::*;

#[cfg(feature = "canon")]
use canonical_derive::Canon;
use core::fmt;
use core::ops::{Add, AddAssign, Mul, MulAssign, Neg, Sub, SubAssign};
use subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption};
Expand All @@ -14,7 +12,6 @@ use bytecheck::CheckBytes;
use rkyv::{Archive, Deserialize as RkyvDeserialize, Serialize as RkyvSerialize};

/// This represents an element $c_0 + c_1 w$ of $\mathbb{F}_{p^12} = \mathbb{F}_{p^6} / w^2 - v$.
#[cfg_attr(feature = "canon", derive(Canon))]
#[cfg_attr(feature = "rkyv-impl", derive(Archive, RkyvSerialize, RkyvDeserialize))]
#[cfg_attr(feature = "rkyv-impl", archive_attr(derive(CheckBytes)))]
pub struct Fp12 {
Expand Down
3 changes: 0 additions & 3 deletions src/fp2.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//! This module implements arithmetic over the quadratic extension field Fp2.

#[cfg(feature = "canon")]
use canonical_derive::Canon;
use core::fmt;
use core::ops::{Add, AddAssign, Mul, MulAssign, Neg, Sub, SubAssign};
use subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption};
Expand All @@ -19,7 +17,6 @@ use rkyv::{Archive, Deserialize as RkyvDeserialize, Serialize as RkyvSerialize};
use crate::fp::Fp;

#[derive(Copy, Clone)]
#[cfg_attr(feature = "canon", derive(Canon))]
#[cfg_attr(feature = "rkyv-impl", derive(Archive, RkyvSerialize, RkyvDeserialize))]
#[cfg_attr(feature = "rkyv-impl", archive_attr(derive(CheckBytes)))]
pub struct Fp2 {
Expand Down
3 changes: 0 additions & 3 deletions src/fp6.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use crate::fp::*;
use crate::fp2::*;

#[cfg(feature = "canon")]
use canonical_derive::Canon;
use core::fmt;
use core::ops::{Add, AddAssign, Mul, MulAssign, Neg, Sub, SubAssign};
use subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption};
Expand All @@ -18,7 +16,6 @@ use serde::{
};

/// This represents an element $c_0 + c_1 v + c_2 v^2$ of $\mathbb{F}_{p^6} = \mathbb{F}_{p^2} / v^3 - u - 1$.
#[cfg_attr(feature = "canon", derive(Canon))]
#[cfg_attr(feature = "rkyv-impl", derive(Archive, RkyvSerialize, RkyvDeserialize))]
#[cfg_attr(feature = "rkyv-impl", archive_attr(derive(CheckBytes)))]
pub struct Fp6 {
Expand Down
24 changes: 0 additions & 24 deletions src/g1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ use core::ops::{Add, AddAssign, Mul, MulAssign, Neg, Sub, SubAssign};
use dusk_bytes::{Error as BytesError, HexDebug, Serializable};
use subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption};

#[cfg(feature = "canon")]
use canonical::{Canon, CanonError, Sink, Source};
#[cfg(feature = "canon")]
use canonical_derive::Canon;
#[cfg(feature = "serde_req")]
use serde::{de::Visitor, Deserialize, Deserializer, Serialize, Serializer};

Expand All @@ -37,25 +33,6 @@ pub struct G1Affine {
infinity: choice::Choice,
}

#[cfg(feature = "canon")]
impl Canon for G1Affine {
fn encode(&self, sink: &mut Sink) {
sink.copy_bytes(&self.to_bytes());
}

fn decode(source: &mut Source) -> Result<Self, CanonError> {
let mut bytes = [0u8; Self::SIZE];

bytes.copy_from_slice(source.read_bytes(Self::SIZE));

Self::from_bytes(&bytes).map_err(|_| CanonError::InvalidEncoding)
}

fn encoded_len(&self) -> usize {
Self::SIZE
}
}

impl Default for G1Affine {
fn default() -> G1Affine {
G1Affine::identity()
Expand Down Expand Up @@ -486,7 +463,6 @@ fn endomorphism(p: &G1Affine) -> G1Affine {

/// This is an element of $\mathbb{G}_1$ represented in the projective coordinate space.
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "canon", derive(Canon))]
#[cfg_attr(feature = "rkyv-impl", derive(Archive, RkyvSerialize, RkyvDeserialize))]
#[cfg_attr(feature = "rkyv-impl", archive_attr(derive(CheckBytes)))]
pub struct G1Projective {
Expand Down
24 changes: 0 additions & 24 deletions src/g2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ use core::ops::{Add, AddAssign, Mul, MulAssign, Neg, Sub, SubAssign};
use dusk_bytes::{Error as BytesError, HexDebug, Serializable};
use subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption};

#[cfg(feature = "canon")]
use canonical::{Canon, CanonError, Sink, Source};
#[cfg(feature = "canon")]
use canonical_derive::Canon;
#[cfg(feature = "serde_req")]
use serde::{de::Visitor, Deserialize, Deserializer, Serialize, Serializer};

Expand All @@ -38,25 +34,6 @@ pub struct G2Affine {
infinity: choice::Choice,
}

#[cfg(feature = "canon")]
impl Canon for G2Affine {
fn encode(&self, sink: &mut Sink) {
sink.copy_bytes(&self.to_bytes());
}

fn decode(source: &mut Source) -> Result<Self, CanonError> {
let mut bytes = [0u8; Self::SIZE];

bytes.copy_from_slice(source.read_bytes(Self::SIZE));

Self::from_bytes(&bytes).map_err(|_| CanonError::InvalidEncoding)
}

fn encoded_len(&self) -> usize {
Self::SIZE
}
}

impl Default for G2Affine {
fn default() -> G2Affine {
G2Affine::identity()
Expand Down Expand Up @@ -529,7 +506,6 @@ impl G2Affine {

/// This is an element of $\mathbb{G}_2$ represented in the projective coordinate space.
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "canon", derive(Canon))]
#[cfg_attr(feature = "rkyv-impl", derive(Archive, RkyvSerialize, RkyvDeserialize))]
#[cfg_attr(feature = "rkyv-impl", archive_attr(derive(CheckBytes)))]
pub struct G2Projective {
Expand Down
3 changes: 0 additions & 3 deletions src/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
//! where `q = 0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001`

use crate::util::{adc, mac, sbb};
#[cfg(feature = "canon")]
use canonical_derive::Canon;
use core::borrow::Borrow;
use core::cmp::{Ord, Ordering, PartialOrd};
use core::convert::TryFrom;
Expand All @@ -27,7 +25,6 @@ use rkyv::{Archive, Deserialize as RkyvDeserialize, Serialize as RkyvSerialize};
// integers in little-endian order. `Scalar` values are always in
// Montgomery form; i.e., Scalar(a) = aR mod q, with R = 2^256.
#[derive(Clone, Copy, Eq, Hash, HexDebug)]
#[cfg_attr(feature = "canon", derive(Canon))]
#[cfg_attr(feature = "rkyv-impl", derive(Archive, RkyvSerialize, RkyvDeserialize))]
#[cfg_attr(feature = "rkyv-impl", archive_attr(derive(CheckBytes)))]
pub struct Scalar(pub [u64; 4]);
Expand Down