From 5c42ebdfc3ea06d66d0bbb8428ad5e8daf3cef45 Mon Sep 17 00:00:00 2001 From: querolita Date: Sat, 7 Oct 2023 12:44:24 +0200 Subject: [PATCH] move OFF table to mod --- .../polynomials/keccak/circuitgates.rs | 18 +----------------- kimchi/src/circuits/polynomials/keccak/mod.rs | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/kimchi/src/circuits/polynomials/keccak/circuitgates.rs b/kimchi/src/circuits/polynomials/keccak/circuitgates.rs index 89586f2cc7..280eb38369 100644 --- a/kimchi/src/circuits/polynomials/keccak/circuitgates.rs +++ b/kimchi/src/circuits/polynomials/keccak/circuitgates.rs @@ -1,5 +1,5 @@ //! Keccak gadget -use super::{DIM, QUARTERS}; +use super::{DIM, OFF, QUARTERS}; use crate::{ auto_clone, auto_clone_array, circuits::{ @@ -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) | //~ | ------------- | --------- | ------------ | ------------- | diff --git a/kimchi/src/circuits/polynomials/keccak/mod.rs b/kimchi/src/circuits/polynomials/keccak/mod.rs index 95d7698220..538159e1b5 100644 --- a/kimchi/src/circuits/polynomials/keccak/mod.rs +++ b/kimchi/src/circuits/polynomials/keccak/mod.rs @@ -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,