Skip to content

Commit

Permalink
move OFF table to mod
Browse files Browse the repository at this point in the history
  • Loading branch information
querolita committed Oct 7, 2023
1 parent c3a23f8 commit 5c42ebd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
18 changes: 1 addition & 17 deletions kimchi/src/circuits/polynomials/keccak/circuitgates.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Keccak gadget
use super::{DIM, QUARTERS};
use super::{DIM, OFF, QUARTERS};
use crate::{
auto_clone, auto_clone_array,
circuits::{
Expand All @@ -12,22 +12,6 @@ use crate::{
use ark_ff::PrimeField;
use std::marker::PhantomData;

/// Creates the 5x5 table of rotation bits for Keccak modulo 64
/// | x \ y | 0 | 1 | 2 | 3 | 4 |
/// | ----- | -- | -- | -- | -- | -- |
/// | 0 | 0 | 36 | 3 | 41 | 18 |
/// | 1 | 1 | 44 | 10 | 45 | 2 |
/// | 2 | 62 | 6 | 43 | 15 | 61 |
/// | 3 | 28 | 55 | 25 | 21 | 56 |
/// | 4 | 27 | 20 | 39 | 8 | 14 |
const OFF: [[u64; DIM]; DIM] = [
[0, 36, 3, 41, 18],
[1, 44, 10, 45, 2],
[62, 6, 43, 15, 61],
[28, 55, 25, 21, 56],
[27, 20, 39, 8, 14],
];

//~
//~ | `KeccakRound` | [0...440) | [440...1540) | [1540...2344) |
//~ | ------------- | --------- | ------------ | ------------- |
Expand Down
17 changes: 17 additions & 0 deletions kimchi/src/circuits/polynomials/keccak/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,23 @@ macro_rules! state_from_vec {
};
}

/// Creates the 5x5 table of rotation bits for Keccak modulo 64
/// | x \ y | 0 | 1 | 2 | 3 | 4 |
/// | ----- | -- | -- | -- | -- | -- |
/// | 0 | 0 | 36 | 3 | 41 | 18 |
/// | 1 | 1 | 44 | 10 | 45 | 2 |
/// | 2 | 62 | 6 | 43 | 15 | 61 |
/// | 3 | 28 | 55 | 25 | 21 | 56 |
/// | 4 | 27 | 20 | 39 | 8 | 14 |
/// Note that the order of the indexing is [y][x] to match the encoding of the witness algorithm
pub(crate) const OFF: [[u64; DIM]; DIM] = [
[0, 1, 62, 28, 27],
[36, 44, 6, 55, 20],
[3, 10, 43, 25, 39],
[41, 45, 15, 21, 8],
[18, 2, 61, 56, 14],
];

pub(crate) const RC: [u64; 24] = [
0x0000000000000001,
0x0000000000008082,
Expand Down

0 comments on commit 5c42ebd

Please sign in to comment.