File tree Expand file tree Collapse file tree 4 files changed +19
-4
lines changed Expand file tree Collapse file tree 4 files changed +19
-4
lines changed Original file line number Diff line number Diff line change 11[package ]
22name = " amcl_wrapper"
3- version = " 0.3.3 "
3+ version = " 0.3.4 "
44authors = [
" lovesh harchandani <[email protected] >" ]
55description = " Wapper over Milagro Cryptographic Library (version 3)"
66repository = " https://github.com/lovesh/amcl_rust_wrapper"
Original file line number Diff line number Diff line change @@ -275,13 +275,28 @@ let poly2 = UnivarPolynomial::random(d);
275275// Create a polynomial from its roots
276276let poly3 = UnivarPolynomial :: new_with_roots (roots );
277277
278+ // Create a polynomial by passing the coefficients to a macro
279+ let poly4 = univar_polynomial! (
280+ FieldElement :: one (),
281+ FieldElement :: zero (),
282+ FieldElement :: from (87u64 ),
283+ - FieldElement :: one (),
284+ FieldElement :: from (300u64 )
285+ );
286+
278287// A polynomial can be evaluated at a field element `v`
279288let res : FieldElement = poly1 . eval (v );
280289
281290// Polynomials can be added, subtracted, multiplied or divided to give new polynomials
282291let sum = UnivarPolynomial :: sum (& poly1 , & poly2 );
292+ // Or use operator overloading
293+ let sum = & poly1 + & poly2 ;
283294let diff = UnivarPolynomial :: difference (& poly1 , & poly2 );
295+ // Or use operator overloading
296+ let diff = & poly1 - & poly2 ;
284297let product = UnivarPolynomial :: multiply (& poly1 , & poly2 );
298+ // Or use operator overloading
299+ let product = & poly1 * & poly2 ;
285300let (quotient , rem ) = UnivarPolynomial :: long_division (& poly1 , & poly2 );
286301```
287302
Original file line number Diff line number Diff line change @@ -716,7 +716,7 @@ macro_rules! impl_group_elem_vec_product_ops {
716716 }
717717
718718 /// Strauss multi-scalar multiplication
719- fn multi_scalar_mul_var_time_without_precomputation<' g, ' f>(
719+ pub fn multi_scalar_mul_var_time_without_precomputation<' g, ' f>(
720720 group_elems: impl IntoIterator <Item = & ' g $group_element>,
721721 field_elems: impl IntoIterator <Item = & ' f FieldElement >,
722722 ) -> Result <$group_element, ValueError > {
Original file line number Diff line number Diff line change @@ -283,7 +283,7 @@ mod tests {
283283 FieldElement :: one( ) ,
284284 FieldElement :: zero( ) ,
285285 FieldElement :: from( 87u64 ) ,
286- FieldElement :: minus_one ( ) ,
286+ - FieldElement :: one ( ) ,
287287 FieldElement :: from( 300u64 )
288288 ) ;
289289 assert_eq ! ( poly. degree( ) , 4 ) ;
@@ -547,7 +547,7 @@ mod tests {
547547 // Test sum and difference of randomly generated polynomials.
548548 let num_test_cases = 100 ;
549549 let mut rng = rand:: thread_rng ( ) ;
550- let mut start = Instant :: now ( ) ;
550+ let start = Instant :: now ( ) ;
551551 for _ in 0 ..num_test_cases {
552552 let left = UnivarPolynomial :: random ( rng. gen_range ( 1 , 100 ) ) ;
553553 let right = UnivarPolynomial :: random ( rng. gen_range ( 1 , 100 ) ) ;
You can’t perform that action at this time.
0 commit comments