From e8c9cb1ade5853862f2bf63c5902580f2e61b51a Mon Sep 17 00:00:00 2001 From: Alivecow Date: Fri, 29 Nov 2024 14:31:52 +0100 Subject: [PATCH] refactor: Imrpove gfmul to remove unneded vec manipulation and imporve performanve --- src/utils/poly.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/utils/poly.rs b/src/utils/poly.rs index 82e991a..eeffc34 100644 --- a/src/utils/poly.rs +++ b/src/utils/poly.rs @@ -613,20 +613,20 @@ pub const RED_POLY: u128 = 0x87000000_00000000_00000000_00000000; pub fn gfmul(poly_a: &Vec, poly_b: &Vec, semantic: &str) -> Result> { let mut red_poly_bytes: ByteArray = ByteArray(RED_POLY.to_be_bytes().to_vec()); - red_poly_bytes.0.push(0x01); + //red_poly_bytes.0.push(0x01); let mut poly1: ByteArray = ByteArray(poly_a.to_owned()); - poly1.0.push(0x00); + //poly1.0.push(0x00); let mut poly2: ByteArray = ByteArray(poly_b.to_owned()); - poly2.0.push(0x00); + //poly2.0.push(0x00); if semantic == "gcm" { poly1.reverse_bits_in_bytevec(); poly2.reverse_bits_in_bytevec(); } - let mut result: ByteArray = ByteArray(vec![0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); + let mut result: ByteArray = ByteArray(vec![0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); if poly2.LSB_is_one() { result.xor_byte_arrays(&poly1); @@ -634,9 +634,9 @@ pub fn gfmul(poly_a: &Vec, poly_b: &Vec, semantic: &str) -> Result, poly_b: &Vec, semantic: &str) -> Result