From e698f5cab3d28fe740a853387859d713ff318885 Mon Sep 17 00:00:00 2001 From: David Kathoh Date: Thu, 21 Mar 2024 12:51:41 +0200 Subject: [PATCH] implemented #24 and made field, polynomial, mpolynomila modules public --- baby-stark/src/main.rs | 6 +++--- baby-stark/src/mpolynomial.rs | 40 +++++++++++++++++++++++++++++++---- 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/baby-stark/src/main.rs b/baby-stark/src/main.rs index 81d4c45..97a789b 100644 --- a/baby-stark/src/main.rs +++ b/baby-stark/src/main.rs @@ -2,9 +2,9 @@ use baby_stark_math_lib; use crate::field::FieldElement; -mod field; -mod polynomial; -mod mpolynomial; +pub mod field; +pub mod polynomial; +pub mod mpolynomial; fn main() { println!("Hello, world!"); diff --git a/baby-stark/src/mpolynomial.rs b/baby-stark/src/mpolynomial.rs index c055fe0..d5430a5 100644 --- a/baby-stark/src/mpolynomial.rs +++ b/baby-stark/src/mpolynomial.rs @@ -1,7 +1,39 @@ -pub struct MPolynomial{ - +use crate::field::FieldElement; +use std::collections::HashMap; +pub struct MPolynomial { + dictionary: HashMap, } -impl MPolynomial{ +impl MPolynomial { + pub fn from(dictionary: HashMap) -> MPolynomial { + MPolynomial { dictionary } + } -} \ No newline at end of file + pub fn zero() -> MPolynomial { + let my_hash_map: HashMap = HashMap::new(); + + MPolynomial { + dictionary: my_hash_map, + } + } +} + +#[cfg(test)] +mod test { + use super::*; + #[test] + fn test_creation_polynomial() { + let mut my_dic: HashMap = HashMap::new(); + my_dic.insert("x".to_string(), FieldElement::new()); + my_dic.insert("y".to_string(), FieldElement::new()); + my_dic.insert("y".to_string(), FieldElement::new()); + let x = MPolynomial { dictionary: my_dic }; + } + + #[test] + fn test_init_polynomial() { + let mut my_dic: HashMap = HashMap::new(); + my_dic.insert("x".to_string(), FieldElement::new()); + let poly = MPolynomial::from(my_dic); + } +}