From 7ffeba3ae46ac777d8d4f91ca1c94a42d848aa98 Mon Sep 17 00:00:00 2001 From: Daniel Lubarov Date: Sun, 12 Sep 2021 18:29:07 -0700 Subject: [PATCH] Delete my old MDS code, now obsolete --- src/field/crandall_field.rs | 95 ------------------------------------- src/field/field_types.rs | 29 ----------- 2 files changed, 124 deletions(-) diff --git a/src/field/crandall_field.rs b/src/field/crandall_field.rs index 7688bf81..d2227d80 100644 --- a/src/field/crandall_field.rs +++ b/src/field/crandall_field.rs @@ -17,90 +17,6 @@ use crate::field::inversion::try_inverse_u64; /// EPSILON = 9 * 2**28 - 1 const EPSILON: u64 = 2415919103; -/// A precomputed 8*8 Cauchy matrix, generated with `Field::mds_8`. -const CAUCHY_MDS_8: [[CrandallField; 8]; 8] = [ - [ - CrandallField(16140901062381928449), - CrandallField(2635249153041947502), - CrandallField(3074457345215605419), - CrandallField(11068046442776179508), - CrandallField(13835058053470224385), - CrandallField(6148914690431210838), - CrandallField(9223372035646816257), - CrandallField(1), - ], - [ - CrandallField(2049638230143736946), - CrandallField(16140901062381928449), - CrandallField(2635249153041947502), - CrandallField(3074457345215605419), - CrandallField(11068046442776179508), - CrandallField(13835058053470224385), - CrandallField(6148914690431210838), - CrandallField(9223372035646816257), - ], - [ - CrandallField(5534023221388089754), - CrandallField(2049638230143736946), - CrandallField(16140901062381928449), - CrandallField(2635249153041947502), - CrandallField(3074457345215605419), - CrandallField(11068046442776179508), - CrandallField(13835058053470224385), - CrandallField(6148914690431210838), - ], - [ - CrandallField(16769767337539665921), - CrandallField(5534023221388089754), - CrandallField(2049638230143736946), - CrandallField(16140901062381928449), - CrandallField(2635249153041947502), - CrandallField(3074457345215605419), - CrandallField(11068046442776179508), - CrandallField(13835058053470224385), - ], - [ - CrandallField(10760600708254618966), - CrandallField(16769767337539665921), - CrandallField(5534023221388089754), - CrandallField(2049638230143736946), - CrandallField(16140901062381928449), - CrandallField(2635249153041947502), - CrandallField(3074457345215605419), - CrandallField(11068046442776179508), - ], - [ - CrandallField(5675921252705733081), - CrandallField(10760600708254618966), - CrandallField(16769767337539665921), - CrandallField(5534023221388089754), - CrandallField(2049638230143736946), - CrandallField(16140901062381928449), - CrandallField(2635249153041947502), - CrandallField(3074457345215605419), - ], - [ - CrandallField(1317624576520973751), - CrandallField(5675921252705733081), - CrandallField(10760600708254618966), - CrandallField(16769767337539665921), - CrandallField(5534023221388089754), - CrandallField(2049638230143736946), - CrandallField(16140901062381928449), - CrandallField(2635249153041947502), - ], - [ - CrandallField(15987178195121148178), - CrandallField(1317624576520973751), - CrandallField(5675921252705733081), - CrandallField(10760600708254618966), - CrandallField(16769767337539665921), - CrandallField(5534023221388089754), - CrandallField(2049638230143736946), - CrandallField(16140901062381928449), - ], -]; - /// A field designed for use with the Crandall reduction algorithm. /// /// Its order is @@ -257,17 +173,6 @@ impl Field for CrandallField { let x74 = x73 * x39; x74 } - - fn mds_8(vec: [Self; 8]) -> [Self; 8] { - let mut result = [Self::ZERO; 8]; - for r in 0..8 { - for c in 0..8 { - let entry = CAUCHY_MDS_8[r][c]; - result[r] += entry * vec[c]; - } - } - result - } } impl PrimeField for CrandallField { diff --git a/src/field/field_types.rs b/src/field/field_types.rs index 62313826..0038dec7 100644 --- a/src/field/field_types.rs +++ b/src/field/field_types.rs @@ -280,35 +280,6 @@ pub trait Field: } } - /// Apply an MDS matrix to the given vector. Any MDS matrix can be used, as long as the same one - /// is used among calls with the same vector length. - /// - /// Note that the default implementation is quite slow. If speed is important, this should be - /// overridden with a field-specific implementation which applies a precomputed MDS matrix. - fn mds(vec: Vec) -> Vec { - // We use a Cauchy matrix with x_r = n + r, y_c = c. - let n = vec.len(); - let mut result = Vec::with_capacity(n); - for r in 0..n { - let mut sum = Self::ZERO; - for c in 0..n { - let x = Self::from_canonical_usize(n + r); - let y = Self::from_canonical_usize(c); - // This is the (r, c) entry of the Cauchy matrix. - let entry = (x - y).inverse(); - sum += entry * vec[c]; - } - result.push(sum); - } - result - } - - /// Like `mds`, but specialized to n=8. For specific fields, this can be overridden with an - /// impl which applies a fast, precomputed 8x8 MDS matrix. - fn mds_8(vec: [Self; 8]) -> [Self; 8] { - Self::mds(vec.to_vec()).try_into().unwrap() - } - fn rand() -> Self { Self::rand_from_rng(&mut rand::thread_rng()) }