Skip to content

Commit

Permalink
Add serialization trait bounds to Polynomial (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanleh authored Nov 19, 2020
1 parent 0b0edb1 commit 58ca7b9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions poly/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ edition = "2018"

[dependencies]
ark-ff = { path = "../ff", default-features = false }
ark-serialize = { path = "../serialize", default-features = false, features = ["derive"] }
ark-std = { git = "https://github.com/arkworks-rs/utils", default-features = false }
rand = { version = "0.7", default-features = false }
rayon = { version = "1", optional = true }
Expand Down
6 changes: 4 additions & 2 deletions poly/src/polynomial/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Modules for working with univariate or multivariate polynomials.
use ark_ff::{Field, Zero};
use ark_serialize::*;
use ark_std::{
fmt::Debug,
hash::Hash,
Expand Down Expand Up @@ -38,7 +38,9 @@ pub trait Polynomial<F: Field>:
}

/// Describes the interface for univariate polynomials
pub trait UVPolynomial<F: Field>: Polynomial<F, Point = F> {
pub trait UVPolynomial<F: Field>:
Polynomial<F, Point = F> + CanonicalSerialize + CanonicalDeserialize
{
/// Constructs a new polynomial from a list of coefficients.
fn from_coefficients_slice(coeffs: &[F]) -> Self;

Expand Down
4 changes: 2 additions & 2 deletions poly/src/polynomial/univariate/dense.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use crate::univariate::DenseOrSparsePolynomial;
use crate::{EvaluationDomain, Evaluations, GeneralEvaluationDomain};
use crate::{Polynomial, UVPolynomial};

use ark_serialize::*;
use ark_std::{
fmt,
ops::{Add, AddAssign, Deref, DerefMut, Div, Mul, Neg, Sub, SubAssign},
Expand All @@ -16,7 +16,7 @@ use rand::Rng;
use rayon::prelude::*;

/// Stores a polynomial in coefficient form.
#[derive(Clone, PartialEq, Eq, Hash, Default)]
#[derive(Clone, PartialEq, Eq, Hash, Default, CanonicalSerialize, CanonicalDeserialize)]
pub struct DensePolynomial<F: Field> {
/// The coefficient of `x^i` is stored at location `i` in `self.coeffs`.
pub coeffs: Vec<F>,
Expand Down

0 comments on commit 58ca7b9

Please sign in to comment.