feat: add the gcm crack
Example testcase is working
This commit is contained in:
parent
16b65b0de4
commit
4c9adb9fdc
7 changed files with 253 additions and 24 deletions
|
|
@ -25,20 +25,14 @@ pub fn ddf(f: Polynomial) -> Vec<(Polynomial, u128)> {
|
|||
|
||||
let g = gcd(&h, &f_star);
|
||||
if g != one_cmp {
|
||||
eprintln!("d is: {}", d);
|
||||
eprintln!("g is: {:?}", &g.clone().to_c_array());
|
||||
|
||||
z.push((g.clone(), d));
|
||||
f_star = f_star.div(&g).0;
|
||||
}
|
||||
eprintln!("d outer is: {}", d);
|
||||
eprintln!("F star degree is {:?}", &f_star.degree());
|
||||
|
||||
d += 1;
|
||||
}
|
||||
|
||||
if f_star != one_cmp {
|
||||
eprintln!("fstar not one");
|
||||
z.push((f_star.clone(), f_star.degree() as u128));
|
||||
} else if z.len() == 0 {
|
||||
z.push((f.clone(), 1));
|
||||
|
|
|
|||
|
|
@ -39,6 +39,18 @@ impl FieldElement {
|
|||
FieldElement::new_no_convert(vec![0x01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||
}
|
||||
|
||||
pub fn to_vec(&self) -> Vec<u8> {
|
||||
self.field_element.clone()
|
||||
}
|
||||
|
||||
/*
|
||||
pub fn padd(&mut self) {
|
||||
if self.field_element.len() % 16 != 0 || ad.is_empty() {
|
||||
ad.append(vec![0u8; 16 - (ad.len() % 16)].as_mut());
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
pub fn new(field_element: Vec<u8>) -> Self {
|
||||
Self {
|
||||
field_element: reverse_bits_in_bytevec(field_element),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use crate::utils::field::ByteArray;
|
||||
use base64::prelude::*;
|
||||
|
||||
use num::traits::FromBytes;
|
||||
use num::traits::{FromBytes, ToBytes};
|
||||
use num::{BigInt, BigUint, One, Zero};
|
||||
|
||||
use std::{str::FromStr, u128, u8, usize};
|
||||
|
|
@ -31,6 +31,10 @@ impl Polynomial {
|
|||
self.polynomial.len() - 1
|
||||
}
|
||||
|
||||
pub fn empty() -> Polynomial {
|
||||
Polynomial::new(vec![])
|
||||
}
|
||||
|
||||
pub fn one() -> Self {
|
||||
Polynomial::new(vec![FieldElement::one()])
|
||||
}
|
||||
|
|
@ -373,6 +377,10 @@ impl Polynomial {
|
|||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn extract_component(&self, i: u32) -> FieldElement {
|
||||
self.polynomial[i as usize].clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl Clone for Polynomial {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue