mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-11 02:03:07 +00:00
Delete my old MDS code, now obsolete
This commit is contained in:
parent
a8d08aa153
commit
7ffeba3ae4
@ -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 {
|
||||
|
||||
@ -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<Self>) -> Vec<Self> {
|
||||
// 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())
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user