1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681
// Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
use super::super::mds::mds_f64_8x8::mds_multiply;
use super::{Digest, ElementHasher, Hasher};
use core::convert::TryInto;
use core::ops::Range;
use math::{fields::f64::BaseElement, FieldElement, StarkField};
mod digest;
pub use digest::ElementDigest;
#[cfg(test)]
mod tests;
// CONSTANTS
// ================================================================================================
/// Sponge state is set to 8 field elements or 64 bytes; 4 elements are reserved for rate and
/// the remaining 4 elements are reserved for capacity.
const STATE_WIDTH: usize = 8;
/// The rate portion of the state is located in elements 0 through 4.
const RATE_RANGE: Range<usize> = 0..4;
const RATE_WIDTH: usize = RATE_RANGE.end - RATE_RANGE.start;
// The compression makes use of the Jive mode, hence ignoring the notion of sponge capacity.
const INPUT1_RANGE: Range<usize> = 0..4;
const INPUT2_RANGE: Range<usize> = 4..8;
/// The capacity portion of the state is located in elements 4, 5, 6 and 7.
const CAPACITY_RANGE: Range<usize> = 4..8;
/// The output of the hash function is a digest which consists of 4 field elements or 32 bytes.
///
/// The digest is returned from state elements 0, 1, 2, 3 (the four elements of the rate).
const DIGEST_RANGE: Range<usize> = 0..4;
const DIGEST_SIZE: usize = DIGEST_RANGE.end - DIGEST_RANGE.start;
/// The number of rounds is set to 7 to target 128-bit security level with 15% security margin
const NUM_ROUNDS: usize = 7;
// HASHER IMPLEMENTATION
// ================================================================================================
/// Implementation of [Hasher] trait for Griffin hash function with 256-bit output.
///
/// The hash function is implemented according to the Griffin
/// [specifications](https://eprint.iacr.org/2020/1143.pdf) with the following caveats:
/// * We set the number of rounds to 7, which implies a 15% security margin instead of the 20%
/// margin used in the specifications (a 20% margin rounds up to 8 rounds). The primary
/// motivation for this is that having the number of rounds be one less than a power of two
/// simplifies AIR design for computations involving the hash function.
/// * When hashing a sequence of elements, implement the Hirose padding rule. However, it also
/// means that our instantiation of Griffin cannot be used in a stream mode as the number
/// of elements to be hashed must be known upfront.
/// * Instead of using the suggested matrix as described in Griffin paper, we use a methodology
/// developed by Polygon Zero to find an MDS matrix with coefficients which are small powers
/// of two in frequency domain. This allows us to dramatically reduce matrix multiplication
/// time. We claim without proof that using a different (MDS) matrix does not affect security of
/// as the branching number is actually increased (9 instead of 6).
///
/// The parameters used to instantiate the function are:
/// * Field: 64-bit prime field with modulus 2^64 - 2^32 + 1.
/// * State width: 8 field elements.
/// * Capacity size: 4 field elements.
/// * Number of founds: 7.
/// * S-Box degree: 7.
///
/// The above parameters target 128-bit security level. The digest consists of four field elements
/// and it can be serialized into 32 bytes (256 bits).
///
/// ## Hash output consistency
/// Functions [hash_elements()](GriffinJive64_256::hash_elements), [merge()](GriffinJive64_256::merge), and
/// [merge_with_int()](GriffinJive64_256::merge_with_int) are not consistent. This is because the former
/// is instantiated with a sponge construction, while the latter use the Jive compression mode and
/// hence do not rely on the sponge construction.
///
/// In addition, [hash()](GriffinJive64_256::hash) function is not consistent with the functions mentioned
/// above. For example, if we take two field elements, serialize them to bytes and hash them using
/// [hash()](GriffinJive64_256::hash), the result will differ from the result obtained by hashing these
/// elements directly using [hash_elements()](GriffinJive64_256::hash_elements) function. The reason for
/// this difference is that [hash()](GriffinJive64_256::hash) function needs to be able to handle
/// arbitrary binary strings, which may or may not encode valid field elements - and thus,
/// deserialization procedure used by this function is different from the procedure used to
/// deserialize valid field elements.
///
/// Thus, if the underlying data consists of valid field elements, it might make more sense
/// to deserialize them into field elements and then hash them using
/// [hash_elements()](GriffinJive64_256::hash_elements) function rather then hashing the serialized bytes
/// using [hash()](GriffinJive64_256::hash) function.
pub struct GriffinJive64_256();
impl Hasher for GriffinJive64_256 {
type Digest = ElementDigest;
const COLLISION_RESISTANCE: u32 = 128;
fn hash(bytes: &[u8]) -> Self::Digest {
// compute the number of elements required to represent the string; we will be processing
// the string in 7-byte chunks, thus the number of elements will be equal to the number
// of such chunks (including a potential partial chunk at the end).
let num_elements = if bytes.len() % 7 == 0 {
bytes.len() / 7
} else {
bytes.len() / 7 + 1
};
// initialize state to all zeros, except for the first element of the capacity part, which
// is set to 1 if the number of elements is not a multiple of RATE_WIDTH.
let mut state = [BaseElement::ZERO; STATE_WIDTH];
if num_elements % RATE_WIDTH != 0 {
state[CAPACITY_RANGE.start] = BaseElement::ONE;
}
// break the string into 7-byte chunks, convert each chunk into a field element, and
// absorb the element into the rate portion of the state. we use 7-byte chunks because
// every 7-byte chunk is guaranteed to map to some field element.
let mut i = 0;
let mut buf = [0_u8; 8];
for (index, chunk) in bytes.chunks(7).enumerate() {
if index < num_elements - 1 {
buf[..7].copy_from_slice(chunk);
} else {
// if we are dealing with the last chunk, it may be smaller than 7 bytes long, so
// we need to handle it slightly differently. we also append a byte with value 1
// to the end of the string; this pads the string in such a way that adding
// trailing zeros results in different hash
let chunk_len = chunk.len();
buf = [0_u8; 8];
buf[..chunk_len].copy_from_slice(chunk);
buf[chunk_len] = 1;
}
// convert the bytes into a field element and absorb it into the rate portion of the
// state; if the rate is filled up, apply the Griffin permutation and start absorbing
// again from zero index.
state[RATE_RANGE.start + i] += BaseElement::new(u64::from_le_bytes(buf));
i += 1;
if i % RATE_WIDTH == 0 {
Self::apply_permutation(&mut state);
i = 0;
}
}
// if we absorbed some elements but didn't apply a permutation to them (would happen when
// the number of elements is not a multiple of RATE_WIDTH), apply a final permutation after
// padding by appending a 1 followed by as many 0 as necessary to make the input length a
// multiple of the RATE_WIDTH.
if i > 0 {
state[RATE_RANGE.start + i] = BaseElement::ONE;
i += 1;
while i != RATE_WIDTH {
state[RATE_RANGE.start + i] = BaseElement::ZERO;
i += 1;
}
Self::apply_permutation(&mut state);
}
// return the first 4 elements of the state as hash result
ElementDigest::new(state[DIGEST_RANGE].try_into().unwrap())
}
// We do not rely on the sponge construction to build our compression function. Instead, we use
// the Jive compression mode designed in https://eprint.iacr.org/2022/840.pdf.
fn merge(values: &[Self::Digest; 2]) -> Self::Digest {
// initialize the state by copying the digest elements into the state
let initial_state: [BaseElement; STATE_WIDTH] = Self::Digest::digests_as_elements(values)
.try_into()
.unwrap();
let mut state = initial_state;
// apply the Griffin permutation and apply the final Jive summation
Self::apply_permutation(&mut state);
Self::apply_jive_summation(&initial_state, &state)
}
// We do not rely on the sponge construction to build our compression function. Instead, we use
// the Jive compression mode designed in https://eprint.iacr.org/2022/840.pdf.
fn merge_with_int(seed: Self::Digest, value: u64) -> Self::Digest {
// initialize the state as follows:
// - seed is copied into the first 4 elements of the state.
// - if the value fits into a single field element, copy it into the fifth rate element
// and set the last state element to 5 (the number of elements to be hashed).
// - if the value doesn't fit into a single field element, split it into two field
// elements, copy them into state elements 5 and 6, and set the last state element
// to 6.
let mut state = [BaseElement::ZERO; STATE_WIDTH];
state[INPUT1_RANGE].copy_from_slice(seed.as_elements());
state[INPUT2_RANGE.start] = BaseElement::new(value);
if value < BaseElement::MODULUS {
state[INPUT2_RANGE.end - 1] = BaseElement::new(DIGEST_SIZE as u64 + 1);
} else {
state[INPUT2_RANGE.start + 1] = BaseElement::new(value / BaseElement::MODULUS);
state[INPUT2_RANGE.end - 1] = BaseElement::new(DIGEST_SIZE as u64 + 2);
}
let initial_state = state;
// apply the Griffin permutation and apply the final Jive summation
Self::apply_permutation(&mut state);
Self::apply_jive_summation(&initial_state, &state)
}
}
impl ElementHasher for GriffinJive64_256 {
type BaseField = BaseElement;
fn hash_elements<E: FieldElement<BaseField = Self::BaseField>>(elements: &[E]) -> Self::Digest {
// convert the elements into a list of base field elements
let elements = E::slice_as_base_elements(elements);
// initialize state to all zeros, except for the first element of the capacity part, which
// is set to 1 if the number of elements is not a multiple of RATE_WIDTH.
let mut state = [BaseElement::ZERO; STATE_WIDTH];
if elements.len() % RATE_WIDTH != 0 {
state[CAPACITY_RANGE.start] = BaseElement::ONE;
}
// absorb elements into the state one by one until the rate portion of the state is filled
// up; then apply the Griffin permutation and start absorbing again; repeat until all
// elements have been absorbed
let mut i = 0;
for &element in elements.iter() {
state[RATE_RANGE.start + i] += element;
i += 1;
if i % RATE_WIDTH == 0 {
Self::apply_permutation(&mut state);
i = 0;
}
}
// if we absorbed some elements but didn't apply a permutation to them (would happen when
// the number of elements is not a multiple of RATE_WIDTH), apply a final permutation after
// padding by appending a 1 followed by as many 0 as necessary to make the input length a
// multiple of the RATE_WIDTH.
if i > 0 {
state[RATE_RANGE.start + i] = BaseElement::ONE;
i += 1;
while i != RATE_WIDTH {
state[RATE_RANGE.start + i] = BaseElement::ZERO;
i += 1;
}
Self::apply_permutation(&mut state);
}
// return the first 4 elements of the state as hash result
ElementDigest::new(state[DIGEST_RANGE].try_into().unwrap())
}
}
// HASH FUNCTION IMPLEMENTATION
// ================================================================================================
impl GriffinJive64_256 {
// CONSTANTS
// --------------------------------------------------------------------------------------------
/// The number of rounds is set to 7 to target 128-bit security level with 40% security margin.
pub const NUM_ROUNDS: usize = NUM_ROUNDS;
/// Sponge state is set to 8 field elements or 64 bytes; 4 elements are reserved for rate and
/// the remaining 4 elements are reserved for capacity.
pub const STATE_WIDTH: usize = STATE_WIDTH;
/// The rate portion of the state is located in elements 4 through 7 (inclusive).
pub const RATE_RANGE: Range<usize> = RATE_RANGE;
/// The capacity portion of the state is located in elements 0, 1, 2, and 3.
pub const CAPACITY_RANGE: Range<usize> = CAPACITY_RANGE;
/// The output of the hash function can be read from state elements 4, 5, 6, and 7.
pub const DIGEST_RANGE: Range<usize> = DIGEST_RANGE;
/// MDS matrix used for computing the linear layer in a Griffin round.
pub const MDS: [[BaseElement; STATE_WIDTH]; STATE_WIDTH] = MDS;
/// Round constants added to the hasher state in the first half of the Griffin round.
pub const ARK: [[BaseElement; STATE_WIDTH]; NUM_ROUNDS - 1] = ARK;
/// Constants alpha_i for Griffin non-linear layer.
pub(crate) const ALPHA: [BaseElement; STATE_WIDTH - 2] = [
BaseElement::new(6303398607380181568),
BaseElement::new(12606797214760363136),
BaseElement::new(463451752725960383),
BaseElement::new(6766850360106141951),
BaseElement::new(13070248967486323519),
BaseElement::new(926903505451920766),
];
/// Constants beta_i for Griffin non-linear layer.
pub(crate) const BETA: [BaseElement; STATE_WIDTH - 2] = [
BaseElement::new(5698628486727258041),
BaseElement::new(4347769877494447843),
BaseElement::new(14394168241716153727),
BaseElement::new(17391079509977791372),
BaseElement::new(13338503682279360778),
BaseElement::new(2236440758620861945),
];
// GRIFFIN PERMUTATION
// --------------------------------------------------------------------------------------------
/// Applies Griffin permutation to the provided state.
pub fn apply_permutation(state: &mut [BaseElement; STATE_WIDTH]) {
for i in 0..NUM_ROUNDS - 1 {
Self::apply_round(state, i);
}
Self::apply_non_linear(state);
Self::apply_linear(state);
}
/// Griffin round function.
#[inline(always)]
pub fn apply_round(state: &mut [BaseElement; STATE_WIDTH], round: usize) {
Self::apply_non_linear(state);
Self::apply_linear(state);
Self::add_constants(state, &ARK[round]);
}
#[inline(always)]
pub fn apply_jive_summation(
initial_state: &[BaseElement; STATE_WIDTH],
final_state: &[BaseElement; STATE_WIDTH],
) -> ElementDigest {
let mut result = [BaseElement::ZERO; DIGEST_SIZE];
for (i, r) in result.iter_mut().enumerate() {
*r = initial_state[i]
+ initial_state[DIGEST_SIZE + i]
+ final_state[i]
+ final_state[DIGEST_SIZE + i];
}
ElementDigest::new(result)
}
// HELPER FUNCTIONS
// --------------------------------------------------------------------------------------------
#[inline(always)]
/// Applies the Griffin non-linear layer
/// to the current hash state.
fn apply_non_linear(state: &mut [BaseElement; STATE_WIDTH]) {
pow_inv_d(&mut state[0]);
pow_d(&mut state[1]);
let l2 = Self::linear_function(2, state[0], state[1], BaseElement::ZERO);
state[2] *= l2.square() + Self::ALPHA[0] * l2 + Self::BETA[0];
let l3 = Self::linear_function(3, state[0], state[1], state[2]);
state[3] *= l3.square() + Self::ALPHA[1] * l3 + Self::BETA[1];
let l4 = Self::linear_function(4, state[0], state[1], state[3]);
state[4] *= l4.square() + Self::ALPHA[2] * l4 + Self::BETA[2];
let l5 = Self::linear_function(5, state[0], state[1], state[4]);
state[5] *= l5.square() + Self::ALPHA[3] * l5 + Self::BETA[3];
let l6 = Self::linear_function(6, state[0], state[1], state[5]);
state[6] *= l6.square() + Self::ALPHA[4] * l6 + Self::BETA[4];
let l7 = Self::linear_function(7, state[0], state[1], state[6]);
state[7] *= l7.square() + Self::ALPHA[5] * l7 + Self::BETA[5];
}
#[inline(always)]
fn apply_linear(state: &mut [BaseElement; STATE_WIDTH]) {
mds_multiply(state)
}
#[inline(always)]
fn add_constants(state: &mut [BaseElement; STATE_WIDTH], ark: &[BaseElement; STATE_WIDTH]) {
state.iter_mut().zip(ark).for_each(|(s, &k)| *s += k);
}
#[inline(always)]
fn linear_function(
round: u64,
z0: BaseElement,
z1: BaseElement,
z2: BaseElement,
) -> BaseElement {
let (r0, r1, r2) = (z0.inner() as u128, z1.inner() as u128, z2.inner() as u128);
let r = (round - 1) as u128 * r0 + r1 + r2;
let s_hi = (r >> 64) as u64;
let s_lo = r as u64;
let z = (s_hi << 32) - s_hi;
let (res, over) = s_lo.overflowing_add(z);
BaseElement::from_mont(res.wrapping_add(0u32.wrapping_sub(over as u32) as u64))
}
}
#[inline(always)]
fn pow_d(x: &mut BaseElement) {
*x = x.exp7();
}
#[inline(always)]
fn pow_inv_d(x: &mut BaseElement) {
// compute base^10540996611094048183 using 72 multiplications
// 10540996611094048183 = b1001001001001001001001001001000110110110110110110110110110110111
// compute base^10
let t1 = x.square();
// compute base^100
let t2 = t1.square();
// compute base^100100
let t3 = square_assign_and_multiply::<3>(t2, t2);
// compute base^100100100100
let t4 = square_assign_and_multiply::<6>(t3, t3);
// compute base^100100100100100100100100
let t5 = square_assign_and_multiply::<12>(t4, t4);
// compute base^100100100100100100100100100100
let t6 = square_assign_and_multiply::<6>(t5, t3);
// compute base^1001001001001001001001001001000100100100100100100100100100100
let t7 = square_assign_and_multiply::<31>(t6, t6);
// compute base^1001001001001001001001001001000110110110110110110110110110110111
let a = (t7.square() * t6).square().square();
let b = t1 * t2 * *x;
*x = a * b;
}
#[inline(always)]
/// Squares an element M times, then multiplies it with tail.
fn square_assign_and_multiply<const M: usize>(base: BaseElement, tail: BaseElement) -> BaseElement {
let mut result = base;
for _ in 0..M {
result = result.square();
}
result * tail
}
// MDS
// ================================================================================================
/// Griffin MDS matrix
const MDS: [[BaseElement; STATE_WIDTH]; STATE_WIDTH] = [
[
BaseElement::new(23),
BaseElement::new(8),
BaseElement::new(13),
BaseElement::new(10),
BaseElement::new(7),
BaseElement::new(6),
BaseElement::new(21),
BaseElement::new(8),
],
[
BaseElement::new(8),
BaseElement::new(23),
BaseElement::new(8),
BaseElement::new(13),
BaseElement::new(10),
BaseElement::new(7),
BaseElement::new(6),
BaseElement::new(21),
],
[
BaseElement::new(21),
BaseElement::new(8),
BaseElement::new(23),
BaseElement::new(8),
BaseElement::new(13),
BaseElement::new(10),
BaseElement::new(7),
BaseElement::new(6),
],
[
BaseElement::new(6),
BaseElement::new(21),
BaseElement::new(8),
BaseElement::new(23),
BaseElement::new(8),
BaseElement::new(13),
BaseElement::new(10),
BaseElement::new(7),
],
[
BaseElement::new(7),
BaseElement::new(6),
BaseElement::new(21),
BaseElement::new(8),
BaseElement::new(23),
BaseElement::new(8),
BaseElement::new(13),
BaseElement::new(10),
],
[
BaseElement::new(10),
BaseElement::new(7),
BaseElement::new(6),
BaseElement::new(21),
BaseElement::new(8),
BaseElement::new(23),
BaseElement::new(8),
BaseElement::new(13),
],
[
BaseElement::new(13),
BaseElement::new(10),
BaseElement::new(7),
BaseElement::new(6),
BaseElement::new(21),
BaseElement::new(8),
BaseElement::new(23),
BaseElement::new(8),
],
[
BaseElement::new(8),
BaseElement::new(13),
BaseElement::new(10),
BaseElement::new(7),
BaseElement::new(6),
BaseElement::new(21),
BaseElement::new(8),
BaseElement::new(23),
],
];
/// Griffin Inverse MDS matrix
#[cfg(test)]
const INV_MDS: [[BaseElement; STATE_WIDTH]; STATE_WIDTH] = [
[
BaseElement::new(10671399028204489528),
BaseElement::new(15436289366139187412),
BaseElement::new(4624329233769728317),
BaseElement::new(18200084821960740316),
BaseElement::new(8736112961492104393),
BaseElement::new(1953609990965186349),
BaseElement::new(12477339747250042564),
BaseElement::new(1495657543820456485),
],
[
BaseElement::new(1495657543820456485),
BaseElement::new(10671399028204489528),
BaseElement::new(15436289366139187412),
BaseElement::new(4624329233769728317),
BaseElement::new(18200084821960740316),
BaseElement::new(8736112961492104393),
BaseElement::new(1953609990965186349),
BaseElement::new(12477339747250042564),
],
[
BaseElement::new(12477339747250042564),
BaseElement::new(1495657543820456485),
BaseElement::new(10671399028204489528),
BaseElement::new(15436289366139187412),
BaseElement::new(4624329233769728317),
BaseElement::new(18200084821960740316),
BaseElement::new(8736112961492104393),
BaseElement::new(1953609990965186349),
],
[
BaseElement::new(1953609990965186349),
BaseElement::new(12477339747250042564),
BaseElement::new(1495657543820456485),
BaseElement::new(10671399028204489528),
BaseElement::new(15436289366139187412),
BaseElement::new(4624329233769728317),
BaseElement::new(18200084821960740316),
BaseElement::new(8736112961492104393),
],
[
BaseElement::new(8736112961492104393),
BaseElement::new(1953609990965186349),
BaseElement::new(12477339747250042564),
BaseElement::new(1495657543820456485),
BaseElement::new(10671399028204489528),
BaseElement::new(15436289366139187412),
BaseElement::new(4624329233769728317),
BaseElement::new(18200084821960740316),
],
[
BaseElement::new(18200084821960740316),
BaseElement::new(8736112961492104393),
BaseElement::new(1953609990965186349),
BaseElement::new(12477339747250042564),
BaseElement::new(1495657543820456485),
BaseElement::new(10671399028204489528),
BaseElement::new(15436289366139187412),
BaseElement::new(4624329233769728317),
],
[
BaseElement::new(4624329233769728317),
BaseElement::new(18200084821960740316),
BaseElement::new(8736112961492104393),
BaseElement::new(1953609990965186349),
BaseElement::new(12477339747250042564),
BaseElement::new(1495657543820456485),
BaseElement::new(10671399028204489528),
BaseElement::new(15436289366139187412),
],
[
BaseElement::new(15436289366139187412),
BaseElement::new(4624329233769728317),
BaseElement::new(18200084821960740316),
BaseElement::new(8736112961492104393),
BaseElement::new(1953609990965186349),
BaseElement::new(12477339747250042564),
BaseElement::new(1495657543820456485),
BaseElement::new(10671399028204489528),
],
];
// ROUND CONSTANTS
// ================================================================================================
/// Griffin round constants;
const ARK: [[BaseElement; STATE_WIDTH]; NUM_ROUNDS - 1] = [
[
BaseElement::new(9692712401870945221),
BaseElement::new(7618007584389424767),
BaseElement::new(5248032629877155397),
BaseElement::new(3331263627507477698),
BaseElement::new(860199187432911550),
BaseElement::new(10360526140302824670),
BaseElement::new(5014858186237911359),
BaseElement::new(4161019260461204222),
],
[
BaseElement::new(2649891723669882704),
BaseElement::new(15035697086627576083),
BaseElement::new(14140087988207356741),
BaseElement::new(357780579603925138),
BaseElement::new(273712483418536090),
BaseElement::new(348552596175072640),
BaseElement::new(11116926243792475367),
BaseElement::new(2475357435469270767),
],
[
BaseElement::new(9513699262061178678),
BaseElement::new(11735848814479196467),
BaseElement::new(12888397717055708631),
BaseElement::new(15194236579723079985),
BaseElement::new(14734897209064082180),
BaseElement::new(9352307275330595094),
BaseElement::new(2536293522055086772),
BaseElement::new(1551701365424645656),
],
[
BaseElement::new(17180574791560887028),
BaseElement::new(10973179380721509279),
BaseElement::new(15451549433162538377),
BaseElement::new(11230437049044589131),
BaseElement::new(14416448585168854586),
BaseElement::new(13520950449774622599),
BaseElement::new(14110026253178816443),
BaseElement::new(7562226163074683487),
],
[
BaseElement::new(15625584526294513461),
BaseElement::new(12868717640985007163),
BaseElement::new(5045176603305276542),
BaseElement::new(6821445918259551845),
BaseElement::new(15049718154108882541),
BaseElement::new(676731535772312475),
BaseElement::new(14779363889066167393),
BaseElement::new(17108914943169063073),
],
[
BaseElement::new(17529530613938644968),
BaseElement::new(13801329800663243071),
BaseElement::new(12666329335088484031),
BaseElement::new(10289051774796875319),
BaseElement::new(46795987162557096),
BaseElement::new(8590445841426612555),
BaseElement::new(7174111149249058757),
BaseElement::new(5820086182616968416),
],
];