mirror of
https://github.com/logos-storage/rust-poseidon-bn254-pure.git
synced 2026-08-11 04:13:11 +00:00
implement all Poseidon2 variations (+ tests) in the Rust crate
This commit is contained in:
parent
f4ba5d09b5
commit
62d3997591
20
README.md
20
README.md
@ -85,8 +85,14 @@ Some approximate benchmark numbers below.
|
||||
|
||||
On RV32IM (the primary target as of now), we have approximately the following cycle counts:
|
||||
|
||||
- Poseidon: about 900k cycles for a single `t=3` permutation
|
||||
- Poseidon2: about 350k cycles for a single `t=3` permutation
|
||||
- Poseidon:
|
||||
- about 615k cycles for a single `t=2` permutation
|
||||
- about 915k cycles for a `t=3` permutation
|
||||
- about 1220k cycles for a `t=4` permutation
|
||||
- Poseidon2:
|
||||
- about 325k cycles for a single `t=2` permutation
|
||||
- about 375k cycles for a `t=3` permutation
|
||||
- about 7705 cycles for a `t=4` permutation
|
||||
|
||||
Note: Poseidon is about 2.5x slower, simply because there are about 2.5x more
|
||||
field multiplications involved (which absolutely dominate the runtime).
|
||||
@ -97,8 +103,14 @@ On modern 64-bit CPU-s, the 64-bit version would be preferred (TODO: implement i
|
||||
|
||||
32 bit version, running on an M2 macbook pro (single threaded):
|
||||
|
||||
- Poseidon: 320 msec for 10,000 `t=3` permutations
|
||||
- Poseidon2: 140 msec for 10,000 `t=3` permutations
|
||||
- Poseidon:
|
||||
- 214 msec for 10,000 `t=2` permutations
|
||||
- 314 msec for 10,000 `t=3` permutations
|
||||
- 414 msec for 10,000 `t=4` permutations
|
||||
- Poseidon2:
|
||||
- 124 msec for 10,000 `t=2` permutations
|
||||
- 142 msec for 10,000 `t=3` permutations
|
||||
- 271 msec for 10,000 `t=4` permutations
|
||||
|
||||
### TODO
|
||||
|
||||
|
||||
@ -3,51 +3,70 @@ use criterion::{criterion_group, criterion_main, Criterion};
|
||||
use std::hint::{black_box};
|
||||
|
||||
use rust_poseidon_bn254_pure::bn254::field::*;
|
||||
use rust_poseidon_bn254_pure::poseidon;
|
||||
use rust_poseidon_bn254_pure::poseidon2;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
type Triple = [Felt; 3];
|
||||
|
||||
fn initial_triple() -> Triple {
|
||||
[ Felt::from_u32(0)
|
||||
, Felt::from_u32(1)
|
||||
, Felt::from_u32(2)
|
||||
]
|
||||
}
|
||||
|
||||
fn iterate_poseidon1(n: usize) -> Triple {
|
||||
let mut state: Triple = initial_triple();
|
||||
for _i in 0..n {
|
||||
state = poseidon::permute::<3>(state);
|
||||
fn initial_state<const T: usize>() -> [Felt; T] {
|
||||
let mut xs: [Felt; T] = [Default::default(); T];
|
||||
for i in 0..T {
|
||||
xs[i] = Felt::from_u32(i as u32);
|
||||
}
|
||||
state
|
||||
xs
|
||||
}
|
||||
|
||||
fn iterate_poseidon2(n: usize) -> Triple {
|
||||
let mut state: Triple = initial_triple();
|
||||
for _i in 0..n {
|
||||
state = poseidon2::permute(state);
|
||||
mod v1 {
|
||||
use super::*;
|
||||
use rust_poseidon_bn254_pure::poseidon::*;
|
||||
|
||||
fn iterate_poseidon1<const T: usize>(n: usize) -> [Felt; T] where Params: PoseidonParams<T> {
|
||||
let mut state: [Felt; T] = initial_state::<T>();
|
||||
for _i in 0..n {
|
||||
state = permute::<T>(state);
|
||||
}
|
||||
state
|
||||
}
|
||||
state
|
||||
|
||||
pub fn bench_iterated_poseidon1<const T: usize>(c: &mut Criterion, n: usize) where Params: PoseidonParams<T> {
|
||||
let msg = format!("Poseidon1 permutation w/ state width t={} iterated {} times", T, n);
|
||||
c.bench_function(&msg, |b| b.iter(|| iterate_poseidon1::<T>(black_box(n)) ));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fn bench_iterated_poseidon1(c: &mut Criterion , n: usize) {
|
||||
let msg = format!("Poseidon1 permutation iterated {} times", n);
|
||||
c.bench_function(&msg, |b| b.iter(|| iterate_poseidon1(black_box(n)) ));
|
||||
}
|
||||
|
||||
fn bench_iterated_poseidon2(c: &mut Criterion , n: usize) {
|
||||
let msg = format!("Poseidon2 permutation iterated {} times", n);
|
||||
c.bench_function(&msg, |b| b.iter(|| iterate_poseidon2(black_box(n)) ));
|
||||
mod v2 {
|
||||
use super::*;
|
||||
use rust_poseidon_bn254_pure::poseidon2::old::*;
|
||||
|
||||
fn iterate_poseidon2<const T: usize>(n: usize) -> [Felt; T] where Params: Poseidon2Params<false,T> {
|
||||
let mut state: [Felt; T] = initial_state::<T>();
|
||||
for _i in 0..n {
|
||||
state = permute::<T>(state);
|
||||
}
|
||||
state
|
||||
}
|
||||
|
||||
pub fn bench_iterated_poseidon2<const T: usize>(c: &mut Criterion, n: usize) where Params: Poseidon2Params<false,T> {
|
||||
let msg = format!("Poseidon2 permutation w/ state width t={} iterated {} times", T, n);
|
||||
c.bench_function(&msg, |b| b.iter(|| iterate_poseidon2::<T>(black_box(n)) ));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
fn bench_permutations(c: &mut Criterion) {
|
||||
bench_iterated_poseidon1(c, 10000);
|
||||
bench_iterated_poseidon2(c, 10000);
|
||||
|
||||
v1::bench_iterated_poseidon1::<2> (c, 10000);
|
||||
v1::bench_iterated_poseidon1::<3> (c, 10000);
|
||||
v1::bench_iterated_poseidon1::<4> (c, 10000);
|
||||
|
||||
v2::bench_iterated_poseidon2::<2> (c, 10000);
|
||||
v2::bench_iterated_poseidon2::<3> (c, 10000);
|
||||
v2::bench_iterated_poseidon2::<4> (c, 10000);
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@ -89,3 +89,14 @@ toMontString32 :: Integer -> String
|
||||
toMontString32 = showWords32 . toWords32 . toMontgomery
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
integerToRust32 :: Integer -> String
|
||||
integerToRust32 x = "Mont::unsafe_make( " ++ toMontString32 x ++ " )"
|
||||
|
||||
listToRust32 :: [Integer] -> [String]
|
||||
listToRust32 xs = zipWith f prefixes xs ++ [close] where
|
||||
f p x = p ++ integerToRust32 x
|
||||
prefixes = " [ " : repeat " , "
|
||||
close = " ];"
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
@ -132,14 +132,32 @@ flipFoldl :: (b -> a -> b) -> [a] -> b -> b
|
||||
flipFoldl f ys x = foldl' f x ys
|
||||
|
||||
permute :: Instance -> State -> State
|
||||
permute which input = output where
|
||||
extMDS = externalMDS which
|
||||
intDiag = internalDiag which
|
||||
( rcIni , rcMiddle , rcFinal ) = splitRoundConsts (roundConsts which)
|
||||
output = flipFoldl (externalRound extMDS ) rcFinal
|
||||
$ flipFoldl (internalRound intDiag) rcMiddle
|
||||
$ flipFoldl (externalRound extMDS ) rcIni
|
||||
$ mdsMul extMDS
|
||||
$ input
|
||||
permute which@(MkInstance width paramSet) input
|
||||
| length input /= fromInteger (fromWidth width) = error "permute: invalid input dimensions"
|
||||
| otherwise = output
|
||||
where
|
||||
extMDS = externalMDS which
|
||||
intDiag = internalDiag which
|
||||
( rcIni , rcMiddle , rcFinal ) = splitRoundConsts (roundConsts which)
|
||||
output = flipFoldl (externalRound extMDS ) rcFinal
|
||||
$ flipFoldl (internalRound intDiag) rcMiddle
|
||||
$ flipFoldl (externalRound extMDS ) rcIni
|
||||
$ mdsMul extMDS
|
||||
$ input
|
||||
|
||||
compress :: Instance -> [F] -> F
|
||||
compress which@(MkInstance width _paramset) input
|
||||
| length input /= fromInteger (fromWidth width - 1) = error "compress: invalid input dimensions"
|
||||
| otherwise = head (permute which $ input ++ [0])
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
compressionTestCases :: IO ()
|
||||
compressionTestCases = forM_ allInstances $ \which@(MkInstance width _paramset) -> do
|
||||
putStrLn "-----------------------"
|
||||
putStrLn $ "instance = " ++ show which
|
||||
let w = fromWidth width
|
||||
let input = map (*111) [1..w-1] :: [Integer]
|
||||
putStrLn $ "input = " ++ show input
|
||||
let hash = compress which (map toF input)
|
||||
putStrLn $ "hash = " ++ show hash
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
|
||||
-- script to convert the round constants to the desired format
|
||||
-- script to convert circomlib's round constants to the desired format
|
||||
|
||||
module Main where
|
||||
|
||||
@ -21,17 +21,6 @@ tgtDir = "out"
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
integerToRust32 :: Integer -> String
|
||||
integerToRust32 x = "Mont::unsafe_make( " ++ toMontString32 x ++ " )"
|
||||
|
||||
listToRust32 :: [Integer] -> [String]
|
||||
listToRust32 xs = zipWith f prefixes xs ++ [close] where
|
||||
f p x = p ++ integerToRust32 x
|
||||
prefixes = " [ " : repeat " , "
|
||||
close = " ];"
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
const_C :: Width -> [String]
|
||||
const_C w = comment : def : ls where
|
||||
comment = "// round constants (t for external, 1 for internal rounds; flattened)"
|
||||
126
constants/haskell/convert_horizen.hs
Normal file
126
constants/haskell/convert_horizen.hs
Normal file
@ -0,0 +1,126 @@
|
||||
|
||||
-- script to convert horizelabs' round constants to the desired format
|
||||
|
||||
module Main where
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
import Data.List
|
||||
import Control.Monad
|
||||
|
||||
import System.FilePath
|
||||
import System.Directory
|
||||
|
||||
import Field
|
||||
import Reference.Poseidon2
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
tgtDirRoot :: FilePath
|
||||
tgtDirRoot = "out"
|
||||
|
||||
tgtDirOld, tgtDirNew :: FilePath
|
||||
tgtDirOld = tgtDirRoot </> "old"
|
||||
tgtDirNew = tgtDirRoot </> "new"
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
const_init :: Instance -> [String]
|
||||
const_init which = comment : def : ls where
|
||||
comment = "// initial (external) round constants (flattened)"
|
||||
def = "pub const INITIAL: [Mont; " ++ show len ++ "] = "
|
||||
xs = map fromF $ concat ini
|
||||
len = length xs
|
||||
ls = listToRust32 xs
|
||||
(ini,_middle,_final) = splitRoundConsts (roundConsts which)
|
||||
|
||||
const_middle :: Instance -> [String]
|
||||
const_middle which = comment : def : ls where
|
||||
comment = "// middle (internal) round constants"
|
||||
def = "pub const INTERNAL: [Mont; " ++ show len ++ "] = "
|
||||
xs = map fromF middle
|
||||
len = length xs
|
||||
ls = listToRust32 xs
|
||||
(_ini,middle,_final) = splitRoundConsts (roundConsts which)
|
||||
|
||||
const_final :: Instance -> [String]
|
||||
const_final which = comment : def : ls where
|
||||
comment = "// final (external) round constants (flattened)"
|
||||
def = "pub const FINAL: [Mont; " ++ show len ++ "] = "
|
||||
xs = map fromF $ concat final
|
||||
len = length xs
|
||||
ls = listToRust32 xs
|
||||
(_ini,_middle,final) = splitRoundConsts (roundConsts which)
|
||||
|
||||
const_diag :: Instance -> [String]
|
||||
const_diag which = comment : def : ls where
|
||||
comment = "// diagonal for the internal mixing matrix"
|
||||
def = "pub const DIAGONAL: [Mont; " ++ show len ++ "] = "
|
||||
xs = map fromF $ internalDiag which
|
||||
len = length xs
|
||||
ls = listToRust32 xs
|
||||
|
||||
const_kat :: Instance -> [String]
|
||||
const_kat which = comment : def : ls where
|
||||
comment = "// known answer test"
|
||||
def = "pub const KAT_MONT: [Mont; " ++ show len ++ "] = "
|
||||
xs = map fromF $ kat which
|
||||
len = length xs
|
||||
ls = listToRust32 xs
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
showWidth :: Instance -> String
|
||||
showWidth (MkInstance width paramset) = "t = " ++ show (fromWidth width)
|
||||
|
||||
showParamSet :: Instance -> String
|
||||
showParamSet (MkInstance width paramset) = case paramset of
|
||||
OldParams -> "\"old\" set of constants"
|
||||
NewParams -> "\"new\" set of constants"
|
||||
|
||||
showInstance :: Instance -> String
|
||||
showInstance which = "`" ++ showWidth which ++ "` (" ++ showParamSet which ++ ")"
|
||||
|
||||
header :: Instance -> [String]
|
||||
header which =
|
||||
[ ""
|
||||
, "// HorizenLabs' Poseidon2 constants for " ++ showInstance which
|
||||
, ""
|
||||
, "use crate::bn254::montgomery::*;"
|
||||
, ""
|
||||
]
|
||||
|
||||
sep :: [String]
|
||||
sep =
|
||||
[ ""
|
||||
, "//------------------------------------------------------------------------------"
|
||||
, ""
|
||||
]
|
||||
|
||||
rustSource :: Instance -> String
|
||||
rustSource t = unlines $ concat
|
||||
[ header t , sep
|
||||
, const_diag t , sep
|
||||
, const_init t , sep
|
||||
, const_middle t , sep
|
||||
, const_final t , sep
|
||||
, const_kat t , sep
|
||||
]
|
||||
|
||||
writeRustConstants :: Instance -> IO ()
|
||||
writeRustConstants which@(MkInstance width paramset) = do
|
||||
let fname = "t" ++ show (fromWidth width) ++ ".rs"
|
||||
let path = case paramset of
|
||||
OldParams -> tgtDirOld </> fname
|
||||
NewParams -> tgtDirNew </> fname
|
||||
print path
|
||||
writeFile path (rustSource which)
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
createDirectoryIfMissing False tgtDirRoot
|
||||
createDirectoryIfMissing False tgtDirOld
|
||||
createDirectoryIfMissing False tgtDirNew
|
||||
forM_ allInstances $ \inst -> writeRustConstants inst
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
@ -115,7 +115,7 @@ fn main() {
|
||||
println!("");
|
||||
|
||||
let input = [ Felt::from_u32(0) , Felt::from_u32(1) , Felt::from_u32(2) ];
|
||||
let output = poseidon2::permute( input );
|
||||
let output = poseidon2::old::permute( input );
|
||||
|
||||
println!("x = {}", input[0] );
|
||||
println!("y = {}", input[1] );
|
||||
@ -140,7 +140,7 @@ fn main() {
|
||||
let now = Instant::now();
|
||||
let mut state: [Felt; 3] = input.clone();
|
||||
for _i in 0..10000 {
|
||||
state = poseidon2::permute(state);
|
||||
state = poseidon2::old::permute(state);
|
||||
}
|
||||
|
||||
// expected output:
|
||||
|
||||
@ -6,7 +6,7 @@ fn main() {
|
||||
|
||||
println!("iterating Poseidon2 twenty times");
|
||||
|
||||
let input = [ Felt::from_u32(0) , Felt::from_u32(1) , Felt::from_u32(2) ];
|
||||
let input = poseidon2::aux::kat_input::<3>();
|
||||
|
||||
println!("x = {}", input[0] );
|
||||
println!("y = {}", input[1] );
|
||||
@ -14,7 +14,7 @@ fn main() {
|
||||
|
||||
let mut state: [Felt; 3] = input.clone();
|
||||
for _i in 0..20 {
|
||||
state = poseidon2::permute(state);
|
||||
state = poseidon2::old::permute(state);
|
||||
}
|
||||
println!("x' = {}", state[0] );
|
||||
println!("y' = {}", state[1] );
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
|
||||
#![allow(incomplete_features)]
|
||||
#![allow(stable_features)]
|
||||
|
||||
#![feature(bigint_helper_methods)]
|
||||
#![feature(generic_const_exprs)]
|
||||
#![feature(random)]
|
||||
#![feature(bigint_helper_methods)]
|
||||
#![feature(trait_alias)]
|
||||
#![feature(generic_const_exprs)]
|
||||
#![feature(unchecked_shifts)]
|
||||
|
||||
pub mod bn254;
|
||||
|
||||
@ -9,5 +9,6 @@ pub use permutation::hash4;
|
||||
|
||||
pub use permutation::compress;
|
||||
|
||||
pub use permutation::{Params,PoseidonParams};
|
||||
pub use permutation::permute;
|
||||
pub use permutation::permute_mont;
|
||||
3
src/poseidon2/constants/mod.rs
Normal file
3
src/poseidon2/constants/mod.rs
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
pub mod old;
|
||||
pub mod new;
|
||||
4
src/poseidon2/constants/new/mod.rs
Normal file
4
src/poseidon2/constants/new/mod.rs
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
pub mod t2;
|
||||
pub mod t3;
|
||||
pub mod t4;
|
||||
114
src/poseidon2/constants/new/t2.rs
Normal file
114
src/poseidon2/constants/new/t2.rs
Normal file
@ -0,0 +1,114 @@
|
||||
|
||||
// HorizenLabs' Poseidon2 constants for `t = 2` ("new" set of constants)
|
||||
|
||||
use crate::bn254::montgomery::*;
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// diagonal for the internal mixing matrix
|
||||
pub const DIAGONAL: [Mont; 2] =
|
||||
[ Mont::unsafe_make( [ 0x4ffffffb , 0xac96341c , 0x9f60cd29 , 0x36fc7695 , 0x7879462e , 0x666ea36f , 0x9a07df2f , 0x0e0a77c1 ] )
|
||||
, Mont::unsafe_make( [ 0x9ffffff6 , 0x592c6838 , 0x3ec19a53 , 0x6df8ed2b , 0xf0f28c5c , 0xccdd46de , 0x340fbe5e , 0x1c14ef83 ] )
|
||||
];
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// initial (external) round constants (flattened)
|
||||
pub const INITIAL: [Mont; 8] =
|
||||
[ Mont::unsafe_make( [ 0xc58aca67 , 0xa96c453d , 0x19a6fa1b , 0x73eb0f43 , 0x02cfebe6 , 0xc1584c49 , 0xab003c81 , 0x0258feae ] )
|
||||
, Mont::unsafe_make( [ 0x883214ee , 0x999f128f , 0x44476181 , 0x3812d562 , 0x1a60e735 , 0xf1c71359 , 0xed432b39 , 0x1d29e209 ] )
|
||||
, Mont::unsafe_make( [ 0x1f9886f9 , 0x10245a46 , 0xa4af9cd7 , 0xc1f6a382 , 0x7be4216c , 0x43dc54de , 0x7782a71d , 0x08dde778 ] )
|
||||
, Mont::unsafe_make( [ 0xcfcc4182 , 0x86d4b4df , 0x4bb31793 , 0xb39eadc2 , 0xaa7b0c79 , 0xf2eb1492 , 0x12efc7fc , 0x14adb8ab ] )
|
||||
, Mont::unsafe_make( [ 0x239d7f99 , 0x5ac9777b , 0x6b10a565 , 0x2de9df1a , 0x052bad6b , 0x0fbbf650 , 0xfdd4cd35 , 0x1d9e1fcd ] )
|
||||
, Mont::unsafe_make( [ 0x5edf14ab , 0x61010186 , 0xe968ec10 , 0x10cc90a9 , 0x05fc111a , 0xbc3715a2 , 0x0f67d489 , 0x2f07f1e2 ] )
|
||||
, Mont::unsafe_make( [ 0xf159c12e , 0xd1b7a8a6 , 0x680a4228 , 0x36243b2a , 0xc6a8e4a8 , 0x20d439ce , 0x13fc8cef , 0x228c4675 ] )
|
||||
, Mont::unsafe_make( [ 0x6e65a009 , 0xd78a36ba , 0x400613f7 , 0x27b2c19d , 0x61a94f58 , 0xb3eba825 , 0x266420ad , 0x1a07ef8d ] )
|
||||
];
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// middle (internal) round constants
|
||||
pub const INTERNAL: [Mont; 56] =
|
||||
[ Mont::unsafe_make( [ 0x30553dfe , 0x8099c7d9 , 0x077c15b7 , 0x87c661d6 , 0x76bd32d3 , 0x5a5ac36a , 0x793f840c , 0x27889e1d ] )
|
||||
, Mont::unsafe_make( [ 0x439e8c4b , 0x29388f35 , 0xa45f0bbb , 0x42a07b4d , 0xb6611e22 , 0x411b6d19 , 0x46a04c15 , 0x0a6d9207 ] )
|
||||
, Mont::unsafe_make( [ 0x27534ec9 , 0x2d7e1c10 , 0x95ff74c4 , 0xd55601d2 , 0x0721d217 , 0xb43d0071 , 0x8ae93cd2 , 0x012686ab ] )
|
||||
, Mont::unsafe_make( [ 0x31841db1 , 0xa489be9a , 0x851ee28b , 0xcfe42b63 , 0x698a5272 , 0x78a78fff , 0x2de332a2 , 0x156e33ea ] )
|
||||
, Mont::unsafe_make( [ 0x2d84bd84 , 0x2b52a717 , 0x823d04f8 , 0xc37eac07 , 0x02284e03 , 0x2dd4d106 , 0x0ceea4f1 , 0x291941dd ] )
|
||||
, Mont::unsafe_make( [ 0x48aa3564 , 0x2d132ca9 , 0xa0f323c9 , 0x0d69b2b0 , 0xe5ac170c , 0xbd135b98 , 0x78df7294 , 0x2eb17bec ] )
|
||||
, Mont::unsafe_make( [ 0xe5174737 , 0xb27b508a , 0x6f1891b5 , 0xed83bd8e , 0xbdc159b6 , 0x9fff519a , 0xda500d5c , 0x18accd26 ] )
|
||||
, Mont::unsafe_make( [ 0xe9789115 , 0x72f41170 , 0x46c3b143 , 0x97b50e3d , 0xbe4cd18e , 0xd3a82a78 , 0xa0b59e10 , 0x0d135f73 ] )
|
||||
, Mont::unsafe_make( [ 0x8475e2d7 , 0xf8f81316 , 0x8900dd99 , 0xac872914 , 0x3ad542b9 , 0x47c245f7 , 0xc86c4bc5 , 0x0d4eaa0c ] )
|
||||
, Mont::unsafe_make( [ 0x61b508a8 , 0xf0eb00af , 0x804e5816 , 0x1d8ef8cd , 0x67629878 , 0xff7ddf43 , 0x8ed0ac37 , 0x2bca06cf ] )
|
||||
, Mont::unsafe_make( [ 0x3d19de16 , 0xca6ad228 , 0x338950e6 , 0x44bac763 , 0x9c4ff430 , 0xb9d829d8 , 0x66b057de , 0x1c59e2d3 ] )
|
||||
, Mont::unsafe_make( [ 0xd9d1bed1 , 0x6893946b , 0x219e8861 , 0x5194597e , 0x0d8ae06b , 0xcfb87949 , 0x7817da48 , 0x2067c27e ] )
|
||||
, Mont::unsafe_make( [ 0x7166ba33 , 0xe1d51635 , 0x78be6da4 , 0xb7d97656 , 0x21265799 , 0xede788ac , 0x6c040fbf , 0x301ec35d ] )
|
||||
, Mont::unsafe_make( [ 0xc117a901 , 0x10869851 , 0x195dc3f7 , 0xe3b9a765 , 0xe4c5cf3e , 0x4c6cdbd3 , 0x9a219d25 , 0x1dbfee28 ] )
|
||||
, Mont::unsafe_make( [ 0x70bbd4ca , 0xc27e2691 , 0xb935068d , 0xb2699884 , 0x47461a9a , 0x85d09b6f , 0x4ee29d1a , 0x0765e3eb ] )
|
||||
, Mont::unsafe_make( [ 0x0a3d4a9a , 0xb80972bc , 0x85221a89 , 0x6a95e823 , 0x845075b1 , 0x29de2e17 , 0x061e5aa4 , 0x2e0bac69 ] )
|
||||
, Mont::unsafe_make( [ 0xc6c215d2 , 0xd9dc3367 , 0xb5b9449e , 0x2aa49878 , 0x38cc73ec , 0xc2b96cf4 , 0x34845f74 , 0x0f8ffda3 ] )
|
||||
, Mont::unsafe_make( [ 0x13bc2971 , 0x9ea9a08f , 0x24884e5b , 0x9e6b7a1b , 0x1e6cb18f , 0xa5ec85eb , 0xbe57c88d , 0x2e381f3c ] )
|
||||
, Mont::unsafe_make( [ 0x166dc32e , 0xcf6f0f63 , 0xb3db063b , 0xb111cc4d , 0xfe90a1d7 , 0x6c58727f , 0x82e2b944 , 0x05e624ff ] )
|
||||
, Mont::unsafe_make( [ 0x9e31edb7 , 0x59582754 , 0x17abef70 , 0xd3bde7cf , 0x2d527a24 , 0xfac533a7 , 0x35787b72 , 0x060ece52 ] )
|
||||
, Mont::unsafe_make( [ 0x0080a33d , 0x30d8f27f , 0x0aa85284 , 0x69110322 , 0x92bf61d2 , 0x3c110030 , 0xd901a295 , 0x1342a4cf ] )
|
||||
, Mont::unsafe_make( [ 0x719426c1 , 0x61b87beb , 0x0eb9ebbd , 0x34ba95d6 , 0x1a829247 , 0xee628044 , 0x17da49d5 , 0x23fad23a ] )
|
||||
, Mont::unsafe_make( [ 0xfac38f4c , 0x2d5671a0 , 0xc1b1a449 , 0xbba9fcc1 , 0xfaaf9c19 , 0x4da9096b , 0xdc045007 , 0x05b4ec45 ] )
|
||||
, Mont::unsafe_make( [ 0xaa8c7f8c , 0x037436a1 , 0x001c7301 , 0x18b3bf03 , 0xb7e5a635 , 0xde9a6fc8 , 0xd9259cb6 , 0x1869c170 ] )
|
||||
, Mont::unsafe_make( [ 0x1bc31bd6 , 0xf72c49c0 , 0x304e1f0c , 0x195c10b2 , 0x5b8fdbeb , 0x15f734f1 , 0x0d2020fe , 0x0d3c0e25 ] )
|
||||
, Mont::unsafe_make( [ 0x52b2e2d9 , 0x0fcff735 , 0x7c4850d5 , 0xd0414e68 , 0x1cd04142 , 0x00744ae0 , 0xff1794c1 , 0x1619ea74 ] )
|
||||
, Mont::unsafe_make( [ 0x73d405b7 , 0x28500b6a , 0xc4fb355a , 0xb4c2f96a , 0x394d3d12 , 0x1dc6a7f3 , 0x51da53c9 , 0x156e721c ] )
|
||||
, Mont::unsafe_make( [ 0x39468327 , 0x5e3d1327 , 0x51b2722d , 0xf372b54e , 0x85fe2518 , 0x9b293559 , 0xc574d844 , 0x17a81a0b ] )
|
||||
, Mont::unsafe_make( [ 0x42051a56 , 0x176a569a , 0x261f3277 , 0xaf6a331b , 0x2b469f7e , 0xe08d06ec , 0x8a8c2cbf , 0x1662a55b ] )
|
||||
, Mont::unsafe_make( [ 0xdf786323 , 0x3bc085de , 0x9e4fd5fa , 0x178e5df3 , 0xc8dd5467 , 0x98f7befe , 0x2b7cd78b , 0x1374c3f6 ] )
|
||||
, Mont::unsafe_make( [ 0x9ed507f4 , 0x9c93097b , 0x2a42fe66 , 0x0e769167 , 0x896a115e , 0x13c16032 , 0x1db230bc , 0x1eda5a3d ] )
|
||||
, Mont::unsafe_make( [ 0x97689721 , 0x36a36647 , 0x4cb25e9f , 0xd8306298 , 0xead47c18 , 0xeb62da57 , 0x8898c9de , 0x240c42cb ] )
|
||||
, Mont::unsafe_make( [ 0x11843d3d , 0x6ef4b4e5 , 0xcb6ee554 , 0xca8edb3e , 0xb39e22ff , 0x6ebd407b , 0xb5c78e6e , 0x2bf5eb2d ] )
|
||||
, Mont::unsafe_make( [ 0xec0aa2c6 , 0xfd07c7c3 , 0xcaae86c9 , 0xb5eecf9d , 0x00c1ac8b , 0xa3453389 , 0x3cee349c , 0x00d3ab5b ] )
|
||||
, Mont::unsafe_make( [ 0x20608a97 , 0x25c0667f , 0x5011ca43 , 0xd7de20ae , 0xf1f021c3 , 0x3bc6c7af , 0x4561b4b6 , 0x2f14c811 ] )
|
||||
, Mont::unsafe_make( [ 0x8c8a6097 , 0x5b1bfc0f , 0x24ba2022 , 0x79f9b35d , 0x39ed6645 , 0x7da661b0 , 0xfd00eedb , 0x05aa835d ] )
|
||||
, Mont::unsafe_make( [ 0x90403aff , 0x6e690c1c , 0x40b9cff8 , 0x55e412a4 , 0xaf3e4cd7 , 0xbb7ea2b4 , 0xd40efc8d , 0x00568e83 ] )
|
||||
, Mont::unsafe_make( [ 0x6373b671 , 0x43af3e26 , 0x3f3814e7 , 0x127f969e , 0x578e552c , 0x2a75164a , 0x7f74fffe , 0x2175fac4 ] )
|
||||
, Mont::unsafe_make( [ 0x65ea944d , 0xeb4c476d , 0x84aa5664 , 0xe947cd84 , 0xaeadc54a , 0x260b6908 , 0xa5d6b0b8 , 0x025e4f0c ] )
|
||||
, Mont::unsafe_make( [ 0x0f8ef8b3 , 0xb2bb86f3 , 0x637bdf9e , 0x503e0262 , 0xde2f07bb , 0xf45a8a04 , 0x7c02d6e8 , 0x22a54915 ] )
|
||||
, Mont::unsafe_make( [ 0xd9a506b9 , 0xb7720222 , 0x07561bc7 , 0x8b03d26c , 0x2bcc0fcb , 0x0c997d27 , 0x70b36742 , 0x214bec26 ] )
|
||||
, Mont::unsafe_make( [ 0x7577bb86 , 0x6db0ef8b , 0xe2bdef59 , 0xd487ffeb , 0xb81b9491 , 0x8fccdcda , 0x9b4e9067 , 0x0d2c4e91 ] )
|
||||
, Mont::unsafe_make( [ 0xf5a00e6b , 0xbc373e8c , 0xfeacdb15 , 0xca5f9450 , 0x1abf5533 , 0xf02e2511 , 0xfc8ef2e1 , 0x2eda54e9 ] )
|
||||
, Mont::unsafe_make( [ 0x28361dde , 0x54a9f39c , 0x8e9bd7d4 , 0x43f7f6c2 , 0x07458591 , 0xd5a77726 , 0xf6658bf2 , 0x1a88852d ] )
|
||||
, Mont::unsafe_make( [ 0x4e0129b2 , 0x9667b08e , 0xbc2802e0 , 0x1b82df4f , 0xcfa6d069 , 0x2667926a , 0x48270df6 , 0x0ef12dac ] )
|
||||
, Mont::unsafe_make( [ 0x4b060dd6 , 0x099e78a5 , 0xcff80798 , 0x941beb22 , 0x766400e2 , 0x01f6da3b , 0x2e4d9c93 , 0x0ad1ca2c ] )
|
||||
, Mont::unsafe_make( [ 0x519dd82c , 0xf20c0e76 , 0xd2ac3c96 , 0x5dd02cdf , 0x83ae55d4 , 0xe391867f , 0xc4fe95d1 , 0x30068131 ] )
|
||||
, Mont::unsafe_make( [ 0xf1f30413 , 0x4dc7005f , 0x2845cfbb , 0xcdb27016 , 0x01758391 , 0xe161cc29 , 0x3bbac7d4 , 0x093f1cff ] )
|
||||
, Mont::unsafe_make( [ 0x7d37e7ca , 0x3a82a99f , 0xa31b215f , 0x86ca9972 , 0xe0e12531 , 0xe0508aa7 , 0x9c0ab846 , 0x2b21602b ] )
|
||||
, Mont::unsafe_make( [ 0x0a0959c2 , 0xc8e75554 , 0x2d6c91f9 , 0x1c7873e8 , 0x98913a15 , 0x1fb10bb0 , 0xe55bc94e , 0x2bd2e3be ] )
|
||||
, Mont::unsafe_make( [ 0x80fba8a1 , 0xa8cc4d59 , 0x2215497d , 0x73800883 , 0x35c93170 , 0xcb613bd5 , 0x1a2fe728 , 0x1928e9ed ] )
|
||||
, Mont::unsafe_make( [ 0xb7086125 , 0x4792d3a4 , 0x40d3912b , 0xd6fca8f8 , 0x9713a132 , 0x157c8bf8 , 0xd197a327 , 0x2ddbc6bd ] )
|
||||
, Mont::unsafe_make( [ 0x8ce21945 , 0xf658ea6e , 0x9bdf695f , 0x9f8edc04 , 0xb37ffe84 , 0x334a7227 , 0x0b3934d8 , 0x03aa0ace ] )
|
||||
, Mont::unsafe_make( [ 0x6178fc72 , 0x3be0c64e , 0x3376a5a5 , 0x8258af15 , 0x72632835 , 0x01bbc50c , 0x78461126 , 0x05c5c5f0 ] )
|
||||
, Mont::unsafe_make( [ 0x5ceb88c8 , 0xca5ca78d , 0x3af51ead , 0xd58ccd5f , 0x4ff64d28 , 0xac6f13a9 , 0x7770d676 , 0x2571325d ] )
|
||||
, Mont::unsafe_make( [ 0x901865aa , 0x227f5268 , 0x298454de , 0xbf1d22d3 , 0xe2de015f , 0x7a477e52 , 0xae1dc826 , 0x2a8bf714 ] )
|
||||
];
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// final (external) round constants (flattened)
|
||||
pub const FINAL: [Mont; 8] =
|
||||
[ Mont::unsafe_make( [ 0x6c03f53f , 0xabe800c5 , 0xe62a8eb9 , 0x99a08bbf , 0x814b855b , 0x858e0814 , 0x0420500a , 0x17a98d6f ] )
|
||||
, Mont::unsafe_make( [ 0x2cf0b07f , 0x2452da7b , 0x6c89a4ee , 0xa1dff84a , 0xda8f2e3b , 0xec02277a , 0x5f5ce1d5 , 0x20968825 ] )
|
||||
, Mont::unsafe_make( [ 0x1066f7c6 , 0xe16ec340 , 0xd78c72f3 , 0x52123b4d , 0x88773994 , 0xfc415ba3 , 0x454240a6 , 0x0bab3f3f ] )
|
||||
, Mont::unsafe_make( [ 0x180a3588 , 0x6e9ebc16 , 0xc4d6f90b , 0x30117fc8 , 0x62607c64 , 0xda576876 , 0x50e75c9a , 0x04b49393 ] )
|
||||
, Mont::unsafe_make( [ 0x205afd38 , 0x9b9f8362 , 0xcc4f42b9 , 0xaeeae293 , 0x59929038 , 0x71501b16 , 0x6ae6a2d7 , 0x0a3f2304 ] )
|
||||
, Mont::unsafe_make( [ 0x90af264a , 0xd6ed03ca , 0xafac7d63 , 0xcf5c0afc , 0xcb0936e8 , 0x8a4de575 , 0xe6f3e596 , 0x15c15d2f ] )
|
||||
, Mont::unsafe_make( [ 0xe3480394 , 0xd0fbe11d , 0x3fa42cd2 , 0xe1be3478 , 0xb5a6722a , 0x93319f25 , 0x363e9dd7 , 0x1869731f ] )
|
||||
, Mont::unsafe_make( [ 0x6e2e4b8d , 0x58588f42 , 0x21b7db86 , 0x7782f8ee , 0x55316d82 , 0xb09873d7 , 0x5f1756fc , 0x062c9c11 ] )
|
||||
];
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// known answer test
|
||||
pub const KAT_MONT: [Mont; 2] =
|
||||
[ Mont::unsafe_make( [ 0x49a10098 , 0xc3563e8a , 0x00ef9c5b , 0x56f99687 , 0x407b4baf , 0x025403b6 , 0x081214c7 , 0x1113e926 ] )
|
||||
, Mont::unsafe_make( [ 0xd4e20563 , 0xc501275d , 0x051641c1 , 0x4c7fe213 , 0xf036a5e0 , 0x50e9cf71 , 0x77056fb7 , 0x1b3a4fb6 ] )
|
||||
];
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
124
src/poseidon2/constants/new/t3.rs
Normal file
124
src/poseidon2/constants/new/t3.rs
Normal file
@ -0,0 +1,124 @@
|
||||
|
||||
// HorizenLabs' Poseidon2 constants for `t = 3` ("new" set of constants)
|
||||
|
||||
use crate::bn254::montgomery::*;
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// diagonal for the internal mixing matrix
|
||||
pub const DIAGONAL: [Mont; 3] =
|
||||
[ Mont::unsafe_make( [ 0x4ffffffb , 0xac96341c , 0x9f60cd29 , 0x36fc7695 , 0x7879462e , 0x666ea36f , 0x9a07df2f , 0x0e0a77c1 ] )
|
||||
, Mont::unsafe_make( [ 0x4ffffffb , 0xac96341c , 0x9f60cd29 , 0x36fc7695 , 0x7879462e , 0x666ea36f , 0x9a07df2f , 0x0e0a77c1 ] )
|
||||
, Mont::unsafe_make( [ 0x9ffffff6 , 0x592c6838 , 0x3ec19a53 , 0x6df8ed2b , 0xf0f28c5c , 0xccdd46de , 0x340fbe5e , 0x1c14ef83 ] )
|
||||
];
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// initial (external) round constants (flattened)
|
||||
pub const INITIAL: [Mont; 12] =
|
||||
[ Mont::unsafe_make( [ 0xce14484c , 0xd722b5d4 , 0xf431d35f , 0x28fdf04e , 0xd8a909c9 , 0x0af406c6 , 0xd234efa0 , 0x2d545ba8 ] )
|
||||
, Mont::unsafe_make( [ 0x348a5584 , 0x55a2a5fc , 0x29e45265 , 0xd73cd959 , 0x83269614 , 0x66e861c4 , 0xb2b473e0 , 0x040e6777 ] )
|
||||
, Mont::unsafe_make( [ 0xf8020b2a , 0x0a830ec1 , 0x99305e94 , 0x8197a4f8 , 0x7ac4428f , 0x3c2e6943 , 0x2f845328 , 0x17eceef0 ] )
|
||||
, Mont::unsafe_make( [ 0xc97d6f8a , 0xa51d3e5b , 0xdc378def , 0x054ffe26 , 0x8abe9c97 , 0xd8440cef , 0x536245d6 , 0x005cbb47 ] )
|
||||
, Mont::unsafe_make( [ 0xe05e41ad , 0x042cdbb0 , 0x86048513 , 0xc2bbc7d3 , 0x749e5203 , 0x24521f75 , 0x0eb46678 , 0x2b353c0d ] )
|
||||
, Mont::unsafe_make( [ 0x70279600 , 0x452e08a3 , 0xf325f46c , 0x8a72c098 , 0xb9aa1466 , 0x6c50ae68 , 0x59c97364 , 0x04850445 ] )
|
||||
, Mont::unsafe_make( [ 0xe225df77 , 0x0ad536bd , 0x1b44ea62 , 0x618246ab , 0xd6d89f5f , 0x9e92bf71 , 0x7134fbff , 0x143c32bc ] )
|
||||
, Mont::unsafe_make( [ 0xafd66bd9 , 0xb88574fa , 0xfe2d1c84 , 0x009eff80 , 0x450d4afa , 0xd8e71adb , 0x568f5057 , 0x2eda25b9 ] )
|
||||
, Mont::unsafe_make( [ 0x246fe49e , 0x25725962 , 0x0d2ac3d7 , 0xed9f756a , 0x4ac9abe4 , 0x3ae3c2d3 , 0xe0b6b88c , 0x0190cdb5 ] )
|
||||
, Mont::unsafe_make( [ 0x50fd3fe6 , 0xe7adc997 , 0x93fc3913 , 0xb747a576 , 0x051ca986 , 0x249a1e43 , 0xd23a561b , 0x1307eb2e ] )
|
||||
, Mont::unsafe_make( [ 0xf79536d3 , 0x9615931f , 0x7a923c33 , 0x24525c94 , 0xf2988ff5 , 0x467ae014 , 0x62b95029 , 0x2c023f47 ] )
|
||||
, Mont::unsafe_make( [ 0xe7c528e0 , 0x92d843f6 , 0xe754e747 , 0x0cc5a90e , 0xf55f9236 , 0x191e21b2 , 0xd4331f4b , 0x28f936f9 ] )
|
||||
];
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// middle (internal) round constants
|
||||
pub const INTERNAL: [Mont; 56] =
|
||||
[ Mont::unsafe_make( [ 0x2bc0a5cf , 0x622adaa2 , 0x3b6eaf8a , 0xd1c5d854 , 0xd0f62457 , 0x330f3eca , 0x156de150 , 0x1007cfff ] )
|
||||
, Mont::unsafe_make( [ 0x51a3a11a , 0x7fcd7a7b , 0x64057c75 , 0xf3effc9d , 0x1300cb0d , 0xbc8a4ec3 , 0x7dcad9a8 , 0x30322f4f ] )
|
||||
, Mont::unsafe_make( [ 0x22b141d5 , 0x475cd066 , 0x28285fae , 0x5d64d8cf , 0x4d284a15 , 0x6e095ffe , 0x9b4cd1c2 , 0x2643235c ] )
|
||||
, Mont::unsafe_make( [ 0xa212daf5 , 0x7c0b0359 , 0x5af14f5d , 0xd75ada0d , 0x061ee257 , 0xa4345628 , 0x4e8ae776 , 0x17b7c8b8 ] )
|
||||
, Mont::unsafe_make( [ 0x742b36f2 , 0x980c58b1 , 0xdfe11248 , 0xa565f2ca , 0x07c3028c , 0x67ef3bea , 0x02b5fb1a , 0x2c282349 ] )
|
||||
, Mont::unsafe_make( [ 0x2d096ab6 , 0xbde1186c , 0xefe9a103 , 0xe1703272 , 0xba8072b1 , 0xbc6f3904 , 0xa3f0234c , 0x29302878 ] )
|
||||
, Mont::unsafe_make( [ 0xb4128e99 , 0x3ee7ba77 , 0xc6a895f6 , 0xc51c0395 , 0x605cbe98 , 0xccbf96f2 , 0x5ca3afca , 0x1e22e274 ] )
|
||||
, Mont::unsafe_make( [ 0x1c835661 , 0x1d3ad669 , 0xa21fab6c , 0xfb5f95a2 , 0xe72c8dce , 0xc1659970 , 0x9436cfb0 , 0x29547452 ] )
|
||||
, Mont::unsafe_make( [ 0x57f54073 , 0x23328b42 , 0x8af8e279 , 0x204e4f68 , 0xe8162f7b , 0xa956bf6f , 0xe06b555a , 0x2f5d17de ] )
|
||||
, Mont::unsafe_make( [ 0x4a172d09 , 0x4a3ada74 , 0xbe5ad794 , 0x0c507c89 , 0xc89c352c , 0x7c7f8bd5 , 0x1f2c7644 , 0x1d2576a4 ] )
|
||||
, Mont::unsafe_make( [ 0x02eeb228 , 0x9bd727e3 , 0x8b1ea1f2 , 0xdf6d767c , 0xf54307d2 , 0xca141180 , 0x236cad38 , 0x2505c0d6 ] )
|
||||
, Mont::unsafe_make( [ 0x954c97c6 , 0xb1e10961 , 0xd3f9fef2 , 0x3c4f0682 , 0x71008c30 , 0x0c80d2cf , 0x05a18dcd , 0x0e15691f ] )
|
||||
, Mont::unsafe_make( [ 0x635f9952 , 0xeffe6ebd , 0xe7671c93 , 0xeb59bc51 , 0xe253cbde , 0x96411255 , 0x37fe27c9 , 0x12c2c089 ] )
|
||||
, Mont::unsafe_make( [ 0x3a1317c4 , 0xb874c941 , 0x3112a9a7 , 0x16e2f433 , 0x94375e0a , 0xc706227f , 0xee77ed31 , 0x17541af3 ] )
|
||||
, Mont::unsafe_make( [ 0x964189af , 0x1c8578d3 , 0xd33043f7 , 0x9606117d , 0x576a465f , 0x47321da7 , 0x05653649 , 0x1d221ece ] )
|
||||
, Mont::unsafe_make( [ 0x7544679e , 0x4fe81253 , 0x9fab065d , 0x22c277f9 , 0x037b2a59 , 0x559c1f97 , 0xb64c1dee , 0x0d335d8c ] )
|
||||
, Mont::unsafe_make( [ 0x11772ad0 , 0xfca74a79 , 0x1ae81a44 , 0x7794ea0b , 0x5c8410db , 0x8599b620 , 0x04fdb4e8 , 0x14a9bc19 ] )
|
||||
, Mont::unsafe_make( [ 0x459458c7 , 0x27c775f5 , 0xeb439f06 , 0x8328d2c0 , 0x734180d6 , 0x40673f0d , 0xe92859b9 , 0x15277115 ] )
|
||||
, Mont::unsafe_make( [ 0xa830e3cb , 0xaf861af4 , 0x663d4a43 , 0x9dac43c8 , 0x169c8dad , 0x667d238c , 0x3980c88f , 0x1fd335e9 ] )
|
||||
, Mont::unsafe_make( [ 0xdabee7be , 0x76cd7452 , 0xb3470c47 , 0x179f9669 , 0x7e3e4c39 , 0xa2bcc37a , 0xae0da84f , 0x00c438f3 ] )
|
||||
, Mont::unsafe_make( [ 0x65896478 , 0xaddee77e , 0x1142693b , 0xf76501d7 , 0x8c00e94a , 0xa2bcea58 , 0x0d1ff415 , 0x01722a62 ] )
|
||||
, Mont::unsafe_make( [ 0x9c23e520 , 0x52e1361a , 0x8d71d221 , 0x4da1bc25 , 0x6bd5021f , 0x4833163a , 0x808e54b0 , 0x0454fd58 ] )
|
||||
, Mont::unsafe_make( [ 0xaf509057 , 0xa34eec98 , 0x56fc3d06 , 0x2e045fe4 , 0x1158c2a0 , 0x90bb4128 , 0x26351255 , 0x0f8cf45c ] )
|
||||
, Mont::unsafe_make( [ 0x31dcc1c4 , 0x243306b1 , 0x08381589 , 0xd17d829d , 0xe114798e , 0xe0c512c5 , 0x10b59fb3 , 0x003d28d5 ] )
|
||||
, Mont::unsafe_make( [ 0x4f6444fb , 0x25b75c23 , 0xfae5b32d , 0xeb353c51 , 0xf1f10957 , 0x00fb023d , 0xa9795a71 , 0x2f2711c2 ] )
|
||||
, Mont::unsafe_make( [ 0x76a3c33c , 0xffe40ffd , 0x506b5ac6 , 0x901a3707 , 0xb1e48843 , 0xae56f79f , 0xb67b0272 , 0x12c0e58c ] )
|
||||
, Mont::unsafe_make( [ 0x56f1402d , 0x63091823 , 0x86d54d35 , 0xb3f95ba4 , 0xa5857b1a , 0x5a2ddb75 , 0xcc4197a9 , 0x28fe9993 ] )
|
||||
, Mont::unsafe_make( [ 0xa3f6b5b0 , 0xb0c450f4 , 0x6a8264d2 , 0xfb32607c , 0x77693cd9 , 0xcf4f33c8 , 0x14e723b6 , 0x1688e518 ] )
|
||||
, Mont::unsafe_make( [ 0x03c59de3 , 0x8ad5b2a9 , 0x4c75b7ed , 0x7d1fd0b5 , 0x13715eb5 , 0x7b4a673a , 0xc9abc9ef , 0x135ae381 ] )
|
||||
, Mont::unsafe_make( [ 0x87e82218 , 0x985df3dd , 0x1c7b6afc , 0x8a8f90a8 , 0x59689ddb , 0x4e5335ed , 0xefb878b7 , 0x0d57011f ] )
|
||||
, Mont::unsafe_make( [ 0xff45c733 , 0xbd085218 , 0xfebbde0c , 0xc45006a6 , 0xd08175e9 , 0x4dd8cc03 , 0x585e3a76 , 0x01489fd5 ] )
|
||||
, Mont::unsafe_make( [ 0xc2adf0e4 , 0xc298e7ce , 0x96d4e0aa , 0xaff1e5dc , 0xed3650d3 , 0xf813062a , 0x4af64218 , 0x14150246 ] )
|
||||
, Mont::unsafe_make( [ 0x96eac478 , 0x2a225f3b , 0x10a0c288 , 0xe2c46377 , 0xaf702e8d , 0x334a38b2 , 0xe2702e40 , 0x078cff44 ] )
|
||||
, Mont::unsafe_make( [ 0xecd11192 , 0x160dc4b8 , 0xaf580450 , 0xbfd46405 , 0xe1574ad2 , 0xc859ded4 , 0xdbbdf10e , 0x0e24f08e ] )
|
||||
, Mont::unsafe_make( [ 0xbab52fbd , 0x91e59108 , 0xec62a826 , 0x9253af9d , 0xd0b98ef8 , 0x7e946b84 , 0xb2e483ea , 0x2fbb7b1a ] )
|
||||
, Mont::unsafe_make( [ 0x83eda039 , 0xac92d3aa , 0x8e1b86ad , 0xa4690909 , 0x3bc0dd1a , 0x4ffd7430 , 0x63c8a8f3 , 0x023ca894 ] )
|
||||
, Mont::unsafe_make( [ 0xec8cac00 , 0x3fd205fc , 0xe62b9259 , 0x4eb6b7a0 , 0x11dc0089 , 0x7a2aeaf5 , 0x90e63b2c , 0x0c3bec03 ] )
|
||||
, Mont::unsafe_make( [ 0xc48910dd , 0xaf9390f4 , 0xa83287eb , 0x5d5890c5 , 0x7fb055f1 , 0x72c8b90e , 0x2dea9c62 , 0x1841ff43 ] )
|
||||
, Mont::unsafe_make( [ 0x59bf0bb5 , 0x69faa71e , 0x809df839 , 0x5bc0f299 , 0x6c468e1c , 0x270e1a31 , 0xd6147416 , 0x29a11242 ] )
|
||||
, Mont::unsafe_make( [ 0xb65fdc48 , 0x8972b665 , 0x4edd199f , 0x5c9c56f9 , 0x06c983ae , 0x7655c00b , 0x1e51c321 , 0x0b0f3ab3 ] )
|
||||
, Mont::unsafe_make( [ 0x4656c733 , 0xa060ea21 , 0xfcfc3711 , 0x3e03eaf6 , 0x768e5a4e , 0x1283ed55 , 0x7b3ed73b , 0x1d52067c ] )
|
||||
, Mont::unsafe_make( [ 0x184334a4 , 0xd3e688c7 , 0x8b440d8e , 0x3300ee2a , 0xeb30bc1a , 0x09cb5cab , 0x6b68a8c9 , 0x10b46893 ] )
|
||||
, Mont::unsafe_make( [ 0x5919c64d , 0xd905c6a4 , 0xa1ecb91d , 0x42c29960 , 0x04a42f1e , 0xdb15563a , 0xd2ff55be , 0x222da53f ] )
|
||||
, Mont::unsafe_make( [ 0xbaf9856a , 0x795621e7 , 0x4a37377f , 0xbd06eab7 , 0x482dfab7 , 0xd69262b4 , 0x940098e7 , 0x06336772 ] )
|
||||
, Mont::unsafe_make( [ 0x0bbc434a , 0xb15532dc , 0xc1914f69 , 0x935ec462 , 0x605fe849 , 0xd263edc8 , 0xdcce9527 , 0x201a1b25 ] )
|
||||
, Mont::unsafe_make( [ 0x7d37cc55 , 0x7f9233db , 0x3fa1e7cb , 0x39e29093 , 0xcb35976a , 0x4b7f45bf , 0x83f0c587 , 0x095f02ff ] )
|
||||
, Mont::unsafe_make( [ 0x39d344c8 , 0xf4eb6a68 , 0xcc408889 , 0x61d3173f , 0x754bc487 , 0x358b1b65 , 0xf8d020da , 0x041a46d8 ] )
|
||||
, Mont::unsafe_make( [ 0xeea956d1 , 0x76955850 , 0x3f7ce928 , 0x329bb5c3 , 0x8b21b882 , 0xb89bbc08 , 0xdbf59315 , 0x1d8400cd ] )
|
||||
, Mont::unsafe_make( [ 0x64087d30 , 0xe7afa14d , 0x521f9766 , 0x7e1d1f05 , 0x0435f6c2 , 0xda7886ca , 0x0c90400d , 0x16204396 ] )
|
||||
, Mont::unsafe_make( [ 0x2efd539c , 0x2406277f , 0xbf80b5ee , 0x7619c402 , 0xb1e02b30 , 0x8df98925 , 0x4f8ba893 , 0x29aa9e80 ] )
|
||||
, Mont::unsafe_make( [ 0x4dda1e31 , 0x61637e66 , 0x27eb3f1d , 0x451c6e57 , 0x3c6bc83c , 0x33a1432b , 0x08d0e74f , 0x12c1abfc ] )
|
||||
, Mont::unsafe_make( [ 0xf65773dd , 0xcc07040f , 0x0c2ec344 , 0x4c04f139 , 0xca1e8523 , 0xe7e912e6 , 0x17a6be33 , 0x0d8eaffd ] )
|
||||
, Mont::unsafe_make( [ 0x9f9fc719 , 0xde8160aa , 0x2a8900c9 , 0x78c44db3 , 0x354fdd17 , 0x60a764e3 , 0x24a81952 , 0x1c20317d ] )
|
||||
, Mont::unsafe_make( [ 0x4a38f228 , 0x27a34e47 , 0x49138197 , 0xdc1f7f9c , 0x0fcc6063 , 0x6a734526 , 0x8c7ed4d2 , 0x0fd1c632 ] )
|
||||
, Mont::unsafe_make( [ 0x913af446 , 0x1a23634f , 0x6ff10352 , 0x089c939a , 0x0250b0fe , 0x7ba874ea , 0x4ea4de4a , 0x081b59ca ] )
|
||||
, Mont::unsafe_make( [ 0x9ce9ff43 , 0xf58f374a , 0x9aab157d , 0xfef4b21e , 0x5302aee7 , 0x6cb30b88 , 0xc9911102 , 0x25685b31 ] )
|
||||
];
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// final (external) round constants (flattened)
|
||||
pub const FINAL: [Mont; 12] =
|
||||
[ Mont::unsafe_make( [ 0xae74b354 , 0x8e8db2dc , 0x368291c9 , 0x18d52d0c , 0x41ab4b08 , 0x5ec62732 , 0x098eabd3 , 0x1284ed5f ] )
|
||||
, Mont::unsafe_make( [ 0xfc6734e0 , 0x1fbe709e , 0x30bc8815 , 0x84a42996 , 0xb0e2c32e , 0x9bf5e155 , 0xf350b3ef , 0x08e211c4 ] )
|
||||
, Mont::unsafe_make( [ 0xb7c9731a , 0x9423ffa0 , 0xead2eb93 , 0xa70300ac , 0x41d22c44 , 0x15262537 , 0x023f12e0 , 0x2fae94ed ] )
|
||||
, Mont::unsafe_make( [ 0x65185ab2 , 0x4b5ff602 , 0x0d9953e3 , 0xbea20e3f , 0x224890c4 , 0x0dfcbf8f , 0x09c0effd , 0x14bccf46 ] )
|
||||
, Mont::unsafe_make( [ 0x2da2e433 , 0xe4cab461 , 0xa8d64ce1 , 0x11e05277 , 0xc7ed715e , 0xbbcaa97b , 0x5bca9fc1 , 0x0ecfcc92 ] )
|
||||
, Mont::unsafe_make( [ 0x70941941 , 0xdfb89513 , 0xce168be1 , 0x960042e3 , 0x6cabdbbb , 0x6d54135d , 0xe464a69a , 0x0221b16b ] )
|
||||
, Mont::unsafe_make( [ 0x20a0f689 , 0x3918cf0b , 0x622af6db , 0xecd0d188 , 0x8a26e246 , 0x4e1b574c , 0xa0d6fa59 , 0x2d85fbe5 ] )
|
||||
, Mont::unsafe_make( [ 0xc5b60d86 , 0x0fc72998 , 0x8fdc2a51 , 0x2a535152 , 0x4eabd232 , 0x7adec22b , 0xf111a956 , 0x0a08535e ] )
|
||||
, Mont::unsafe_make( [ 0xca492b78 , 0x0df1d9e2 , 0xa8d99ad4 , 0x4a01db83 , 0xcbf1383d , 0xeb2bcb74 , 0x4b7a3011 , 0x2e998482 ] )
|
||||
, Mont::unsafe_make( [ 0xc20b3c54 , 0x267cc7a6 , 0xd0e2fdca , 0x619ad1e0 , 0xcfe99da2 , 0x9668fc44 , 0x396bc175 , 0x15f960d8 ] )
|
||||
, Mont::unsafe_make( [ 0xf8b105ca , 0x17e87a80 , 0xfa2042ea , 0x666e49d9 , 0x4734c297 , 0xc40330f5 , 0x4524e0dc , 0x2a656ded ] )
|
||||
, Mont::unsafe_make( [ 0x3fa848fd , 0x1a8a41ea , 0x42aea9aa , 0x68c01b27 , 0x05f7acad , 0xc5ff17a4 , 0x2731e92a , 0x05932f8c ] )
|
||||
];
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// known answer test
|
||||
pub const KAT_MONT: [Mont; 3] =
|
||||
[ Mont::unsafe_make( [ 0x8d6a2709 , 0xfb7f1906 , 0x770e6292 , 0x6fcc39ad , 0x48674726 , 0x2d2442e2 , 0x514c1087 , 0x12c16376 ] )
|
||||
, Mont::unsafe_make( [ 0x0c20f794 , 0xfbaedb5e , 0xc2cc7e59 , 0xa6dd24c6 , 0x1ddfd9d6 , 0x09134d91 , 0xeef6553a , 0x1ed48020 ] )
|
||||
, Mont::unsafe_make( [ 0x072d1562 , 0xf4b192da , 0x36eb1db6 , 0xa6ec9626 , 0xca0709b0 , 0x8b84f649 , 0x2dfb8ff6 , 0x0f0dcd4c ] )
|
||||
];
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
134
src/poseidon2/constants/new/t4.rs
Normal file
134
src/poseidon2/constants/new/t4.rs
Normal file
@ -0,0 +1,134 @@
|
||||
|
||||
// HorizenLabs' Poseidon2 constants for `t = 4` ("new" set of constants)
|
||||
|
||||
use crate::bn254::montgomery::*;
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// diagonal for the internal mixing matrix
|
||||
pub const DIAGONAL: [Mont; 4] =
|
||||
[ Mont::unsafe_make( [ 0x7b603c75 , 0x78b3c4df , 0x4a97b9e3 , 0xdd54552f , 0xf70388e9 , 0xc9ceb940 , 0x6f112b7e , 0x300af8e8 ] )
|
||||
, Mont::unsafe_make( [ 0x39b1ef67 , 0x00deb141 , 0xcca2343d , 0xccb2bdef , 0xdbe2f558 , 0x6c43a052 , 0x506e775c , 0x1063a869 ] )
|
||||
, Mont::unsafe_make( [ 0x378e2f93 , 0x94eea894 , 0x7882666b , 0x93faf7c0 , 0x9995cfdc , 0x21288cc5 , 0xb9b0b7d3 , 0x027e7283 ] )
|
||||
, Mont::unsafe_make( [ 0xba986fc1 , 0xb35e450f , 0x7560ef38 , 0x926ccb78 , 0x895114e8 , 0x1e1e2685 , 0x4cbcead3 , 0x2841f431 ] )
|
||||
];
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// initial (external) round constants (flattened)
|
||||
pub const INITIAL: [Mont; 16] =
|
||||
[ Mont::unsafe_make( [ 0xeccba526 , 0x40e29857 , 0x628bb63c , 0x78b5d11f , 0x24d71c1d , 0x90a91f81 , 0x257c701f , 0x22b90b99 ] )
|
||||
, Mont::unsafe_make( [ 0xd5e88168 , 0xdda103bc , 0x563908df , 0xcadec275 , 0x9bda666a , 0xcb42faa4 , 0x14878465 , 0x12c1e60e ] )
|
||||
, Mont::unsafe_make( [ 0xde1800c2 , 0xe2ee3f59 , 0x539090ba , 0xc7979d60 , 0x8efd09c7 , 0xb1749010 , 0x6c889238 , 0x157ae4cd ] )
|
||||
, Mont::unsafe_make( [ 0xfdf35e56 , 0x8d47060c , 0x6012e0bb , 0x24d3c6c5 , 0xd9c7f211 , 0x23e529e2 , 0xe7feeb7c , 0x0ca313c0 ] )
|
||||
, Mont::unsafe_make( [ 0x4ec24b7c , 0x969ae587 , 0xd4b3aa33 , 0x178d4318 , 0x09ed64f8 , 0x6c88dcc6 , 0x93dc51cf , 0x2f010ac6 ] )
|
||||
, Mont::unsafe_make( [ 0xe65e43e8 , 0x57fb28a4 , 0x40bb2e20 , 0x8879374e , 0x2db3a00b , 0x2edbd964 , 0x42f98e5e , 0x03519d1e ] )
|
||||
, Mont::unsafe_make( [ 0x0ea1bdea , 0x6cd49782 , 0xa94b2b4d , 0x7547fcc6 , 0xd0b9a60b , 0xd170eabd , 0xbba571b3 , 0x2d4d4875 ] )
|
||||
, Mont::unsafe_make( [ 0xbec195b2 , 0x6ef12da5 , 0x40632693 , 0x1949053b , 0x23aaa26c , 0x52a07adc , 0x9e08bb84 , 0x2462f2ed ] )
|
||||
, Mont::unsafe_make( [ 0xeed56c26 , 0x86b215d7 , 0xb44e8536 , 0x8e8a775a , 0xb24328ac , 0x4b28315d , 0x9b91a22b , 0x2284e685 ] )
|
||||
, Mont::unsafe_make( [ 0xbcecf683 , 0x24435d7b , 0x784b101a , 0x30558031 , 0x043ca93a , 0x8152ba72 , 0x92a1bf2f , 0x2ef0fea0 ] )
|
||||
, Mont::unsafe_make( [ 0xea71df23 , 0x31f7ebe8 , 0x8b396ad0 , 0x5a40c44d , 0xc9964844 , 0x12103e68 , 0x11796f09 , 0x2fbf0a07 ] )
|
||||
, Mont::unsafe_make( [ 0xb9a474d2 , 0xd171b165 , 0x0d05e663 , 0xde9cc229 , 0x209d7a7a , 0xaaa87c63 , 0xc13594ca , 0x138033c1 ] )
|
||||
, Mont::unsafe_make( [ 0xd4ed1036 , 0x7bfd9fcb , 0x832eba40 , 0x5d413eaa , 0xe9b81cf4 , 0xb509d471 , 0x11f48909 , 0x1287cef7 ] )
|
||||
, Mont::unsafe_make( [ 0x946b6f1f , 0xaa8460cf , 0x1df9301d , 0xd383ed88 , 0x64f23a61 , 0x13dab194 , 0x4d94f496 , 0x03edc8f2 ] )
|
||||
, Mont::unsafe_make( [ 0xec4a0545 , 0x8fb0a2ba , 0x6fa7e269 , 0x62950a98 , 0x08420ccb , 0x8b2e63ef , 0x0ff8ad46 , 0x24357c1c ] )
|
||||
, Mont::unsafe_make( [ 0x47d708de , 0xebc39846 , 0x28054f45 , 0xfa8876a5 , 0x353025ae , 0x529aa21b , 0x548a5daa , 0x11e5fb7b ] )
|
||||
];
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// middle (internal) round constants
|
||||
pub const INTERNAL: [Mont; 56] =
|
||||
[ Mont::unsafe_make( [ 0x31825829 , 0x1c447b01 , 0x96cfd279 , 0x6eea85c3 , 0x44792b70 , 0x906fa66e , 0x1192fc58 , 0x0f417b2b ] )
|
||||
, Mont::unsafe_make( [ 0xf4ab8c3d , 0x893dc44f , 0x7480b4d7 , 0xdc5162ae , 0xef2ce577 , 0xd2d2263c , 0xcf84da5b , 0x2bff5bd4 ] )
|
||||
, Mont::unsafe_make( [ 0xd5b4b49b , 0xb77ac980 , 0x90498325 , 0x333a0386 , 0x7648701e , 0x7d075bd4 , 0xbe83b2ac , 0x14e2b4d3 ] )
|
||||
, Mont::unsafe_make( [ 0xe1e7fee7 , 0x529b26c9 , 0x471f6c16 , 0xe3b9ce82 , 0xfc148e9a , 0x7b784e18 , 0xa7d121ad , 0x0af58ae3 ] )
|
||||
, Mont::unsafe_make( [ 0x163db662 , 0xf8d1c651 , 0x97676b5a , 0x1e3bceb5 , 0x469bd269 , 0x2e280d1a , 0xf4da683b , 0x1cc9d2ea ] )
|
||||
, Mont::unsafe_make( [ 0x5e8c3243 , 0x284f1e6a , 0xa443c438 , 0xdf6e2c5f , 0x13990c9c , 0xa141ac6c , 0xd9963ebf , 0x2406d65e ] )
|
||||
, Mont::unsafe_make( [ 0xd5e8b643 , 0x833da6ae , 0xd94bbf99 , 0xf6e1ac68 , 0xbac7591f , 0x92e1ab49 , 0xf779855e , 0x1f14ec7c ] )
|
||||
, Mont::unsafe_make( [ 0xb2dbe89c , 0x1f360ba6 , 0xfa7aa570 , 0x39a6bfce , 0xabd3c437 , 0x7f9114a8 , 0xa38ff005 , 0x241559c0 ] )
|
||||
, Mont::unsafe_make( [ 0xe32b0fa5 , 0x82f0f015 , 0xa9827bdf , 0x15b14571 , 0x604b82fb , 0xb77fbead , 0x8f1bd0dd , 0x08436825 ] )
|
||||
, Mont::unsafe_make( [ 0x8341eaab , 0x6e0151e9 , 0x39d2ae2b , 0x347e8c0f , 0xfd8e7354 , 0x2f6a4f01 , 0xae4780c7 , 0x1224728e ] )
|
||||
, Mont::unsafe_make( [ 0x7277da93 , 0xa64a59e0 , 0x7e750319 , 0xec9ffe49 , 0x2fd81230 , 0xf8de0d29 , 0x0e4cf7e7 , 0x200ba007 ] )
|
||||
, Mont::unsafe_make( [ 0x47f74c1e , 0x3eee8ca1 , 0x3d394847 , 0xb459e1c1 , 0x72dfc6e9 , 0xad3a506f , 0xa98cdf30 , 0x0024a1a4 ] )
|
||||
, Mont::unsafe_make( [ 0x22ba290c , 0x4677744f , 0x9828d067 , 0x9665c306 , 0x08482095 , 0x47a5ab4a , 0x4a7b53a1 , 0x050856d3 ] )
|
||||
, Mont::unsafe_make( [ 0x36447fd5 , 0xe9ac9900 , 0xff728f98 , 0x67e1d967 , 0xd8f9b85b , 0x520db222 , 0x49da28d0 , 0x300d7539 ] )
|
||||
, Mont::unsafe_make( [ 0x3031c219 , 0xe0a4d3db , 0x9599d375 , 0xbdfc328b , 0xfe507de4 , 0x11f23cd7 , 0xb0ae16c8 , 0x1bf0b2f3 ] )
|
||||
, Mont::unsafe_make( [ 0xeeba2623 , 0x18018546 , 0x707f1b9c , 0x1de71123 , 0xd000f8e9 , 0x7f6c0e2a , 0x2d82057f , 0x28f46b32 ] )
|
||||
, Mont::unsafe_make( [ 0x4e5db6eb , 0x3ac593da , 0x193a3b2d , 0x3ff4bba0 , 0x69346ef2 , 0xe0ad26ec , 0xc138914e , 0x24849ad2 ] )
|
||||
, Mont::unsafe_make( [ 0x9a188251 , 0xa68ceacc , 0x7ab50758 , 0x905a4a60 , 0x9f998afa , 0xdeba6d53 , 0xdf96654f , 0x1fff49f7 ] )
|
||||
, Mont::unsafe_make( [ 0x7cc3a431 , 0xc067c30e , 0xcd522f83 , 0x34d758f9 , 0xd217edeb , 0x3435becc , 0x9fbdf039 , 0x2a89e513 ] )
|
||||
, Mont::unsafe_make( [ 0x60a8f7cc , 0xd5a6847c , 0xc7ba7883 , 0xd5aff503 , 0xd28ddd20 , 0x8b2bfd2a , 0x8a279fc0 , 0x10183588 ] )
|
||||
, Mont::unsafe_make( [ 0xe3eb3735 , 0x50fa7503 , 0xcd5e9211 , 0xd8495c79 , 0x40c3544b , 0x7b7e2a50 , 0xa94415a4 , 0x197e6d90 ] )
|
||||
, Mont::unsafe_make( [ 0x32ef2471 , 0x6ea1d225 , 0x82af0ac7 , 0x4e961770 , 0x1189f2bb , 0xed2f1dfb , 0x7bd9b353 , 0x27fbb36a ] )
|
||||
, Mont::unsafe_make( [ 0x7ddb3c34 , 0xa7ee2538 , 0x4d0fe612 , 0xf3014544 , 0x43c5762b , 0x9c0473e0 , 0x61fc9c12 , 0x2bfa2b74 ] )
|
||||
, Mont::unsafe_make( [ 0xa8d7a2d8 , 0xe74c0280 , 0xd1baac9f , 0x15b2fc08 , 0x5fda8359 , 0x7ef491cb , 0x179ee045 , 0x2622426d ] )
|
||||
, Mont::unsafe_make( [ 0xb783f986 , 0xfeea8798 , 0x37df791c , 0x21f8b558 , 0x41f1f926 , 0x4715c048 , 0xec5c3f93 , 0x100ebb18 ] )
|
||||
, Mont::unsafe_make( [ 0xf6947206 , 0x122aa722 , 0x46ac0fee , 0x522b1219 , 0x69dac1c0 , 0x45b9250f , 0x7572f636 , 0x25293cd2 ] )
|
||||
, Mont::unsafe_make( [ 0x136b08ab , 0x936f54ff , 0x430020cc , 0x700dd002 , 0x94739877 , 0xd06242f7 , 0x62417cab , 0x2268c9c1 ] )
|
||||
, Mont::unsafe_make( [ 0xd0a2241a , 0x1c9b445d , 0x21df29cd , 0xc11cb47b , 0x594f0f09 , 0xf7a492c3 , 0x146edc66 , 0x034b38a7 ] )
|
||||
, Mont::unsafe_make( [ 0x183b8133 , 0x1dfe4ac0 , 0x13fb779a , 0x1ef0319b , 0xab5f926e , 0x11dbf892 , 0x3659a7ee , 0x17a856c5 ] )
|
||||
, Mont::unsafe_make( [ 0xcd5307a6 , 0x059e222b , 0xd2effb7c , 0xccfaf000 , 0x9a8cf932 , 0x1fd59fef , 0x93909eae , 0x0c4ce24e ] )
|
||||
, Mont::unsafe_make( [ 0xe2301d0e , 0x42d0cafe , 0x2bdcb93f , 0x79696ca2 , 0x3592018b , 0x5bacb0d6 , 0xe7715542 , 0x29294687 ] )
|
||||
, Mont::unsafe_make( [ 0x04c7099b , 0x42a54148 , 0x43e5c38a , 0x6fe76c62 , 0xaf4e6367 , 0x254493c8 , 0x56bc983d , 0x1e3fcd81 ] )
|
||||
, Mont::unsafe_make( [ 0xf2412486 , 0xa7ff7255 , 0x401795c0 , 0x7501ca14 , 0xb6e4b1ff , 0x2d0e3a0d , 0xa3cc320f , 0x0096d162 ] )
|
||||
, Mont::unsafe_make( [ 0x8b1125f9 , 0x789c20e4 , 0x5612a45c , 0x528ce70d , 0xa75e2b38 , 0x8d645f61 , 0x5b1fa715 , 0x26549dc1 ] )
|
||||
, Mont::unsafe_make( [ 0xba5758e9 , 0x775b5e0f , 0x41c98c95 , 0xd39a069c , 0x6ed9fd47 , 0x68a78431 , 0x70bcfbe6 , 0x2dd54f40 ] )
|
||||
, Mont::unsafe_make( [ 0xd1ba98ba , 0x9d57dffc , 0xf0d32b4f , 0x2554bc6b , 0xff5eaacc , 0xfaa1a29b , 0xc8ea6c31 , 0x1bf848fc ] )
|
||||
, Mont::unsafe_make( [ 0x84b1bcb6 , 0x3264c886 , 0x35f99477 , 0xb5e9ff43 , 0x3bdc6348 , 0x81aca759 , 0x28a0b816 , 0x1a6338f4 ] )
|
||||
, Mont::unsafe_make( [ 0x9cba1dea , 0x24779cc6 , 0x218f1be6 , 0x308776f8 , 0x2b3f619e , 0x3a9e52d1 , 0xce3e2de3 , 0x06d8d604 ] )
|
||||
, Mont::unsafe_make( [ 0x7e64dc49 , 0xc7b00cf3 , 0x2949bc23 , 0x06d1c180 , 0xa1b25168 , 0xfd608a1f , 0xba188f7a , 0x22ebae49 ] )
|
||||
, Mont::unsafe_make( [ 0x458d8a3d , 0xca1469d4 , 0xafb084b6 , 0x7623fb53 , 0xd556d8f0 , 0xa0abc7e8 , 0x5f3dfadf , 0x2a8b5c3b ] )
|
||||
, Mont::unsafe_make( [ 0x9c1595c3 , 0x33f5eadd , 0x1d084193 , 0x54d6810e , 0x50c2db99 , 0xa13eb5c9 , 0xb6209dfc , 0x1ac1693f ] )
|
||||
, Mont::unsafe_make( [ 0x493ffadb , 0x57b804a8 , 0xda07b05e , 0xf4ecda7b , 0x1dde9556 , 0x365ad26d , 0xf165a935 , 0x26840fe4 ] )
|
||||
, Mont::unsafe_make( [ 0x444341c1 , 0xcb958721 , 0x9bbb1137 , 0xd202fc00 , 0xefbfbaef , 0xe10a117b , 0xcff0718b , 0x2fefe67c ] )
|
||||
, Mont::unsafe_make( [ 0x56a5da25 , 0x57166a5f , 0x559f2de5 , 0x9651ac4d , 0x440d7536 , 0xe0a3ce57 , 0x9c2e8df9 , 0x1d7d8da3 ] )
|
||||
, Mont::unsafe_make( [ 0x7e751759 , 0x955694cf , 0xb2bf9669 , 0x1f19c299 , 0x7d697b72 , 0x891a562d , 0x2c62c131 , 0x25b1eb3a ] )
|
||||
, Mont::unsafe_make( [ 0xd244680e , 0x27d15e03 , 0x8503b16b , 0x52a13993 , 0x7e1780d7 , 0xa6029398 , 0x7f79736c , 0x27bdf8da ] )
|
||||
, Mont::unsafe_make( [ 0x34550fcd , 0x116f5556 , 0x2fff7266 , 0x3df9127a , 0xd381aa33 , 0xf3cd0bf9 , 0x034f31b9 , 0x16c19d6f ] )
|
||||
, Mont::unsafe_make( [ 0x699047ae , 0x66d80999 , 0x729fbceb , 0xd3be6bda , 0xfaf882be , 0xcfabbd2a , 0x43fd6e3f , 0x05b5d05f ] )
|
||||
, Mont::unsafe_make( [ 0x481ddafa , 0x2c74114e , 0x6e9f472b , 0x80743412 , 0xcd20418a , 0xab570928 , 0xa200a5af , 0x283d4a89 ] )
|
||||
, Mont::unsafe_make( [ 0x2d41f6b9 , 0xd411d724 , 0xce58b2a3 , 0x2633b38d , 0xb9f250f6 , 0xb88e71e3 , 0x3927530c , 0x1fd33b9c ] )
|
||||
, Mont::unsafe_make( [ 0x2acef0f6 , 0x97b472e6 , 0xfcd93bbc , 0x14790dc3 , 0x1e349424 , 0x5400b048 , 0x01ac2e60 , 0x2ceaf69d ] )
|
||||
, Mont::unsafe_make( [ 0x14449780 , 0x668c4cd5 , 0x6641b850 , 0x43c5c8d0 , 0xb2b749e2 , 0x4f75ba88 , 0xac4732f2 , 0x267a187c ] )
|
||||
, Mont::unsafe_make( [ 0xf9a8fb0b , 0xb085fdc4 , 0x29e44e36 , 0x71be2e01 , 0x50b499a4 , 0xe6b0eeb8 , 0x103cddba , 0x02b354c2 ] )
|
||||
, Mont::unsafe_make( [ 0x7467dcbf , 0x0597e2d6 , 0xcfc45fb9 , 0xfb80c331 , 0x03d6a081 , 0xdac61e4a , 0xbcdb094a , 0x1a11b729 ] )
|
||||
, Mont::unsafe_make( [ 0x6f25bfbd , 0xf3fee4e3 , 0xb09c65b3 , 0x2e1ebc2b , 0xea732590 , 0xe2e0496c , 0x01012352 , 0x0880a9b3 ] )
|
||||
, Mont::unsafe_make( [ 0xaf984d00 , 0x71df5a89 , 0x7d56dd30 , 0x7edb4688 , 0xcaf42515 , 0xec05215a , 0x4fcf3d35 , 0x18ff6fdc ] )
|
||||
];
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// final (external) round constants (flattened)
|
||||
pub const FINAL: [Mont; 16] =
|
||||
[ Mont::unsafe_make( [ 0x1a7623ba , 0xd452149f , 0x905865d9 , 0x13d73472 , 0xa82dff72 , 0x68860941 , 0x76757a07 , 0x00f33f46 ] )
|
||||
, Mont::unsafe_make( [ 0x6d294f41 , 0x0e60a44a , 0xddc4baa0 , 0x03b13324 , 0xc39ab341 , 0x4c7ce58c , 0x2abe19c0 , 0x139be6cb ] )
|
||||
, Mont::unsafe_make( [ 0x7fa5c783 , 0x9ee46be3 , 0x2fa0605d , 0x4b80d6e9 , 0xa0b58710 , 0xe18d39ea , 0x03fe6d3b , 0x019935cf ] )
|
||||
, Mont::unsafe_make( [ 0x6f646bef , 0xa11eecbd , 0x3d0c2ba1 , 0xdf805be1 , 0x8f8d6723 , 0xb1843fb1 , 0x6c90fbd4 , 0x0ecac0e0 ] )
|
||||
, Mont::unsafe_make( [ 0xdb7f08aa , 0x20ca3789 , 0x1bb2f0df , 0x8d428008 , 0x72d173e5 , 0x37f8a0a7 , 0xf81ae93b , 0x2704fea2 ] )
|
||||
, Mont::unsafe_make( [ 0xd5ab61aa , 0x0b57a210 , 0x8189a1ea , 0xb5bcedca , 0xb293e0ac , 0x1cdbbf1a , 0xf9ed48ae , 0x100b4344 ] )
|
||||
, Mont::unsafe_make( [ 0x9c057fc4 , 0x907e5f4a , 0x29d2396b , 0x575a1e17 , 0xb02a0d47 , 0x2f81eb61 , 0x354d25f3 , 0x201c9d0d ] )
|
||||
, Mont::unsafe_make( [ 0xb19775e8 , 0x6e0d1e92 , 0xc85487ae , 0x1b0ff212 , 0xed730bb5 , 0x77fa05e5 , 0x3ab6b8d0 , 0x0da570e8 ] )
|
||||
, Mont::unsafe_make( [ 0xd96b8f30 , 0xe33228d2 , 0xfb9be93a , 0xb89a3bb8 , 0xbee565b1 , 0x35e9eca0 , 0xae156020 , 0x273df6b0 ] )
|
||||
, Mont::unsafe_make( [ 0xdb5ac551 , 0xa436a2ac , 0x41c606e4 , 0x8514ac3b , 0xcdf04c60 , 0xc28036d7 , 0x7eb66e66 , 0x1ea07111 ] )
|
||||
, Mont::unsafe_make( [ 0x108821f4 , 0x6126235d , 0xee75f731 , 0x4a7765cf , 0x07674e14 , 0x743ed0ff , 0x0a3cc48c , 0x05925bb8 ] )
|
||||
, Mont::unsafe_make( [ 0x5b2e74a1 , 0x7a92010e , 0x3b0684db , 0xfee649f0 , 0x1a3caab2 , 0x7aa7ccf8 , 0xfdfbc79d , 0x23720c2c ] )
|
||||
, Mont::unsafe_make( [ 0x6e304e37 , 0x460a8549 , 0x62040055 , 0xdd8f5275 , 0xfd5a7579 , 0x40a70979 , 0x087a3e1c , 0x1f03fbf1 ] )
|
||||
, Mont::unsafe_make( [ 0x81c186ed , 0x0b43e0bf , 0x61079afb , 0x47ce7c09 , 0x2e55217d , 0xb9f3357e , 0x6775a696 , 0x17e4fd8d ] )
|
||||
, Mont::unsafe_make( [ 0x633b1599 , 0xb74d133c , 0xba2d94e2 , 0x4bf76b0f , 0xc5cd67f8 , 0xfec7cce4 , 0xea7f1aaa , 0x183bceae ] )
|
||||
, Mont::unsafe_make( [ 0x8bfc0bd8 , 0x62a251f5 , 0xebc5885b , 0xa47572f6 , 0xefcf2b6d , 0x37c60ff8 , 0xdc1b5f33 , 0x1fd8d931 ] )
|
||||
];
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// known answer test
|
||||
pub const KAT_MONT: [Mont; 4] =
|
||||
[ Mont::unsafe_make( [ 0x77120d65 , 0x9b1fbe62 , 0xdc539e70 , 0x25c530d7 , 0x8b955057 , 0x8d2f9be4 , 0xf951fa9a , 0x15232793 ] )
|
||||
, Mont::unsafe_make( [ 0x0736a9f8 , 0x7f16fe60 , 0x57237342 , 0xf610ae20 , 0x8ed75d8a , 0x092ee018 , 0x5564c603 , 0x30306668 ] )
|
||||
, Mont::unsafe_make( [ 0x3722aaa9 , 0xa4350bee , 0x157e774f , 0x7dc31a09 , 0x749c7dbc , 0x4f2b3844 , 0x14607b01 , 0x2c6d5895 ] )
|
||||
, Mont::unsafe_make( [ 0xf25dafe0 , 0xc40e953b , 0x965bc5e1 , 0x531dc067 , 0x9c53719c , 0x74c689ab , 0x64d9f5f4 , 0x05dfdac1 ] )
|
||||
];
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
4
src/poseidon2/constants/old/mod.rs
Normal file
4
src/poseidon2/constants/old/mod.rs
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
pub mod t2;
|
||||
pub mod t3;
|
||||
pub mod t4;
|
||||
114
src/poseidon2/constants/old/t2.rs
Normal file
114
src/poseidon2/constants/old/t2.rs
Normal file
@ -0,0 +1,114 @@
|
||||
|
||||
// HorizenLabs' Poseidon2 constants for `t = 2` ("old" set of constants)
|
||||
|
||||
use crate::bn254::montgomery::*;
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// diagonal for the internal mixing matrix
|
||||
pub const DIAGONAL: [Mont; 2] =
|
||||
[ Mont::unsafe_make( [ 0x4ffffffb , 0xac96341c , 0x9f60cd29 , 0x36fc7695 , 0x7879462e , 0x666ea36f , 0x9a07df2f , 0x0e0a77c1 ] )
|
||||
, Mont::unsafe_make( [ 0x9ffffff6 , 0x592c6838 , 0x3ec19a53 , 0x6df8ed2b , 0xf0f28c5c , 0xccdd46de , 0x340fbe5e , 0x1c14ef83 ] )
|
||||
];
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// initial (external) round constants (flattened)
|
||||
pub const INITIAL: [Mont; 8] =
|
||||
[ Mont::unsafe_make( [ 0xdc22cd61 , 0x623d4bf3 , 0xa5754f2b , 0x684f658e , 0xa5f212f6 , 0x2e05e544 , 0x38bbd72f , 0x2c0aee65 ] )
|
||||
, Mont::unsafe_make( [ 0x1afced7a , 0x9e9058ae , 0x71661438 , 0x186b1cff , 0x4e99d1a9 , 0x2b400f85 , 0xe610a639 , 0x112cd2c5 ] )
|
||||
, Mont::unsafe_make( [ 0x9cc41e79 , 0x97e45d31 , 0x80f5d0b6 , 0xd688dbbf , 0x4fd475fd , 0x06c7a616 , 0x6ef9683e , 0x177a911a ] )
|
||||
, Mont::unsafe_make( [ 0xa1343023 , 0x196bae3f , 0xf695daab , 0xb32011be , 0xbca31837 , 0xcf1dd55e , 0xc1b956a8 , 0x05dd3586 ] )
|
||||
, Mont::unsafe_make( [ 0xf3da77a3 , 0xabde6741 , 0x94e9abed , 0xd455e63c , 0x35c04e06 , 0x781c80db , 0xe9868292 , 0x09d7bffe ] )
|
||||
, Mont::unsafe_make( [ 0x85dc2e26 , 0x51df442f , 0x0dcfab66 , 0xd1046c99 , 0xfab8a571 , 0x6e2900f4 , 0x7fb962f9 , 0x1d0d23a1 ] )
|
||||
, Mont::unsafe_make( [ 0x29d65b86 , 0x67607d77 , 0xf8a9c0ce , 0x9954956c , 0x1efa4852 , 0xa6c06616 , 0x67447a6c , 0x1e37ebd1 ] )
|
||||
, Mont::unsafe_make( [ 0xd5af809f , 0x11dacbfb , 0x3ded422e , 0x2f2e0d07 , 0x8c09636d , 0xa76fe6d5 , 0x41d9d21e , 0x02902936 ] )
|
||||
];
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// middle (internal) round constants
|
||||
pub const INTERNAL: [Mont; 56] =
|
||||
[ Mont::unsafe_make( [ 0x3e5c3607 , 0x6e0f9da5 , 0x940d461a , 0x34c24f16 , 0xbf051e52 , 0x3afa862f , 0x1da59583 , 0x1a35b5ab ] )
|
||||
, Mont::unsafe_make( [ 0x9316ec92 , 0xd381366e , 0xbd3d46a1 , 0xaedccd5b , 0xdf82d8a2 , 0xc73ab1ae , 0xfa439d40 , 0x2eb4dc95 ] )
|
||||
, Mont::unsafe_make( [ 0xe484cb05 , 0x24d2207e , 0x65c61dfe , 0xc795dbb6 , 0xdbeace30 , 0xbc284cc5 , 0x10afab5e , 0x0e5d3b9c ] )
|
||||
, Mont::unsafe_make( [ 0xafd3e24f , 0xa9c947cb , 0xbceff16b , 0x01c8dc7c , 0x880a39db , 0xc4223820 , 0x8f482a1e , 0x1b2c2d01 ] )
|
||||
, Mont::unsafe_make( [ 0xc7601e94 , 0x1acd9219 , 0x1575a0f2 , 0x553bf5ca , 0x98cce1c6 , 0x508563b9 , 0xd5d14fb3 , 0x06c49852 ] )
|
||||
, Mont::unsafe_make( [ 0xb8f954cd , 0xf6fd7c88 , 0x1d7d9666 , 0x66c3d016 , 0xe256f86b , 0xfc3a90e2 , 0x3073ee7c , 0x2f48b5b8 ] )
|
||||
, Mont::unsafe_make( [ 0xf0fe8c28 , 0xb3d98b7d , 0xd33a093d , 0xd17dad33 , 0xc008b3b8 , 0x3e96868d , 0x9caa5c5f , 0x196f62b4 ] )
|
||||
, Mont::unsafe_make( [ 0x8a32ea06 , 0xc4faf7db , 0x09969c0b , 0xe2b4f51a , 0x287cca8d , 0x98f3a205 , 0xf57e9c12 , 0x0b10454a ] )
|
||||
, Mont::unsafe_make( [ 0x15f63610 , 0xb78b5069 , 0xa66ca32d , 0x6f2d0c98 , 0xa1e440df , 0x6d0e1b94 , 0xb44ac514 , 0x16972ed1 ] )
|
||||
, Mont::unsafe_make( [ 0x429a832b , 0x40df63fb , 0xe0fffe66 , 0xe641aba7 , 0x48978bbd , 0x2a75a9db , 0x4b730d86 , 0x1faccff6 ] )
|
||||
, Mont::unsafe_make( [ 0xaa9160d3 , 0xa80d7fe4 , 0x5c0757df , 0x1c14d4bb , 0xe1738827 , 0x5b90f8dd , 0x3440510b , 0x0142ddc7 ] )
|
||||
, Mont::unsafe_make( [ 0x5f630811 , 0x883b90d0 , 0xea1390cb , 0xc4e1ec28 , 0x7f59679d , 0x1bd4804c , 0x1af5f0e2 , 0x26ca0d03 ] )
|
||||
, Mont::unsafe_make( [ 0xa567a3ce , 0x1cd803bd , 0x4700e1af , 0x7cc78457 , 0x368a72cd , 0xd7dbdb8b , 0xeda21b5a , 0x0a0e5e07 ] )
|
||||
, Mont::unsafe_make( [ 0xa8aed552 , 0xcc281874 , 0xde804d53 , 0x5feb0497 , 0x917e1f34 , 0x4e6383a6 , 0x09830e0e , 0x1b0492f8 ] )
|
||||
, Mont::unsafe_make( [ 0xe7a00ff4 , 0x790cfd36 , 0xcaa06828 , 0x186c95fa , 0xee4cae6b , 0x5be0be66 , 0xa09a1296 , 0x21937f74 ] )
|
||||
, Mont::unsafe_make( [ 0x01291a8c , 0xe155f668 , 0xa538a809 , 0xab229d59 , 0x5dcb80ec , 0x4ad4976f , 0x96159d65 , 0x24a83ec9 ] )
|
||||
, Mont::unsafe_make( [ 0xe2e49633 , 0xa728c447 , 0x7a313e1b , 0xe79117eb , 0x36db2397 , 0xb9d07402 , 0xce593f05 , 0x2120c644 ] )
|
||||
, Mont::unsafe_make( [ 0x777f07da , 0x7f8284bf , 0xda324b4f , 0x74943f5f , 0x66f7257d , 0x199c7201 , 0xf35f8b10 , 0x1d506b82 ] )
|
||||
, Mont::unsafe_make( [ 0x7b781c81 , 0xf89aa55d , 0x9165fac8 , 0x354eb245 , 0xa59279bf , 0xdbdd452b , 0x81a53d70 , 0x2bcc25bb ] )
|
||||
, Mont::unsafe_make( [ 0x08c036b8 , 0xf5b8ba4f , 0xb7a54ba1 , 0x1f414f0c , 0xdb6b0ef3 , 0xc08e5ddf , 0x8c3e7412 , 0x2b569fd5 ] )
|
||||
, Mont::unsafe_make( [ 0xc863d2e0 , 0xc374a2cd , 0xd40a784e , 0x9e1d69aa , 0x60ba596e , 0x6a181dc2 , 0xa9701abb , 0x2345e87f ] )
|
||||
, Mont::unsafe_make( [ 0x0af681e5 , 0x483c4826 , 0xd945fc94 , 0x2ebc497a , 0x8ea4772c , 0x84656913 , 0x7e600485 , 0x07325023 ] )
|
||||
, Mont::unsafe_make( [ 0xae5e0b84 , 0x110bb5ea , 0xd7408f99 , 0xe7f80413 , 0x53ccdb71 , 0xd0643c93 , 0x26adc611 , 0x152216a7 ] )
|
||||
, Mont::unsafe_make( [ 0xb2d13315 , 0xccdc0bc8 , 0xcbca48cc , 0x1c265efc , 0x1efe86cf , 0xfa80861a , 0xf4a27b59 , 0x2a742845 ] )
|
||||
, Mont::unsafe_make( [ 0xb9eea93b , 0xbe5b1059 , 0x5305b6b2 , 0xdf9b5219 , 0xfa08d3c8 , 0x9bab2a6d , 0x574635ce , 0x29bb95be ] )
|
||||
, Mont::unsafe_make( [ 0x1a6f2227 , 0xca138ec4 , 0xdcf45e58 , 0x271c5f01 , 0xfdc76c91 , 0x71b737db , 0x7efe703f , 0x055d1e2f ] )
|
||||
, Mont::unsafe_make( [ 0x044307b6 , 0xb7ff3493 , 0x3ba92e53 , 0x183347db , 0x44bdcc12 , 0xba638fc7 , 0xa3264de1 , 0x27a28c70 ] )
|
||||
, Mont::unsafe_make( [ 0x785422d0 , 0x9598611f , 0xe1752856 , 0xe676a91d , 0x4e7272c1 , 0xc177888a , 0x8ad17a83 , 0x254e8506 ] )
|
||||
, Mont::unsafe_make( [ 0x676eacef , 0xb7e029f1 , 0x2b6112d1 , 0xe4733508 , 0x132cfa49 , 0xf42c75e3 , 0x20191917 , 0x01c9918b ] )
|
||||
, Mont::unsafe_make( [ 0x67f94ed8 , 0xa70b289f , 0x9baff29c , 0x141a80bb , 0x7b1f58b9 , 0x6392b17c , 0xbf330703 , 0x2eddd469 ] )
|
||||
, Mont::unsafe_make( [ 0xf5161eda , 0x60b2bb20 , 0x38c47ddc , 0xc2c8a4d3 , 0xf8d1136d , 0x8cb61c06 , 0x56b6633f , 0x294b77a9 ] )
|
||||
, Mont::unsafe_make( [ 0x191090d5 , 0x14d2b36c , 0xe5ffb03d , 0x2e2290af , 0x49b41da8 , 0xbe7c9fdc , 0x4227cb55 , 0x14749068 ] )
|
||||
, Mont::unsafe_make( [ 0x7b6e054f , 0xacf74981 , 0x167523a6 , 0xb9de5f3b , 0x5994bb18 , 0x1e77771b , 0x60ad3a6f , 0x08f55949 ] )
|
||||
, Mont::unsafe_make( [ 0xa90aaccd , 0x982f4991 , 0x2c4c7f64 , 0xbd59a80a , 0x05569518 , 0x76b97997 , 0x4720ae92 , 0x1f8856ed ] )
|
||||
, Mont::unsafe_make( [ 0xe3c2b351 , 0x03e7b2b7 , 0x6a2df1d1 , 0x54a04370 , 0x998778bf , 0xb70bb467 , 0x2022c177 , 0x294e681d ] )
|
||||
, Mont::unsafe_make( [ 0x37ae6968 , 0x7c2e7046 , 0x23f55934 , 0x9d46b785 , 0x8e673b86 , 0x2c57ccbd , 0x5c92abe0 , 0x29370541 ] )
|
||||
, Mont::unsafe_make( [ 0x5f4be608 , 0x6e6715e4 , 0x54a4eeec , 0xf2f3f901 , 0xe167b3af , 0xb0244817 , 0x3be5cae9 , 0x2cfc2578 ] )
|
||||
, Mont::unsafe_make( [ 0x914b838b , 0x4b837a68 , 0x2c41c7bf , 0x00f025eb , 0x81a3da78 , 0x3a35c17f , 0x558e82d9 , 0x2121ba04 ] )
|
||||
, Mont::unsafe_make( [ 0xa21b5f65 , 0xe149ea98 , 0x9f908c94 , 0xc816e7ef , 0x2ab998aa , 0x63e4857e , 0x90d8e90c , 0x0e60f3a2 ] )
|
||||
, Mont::unsafe_make( [ 0x2137b839 , 0xbe766a57 , 0x61397f52 , 0xa4034e89 , 0x9582a334 , 0x2b759504 , 0x61271037 , 0x20308660 ] )
|
||||
, Mont::unsafe_make( [ 0xefc8d2c1 , 0x42aee5bf , 0xcb50b210 , 0x7e5c2b30 , 0x494fdb1d , 0xda20d10e , 0x3b10074e , 0x2bf86399 ] )
|
||||
, Mont::unsafe_make( [ 0x6d65f834 , 0x6d065b00 , 0x0203ad25 , 0x8183d839 , 0xa8167b1b , 0x8d12b915 , 0x2cbc327d , 0x18e9800d ] )
|
||||
, Mont::unsafe_make( [ 0x555346d1 , 0x187a5029 , 0x5b23dc96 , 0x5912f5c2 , 0x5644113a , 0xbad8490a , 0xe499cff5 , 0x0823666e ] )
|
||||
, Mont::unsafe_make( [ 0x1a8800e0 , 0xbb980e2e , 0x31beabfa , 0xb09d5261 , 0xf5c619ac , 0x39e44025 , 0x81c9f49c , 0x1ab65296 ] )
|
||||
, Mont::unsafe_make( [ 0x6415467d , 0x4c62d6e9 , 0x2b655e94 , 0x8192b150 , 0xd747d3cc , 0x2bf9f014 , 0x0ce613c2 , 0x194e0505 ] )
|
||||
, Mont::unsafe_make( [ 0x520be0c0 , 0x420da44b , 0x787770e4 , 0x2e7c687b , 0xe7b2a2cb , 0xe7ecc3d8 , 0x03eb2102 , 0x21212f99 ] )
|
||||
, Mont::unsafe_make( [ 0xf8f13e30 , 0x6b7abdca , 0xd6f33336 , 0x3c9e72f9 , 0xebe20a0c , 0x8682e2e1 , 0x830de2d8 , 0x0a3541a5 ] )
|
||||
, Mont::unsafe_make( [ 0x0e8d6d37 , 0x692445dc , 0x7ade4c3f , 0x800331ea , 0x6a6de7b5 , 0x86684211 , 0x94303281 , 0x1e3f4305 ] )
|
||||
, Mont::unsafe_make( [ 0xcd9dccf6 , 0x9a329354 , 0x7b2f1747 , 0x831dc5ba , 0x75fef05b , 0xb43c723d , 0x129381c0 , 0x07838a10 ] )
|
||||
, Mont::unsafe_make( [ 0x442ecdf4 , 0x16814e38 , 0xce82386c , 0x3847cc27 , 0x96e51276 , 0x5184a839 , 0x9d9641cf , 0x1c939dfc ] )
|
||||
, Mont::unsafe_make( [ 0x6e5698cf , 0xcdaae26a , 0xac81956c , 0x0e7941ab , 0x486a208f , 0x05dd9408 , 0xd3c032d6 , 0x1a56aab2 ] )
|
||||
, Mont::unsafe_make( [ 0xe7fc9ee5 , 0xffedbac0 , 0xb35fe433 , 0x872a80ca , 0x4ea13040 , 0x39ff51a2 , 0xed65c506 , 0x2481e8b8 ] )
|
||||
, Mont::unsafe_make( [ 0x66db03db , 0x68353210 , 0x8537de07 , 0x83a4d07d , 0x4ebc88e0 , 0x4d6b1ec9 , 0x06407c8c , 0x1460f62f ] )
|
||||
, Mont::unsafe_make( [ 0xb92a2029 , 0xd94e7f7c , 0x77c4f7b5 , 0x65618e32 , 0x432fc1c1 , 0x6791b076 , 0x96cfa73a , 0x04e9f557 ] )
|
||||
, Mont::unsafe_make( [ 0xda96523d , 0xca1a968b , 0xd6e76dac , 0x5a428b33 , 0x06d43e84 , 0x95d62f18 , 0x54f56c1f , 0x1d901643 ] )
|
||||
, Mont::unsafe_make( [ 0xb9c723bc , 0xdd0f07db , 0x57f64219 , 0x088d8adf , 0xa06a1f15 , 0x8a980244 , 0xfa1f898f , 0x227dd941 ] )
|
||||
];
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// final (external) round constants (flattened)
|
||||
pub const FINAL: [Mont; 8] =
|
||||
[ Mont::unsafe_make( [ 0xc2c7dba9 , 0xa721ee60 , 0x7aab9eb0 , 0xa9092d5c , 0x998b2afe , 0xe72ad6d1 , 0x561e0c90 , 0x0dcd7e55 ] )
|
||||
, Mont::unsafe_make( [ 0x45f0f16d , 0xb0a6222c , 0x6b6f590b , 0xb7106e0e , 0x022f22ad , 0x02de6414 , 0x4bf32ddb , 0x2af7de36 ] )
|
||||
, Mont::unsafe_make( [ 0xc0c9f636 , 0xc5698979 , 0x7e7a3613 , 0x29dab601 , 0xaef2321e , 0x20e04ef3 , 0xa0ae441c , 0x292b64ec ] )
|
||||
, Mont::unsafe_make( [ 0x557f5cce , 0x2185d9ca , 0xd3841567 , 0x5634c09a , 0x43d85a36 , 0x4e967130 , 0xea36dcf0 , 0x22201c01 ] )
|
||||
, Mont::unsafe_make( [ 0x3f4abbeb , 0xa267e494 , 0x49389606 , 0xd665a397 , 0xb2ec2fac , 0x2e0db445 , 0xf79133e9 , 0x1bab689c ] )
|
||||
, Mont::unsafe_make( [ 0xc7fb0089 , 0xa968947d , 0x7b560193 , 0xfdb77eb6 , 0xa46b57a9 , 0x751baa95 , 0xabe0fa02 , 0x005cf1a7 ] )
|
||||
, Mont::unsafe_make( [ 0x76b6d753 , 0x5f62680e , 0xde835504 , 0x1959420d , 0xbf58eb51 , 0x2a729c92 , 0xba4fa32b , 0x043cc4bd ] )
|
||||
, Mont::unsafe_make( [ 0x7ece8e89 , 0xfad4a2e6 , 0x0362a94f , 0x1d2cd784 , 0xa0417fb2 , 0x7c8def54 , 0x855a46c8 , 0x161015b3 ] )
|
||||
];
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// known answer test
|
||||
pub const KAT_MONT: [Mont; 2] =
|
||||
[ Mont::unsafe_make( [ 0x550b4d8f , 0x74b514c1 , 0xfc1df1a7 , 0xa0d96e9d , 0x9c0a063b , 0x47839176 , 0x606406c2 , 0x222974fe ] )
|
||||
, Mont::unsafe_make( [ 0xf3df0686 , 0x95a09c92 , 0x04693a48 , 0x3ccaead1 , 0x7e56559c , 0xf1474016 , 0x15567e7d , 0x1837367c ] )
|
||||
];
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@ -1,129 +1,124 @@
|
||||
|
||||
//
|
||||
// round constants for Poseidon2, t=3, in Montgomery representation
|
||||
//
|
||||
// NOTE:
|
||||
//
|
||||
// this implementation USED TO BE compatible with <https://github.com/HorizenLabs/poseidon2>
|
||||
//
|
||||
// UNTIL they replaced the constants for some mysterious reasons in
|
||||
// <https://github.com/HorizenLabs/poseidon2/commit/bb476b9ca38198cf5092487283c8b8c5d4317c4e>
|
||||
//
|
||||
// this other repo: <https://extgit.isec.tugraz.at/krypto/zkfriendlyhashzoo>
|
||||
// still seems to use the old constants, so we are compatible with that one
|
||||
//
|
||||
|
||||
#![allow(non_snake_case)]
|
||||
// HorizenLabs' Poseidon2 constants for `t = 3` ("old" set of constants)
|
||||
|
||||
use crate::bn254::montgomery::*;
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
pub const INITIAL_MONT: [Mont; 12] =
|
||||
[ Mont::unsafe_make( [ 0x42f2eba6 , 0xb1693d8b , 0x5d24cf7a , 0x4e710def , 0x1fd70184 , 0xa1a5d087 , 0xc2d97c26 , 0x2a77f249 ] )
|
||||
, Mont::unsafe_make( [ 0xbb4b16d5 , 0x4113be97 , 0xce0b9abb , 0x026c0a64 , 0x9adb21de , 0xecb64fde , 0x3bf15eac , 0x0d4b2334 ] )
|
||||
, Mont::unsafe_make( [ 0xb0b90473 , 0xa9c5a16a , 0xaf146e12 , 0x8627e0b6 , 0x294d77b2 , 0xcb2d10c7 , 0x47cba8ce , 0x0e39626a ] )
|
||||
, Mont::unsafe_make( [ 0x456563d6 , 0x8a269385 , 0x04fb1419 , 0x88fddd32 , 0xdea1e4a6 , 0x0067fdf8 , 0xbb0af388 , 0x01bee8f9 ] )
|
||||
, Mont::unsafe_make( [ 0xff6c7fb8 , 0x40db6d56 , 0xb497efc0 , 0x2afa79e5 , 0xaab04c64 , 0xdff3fb1b , 0x4efb8a54 , 0x2b07d5f5 ] )
|
||||
, Mont::unsafe_make( [ 0xb3f647bb , 0x5bb104e3 , 0x7140ea02 , 0xa8be0ae1 , 0xcd1340c6 , 0x683c9003 , 0x8ad068be , 0x1371e26f ] )
|
||||
, Mont::unsafe_make( [ 0x5e27d01b , 0x2c198e38 , 0x2490a615 , 0x166e6e2e , 0x684fdff7 , 0x4de0ab9c , 0xc1681989 , 0x29380ed4 ] )
|
||||
, Mont::unsafe_make( [ 0x9b525a24 , 0x762c2082 , 0x8ef323c6 , 0x966ad8cb , 0xbdb6627e , 0x2effe12a , 0x30659173 , 0x27cfd6db ] )
|
||||
, Mont::unsafe_make( [ 0x4902b834 , 0x885bbc0e , 0xf2af370d , 0x4c2db387 , 0xb2acf5e5 , 0x464fad96 , 0x0b08c5a3 , 0x00cf858a ] )
|
||||
, Mont::unsafe_make( [ 0xcdc0c61e , 0xb79b8afe , 0xc2cd824b , 0x5447ea21 , 0xbca8be19 , 0x67e92fda , 0x776f72cb , 0x1f745966 ] )
|
||||
, Mont::unsafe_make( [ 0x5b07d576 , 0x5a35908b , 0xf3073940 , 0x810b6dc1 , 0x79410b8a , 0xe5bb1710 , 0xbe42336f , 0x297ee48b ] )
|
||||
, Mont::unsafe_make( [ 0x230bcbc0 , 0xb089556e , 0x6688210d , 0x0c35d166 , 0x64c571dd , 0x2157524f , 0x9bd404b0 , 0x038f0842 ] )
|
||||
];
|
||||
|
||||
pub const INTERNAL_MONT: [Mont; 56] =
|
||||
[ Mont::unsafe_make( [ 0x4e85dcf6 , 0x729f1c5c , 0x5a76e5d3 , 0x06667b09 , 0xdb3d1b44 , 0x46a5588a , 0xe52473ed , 0x27618829 ] )
|
||||
, Mont::unsafe_make( [ 0xb24557d5 , 0x9053a8bd , 0x005d8c3e , 0x358fdd39 , 0xf07751a2 , 0x5a35c313 , 0x5a6de168 , 0x06d6fdf3 ] )
|
||||
, Mont::unsafe_make( [ 0x29e8e6ce , 0x26d2e78b , 0x6c9e0a2f , 0x7cd791ee , 0x4c3cb659 , 0xb015455b , 0xdb8a6817 , 0x295b508d ] )
|
||||
, Mont::unsafe_make( [ 0xb3d34fdc , 0xfb912af2 , 0xb4fbb04d , 0xaa015e4f , 0xd4591107 , 0x8e5eaefb , 0xcdd5fb63 , 0x0b4fc2ac ] )
|
||||
, Mont::unsafe_make( [ 0x37e5d9da , 0x5bc74281 , 0xf9889a67 , 0x195d5f38 , 0x8deba8f3 , 0x586423d6 , 0xc3306561 , 0x11207ea4 ] )
|
||||
, Mont::unsafe_make( [ 0x8efbe8fe , 0x24bf27a1 , 0x6cdc20ce , 0xb1f9708f , 0x6885d989 , 0x5071e9fb , 0xf74dd628 , 0x2dd4f2b6 ] )
|
||||
, Mont::unsafe_make( [ 0x4cf1ae27 , 0x40d10649 , 0x88718136 , 0x35fb17f4 , 0x36b7f085 , 0xa972484d , 0x5b8fe63f , 0x29d25adc ] )
|
||||
, Mont::unsafe_make( [ 0xf4e01b53 , 0x7d712ad1 , 0x61be8b06 , 0x144d3895 , 0x43a12106 , 0x50da5842 , 0x1bcac09c , 0x0e2b8e59 ] )
|
||||
, Mont::unsafe_make( [ 0x8d10763d , 0x869a28e0 , 0x63b04a7e , 0xb344842c , 0xc58ad69b , 0x489b6d70 , 0x5244be8f , 0x14f5dbcf ] )
|
||||
, Mont::unsafe_make( [ 0x29438892 , 0x53f45210 , 0xd6807018 , 0x9cbaf24b , 0xd8357056 , 0xc58a3378 , 0xdc016da5 , 0x12022bb3 ] )
|
||||
, Mont::unsafe_make( [ 0x03da2309 , 0x9e235cd0 , 0x1c9798e2 , 0x1a288385 , 0x949390f7 , 0x15278dc6 , 0x4bc31467 , 0x2d8b2b26 ] )
|
||||
, Mont::unsafe_make( [ 0x015e6065 , 0x19200b9d , 0x867e6cb0 , 0x13fbe131 , 0x1a1a5ae5 , 0xb5b9fbd1 , 0xc13f2685 , 0x0683e215 ] )
|
||||
, Mont::unsafe_make( [ 0xc66ae350 , 0x4b00a737 , 0x023510b7 , 0x1d6288eb , 0x0ad9e0d3 , 0xa042aa85 , 0x8d52592d , 0x1fb234d5 ] )
|
||||
, Mont::unsafe_make( [ 0x775a1ff8 , 0x378a414c , 0x7224f0c5 , 0x30a41e1a , 0xed1889c7 , 0xe3eb0de4 , 0x010f600b , 0x18204127 ] )
|
||||
, Mont::unsafe_make( [ 0xe13fe6b3 , 0x88325bd1 , 0xea53514f , 0xb7f3106a , 0x07b3acc0 , 0x36a3f6ea , 0xdbb93bb6 , 0x243e682d ] )
|
||||
, Mont::unsafe_make( [ 0x13f33082 , 0x46cae2de , 0x28693f33 , 0x01f6c56d , 0x74c36e9e , 0x3823d11b , 0xd29d75d2 , 0x05d0a79d ] )
|
||||
, Mont::unsafe_make( [ 0x660ea9c1 , 0xed4414eb , 0x359d662a , 0x9253e621 , 0x9102952b , 0xe16deb4f , 0x68c10b3f , 0x2c262cad ] )
|
||||
, Mont::unsafe_make( [ 0x35c38757 , 0xbc548b89 , 0x91f24c08 , 0xcae285ce , 0x46e16208 , 0x67d48bde , 0x4de131ff , 0x274b6e3e ] )
|
||||
, Mont::unsafe_make( [ 0x889fd818 , 0x90ee94fe , 0xfe2c52c2 , 0xaf41e23d , 0x4e76a144 , 0xc2816b36 , 0x9b41c593 , 0x0e858822 ] )
|
||||
, Mont::unsafe_make( [ 0x7449dcda , 0x6a7f5a74 , 0xf7d3b716 , 0x4f7bb322 , 0x1f2097bc , 0x380fd579 , 0xbd1fcb2f , 0x186a1781 ] )
|
||||
, Mont::unsafe_make( [ 0x9078f1ce , 0xfcc5c1f2 , 0x30c3444d , 0x31cbb275 , 0x26cef6dd , 0x27f91d49 , 0x202f6b0d , 0x05f2609e ] )
|
||||
, Mont::unsafe_make( [ 0xaa5f49a5 , 0x0735e6be , 0x68742f0a , 0x64a75940 , 0xbdf54442 , 0x63d385e6 , 0x2c7b637a , 0x008cc8fd ] )
|
||||
, Mont::unsafe_make( [ 0xabc6c53e , 0x0d374d31 , 0xe33e9602 , 0x7e33771f , 0x4fe2dd44 , 0x587591c2 , 0x38d3ff8c , 0x1bad829c ] )
|
||||
, Mont::unsafe_make( [ 0xb43a9a03 , 0xab825c95 , 0xc9d19c2e , 0x5865c9ba , 0xaac6d44b , 0x914fb969 , 0x3a336ae5 , 0x1775bc47 ] )
|
||||
, Mont::unsafe_make( [ 0xb5d34d95 , 0x54708f63 , 0x16969889 , 0xca75c6a1 , 0xfaed5abc , 0x296328e0 , 0xd888067b , 0x09f43898 ] )
|
||||
, Mont::unsafe_make( [ 0x03a4fcc8 , 0x9165580f , 0xd3c74f09 , 0x1cf68ff4 , 0xbe129fc9 , 0x7cb52f36 , 0x9c7a64e5 , 0x178e28f4 ] )
|
||||
, Mont::unsafe_make( [ 0xc7bd773d , 0x69cb5a58 , 0xb12dde2c , 0x5f9f5d92 , 0x994e0c37 , 0x4b7c55d0 , 0x4cf31cc3 , 0x2a40f567 ] )
|
||||
, Mont::unsafe_make( [ 0xe5d5f6ed , 0x060e8dae , 0xc58e69be , 0x2e8db620 , 0x90340c10 , 0xa8c9c67a , 0xa1f1d861 , 0x1a0d23bb ] )
|
||||
, Mont::unsafe_make( [ 0x3f80926c , 0x0a8747ac , 0xae231ec4 , 0xef7aecd9 , 0x98ef4751 , 0x66d02787 , 0xaf412bf6 , 0x2d4781b3 ] )
|
||||
, Mont::unsafe_make( [ 0x5eff0df0 , 0x89bdf220 , 0xa9a41667 , 0x8e272242 , 0xcf3b0781 , 0xe85f0a25 , 0x41196e63 , 0x0802c22d ] )
|
||||
, Mont::unsafe_make( [ 0x7c9dc2bd , 0xc28bf011 , 0x3063e6bb , 0x11b17348 , 0xbbd0dce3 , 0x35086d2c , 0xe2ba94ec , 0x2fbbe460 ] )
|
||||
, Mont::unsafe_make( [ 0x5e639781 , 0xbfd77e5d , 0xdb93b9f6 , 0x33db73c0 , 0xf0cd66e9 , 0x67a35257 , 0xcb5f1ba8 , 0x0c21091d ] )
|
||||
, Mont::unsafe_make( [ 0x1227b9ec , 0x5697e4ce , 0x030cf103 , 0x607d8b75 , 0x0f44d7eb , 0x8e383a20 , 0x22bcc119 , 0x228c2691 ] )
|
||||
, Mont::unsafe_make( [ 0xaf607ea4 , 0x2eb59d63 , 0x71645cac , 0x34dd9352 , 0xba5f377e , 0xca7a232b , 0x56c9ef33 , 0x1171a345 ] )
|
||||
, Mont::unsafe_make( [ 0x3bc791f0 , 0x8410529f , 0x784f8bcd , 0xaa2ba025 , 0xf1b2a126 , 0xf3e454b7 , 0xddb48756 , 0x0d8a3e8d ] )
|
||||
, Mont::unsafe_make( [ 0x374c0135 , 0xa6794d17 , 0xba34332b , 0x4ff5f7d6 , 0x25dbd35f , 0x6244c6e8 , 0x6cae2101 , 0x0c1e12ce ] )
|
||||
, Mont::unsafe_make( [ 0xa142867f , 0xe97193e0 , 0x40ab67b6 , 0x09a5e3cf , 0xbcd9a799 , 0x260f9192 , 0x500b09c6 , 0x07bdf64c ] )
|
||||
, Mont::unsafe_make( [ 0xd02d73c0 , 0xe3cde7b1 , 0x884bea23 , 0x43f04876 , 0xe7d62636 , 0x139e1dc6 , 0x8566b5a4 , 0x1d3207f4 ] )
|
||||
, Mont::unsafe_make( [ 0x9078d343 , 0x169d28f3 , 0x39d28bff , 0xd051990b , 0x6e1ef5c0 , 0xef51679c , 0xff85342f , 0x2c8dbb8f ] )
|
||||
, Mont::unsafe_make( [ 0x9d65a6a0 , 0x432125d8 , 0xceca5494 , 0x5091bfeb , 0xc6bff508 , 0x523ea9a7 , 0x122ffd5d , 0x14b8f6c7 ] )
|
||||
, Mont::unsafe_make( [ 0x0f661354 , 0x5e2b5800 , 0xdee65357 , 0x5f189927 , 0x38ae6a38 , 0x99ae4e39 , 0x79209fea , 0x2b264b2d ] )
|
||||
, Mont::unsafe_make( [ 0x091da1a1 , 0x3f3b759c , 0x38ff8753 , 0x0cc51912 , 0x58d74074 , 0xa892fb02 , 0xc1970630 , 0x0059a513 ] )
|
||||
, Mont::unsafe_make( [ 0x39e70aab , 0x593bf9f5 , 0x46b83fc9 , 0x14eac710 , 0x480ce495 , 0x314170c8 , 0xb68e88b1 , 0x1f4c5aa0 ] )
|
||||
, Mont::unsafe_make( [ 0x603ac0a1 , 0x62c702ee , 0xe45ed01c , 0x9e4958b5 , 0x43a59c00 , 0x599fdeeb , 0xd1983b75 , 0x1dff5d33 ] )
|
||||
, Mont::unsafe_make( [ 0xf4590cf5 , 0xea6e9f09 , 0x1a6bdd7d , 0x8a53e041 , 0xe78b5c0e , 0xff35a7d5 , 0x94e519d2 , 0x0e979222 ] )
|
||||
, Mont::unsafe_make( [ 0x932c18ce , 0xadc4f723 , 0x6752fa16 , 0xeacad5d8 , 0x153509b8 , 0xf2329e87 , 0xd411c58a , 0x1bcbd0dd ] )
|
||||
, Mont::unsafe_make( [ 0xaee9b40c , 0x960c7957 , 0xd8cfb6db , 0xd16b74b7 , 0x2eb831ed , 0xbb2907fe , 0x2e500b1d , 0x0a035e62 ] )
|
||||
, Mont::unsafe_make( [ 0xb4d3344e , 0x50b32396 , 0x3b0bbb10 , 0xfa812c38 , 0x38b477f7 , 0x6a21a780 , 0xc04870ec , 0x1fdb5f78 ] )
|
||||
, Mont::unsafe_make( [ 0xe2fefd97 , 0xa6671bb2 , 0xda4b3dbf , 0x7bd7afc1 , 0x8dc8411d , 0x949a22d8 , 0x568ec5db , 0x2ee97af4 ] )
|
||||
, Mont::unsafe_make( [ 0xf244590a , 0x5f61c941 , 0x6eb8ea6b , 0xb3f32aed , 0x72243faa , 0x56d2e58c , 0x25ccd958 , 0x19b0535c ] )
|
||||
, Mont::unsafe_make( [ 0x0905e5a5 , 0x3106c426 , 0xd6812a37 , 0xe3fa20e5 , 0xa1e45ea7 , 0xc51acc1f , 0x0cbdf2e8 , 0x0692d355 ] )
|
||||
, Mont::unsafe_make( [ 0x7b628f44 , 0x0ae878df , 0x9abcf165 , 0x2087612c , 0x40836a64 , 0x6219b887 , 0xb448ee3f , 0x2b4ab9ee ] )
|
||||
, Mont::unsafe_make( [ 0x7d95d508 , 0xce879245 , 0x461e3a20 , 0x71b237fb , 0x0381ac2f , 0x96457597 , 0x46763400 , 0x0d3454a3 ] )
|
||||
, Mont::unsafe_make( [ 0x8a42ab95 , 0x99731740 , 0xb078aff7 , 0x94b452e5 , 0x59ce0efc , 0x03203a96 , 0xaf4fd155 , 0x24b7b333 ] )
|
||||
, Mont::unsafe_make( [ 0xbde1a9cf , 0xb39b95a7 , 0x26e1cc78 , 0x2c83ef59 , 0x0adc23e3 , 0x50da60af , 0xed395e24 , 0x101564cc ] )
|
||||
, Mont::unsafe_make( [ 0xbe1d1a1d , 0x03ef1324 , 0xe59f8484 , 0x3e083c44 , 0xcbd0a743 , 0x630822ad , 0x6e18d09b , 0x0fc929ed ] )
|
||||
];
|
||||
|
||||
pub const FINAL_MONT: [Mont; 12] =
|
||||
[ Mont::unsafe_make( [ 0x627906b6 , 0x634471eb , 0x5e77842e , 0x95dffe11 , 0xa61da352 , 0x1ba3cd39 , 0x5edc80c0 , 0x101f3e20 ] )
|
||||
, Mont::unsafe_make( [ 0x652121dc , 0x105d4377 , 0xcc8f0cd3 , 0xa1159e8b , 0xe9202b85 , 0x3b5ed230 , 0x30b81917 , 0x24a9197d ] )
|
||||
, Mont::unsafe_make( [ 0xbb925f72 , 0xdfa08515 , 0x0ef56f8b , 0xd50c4c33 , 0x4c7d553f , 0xfb42bcb8 , 0xbefffe9a , 0x1ea8c492 ] )
|
||||
, Mont::unsafe_make( [ 0xaaa92bd3 , 0x1343b3e5 , 0x085e5cdb , 0xed59870d , 0xa2de8f0c , 0x507a7731 , 0x0faac518 , 0x27a91fea ] )
|
||||
, Mont::unsafe_make( [ 0xe4bea4e1 , 0x2d5631a1 , 0x61b55cdf , 0x98932af5 , 0x666118e8 , 0x5541d4c1 , 0x161724ac , 0x144a795d ] )
|
||||
, Mont::unsafe_make( [ 0x38bcb906 , 0x3c881f21 , 0x074edd94 , 0xf18afe5c , 0x3b8b2895 , 0xbad2ff32 , 0x5e5e58ed , 0x158ddd4a ] )
|
||||
, Mont::unsafe_make( [ 0x6b8c863a , 0x4450fbc9 , 0x31caef53 , 0x7252f88d , 0xd4b917ed , 0xdd88b5e7 , 0xa8cc153a , 0x121eca65 ] )
|
||||
, Mont::unsafe_make( [ 0xe0ac97fe , 0x0d19a3b3 , 0x8f402f80 , 0x055b50ce , 0xc57db1d6 , 0xde71b42c , 0x3733da62 , 0x152ff9ae ] )
|
||||
, Mont::unsafe_make( [ 0x8173614d , 0x86d14976 , 0xc2cfd7ef , 0x2a322196 , 0xc51e0667 , 0x2b71ba22 , 0xcc03d67b , 0x111972f4 ] )
|
||||
, Mont::unsafe_make( [ 0xc9e8fef0 , 0x2e1bcba5 , 0x3d69be22 , 0xa92062ff , 0x71696c8e , 0x75d30160 , 0xbbeaf53c , 0x203e6d54 ] )
|
||||
, Mont::unsafe_make( [ 0xecaf1bb4 , 0xaa1dae06 , 0x8d7c02d3 , 0x18722e47 , 0xb89c1922 , 0x6e0cf8d4 , 0xadcef941 , 0x0f1b20d3 ] )
|
||||
, Mont::unsafe_make( [ 0x28ed5623 , 0x1ab64957 , 0xf6e7df29 , 0xe0b4f851 , 0x5f096ec5 , 0x138c02b9 , 0xf82ea12e , 0x2602b7a1 ] )
|
||||
// diagonal for the internal mixing matrix
|
||||
pub const DIAGONAL: [Mont; 3] =
|
||||
[ Mont::unsafe_make( [ 0x4ffffffb , 0xac96341c , 0x9f60cd29 , 0x36fc7695 , 0x7879462e , 0x666ea36f , 0x9a07df2f , 0x0e0a77c1 ] )
|
||||
, Mont::unsafe_make( [ 0x4ffffffb , 0xac96341c , 0x9f60cd29 , 0x36fc7695 , 0x7879462e , 0x666ea36f , 0x9a07df2f , 0x0e0a77c1 ] )
|
||||
, Mont::unsafe_make( [ 0x9ffffff6 , 0x592c6838 , 0x3ec19a53 , 0x6df8ed2b , 0xf0f28c5c , 0xccdd46de , 0x340fbe5e , 0x1c14ef83 ] )
|
||||
];
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
pub const fn get_initial_RCs(r: usize) -> [Mont; 3] {
|
||||
let j = 3*r;
|
||||
let x: Mont = INITIAL_MONT[j ];
|
||||
let y: Mont = INITIAL_MONT[j+1];
|
||||
let z: Mont = INITIAL_MONT[j+2];
|
||||
[x,y,z]
|
||||
}
|
||||
|
||||
pub const fn get_final_RCs(r: usize) -> [Mont; 3] {
|
||||
let j = 3*r;
|
||||
let x: Mont = FINAL_MONT[j ];
|
||||
let y: Mont = FINAL_MONT[j+1];
|
||||
let z: Mont = FINAL_MONT[j+2];
|
||||
[x,y,z]
|
||||
}
|
||||
// initial (external) round constants (flattened)
|
||||
pub const INITIAL: [Mont; 12] =
|
||||
[ Mont::unsafe_make( [ 0x42f2eba6 , 0xb1693d8b , 0x5d24cf7a , 0x4e710def , 0x1fd70184 , 0xa1a5d087 , 0xc2d97c26 , 0x2a77f249 ] )
|
||||
, Mont::unsafe_make( [ 0xbb4b16d5 , 0x4113be97 , 0xce0b9abb , 0x026c0a64 , 0x9adb21de , 0xecb64fde , 0x3bf15eac , 0x0d4b2334 ] )
|
||||
, Mont::unsafe_make( [ 0xb0b90473 , 0xa9c5a16a , 0xaf146e12 , 0x8627e0b6 , 0x294d77b2 , 0xcb2d10c7 , 0x47cba8ce , 0x0e39626a ] )
|
||||
, Mont::unsafe_make( [ 0x456563d6 , 0x8a269385 , 0x04fb1419 , 0x88fddd32 , 0xdea1e4a6 , 0x0067fdf8 , 0xbb0af388 , 0x01bee8f9 ] )
|
||||
, Mont::unsafe_make( [ 0xff6c7fb8 , 0x40db6d56 , 0xb497efc0 , 0x2afa79e5 , 0xaab04c64 , 0xdff3fb1b , 0x4efb8a54 , 0x2b07d5f5 ] )
|
||||
, Mont::unsafe_make( [ 0xb3f647bb , 0x5bb104e3 , 0x7140ea02 , 0xa8be0ae1 , 0xcd1340c6 , 0x683c9003 , 0x8ad068be , 0x1371e26f ] )
|
||||
, Mont::unsafe_make( [ 0x5e27d01b , 0x2c198e38 , 0x2490a615 , 0x166e6e2e , 0x684fdff7 , 0x4de0ab9c , 0xc1681989 , 0x29380ed4 ] )
|
||||
, Mont::unsafe_make( [ 0x9b525a24 , 0x762c2082 , 0x8ef323c6 , 0x966ad8cb , 0xbdb6627e , 0x2effe12a , 0x30659173 , 0x27cfd6db ] )
|
||||
, Mont::unsafe_make( [ 0x4902b834 , 0x885bbc0e , 0xf2af370d , 0x4c2db387 , 0xb2acf5e5 , 0x464fad96 , 0x0b08c5a3 , 0x00cf858a ] )
|
||||
, Mont::unsafe_make( [ 0xcdc0c61e , 0xb79b8afe , 0xc2cd824b , 0x5447ea21 , 0xbca8be19 , 0x67e92fda , 0x776f72cb , 0x1f745966 ] )
|
||||
, Mont::unsafe_make( [ 0x5b07d576 , 0x5a35908b , 0xf3073940 , 0x810b6dc1 , 0x79410b8a , 0xe5bb1710 , 0xbe42336f , 0x297ee48b ] )
|
||||
, Mont::unsafe_make( [ 0x230bcbc0 , 0xb089556e , 0x6688210d , 0x0c35d166 , 0x64c571dd , 0x2157524f , 0x9bd404b0 , 0x038f0842 ] )
|
||||
];
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// middle (internal) round constants
|
||||
pub const INTERNAL: [Mont; 56] =
|
||||
[ Mont::unsafe_make( [ 0x4e85dcf6 , 0x729f1c5c , 0x5a76e5d3 , 0x06667b09 , 0xdb3d1b44 , 0x46a5588a , 0xe52473ed , 0x27618829 ] )
|
||||
, Mont::unsafe_make( [ 0xb24557d5 , 0x9053a8bd , 0x005d8c3e , 0x358fdd39 , 0xf07751a2 , 0x5a35c313 , 0x5a6de168 , 0x06d6fdf3 ] )
|
||||
, Mont::unsafe_make( [ 0x29e8e6ce , 0x26d2e78b , 0x6c9e0a2f , 0x7cd791ee , 0x4c3cb659 , 0xb015455b , 0xdb8a6817 , 0x295b508d ] )
|
||||
, Mont::unsafe_make( [ 0xb3d34fdc , 0xfb912af2 , 0xb4fbb04d , 0xaa015e4f , 0xd4591107 , 0x8e5eaefb , 0xcdd5fb63 , 0x0b4fc2ac ] )
|
||||
, Mont::unsafe_make( [ 0x37e5d9da , 0x5bc74281 , 0xf9889a67 , 0x195d5f38 , 0x8deba8f3 , 0x586423d6 , 0xc3306561 , 0x11207ea4 ] )
|
||||
, Mont::unsafe_make( [ 0x8efbe8fe , 0x24bf27a1 , 0x6cdc20ce , 0xb1f9708f , 0x6885d989 , 0x5071e9fb , 0xf74dd628 , 0x2dd4f2b6 ] )
|
||||
, Mont::unsafe_make( [ 0x4cf1ae27 , 0x40d10649 , 0x88718136 , 0x35fb17f4 , 0x36b7f085 , 0xa972484d , 0x5b8fe63f , 0x29d25adc ] )
|
||||
, Mont::unsafe_make( [ 0xf4e01b53 , 0x7d712ad1 , 0x61be8b06 , 0x144d3895 , 0x43a12106 , 0x50da5842 , 0x1bcac09c , 0x0e2b8e59 ] )
|
||||
, Mont::unsafe_make( [ 0x8d10763d , 0x869a28e0 , 0x63b04a7e , 0xb344842c , 0xc58ad69b , 0x489b6d70 , 0x5244be8f , 0x14f5dbcf ] )
|
||||
, Mont::unsafe_make( [ 0x29438892 , 0x53f45210 , 0xd6807018 , 0x9cbaf24b , 0xd8357056 , 0xc58a3378 , 0xdc016da5 , 0x12022bb3 ] )
|
||||
, Mont::unsafe_make( [ 0x03da2309 , 0x9e235cd0 , 0x1c9798e2 , 0x1a288385 , 0x949390f7 , 0x15278dc6 , 0x4bc31467 , 0x2d8b2b26 ] )
|
||||
, Mont::unsafe_make( [ 0x015e6065 , 0x19200b9d , 0x867e6cb0 , 0x13fbe131 , 0x1a1a5ae5 , 0xb5b9fbd1 , 0xc13f2685 , 0x0683e215 ] )
|
||||
, Mont::unsafe_make( [ 0xc66ae350 , 0x4b00a737 , 0x023510b7 , 0x1d6288eb , 0x0ad9e0d3 , 0xa042aa85 , 0x8d52592d , 0x1fb234d5 ] )
|
||||
, Mont::unsafe_make( [ 0x775a1ff8 , 0x378a414c , 0x7224f0c5 , 0x30a41e1a , 0xed1889c7 , 0xe3eb0de4 , 0x010f600b , 0x18204127 ] )
|
||||
, Mont::unsafe_make( [ 0xe13fe6b3 , 0x88325bd1 , 0xea53514f , 0xb7f3106a , 0x07b3acc0 , 0x36a3f6ea , 0xdbb93bb6 , 0x243e682d ] )
|
||||
, Mont::unsafe_make( [ 0x13f33082 , 0x46cae2de , 0x28693f33 , 0x01f6c56d , 0x74c36e9e , 0x3823d11b , 0xd29d75d2 , 0x05d0a79d ] )
|
||||
, Mont::unsafe_make( [ 0x660ea9c1 , 0xed4414eb , 0x359d662a , 0x9253e621 , 0x9102952b , 0xe16deb4f , 0x68c10b3f , 0x2c262cad ] )
|
||||
, Mont::unsafe_make( [ 0x35c38757 , 0xbc548b89 , 0x91f24c08 , 0xcae285ce , 0x46e16208 , 0x67d48bde , 0x4de131ff , 0x274b6e3e ] )
|
||||
, Mont::unsafe_make( [ 0x889fd818 , 0x90ee94fe , 0xfe2c52c2 , 0xaf41e23d , 0x4e76a144 , 0xc2816b36 , 0x9b41c593 , 0x0e858822 ] )
|
||||
, Mont::unsafe_make( [ 0x7449dcda , 0x6a7f5a74 , 0xf7d3b716 , 0x4f7bb322 , 0x1f2097bc , 0x380fd579 , 0xbd1fcb2f , 0x186a1781 ] )
|
||||
, Mont::unsafe_make( [ 0x9078f1ce , 0xfcc5c1f2 , 0x30c3444d , 0x31cbb275 , 0x26cef6dd , 0x27f91d49 , 0x202f6b0d , 0x05f2609e ] )
|
||||
, Mont::unsafe_make( [ 0xaa5f49a5 , 0x0735e6be , 0x68742f0a , 0x64a75940 , 0xbdf54442 , 0x63d385e6 , 0x2c7b637a , 0x008cc8fd ] )
|
||||
, Mont::unsafe_make( [ 0xabc6c53e , 0x0d374d31 , 0xe33e9602 , 0x7e33771f , 0x4fe2dd44 , 0x587591c2 , 0x38d3ff8c , 0x1bad829c ] )
|
||||
, Mont::unsafe_make( [ 0xb43a9a03 , 0xab825c95 , 0xc9d19c2e , 0x5865c9ba , 0xaac6d44b , 0x914fb969 , 0x3a336ae5 , 0x1775bc47 ] )
|
||||
, Mont::unsafe_make( [ 0xb5d34d95 , 0x54708f63 , 0x16969889 , 0xca75c6a1 , 0xfaed5abc , 0x296328e0 , 0xd888067b , 0x09f43898 ] )
|
||||
, Mont::unsafe_make( [ 0x03a4fcc8 , 0x9165580f , 0xd3c74f09 , 0x1cf68ff4 , 0xbe129fc9 , 0x7cb52f36 , 0x9c7a64e5 , 0x178e28f4 ] )
|
||||
, Mont::unsafe_make( [ 0xc7bd773d , 0x69cb5a58 , 0xb12dde2c , 0x5f9f5d92 , 0x994e0c37 , 0x4b7c55d0 , 0x4cf31cc3 , 0x2a40f567 ] )
|
||||
, Mont::unsafe_make( [ 0xe5d5f6ed , 0x060e8dae , 0xc58e69be , 0x2e8db620 , 0x90340c10 , 0xa8c9c67a , 0xa1f1d861 , 0x1a0d23bb ] )
|
||||
, Mont::unsafe_make( [ 0x3f80926c , 0x0a8747ac , 0xae231ec4 , 0xef7aecd9 , 0x98ef4751 , 0x66d02787 , 0xaf412bf6 , 0x2d4781b3 ] )
|
||||
, Mont::unsafe_make( [ 0x5eff0df0 , 0x89bdf220 , 0xa9a41667 , 0x8e272242 , 0xcf3b0781 , 0xe85f0a25 , 0x41196e63 , 0x0802c22d ] )
|
||||
, Mont::unsafe_make( [ 0x7c9dc2bd , 0xc28bf011 , 0x3063e6bb , 0x11b17348 , 0xbbd0dce3 , 0x35086d2c , 0xe2ba94ec , 0x2fbbe460 ] )
|
||||
, Mont::unsafe_make( [ 0x5e639781 , 0xbfd77e5d , 0xdb93b9f6 , 0x33db73c0 , 0xf0cd66e9 , 0x67a35257 , 0xcb5f1ba8 , 0x0c21091d ] )
|
||||
, Mont::unsafe_make( [ 0x1227b9ec , 0x5697e4ce , 0x030cf103 , 0x607d8b75 , 0x0f44d7eb , 0x8e383a20 , 0x22bcc119 , 0x228c2691 ] )
|
||||
, Mont::unsafe_make( [ 0xaf607ea4 , 0x2eb59d63 , 0x71645cac , 0x34dd9352 , 0xba5f377e , 0xca7a232b , 0x56c9ef33 , 0x1171a345 ] )
|
||||
, Mont::unsafe_make( [ 0x3bc791f0 , 0x8410529f , 0x784f8bcd , 0xaa2ba025 , 0xf1b2a126 , 0xf3e454b7 , 0xddb48756 , 0x0d8a3e8d ] )
|
||||
, Mont::unsafe_make( [ 0x374c0135 , 0xa6794d17 , 0xba34332b , 0x4ff5f7d6 , 0x25dbd35f , 0x6244c6e8 , 0x6cae2101 , 0x0c1e12ce ] )
|
||||
, Mont::unsafe_make( [ 0xa142867f , 0xe97193e0 , 0x40ab67b6 , 0x09a5e3cf , 0xbcd9a799 , 0x260f9192 , 0x500b09c6 , 0x07bdf64c ] )
|
||||
, Mont::unsafe_make( [ 0xd02d73c0 , 0xe3cde7b1 , 0x884bea23 , 0x43f04876 , 0xe7d62636 , 0x139e1dc6 , 0x8566b5a4 , 0x1d3207f4 ] )
|
||||
, Mont::unsafe_make( [ 0x9078d343 , 0x169d28f3 , 0x39d28bff , 0xd051990b , 0x6e1ef5c0 , 0xef51679c , 0xff85342f , 0x2c8dbb8f ] )
|
||||
, Mont::unsafe_make( [ 0x9d65a6a0 , 0x432125d8 , 0xceca5494 , 0x5091bfeb , 0xc6bff508 , 0x523ea9a7 , 0x122ffd5d , 0x14b8f6c7 ] )
|
||||
, Mont::unsafe_make( [ 0x0f661354 , 0x5e2b5800 , 0xdee65357 , 0x5f189927 , 0x38ae6a38 , 0x99ae4e39 , 0x79209fea , 0x2b264b2d ] )
|
||||
, Mont::unsafe_make( [ 0x091da1a1 , 0x3f3b759c , 0x38ff8753 , 0x0cc51912 , 0x58d74074 , 0xa892fb02 , 0xc1970630 , 0x0059a513 ] )
|
||||
, Mont::unsafe_make( [ 0x39e70aab , 0x593bf9f5 , 0x46b83fc9 , 0x14eac710 , 0x480ce495 , 0x314170c8 , 0xb68e88b1 , 0x1f4c5aa0 ] )
|
||||
, Mont::unsafe_make( [ 0x603ac0a1 , 0x62c702ee , 0xe45ed01c , 0x9e4958b5 , 0x43a59c00 , 0x599fdeeb , 0xd1983b75 , 0x1dff5d33 ] )
|
||||
, Mont::unsafe_make( [ 0xf4590cf5 , 0xea6e9f09 , 0x1a6bdd7d , 0x8a53e041 , 0xe78b5c0e , 0xff35a7d5 , 0x94e519d2 , 0x0e979222 ] )
|
||||
, Mont::unsafe_make( [ 0x932c18ce , 0xadc4f723 , 0x6752fa16 , 0xeacad5d8 , 0x153509b8 , 0xf2329e87 , 0xd411c58a , 0x1bcbd0dd ] )
|
||||
, Mont::unsafe_make( [ 0xaee9b40c , 0x960c7957 , 0xd8cfb6db , 0xd16b74b7 , 0x2eb831ed , 0xbb2907fe , 0x2e500b1d , 0x0a035e62 ] )
|
||||
, Mont::unsafe_make( [ 0xb4d3344e , 0x50b32396 , 0x3b0bbb10 , 0xfa812c38 , 0x38b477f7 , 0x6a21a780 , 0xc04870ec , 0x1fdb5f78 ] )
|
||||
, Mont::unsafe_make( [ 0xe2fefd97 , 0xa6671bb2 , 0xda4b3dbf , 0x7bd7afc1 , 0x8dc8411d , 0x949a22d8 , 0x568ec5db , 0x2ee97af4 ] )
|
||||
, Mont::unsafe_make( [ 0xf244590a , 0x5f61c941 , 0x6eb8ea6b , 0xb3f32aed , 0x72243faa , 0x56d2e58c , 0x25ccd958 , 0x19b0535c ] )
|
||||
, Mont::unsafe_make( [ 0x0905e5a5 , 0x3106c426 , 0xd6812a37 , 0xe3fa20e5 , 0xa1e45ea7 , 0xc51acc1f , 0x0cbdf2e8 , 0x0692d355 ] )
|
||||
, Mont::unsafe_make( [ 0x7b628f44 , 0x0ae878df , 0x9abcf165 , 0x2087612c , 0x40836a64 , 0x6219b887 , 0xb448ee3f , 0x2b4ab9ee ] )
|
||||
, Mont::unsafe_make( [ 0x7d95d508 , 0xce879245 , 0x461e3a20 , 0x71b237fb , 0x0381ac2f , 0x96457597 , 0x46763400 , 0x0d3454a3 ] )
|
||||
, Mont::unsafe_make( [ 0x8a42ab95 , 0x99731740 , 0xb078aff7 , 0x94b452e5 , 0x59ce0efc , 0x03203a96 , 0xaf4fd155 , 0x24b7b333 ] )
|
||||
, Mont::unsafe_make( [ 0xbde1a9cf , 0xb39b95a7 , 0x26e1cc78 , 0x2c83ef59 , 0x0adc23e3 , 0x50da60af , 0xed395e24 , 0x101564cc ] )
|
||||
, Mont::unsafe_make( [ 0xbe1d1a1d , 0x03ef1324 , 0xe59f8484 , 0x3e083c44 , 0xcbd0a743 , 0x630822ad , 0x6e18d09b , 0x0fc929ed ] )
|
||||
];
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// final (external) round constants (flattened)
|
||||
pub const FINAL: [Mont; 12] =
|
||||
[ Mont::unsafe_make( [ 0x627906b6 , 0x634471eb , 0x5e77842e , 0x95dffe11 , 0xa61da352 , 0x1ba3cd39 , 0x5edc80c0 , 0x101f3e20 ] )
|
||||
, Mont::unsafe_make( [ 0x652121dc , 0x105d4377 , 0xcc8f0cd3 , 0xa1159e8b , 0xe9202b85 , 0x3b5ed230 , 0x30b81917 , 0x24a9197d ] )
|
||||
, Mont::unsafe_make( [ 0xbb925f72 , 0xdfa08515 , 0x0ef56f8b , 0xd50c4c33 , 0x4c7d553f , 0xfb42bcb8 , 0xbefffe9a , 0x1ea8c492 ] )
|
||||
, Mont::unsafe_make( [ 0xaaa92bd3 , 0x1343b3e5 , 0x085e5cdb , 0xed59870d , 0xa2de8f0c , 0x507a7731 , 0x0faac518 , 0x27a91fea ] )
|
||||
, Mont::unsafe_make( [ 0xe4bea4e1 , 0x2d5631a1 , 0x61b55cdf , 0x98932af5 , 0x666118e8 , 0x5541d4c1 , 0x161724ac , 0x144a795d ] )
|
||||
, Mont::unsafe_make( [ 0x38bcb906 , 0x3c881f21 , 0x074edd94 , 0xf18afe5c , 0x3b8b2895 , 0xbad2ff32 , 0x5e5e58ed , 0x158ddd4a ] )
|
||||
, Mont::unsafe_make( [ 0x6b8c863a , 0x4450fbc9 , 0x31caef53 , 0x7252f88d , 0xd4b917ed , 0xdd88b5e7 , 0xa8cc153a , 0x121eca65 ] )
|
||||
, Mont::unsafe_make( [ 0xe0ac97fe , 0x0d19a3b3 , 0x8f402f80 , 0x055b50ce , 0xc57db1d6 , 0xde71b42c , 0x3733da62 , 0x152ff9ae ] )
|
||||
, Mont::unsafe_make( [ 0x8173614d , 0x86d14976 , 0xc2cfd7ef , 0x2a322196 , 0xc51e0667 , 0x2b71ba22 , 0xcc03d67b , 0x111972f4 ] )
|
||||
, Mont::unsafe_make( [ 0xc9e8fef0 , 0x2e1bcba5 , 0x3d69be22 , 0xa92062ff , 0x71696c8e , 0x75d30160 , 0xbbeaf53c , 0x203e6d54 ] )
|
||||
, Mont::unsafe_make( [ 0xecaf1bb4 , 0xaa1dae06 , 0x8d7c02d3 , 0x18722e47 , 0xb89c1922 , 0x6e0cf8d4 , 0xadcef941 , 0x0f1b20d3 ] )
|
||||
, Mont::unsafe_make( [ 0x28ed5623 , 0x1ab64957 , 0xf6e7df29 , 0xe0b4f851 , 0x5f096ec5 , 0x138c02b9 , 0xf82ea12e , 0x2602b7a1 ] )
|
||||
];
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// known answer test
|
||||
pub const KAT_MONT: [Mont; 3] =
|
||||
[ Mont::unsafe_make( [ 0x135c7fb8 , 0xc2509728 , 0x8351bf4e , 0xb281e3d8 , 0x425b5e8f , 0x6061386a , 0x2e44af53 , 0x2650b35b ] )
|
||||
, Mont::unsafe_make( [ 0xfb6e7934 , 0x71f97274 , 0x83ebf335 , 0xfbb95ae2 , 0x8098a33a , 0x279b18bd , 0x05459fc0 , 0x2fc0aa04 ] )
|
||||
, Mont::unsafe_make( [ 0x674b2205 , 0x0970dd10 , 0xbc68391d , 0x975dba55 , 0xe76bb5a6 , 0x90846d0c , 0x7d50fe25 , 0x0251f933 ] )
|
||||
];
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
134
src/poseidon2/constants/old/t4.rs
Normal file
134
src/poseidon2/constants/old/t4.rs
Normal file
@ -0,0 +1,134 @@
|
||||
|
||||
// HorizenLabs' Poseidon2 constants for `t = 4` ("old" set of constants)
|
||||
|
||||
use crate::bn254::montgomery::*;
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// diagonal for the internal mixing matrix
|
||||
pub const DIAGONAL: [Mont; 4] =
|
||||
[ Mont::unsafe_make( [ 0x38714f6c , 0xbd449ba4 , 0xa92af07a , 0x2c2b5e46 , 0xd62203af , 0x89fefb91 , 0xc8afeef9 , 0x090609d4 ] )
|
||||
, Mont::unsafe_make( [ 0x8ed1b9ba , 0xc42d7c1d , 0x8002518b , 0x56b3c651 , 0x8a2c720d , 0x787eed3b , 0xd999a838 , 0x246c8982 ] )
|
||||
, Mont::unsafe_make( [ 0x08a9ccb8 , 0xd2021bee , 0x7e46c5ea , 0xf11d58c9 , 0xce227c83 , 0xb2087f61 , 0x1e7bf8a3 , 0x026227d5 ] )
|
||||
, Mont::unsafe_make( [ 0xe34c495f , 0xba418ea4 , 0xfbd6e755 , 0x284be5b1 , 0xa3bbc430 , 0x225b366e , 0x12b01e09 , 0x02cad13e ] )
|
||||
];
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// initial (external) round constants (flattened)
|
||||
pub const INITIAL: [Mont; 16] =
|
||||
[ Mont::unsafe_make( [ 0xf8703cf2 , 0x6482cc05 , 0x92c61695 , 0xd4de4537 , 0x1313a9e2 , 0x95a6616c , 0xc361ae57 , 0x2887e687 ] )
|
||||
, Mont::unsafe_make( [ 0xdca61361 , 0x1664bb9f , 0xf4577527 , 0x2fdbfc4d , 0xc6b6b5ac , 0x05a69b1f , 0x78243f5b , 0x16a94df4 ] )
|
||||
, Mont::unsafe_make( [ 0x50195823 , 0x806b9815 , 0x4449b3d2 , 0x5c0b85b1 , 0xd2927083 , 0xb8ec862d , 0xdafa32d0 , 0x13797fd0 ] )
|
||||
, Mont::unsafe_make( [ 0x8039868d , 0xc29dcd4d , 0x9c928e3c , 0x9e6b3553 , 0xfc8e6c56 , 0xc4c07f3e , 0x82f3f45f , 0x0dcc5ca4 ] )
|
||||
, Mont::unsafe_make( [ 0x502c54ce , 0x2692d27e , 0x49fe578a , 0x93ab94cd , 0xd2ac4360 , 0x8686b716 , 0xcb8a777f , 0x23cb4641 ] )
|
||||
, Mont::unsafe_make( [ 0x7425c974 , 0xb478c30a , 0x4c1808f4 , 0xf36bf33c , 0x36101b81 , 0xe87ab04e , 0xa0d34ac7 , 0x160586ac ] )
|
||||
, Mont::unsafe_make( [ 0xdf839449 , 0xb8950f50 , 0x3bb3a74e , 0xeb340220 , 0x71ada646 , 0x959a2987 , 0x8347b5e1 , 0x1b238fc5 ] )
|
||||
, Mont::unsafe_make( [ 0x5dec1b62 , 0x03ee808b , 0x24a5b0e3 , 0xca989f68 , 0x969b1679 , 0x0a9dd6f3 , 0xb5594488 , 0x2f381880 ] )
|
||||
, Mont::unsafe_make( [ 0x31f7bc7d , 0x4dc1bde9 , 0xc3c821c4 , 0x297fe7bc , 0xef5a13e9 , 0x3d187d41 , 0x6dd44991 , 0x22ce9449 ] )
|
||||
, Mont::unsafe_make( [ 0xe5c30010 , 0xb49b0d22 , 0xa4bcd2e6 , 0x32c31ffe , 0x53635b98 , 0x9b673972 , 0xba55cdf2 , 0x19bc3f5d ] )
|
||||
, Mont::unsafe_make( [ 0xd888f747 , 0xbfb710c9 , 0x88b42853 , 0xd3830eef , 0xf3d66c38 , 0xfc297daa , 0x8d8380a4 , 0x1c338478 ] )
|
||||
, Mont::unsafe_make( [ 0x0f91afa4 , 0x5be81fd6 , 0x08bef3bc , 0xde692501 , 0x15410602 , 0xb9209581 , 0x15cfcf87 , 0x0f4930c0 ] )
|
||||
, Mont::unsafe_make( [ 0xac7bb650 , 0x140775f3 , 0xb3db8982 , 0xef2aeed8 , 0xe042538c , 0x9a877347 , 0x172e80cf , 0x1d2908d5 ] )
|
||||
, Mont::unsafe_make( [ 0x9e0cd4e5 , 0xd4e49691 , 0x8b54214f , 0x6af9acee , 0x9d68397b , 0x2bb29fd0 , 0x6ac689e1 , 0x04601bf2 ] )
|
||||
, Mont::unsafe_make( [ 0xf442e31b , 0x9a1ef65f , 0x36bf93fa , 0x013e1d34 , 0x53e7f886 , 0x91f5eed9 , 0x01073125 , 0x1f46ca5d ] )
|
||||
, Mont::unsafe_make( [ 0xfbe64967 , 0xfbc878e6 , 0x28974c04 , 0x9b816454 , 0xd02e7bc3 , 0x27082fa5 , 0x8b747176 , 0x24b36d27 ] )
|
||||
];
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// middle (internal) round constants
|
||||
pub const INTERNAL: [Mont; 56] =
|
||||
[ Mont::unsafe_make( [ 0x63a87f11 , 0x32b24ddf , 0xc68a2d80 , 0x4399e089 , 0xc5e781dc , 0xe8cf46be , 0x0ea42950 , 0x24179f86 ] )
|
||||
, Mont::unsafe_make( [ 0xbb41a1cd , 0x8e596a43 , 0xed67333a , 0xb8905327 , 0x5e7deb77 , 0x9ca2760e , 0x072cf73f , 0x2a1138e6 ] )
|
||||
, Mont::unsafe_make( [ 0xc4873e4c , 0xa2d6fe26 , 0x922c4116 , 0x4fdb4a9a , 0xa7ad9dc5 , 0x67929db0 , 0xe9115aa2 , 0x2ece82ef ] )
|
||||
, Mont::unsafe_make( [ 0xf0183919 , 0x7da2423a , 0x90ab2a83 , 0x83074ecd , 0x3ed825cc , 0xac50cfef , 0x20eb9223 , 0x1b7040e8 ] )
|
||||
, Mont::unsafe_make( [ 0x63680308 , 0x31c4f897 , 0x0fc5ae2f , 0xb7069600 , 0x7ac28bae , 0xc71f1418 , 0xabb909bb , 0x067a5790 ] )
|
||||
, Mont::unsafe_make( [ 0x24bc6963 , 0x3e6253d8 , 0xe3957d21 , 0x128434d2 , 0x45751bd0 , 0x73e88e83 , 0x2bf935fe , 0x1ec27510 ] )
|
||||
, Mont::unsafe_make( [ 0xb1cd4b35 , 0x3f7fd69b , 0x8087281c , 0x6bbd302d , 0xcad1bb50 , 0x74b7b34f , 0x57e9f653 , 0x12822b2e ] )
|
||||
, Mont::unsafe_make( [ 0x07bfbd61 , 0xac0ae45c , 0x7cd7f0d5 , 0xb518f596 , 0x2b591e23 , 0xb8614d58 , 0xe4bf33d2 , 0x2fa8547b ] )
|
||||
, Mont::unsafe_make( [ 0xf91bb545 , 0x582e17c9 , 0x57c2a98a , 0x3fa22419 , 0xe79a8bd0 , 0xad2b4437 , 0x5fb99b83 , 0x0837512a ] )
|
||||
, Mont::unsafe_make( [ 0x78e91647 , 0x229f8d81 , 0x03b26fcc , 0x8d9681e9 , 0x79434c4a , 0x45db40d2 , 0x7b1e5225 , 0x07ee329d ] )
|
||||
, Mont::unsafe_make( [ 0x22c17fc8 , 0x6318c16c , 0xfc9e5d68 , 0xbfdd2fea , 0x442ac9c5 , 0xacdbeef5 , 0x050dc0c7 , 0x00ae5ded ] )
|
||||
, Mont::unsafe_make( [ 0x5515674c , 0x9083446f , 0xc9310224 , 0xd2524733 , 0x131e63ff , 0x1f177d64 , 0x3b5a088c , 0x2fdc6f9d ] )
|
||||
, Mont::unsafe_make( [ 0xb9b68f1c , 0x562525e1 , 0x06aff56d , 0xcbff0541 , 0x92646360 , 0x89fc2bc1 , 0x529e1a85 , 0x02936b79 ] )
|
||||
, Mont::unsafe_make( [ 0x8ed01726 , 0x835afa7b , 0x231dfb7b , 0x5c81156e , 0x82ac566f , 0xafdf42f4 , 0x12944b7a , 0x0ae513f4 ] )
|
||||
, Mont::unsafe_make( [ 0x64153fa2 , 0xc3b7b380 , 0x922c85e2 , 0x9fa20da0 , 0x2442401a , 0xe399f530 , 0x86ef8eed , 0x034d20c4 ] )
|
||||
, Mont::unsafe_make( [ 0x01c7028f , 0xfccf931d , 0x177396a7 , 0x5cc1fdc2 , 0xfc6701d4 , 0x0db510f1 , 0xef34d26a , 0x211dee7c ] )
|
||||
, Mont::unsafe_make( [ 0x959b730c , 0x1f9fbd0d , 0xd08dbdda , 0x02212476 , 0x00dda9e8 , 0x5a76106a , 0x225fdd1d , 0x13377b7a ] )
|
||||
, Mont::unsafe_make( [ 0x0bbbf47b , 0x2208a351 , 0xbecd424c , 0x87ceb7e4 , 0x1a507c93 , 0x2857ed91 , 0xb12af71f , 0x10026a8f ] )
|
||||
, Mont::unsafe_make( [ 0x34fc7997 , 0x2a5882ce , 0x30b9f4b1 , 0x281eaee2 , 0xcb39b245 , 0x0184e2ae , 0xb3dbe484 , 0x2f9a9a34 ] )
|
||||
, Mont::unsafe_make( [ 0xd6494752 , 0x361cf48e , 0x53aaecb3 , 0x37855734 , 0x06edb45b , 0x1475e1a0 , 0x6ebc4e45 , 0x0ed71954 ] )
|
||||
, Mont::unsafe_make( [ 0x0e0a468d , 0x7a59eefd , 0x2f92b52b , 0x7b4e3488 , 0xa4f50258 , 0x835f3260 , 0xcbbd4ee9 , 0x209f884a ] )
|
||||
, Mont::unsafe_make( [ 0x3992166b , 0xa6084fc8 , 0x7884e26a , 0x23f9d216 , 0x85922b82 , 0xdae6419e , 0x7b308319 , 0x1aaf1c38 ] )
|
||||
, Mont::unsafe_make( [ 0x4f72f940 , 0x448e1b88 , 0x090c845e , 0x474e3b1a , 0x76a28f52 , 0xd76dc821 , 0xb3900ca5 , 0x0661f5bb ] )
|
||||
, Mont::unsafe_make( [ 0x17d14633 , 0x8d82b96f , 0x9211cea0 , 0xa55abf68 , 0xed016dc0 , 0x0a0ea58d , 0xacc022b0 , 0x26980bd7 ] )
|
||||
, Mont::unsafe_make( [ 0xfbc5ba96 , 0xd233bfbb , 0xb8d87dbb , 0xfb19f391 , 0x6fc8adcd , 0xef26e2f0 , 0x4a62fbe3 , 0x29f05386 ] )
|
||||
, Mont::unsafe_make( [ 0x034a5e9a , 0xca005b5f , 0x1d3f4e64 , 0xa5ab9533 , 0x1d7df942 , 0x6db6bdc1 , 0x3262ed01 , 0x11c1115e ] )
|
||||
, Mont::unsafe_make( [ 0x4b4fdc49 , 0x6932c528 , 0x4defd62e , 0x270479ff , 0x34b1735d , 0x6bfb90f8 , 0x9f1866ab , 0x1c6ef70f ] )
|
||||
, Mont::unsafe_make( [ 0xdc94435b , 0xc84790e5 , 0xa285bc1c , 0x301c52bc , 0x3df2edaf , 0x4f004e58 , 0xf36b28f6 , 0x2acfde59 ] )
|
||||
, Mont::unsafe_make( [ 0x38ad3917 , 0xec01c44e , 0x576ffac3 , 0xdb94dcb0 , 0xf13b00c5 , 0x4110dcca , 0x61ba8149 , 0x10a265d2 ] )
|
||||
, Mont::unsafe_make( [ 0x6bca5ab4 , 0x602c5aa2 , 0xf7f88e49 , 0x1865586a , 0x00f32fae , 0x63a81fa2 , 0xfcb54a68 , 0x1826af5c ] )
|
||||
, Mont::unsafe_make( [ 0x558f5acb , 0xe91fcaf0 , 0x765655ac , 0x266dac80 , 0x8b8e9896 , 0x8b40e59a , 0x8e59bd63 , 0x1c11c622 ] )
|
||||
, Mont::unsafe_make( [ 0x835ebe43 , 0xb3668077 , 0x57b83bef , 0x6460005e , 0xafa0d882 , 0xd2290bd2 , 0x6875c392 , 0x2bc97856 ] )
|
||||
, Mont::unsafe_make( [ 0x39c5e008 , 0x41764c3a , 0xe184dd8a , 0xd7112598 , 0xe7c8878c , 0x8b7fd727 , 0x9fa64e5f , 0x3016a322 ] )
|
||||
, Mont::unsafe_make( [ 0x6fd21bae , 0xb225d1fa , 0x4dec5f3a , 0x4a0a832c , 0x4b1d4816 , 0xfad60f34 , 0xeb9be829 , 0x1c09053e ] )
|
||||
, Mont::unsafe_make( [ 0x17340552 , 0x7c721de0 , 0x1195f30a , 0x99244f79 , 0xc9301f8c , 0xa617c790 , 0xa08d506c , 0x2408b160 ] )
|
||||
, Mont::unsafe_make( [ 0xba423408 , 0xd073aaff , 0x8ae14508 , 0x71125dd4 , 0x671ef587 , 0xe326a452 , 0x66daa9b8 , 0x228d989c ] )
|
||||
, Mont::unsafe_make( [ 0xd516adfc , 0x6a2a6ee8 , 0x4214cbde , 0xbd2a77e7 , 0xad28fdc9 , 0x40c0d8ac , 0xf92eaa57 , 0x2a597159 ] )
|
||||
, Mont::unsafe_make( [ 0xcf88f39c , 0x3ff5a659 , 0xacfeef85 , 0xbd642a72 , 0x29ee03ca , 0x69b16869 , 0x58f126aa , 0x01f47dc1 ] )
|
||||
, Mont::unsafe_make( [ 0x05068e50 , 0xb4a35fe1 , 0x0170263a , 0x925dabe7 , 0x16015ca1 , 0x5954f326 , 0xa897d970 , 0x13afed7d ] )
|
||||
, Mont::unsafe_make( [ 0xd973e478 , 0xac6e4e08 , 0xae4fbe93 , 0x02c10825 , 0xb7da6de8 , 0x9e626c47 , 0x407875f3 , 0x29e95405 ] )
|
||||
, Mont::unsafe_make( [ 0x7f3cadb8 , 0x560bf631 , 0x4762c202 , 0x1cea590a , 0x1b864256 , 0x64547963 , 0x76ca9137 , 0x0845a1b6 ] )
|
||||
, Mont::unsafe_make( [ 0xc9e8222b , 0x6f0b63d8 , 0x5e6e2272 , 0xe3b09d34 , 0x5ded3f8b , 0x3a655406 , 0xe21690b0 , 0x068bfbed ] )
|
||||
, Mont::unsafe_make( [ 0xd560dd1c , 0xa1893149 , 0xf2af7d52 , 0x21586179 , 0xb0031886 , 0x236ac59a , 0x483171fa , 0x0ef10ea0 ] )
|
||||
, Mont::unsafe_make( [ 0x8ac4549a , 0x34b91549 , 0x61a058c3 , 0x6fc950cc , 0x67d6917c , 0x24166cfd , 0xd9ac35d4 , 0x191fce22 ] )
|
||||
, Mont::unsafe_make( [ 0x49d2a6b8 , 0xfd93f933 , 0x597acbe9 , 0xf03cd2f3 , 0xfd48999a , 0x2cc94bd7 , 0xedd197f6 , 0x23199553 ] )
|
||||
, Mont::unsafe_make( [ 0xa358cf53 , 0x7a16b2fb , 0x711de14f , 0xf953f552 , 0xcd1b74aa , 0xf9d23261 , 0x2dc5cab1 , 0x03d68909 ] )
|
||||
, Mont::unsafe_make( [ 0x1155469f , 0x8d676214 , 0xbc279819 , 0xd3fb3aa2 , 0x743e7aee , 0x1cbf86c9 , 0xa86d7a64 , 0x2fddc3cb ] )
|
||||
, Mont::unsafe_make( [ 0x299d0839 , 0x041d54ff , 0x6f40c7ee , 0x01a95937 , 0x69d2aae8 , 0x4941cba3 , 0x5ab1ca73 , 0x198afca8 ] )
|
||||
, Mont::unsafe_make( [ 0xbe0f6cf9 , 0x51f145c0 , 0x54368550 , 0x6e06e933 , 0xe6923803 , 0x7b6789b6 , 0xcce276a0 , 0x300b083d ] )
|
||||
, Mont::unsafe_make( [ 0xc11fab61 , 0xf169c2f1 , 0xe39df401 , 0xcde431c3 , 0x9714b7dc , 0x3374c982 , 0x30304f44 , 0x0a8d0259 ] )
|
||||
, Mont::unsafe_make( [ 0xf650e13a , 0x84045538 , 0x44199b84 , 0x1264bcd7 , 0x9ca9bf28 , 0x9d7390fd , 0x7e0ecd21 , 0x156ab7a7 ] )
|
||||
, Mont::unsafe_make( [ 0x3969b6da , 0xfcf9daec , 0xfcaf59a5 , 0x152eb98b , 0x756e103d , 0xd003ce7a , 0xe48e5d81 , 0x19d4fa93 ] )
|
||||
, Mont::unsafe_make( [ 0x6733b3be , 0x9ab4f0c9 , 0x5689197d , 0x6287074d , 0x89106ed1 , 0xe43d0693 , 0xd70e7b0f , 0x1f26ae44 ] )
|
||||
, Mont::unsafe_make( [ 0x71d70229 , 0x26cbba79 , 0x058ce3bf , 0x53d0900b , 0xebfbd9fe , 0x3a847ecf , 0xcd80fa42 , 0x26bf21aa ] )
|
||||
, Mont::unsafe_make( [ 0x59728b5f , 0xd91546d0 , 0x24f28398 , 0xa2d4657f , 0x41bd7133 , 0xbc56176b , 0x171fec0c , 0x259d39ba ] )
|
||||
, Mont::unsafe_make( [ 0x6bd8f9de , 0x61a581a8 , 0x9f2f63a8 , 0x26c547f6 , 0xbf4cb45d , 0xc4a7ecdc , 0xcacbad07 , 0x25c6b8d5 ] )
|
||||
];
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// final (external) round constants (flattened)
|
||||
pub const FINAL: [Mont; 16] =
|
||||
[ Mont::unsafe_make( [ 0xee7b911c , 0x1dc1a62e , 0xb64c16f8 , 0x81c5b0e4 , 0x886a8101 , 0xf0b1bb86 , 0x7577f139 , 0x299d41d3 ] )
|
||||
, Mont::unsafe_make( [ 0xbd90a340 , 0xfc235b0d , 0xcd23b385 , 0x59870fef , 0x6a9ab5c1 , 0x12224cb7 , 0x8ca322a3 , 0x1f1d0f74 ] )
|
||||
, Mont::unsafe_make( [ 0xeb0e2f5b , 0x6fa61272 , 0xc8843b8c , 0x278ec838 , 0xaa1617d8 , 0x320ff3d6 , 0x989f5be9 , 0x0c6cf6a2 ] )
|
||||
, Mont::unsafe_make( [ 0x24142950 , 0x90c8273d , 0x1df6b180 , 0x53984a1a , 0x03271799 , 0x8ff74726 , 0x6e65bd91 , 0x1e39cb11 ] )
|
||||
, Mont::unsafe_make( [ 0xbb915d9b , 0xfbaca328 , 0x659e07e4 , 0xccd436d2 , 0x351deb38 , 0xf50856b7 , 0xa8b929c3 , 0x1a113344 ] )
|
||||
, Mont::unsafe_make( [ 0x0c6b5cfd , 0xd1d50ac4 , 0xd71dda88 , 0xb238293c , 0xdcc86bf4 , 0xff760565 , 0xcd502341 , 0x085a36f4 ] )
|
||||
, Mont::unsafe_make( [ 0x66f38970 , 0x806084d8 , 0xb032fc24 , 0xfaed3909 , 0x2ce17c0c , 0xc0f57174 , 0x83b646b6 , 0x1eda9e3a ] )
|
||||
, Mont::unsafe_make( [ 0xe8592770 , 0x84be1ce1 , 0x5c59d9a9 , 0x5a4e6c56 , 0x962ae15b , 0xda93224a , 0x624c3ab0 , 0x06b4eec6 ] )
|
||||
, Mont::unsafe_make( [ 0x2772f3cb , 0xe0592b6e , 0xa1364145 , 0x3de596b3 , 0x96b16c18 , 0xdfe866b5 , 0xa48ef21a , 0x0185b617 ] )
|
||||
, Mont::unsafe_make( [ 0xb9678729 , 0xaddcb1b4 , 0xc6a711ce , 0xe473e83e , 0x02240906 , 0x83130a7f , 0xbbd8faf2 , 0x084a5673 ] )
|
||||
, Mont::unsafe_make( [ 0xa5e59b68 , 0x62a1b415 , 0x362feed4 , 0x0085b2a1 , 0x38879c1d , 0x244bfcad , 0x3636b542 , 0x07f0c69b ] )
|
||||
, Mont::unsafe_make( [ 0xd02575e9 , 0x656e2a85 , 0xe3b9222d , 0x387a6bab , 0xfd91b384 , 0x87762f9c , 0xb26c71a3 , 0x0ca431cb ] )
|
||||
, Mont::unsafe_make( [ 0xe945dea1 , 0xd462bdd8 , 0xcd951d07 , 0xeabf916a , 0xedae55b2 , 0x31bf8b87 , 0x1e0c023f , 0x122a0ea8 ] )
|
||||
, Mont::unsafe_make( [ 0x04d5bc24 , 0xacb9ffac , 0x5b5a7c4e , 0x2cc729d4 , 0x04f6c2a0 , 0x5f4e5d01 , 0xdcf0f4ee , 0x27d45d1f ] )
|
||||
, Mont::unsafe_make( [ 0x52f68f67 , 0x937d812b , 0x08b6aaa5 , 0x59e1b259 , 0x91adea5e , 0x0d8af00a , 0x9e672d4e , 0x035bc029 ] )
|
||||
, Mont::unsafe_make( [ 0x8156da44 , 0xf5a74411 , 0xdc43336a , 0xa271d755 , 0xaa2f4efb , 0x956bfc41 , 0x3b371804 , 0x2f9eb2d7 ] )
|
||||
];
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// known answer test
|
||||
pub const KAT_MONT: [Mont; 4] =
|
||||
[ Mont::unsafe_make( [ 0x730e9f6f , 0x328345ff , 0xbd614d43 , 0x1aaf0a22 , 0x56327b1a , 0x005f717f , 0x086c6c0a , 0x165cb264 ] )
|
||||
, Mont::unsafe_make( [ 0xb5b5f3b0 , 0x087e2222 , 0x63f7babd , 0x5eb125ff , 0x74a059da , 0xebb9cb2a , 0xe09e3682 , 0x2192496e ] )
|
||||
, Mont::unsafe_make( [ 0x3a46a64a , 0xebd973b0 , 0x74d22d4b , 0x29964a74 , 0x2a4ea87c , 0x948e7fbf , 0x82fd731c , 0x09850d6d ] )
|
||||
, Mont::unsafe_make( [ 0x152b3fb8 , 0x23a0a53c , 0x912962aa , 0x48e1a1f2 , 0x28f9e692 , 0x404427e2 , 0x2f91d3d6 , 0x26af8324 ] )
|
||||
];
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
121
src/poseidon2/diag.rs
Normal file
121
src/poseidon2/diag.rs
Normal file
@ -0,0 +1,121 @@
|
||||
|
||||
//
|
||||
// internal diffusion matrices (diagonal + constant 1 matrix)
|
||||
//
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
use crate::bn254::montgomery::*;
|
||||
|
||||
#[inline(always)]
|
||||
fn add3(x: Mont, y: Mont, z: Mont) -> Mont {
|
||||
Mont::add(Mont::add(x,y),z)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn add4(x: Mont, y: Mont, z: Mont, w: Mont) -> Mont {
|
||||
Mont::add(Mont::add(x,y),Mont::add(z,w))
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn diag_T2(x: [Mont; 2]) -> [Mont; 2] {
|
||||
let s = Mont::add( x[0] , x[1] );
|
||||
[ Mont::add( s , x[0] )
|
||||
, Mont::add( s , Mont::dbl( x[1] ) )
|
||||
]
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn diag_T3(x: [Mont; 3]) -> [Mont; 3] {
|
||||
let s = add3( x[0], x[1], x[2] );
|
||||
[ Mont::add( s , x[0] )
|
||||
, Mont::add( s , x[1] )
|
||||
, Mont::add( s , Mont::dbl( x[2] ) )
|
||||
]
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// *** "old" params ***
|
||||
|
||||
pub mod old {
|
||||
|
||||
pub mod t2 {
|
||||
use super::super::*;
|
||||
|
||||
#[inline(always)]
|
||||
pub fn diag(x: [Mont; 2]) -> [Mont; 2] { diag_T2(x) }
|
||||
|
||||
}
|
||||
|
||||
pub mod t3 {
|
||||
use super::super::*;
|
||||
|
||||
#[inline(always)]
|
||||
pub fn diag(x: [Mont; 3]) -> [Mont; 3] { diag_T3(x) }
|
||||
|
||||
}
|
||||
|
||||
pub mod t4 {
|
||||
use crate::bn254::montgomery::*;
|
||||
use crate::poseidon2::constants::old::t4::{DIAGONAL};
|
||||
use super::super::{add4};
|
||||
|
||||
#[inline(always)]
|
||||
pub fn diag(x: [Mont; 4]) -> [Mont; 4] {
|
||||
let s = add4( x[0], x[1], x[2], x[3] );
|
||||
[ Mont::add( s , Mont::mul( x[0] , DIAGONAL[0] ) )
|
||||
, Mont::add( s , Mont::mul( x[1] , DIAGONAL[1] ) )
|
||||
, Mont::add( s , Mont::mul( x[2] , DIAGONAL[2] ) )
|
||||
, Mont::add( s , Mont::mul( x[3] , DIAGONAL[3] ) )
|
||||
]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// *** "new" params ***
|
||||
|
||||
pub mod new {
|
||||
|
||||
pub mod t2 {
|
||||
use super::super::*;
|
||||
|
||||
#[inline(always)]
|
||||
pub fn diag(x: [Mont; 2]) -> [Mont; 2] { diag_T2(x) }
|
||||
|
||||
}
|
||||
|
||||
pub mod t3 {
|
||||
use super::super::*;
|
||||
|
||||
#[inline(always)]
|
||||
pub fn diag(x: [Mont; 3]) -> [Mont; 3] { diag_T3(x) }
|
||||
|
||||
}
|
||||
|
||||
pub mod t4 {
|
||||
use crate::bn254::montgomery::*;
|
||||
use crate::poseidon2::constants::new::t4::{DIAGONAL};
|
||||
use super::super::{add4};
|
||||
|
||||
#[inline(always)]
|
||||
pub fn diag(x: [Mont; 4]) -> [Mont; 4] {
|
||||
let s = add4( x[0], x[1], x[2], x[3] );
|
||||
[ Mont::add( s , Mont::mul( x[0] , DIAGONAL[0] ) )
|
||||
, Mont::add( s , Mont::mul( x[1] , DIAGONAL[1] ) )
|
||||
, Mont::add( s , Mont::mul( x[2] , DIAGONAL[2] ) )
|
||||
, Mont::add( s , Mont::mul( x[3] , DIAGONAL[3] ) )
|
||||
]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
70
src/poseidon2/mds.rs
Normal file
70
src/poseidon2/mds.rs
Normal file
@ -0,0 +1,70 @@
|
||||
|
||||
//
|
||||
// MDS matrices (used in the external rounds and the standalaone linear layer)
|
||||
//
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
use crate::bn254::montgomery::*;
|
||||
|
||||
#[inline(always)]
|
||||
fn add3(x: Mont, y: Mont, z: Mont) -> Mont {
|
||||
Mont::add(Mont::add(x,y),z)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn times4(x: Mont) -> Mont {
|
||||
Mont::dbl(Mont::dbl(x))
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
pub mod t2 {
|
||||
use crate::bn254::montgomery::*;
|
||||
|
||||
#[inline(always)]
|
||||
pub fn mds(x: [Mont; 2]) -> [Mont; 2] {
|
||||
let s = Mont::add( x[0], x[1] );
|
||||
[ Mont::add( s , x[0] )
|
||||
, Mont::add( s , x[1] )
|
||||
]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pub mod t3 {
|
||||
use super::*;
|
||||
|
||||
#[inline(always)]
|
||||
pub fn mds(x: [Mont; 3]) -> [Mont; 3] {
|
||||
let s = add3( x[0], x[1], x[2] );
|
||||
[ Mont::add( s , x[0] )
|
||||
, Mont::add( s , x[1] )
|
||||
, Mont::add( s , x[2] )
|
||||
]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pub mod t4 {
|
||||
use super::*;
|
||||
|
||||
pub fn mds(x: [Mont; 4]) -> [Mont; 4] {
|
||||
let t0 = x[0] + x[1] ;
|
||||
let t1 = x[2] + x[3] ;
|
||||
let t2 = Mont::dbl( x[1] ) + t1 ;
|
||||
let t3 = Mont::dbl( x[3] ) + t0 ;
|
||||
let t4 = times4( t1 ) + t3 ;
|
||||
let t5 = times4( t0 ) + t2 ;
|
||||
let t6 = t3 + t5 ;
|
||||
let t7 = t2 + t4 ;
|
||||
[ t6 , t5 , t7, t4]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@ -1,8 +1,211 @@
|
||||
|
||||
pub mod constants;
|
||||
pub mod permutation;
|
||||
pub mod mds;
|
||||
pub mod diag;
|
||||
|
||||
pub use permutation::compress;
|
||||
pub use permutation::{Params,Poseidon2Params};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// helpers
|
||||
pub mod aux {
|
||||
|
||||
use crate::bn254::field::{Felt};
|
||||
|
||||
pub fn kat_input<const T: usize>() -> [Felt; T] {
|
||||
let mut xs: [Felt; T] = [Default::default(); T];
|
||||
for i in 0..T {
|
||||
xs[i] = Felt::from_u32(i as u32);
|
||||
}
|
||||
xs
|
||||
}
|
||||
|
||||
pub fn print_state<const T: usize>( prefix: &str, xs: [Felt; T] ) {
|
||||
for i in 0..T {
|
||||
println!(" - {}[{}] -> {}" , prefix, i , xs[i] );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// "old" set of constants
|
||||
|
||||
pub mod old {
|
||||
use crate::bn254::field::{Felt};
|
||||
pub use crate::poseidon2::permutation::{Params,Poseidon2Params};
|
||||
|
||||
pub fn permute<const T: usize>(input: [Felt; T]) -> [Felt; T] where Params: Poseidon2Params<false,T> {
|
||||
crate::poseidon2::permutation::permute::<false,T>( input )
|
||||
}
|
||||
|
||||
pub fn compress<const K: usize>(input: [Felt; K]) -> Felt where Params: Poseidon2Params<false,{K+1}> {
|
||||
crate::poseidon2::permutation::compress::<false,K>( input )
|
||||
}
|
||||
|
||||
pub fn hash1(a: Felt) -> Felt {
|
||||
compress::<1>([ a ])
|
||||
}
|
||||
|
||||
pub fn hash2(a: Felt, b: Felt) -> Felt {
|
||||
compress::<2>([ a, b ])
|
||||
}
|
||||
|
||||
pub fn hash3(a: Felt, b: Felt, c: Felt) -> Felt {
|
||||
compress::<3>([ a, b, c ])
|
||||
}
|
||||
|
||||
//--------------------------------------------------------
|
||||
// tests for the "old" permutations
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
|
||||
use crate::bn254::field::{Felt};
|
||||
use super::super::aux::*;
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn old_permute2_kat() {
|
||||
let out: [Felt; 2] = permute::<2>( kat_input::<2>() );
|
||||
print_state::<2>( "output" , out );
|
||||
assert_eq!( Felt::to_hex_string( out[0] ) , "0x1713924640bec577e44f2c0c4b3c73339c135cf4678b6ede5bce727791e9c1ef" );
|
||||
assert_eq!( Felt::to_hex_string( out[1] ) , "0x1ddcaa93e296bbc6cb89bf4052134cba5c1e35c4367e0d4d9344b576cf532c04" );
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn old_permute3_kat() {
|
||||
let out: [Felt; 3] = permute::<3>( kat_input::<3>() );
|
||||
print_state::<3>( "output" , out );
|
||||
assert_eq!( Felt::to_hex_string( out[0] ) , "0x30610a447b7dec194697fb50786aa7421494bd64c221ba4d3b1af25fb07bd103" );
|
||||
assert_eq!( Felt::to_hex_string( out[1] ) , "0x13f731d6ffbad391be22d2ac364151849e19fa38eced4e761bcd21dbdc600288" );
|
||||
assert_eq!( Felt::to_hex_string( out[2] ) , "0x1433e2c8f68382c447c5c14b8b3df7cbfd9273dd655fe52f1357c27150da786f" );
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn old_permute4_kat() {
|
||||
let out: [Felt; 4] = permute::<4>( kat_input::<4>() );
|
||||
print_state::<4>( "output" , out );
|
||||
assert_eq!( Felt::to_hex_string( out[0] ) , "0x2dae4aa60bf00f42e7e409b7d79112ef8c82dc98c8703a18f349cc1acb0c0a01" );
|
||||
assert_eq!( Felt::to_hex_string( out[1] ) , "0x024badd303fa99d176db98904313d803889ca6520ff89ccd821d82e128982cf0" );
|
||||
assert_eq!( Felt::to_hex_string( out[2] ) , "0x2621eb27814db8e95fbb3d33bc7050e9a15b68bc56897a99440343bd53415fe4" );
|
||||
assert_eq!( Felt::to_hex_string( out[3] ) , "0x1e894ea2894a467e113d91475ce583b82c6b421633989cfb2fb98d2008c7283c" );
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn old_hash1() {
|
||||
let hash: Felt = hash1( Felt::from_u32(111) );
|
||||
println!("hash = {}", hash);
|
||||
assert_eq!( Felt::to_hex_string( hash ) , "0x02bd8af9e7ea86b0861a82b55c865efc07b450e829a728c1afbceda702a4e4d1" );
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn old_hash2() {
|
||||
let hash: Felt = hash2( Felt::from_u32(111) , Felt::from_u32(222) );
|
||||
println!("hash = {}", hash);
|
||||
assert_eq!( Felt::to_hex_string( hash ) , "0x23063d9199d3aa163ccc0dc8342dddc6abb95c549ceb2593bb453971ee576834" );
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn old_hash3() {
|
||||
let hash: Felt = hash3( Felt::from_u32(111) , Felt::from_u32(222) , Felt::from_u32(333) );
|
||||
println!("hash = {}", hash);
|
||||
assert_eq!( Felt::to_hex_string( hash ) , "0x199e9230763587614801abcca27e80a7a87bd1a32be92dc8e0b64274b1a04c67" );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// "new" set of constants
|
||||
|
||||
pub mod new {
|
||||
use crate::bn254::field::{Felt};
|
||||
pub use crate::poseidon2::permutation::{Params,Poseidon2Params};
|
||||
|
||||
pub fn permute<const T: usize>(input: [Felt; T]) -> [Felt; T] where Params: Poseidon2Params<true,T> {
|
||||
crate::poseidon2::permutation::permute::<true,T>( input )
|
||||
}
|
||||
|
||||
pub fn compress<const K: usize>(input: [Felt; K]) -> Felt where Params: Poseidon2Params<true,{K+1}> {
|
||||
crate::poseidon2::permutation::compress::<true,K>( input )
|
||||
}
|
||||
|
||||
pub fn hash1(a: Felt) -> Felt {
|
||||
compress::<1>([ a ])
|
||||
}
|
||||
|
||||
pub fn hash2(a: Felt, b: Felt) -> Felt {
|
||||
compress::<2>([ a, b ])
|
||||
}
|
||||
|
||||
pub fn hash3(a: Felt, b: Felt, c: Felt) -> Felt {
|
||||
compress::<3>([ a, b, c ])
|
||||
}
|
||||
|
||||
//--------------------------------------------------------
|
||||
// tests for the "new" permutations
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
|
||||
use crate::bn254::field::{Felt};
|
||||
use super::super::aux::*;
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn new_permute2_kat() {
|
||||
let out: [Felt; 2] = permute::<2>( kat_input::<2>() );
|
||||
print_state::<2>( "output" , out );
|
||||
assert_eq!( Felt::to_hex_string( out[0] ) , "0x1d01e56f49579cec72319e145f06f6177f6c5253206e78c2689781452a31878b" );
|
||||
assert_eq!( Felt::to_hex_string( out[1] ) , "0x0d189ec589c41b8cffa88cfc523618a055abe8192c70f75aa72fc514560f6c61" );
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn new_permute3_kat() {
|
||||
let out: [Felt; 3] = permute::<3>( kat_input::<3>() );
|
||||
print_state::<3>( "output" , out );
|
||||
assert_eq!( Felt::to_hex_string( out[0] ) , "0x0bb61d24daca55eebcb1929a82650f328134334da98ea4f847f760054f4a3033" );
|
||||
assert_eq!( Felt::to_hex_string( out[1] ) , "0x303b6f7c86d043bfcbcc80214f26a30277a15d3f74ca654992defe7ff8d03570" );
|
||||
assert_eq!( Felt::to_hex_string( out[2] ) , "0x1ed25194542b12eef8617361c3ba7c52e660b145994427cc86296242cf766ec8" );
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn new_permute4_kat() {
|
||||
let out: [Felt; 4] = permute::<4>( kat_input::<4>() );
|
||||
print_state::<4>( "output" , out );
|
||||
assert_eq!( Felt::to_hex_string( out[0] ) , "0x01bd538c2ee014ed5141b29e9ae240bf8db3fe5b9a38629a9647cf8d76c01737" );
|
||||
assert_eq!( Felt::to_hex_string( out[1] ) , "0x239b62e7db98aa3a2a8f6a0d2fa1709e7a35959aa6c7034814d9daa90cbac662" );
|
||||
assert_eq!( Felt::to_hex_string( out[2] ) , "0x04cbb44c61d928ed06808456bf758cbf0c18d1e15a7b6dbc8245fa7515d5e3cb" );
|
||||
assert_eq!( Felt::to_hex_string( out[3] ) , "0x2e11c5cff2a22c64d01304b778d78f6998eff1ab73163a35603f54794c30847a" );
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn new_hash1() {
|
||||
let hash: Felt = hash1( Felt::from_u32(111) );
|
||||
println!("hash = {}", hash);
|
||||
assert_eq!( Felt::to_hex_string( hash ) , "0x04039c0cf1c60a357ab0fe3acf0687aa773da2ad16531da75c014fb54eac55e2" );
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn new_hash2() {
|
||||
let hash: Felt = hash2( Felt::from_u32(111) , Felt::from_u32(222) );
|
||||
println!("hash = {}", hash);
|
||||
assert_eq!( Felt::to_hex_string( hash ) , "0x0af73d8a3f066649dbdb14e1c9923a0d1cdd822d22f1e8dabcec606131706093" );
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn new_hash3() {
|
||||
let hash: Felt = hash3( Felt::from_u32(111) , Felt::from_u32(222) , Felt::from_u32(333) );
|
||||
println!("hash = {}", hash);
|
||||
assert_eq!( Felt::to_hex_string( hash ) , "0x1e21998b4bed0485cbf36d22656d04b5b49c4d2018afd95dae20c837e7c7f653" );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
pub use permutation::permute;
|
||||
pub use permutation::permute_mont;
|
||||
@ -4,10 +4,77 @@
|
||||
|
||||
use crate::bn254::field::*;
|
||||
use crate::bn254::montgomery::*;
|
||||
use crate::poseidon2::constants::*;
|
||||
|
||||
pub type FeltTriple = [Felt; 3];
|
||||
pub type MontTriple = [Mont; 3];
|
||||
use crate::poseidon2::constants::old;
|
||||
use crate::poseidon2::constants::new;
|
||||
|
||||
use crate::poseidon2::mds;
|
||||
use crate::poseidon2::diag;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
pub struct Params;
|
||||
|
||||
pub trait Poseidon2Params<const NEW: bool, const T: usize> {
|
||||
const NP: usize;
|
||||
fn const_initial () -> &'static [Mont];
|
||||
fn const_internal() -> &'static [Mont];
|
||||
fn const_final () -> &'static [Mont];
|
||||
fn const_KAT () -> &'static [Mont];
|
||||
fn mul_by_mds ( xs: [Mont; T] ) -> [Mont; T];
|
||||
fn mul_by_diag ( xs: [Mont; T] ) -> [Mont; T];
|
||||
}
|
||||
|
||||
macro_rules! impl_params {
|
||||
($NEW:literal, $T:literal, $oldnew:ident, $tmod:ident) => {
|
||||
impl Poseidon2Params<$NEW,$T> for Params {
|
||||
const NP: usize = 56;
|
||||
fn const_initial () -> &'static [Mont] { &$oldnew::$tmod::INITIAL }
|
||||
fn const_internal() -> &'static [Mont] { &$oldnew::$tmod::INTERNAL }
|
||||
fn const_final () -> &'static [Mont] { &$oldnew::$tmod::FINAL }
|
||||
fn const_KAT () -> &'static [Mont] { &$oldnew::$tmod::KAT_MONT }
|
||||
fn mul_by_mds ( xs: [Mont; $T] ) -> [Mont; $T] { mds::$tmod::mds(xs) }
|
||||
fn mul_by_diag( xs: [Mont; $T] ) -> [Mont; $T] { diag::$oldnew::$tmod::diag(xs) }
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// old parameters
|
||||
impl_params!( false, 2, old, t2 );
|
||||
impl_params!( false, 3, old, t3 );
|
||||
impl_params!( false, 4, old, t4 );
|
||||
|
||||
// new parameters
|
||||
impl_params!( true, 2, new, t2 );
|
||||
impl_params!( true, 3, new, t3 );
|
||||
impl_params!( true, 4, new, t4 );
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#[inline(always)]
|
||||
fn get_initial_rcs<const NEW: bool, const T: usize>(round: usize) -> [Mont; T] where Params: Poseidon2Params<NEW,T> {
|
||||
let mut rcs: [Mont; T] = [Default::default(); T];
|
||||
let k = round * T;
|
||||
for i in 0..T {
|
||||
rcs[i] = <Params as Poseidon2Params<NEW,T>>::const_initial() [k+i];
|
||||
}
|
||||
rcs
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn get_final_rcs<const NEW: bool, const T: usize>(round: usize) -> [Mont; T] where Params: Poseidon2Params<NEW,T> {
|
||||
let mut rcs: [Mont; T] = [Default::default(); T];
|
||||
let k = round * T;
|
||||
for i in 0..T {
|
||||
rcs[i] = <Params as Poseidon2Params<NEW,T>>::const_final() [k+i];
|
||||
}
|
||||
rcs
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn get_internal_rc<const NEW: bool, const T: usize>(round: usize) -> Mont where Params: Poseidon2Params<NEW,T> {
|
||||
<Params as Poseidon2Params<NEW,T>>::const_internal()[ round ]
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@ -18,74 +85,69 @@ fn sbox(x: Mont) -> Mont {
|
||||
Mont::mul(x,x4)
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#[inline(always)]
|
||||
fn add3(x: Mont, y: Mont, z: Mont) -> Mont {
|
||||
Mont::add(Mont::add(x,y),z)
|
||||
fn internal_round<const NEW: bool, const T: usize>(input: [Mont; T], rc: Mont) -> [Mont; T]
|
||||
where Params: Poseidon2Params<NEW,T> {
|
||||
let mut xs: [Mont; T] = input;
|
||||
xs[0] = sbox( Mont::add( xs[0] , rc ) );
|
||||
<Params as Poseidon2Params<NEW,T>>::mul_by_diag( xs )
|
||||
}
|
||||
|
||||
fn linear(input: MontTriple) -> MontTriple {
|
||||
let s = add3( input[0], input[1], input[2] );
|
||||
[ Mont::add( s , input[0] )
|
||||
, Mont::add( s , input[1] )
|
||||
, Mont::add( s , input[2] )
|
||||
]
|
||||
fn external_round<const NEW: bool, const T: usize>(input: [Mont; T], rcs: [Mont;T]) -> [Mont; T]
|
||||
where Params: Poseidon2Params<NEW,T> {
|
||||
let mut xs: [Mont; T] = [Default::default(); T];
|
||||
for i in 0..T {
|
||||
xs[i] = sbox( Mont::add( input[i] , rcs[i] ) );
|
||||
}
|
||||
<Params as Poseidon2Params<NEW,T>>::mul_by_mds( xs )
|
||||
}
|
||||
|
||||
fn internal_round(input: MontTriple, rc: Mont) -> MontTriple {
|
||||
let x = sbox( Mont::add( input[0] , rc ) );
|
||||
let s = add3( x , input[1] , input[2] );
|
||||
[ Mont::add( s , x )
|
||||
, Mont::add( s , input[1] )
|
||||
, Mont::add( s , Mont::dbl(input[2]) )
|
||||
]
|
||||
}
|
||||
|
||||
fn external_round(input: MontTriple, rcs: MontTriple) -> MontTriple {
|
||||
let x = sbox( Mont::add( input[0] , rcs[0] ) );
|
||||
let y = sbox( Mont::add( input[1] , rcs[1] ) );
|
||||
let z = sbox( Mont::add( input[2] , rcs[2] ) );
|
||||
let s = add3( x , y , z );
|
||||
[ Mont::add( s , x )
|
||||
, Mont::add( s , y )
|
||||
, Mont::add( s , z )
|
||||
]
|
||||
}
|
||||
|
||||
pub fn permute_mont(input: MontTriple) -> MontTriple {
|
||||
let mut state = linear(input);
|
||||
for i in 0..4 { state = external_round( state , get_initial_RCs(i) ); }
|
||||
for i in 0..56 { state = internal_round( state , INTERNAL_MONT [i] ); }
|
||||
for i in 0..4 { state = external_round( state , get_final_RCs (i) ); }
|
||||
pub fn permute_mont<const NEW: bool, const T: usize>(input: [Mont; T]) -> [Mont; T]
|
||||
where Params: Poseidon2Params<NEW,T> {
|
||||
let mut state = <Params as Poseidon2Params<NEW,T>>::mul_by_mds(input);
|
||||
for i in 0..4 { state = external_round::<NEW,T>( state , get_initial_rcs::<NEW,T>(i) ); }
|
||||
for i in 0..56 { state = internal_round::<NEW,T>( state , get_internal_rc::<NEW,T>(i) ); }
|
||||
for i in 0..4 { state = external_round::<NEW,T>( state , get_final_rcs ::<NEW,T>(i) ); }
|
||||
state
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
pub fn compress(input: [Felt; 2]) -> Felt {
|
||||
let mut state: [Mont; 3] = [Mont::zero(); 3];
|
||||
for i in 0..2 { state[i] = Felt::to_mont(input[i]); }
|
||||
state = permute_mont(state);
|
||||
pub fn compress<const NEW: bool, const K: usize>(input: [Felt; K]) -> Felt
|
||||
where Params: Poseidon2Params<NEW,{K+1}> {
|
||||
let mut state: [Mont; K+1] = [Mont::zero(); K+1];
|
||||
for i in 0..K {
|
||||
state[i] = Felt::to_mont(input[i]);
|
||||
}
|
||||
state = permute_mont::<NEW,{K+1}>(state);
|
||||
Felt::from_mont(state[0])
|
||||
}
|
||||
|
||||
pub fn permute(input: [Felt; 3]) -> [Felt; 3] {
|
||||
let state: MontTriple = Felt::to_mont_vec(input);
|
||||
let output = permute_mont(state);
|
||||
pub fn permute<const NEW: bool, const T: usize>(input: [Felt; T]) -> [Felt; T]
|
||||
where Params: Poseidon2Params<NEW,T> {
|
||||
let state: [Mont; T] = Felt::to_mont_vec(input);
|
||||
let output = permute_mont::<NEW,T>(state);
|
||||
Felt::from_mont_vec(output)
|
||||
}
|
||||
|
||||
pub fn permute_iterated(input: [Felt; 3], count: usize) -> [Felt; 3] {
|
||||
/*
|
||||
pub fn permute_iterated<const NEW: bool, const T: usize>(input: [Felt; T], count: usize) -> [Felt; T]
|
||||
where Params: Poseidon2Params<NEW,T> {
|
||||
let mut state: MontTriple = Felt::to_mont_vec(input);
|
||||
for _i in 0..count {
|
||||
state = permute_mont(state);
|
||||
state = permute_mont::<NEW,T>(state);
|
||||
}
|
||||
let out: FeltTriple = Felt::from_mont_vec(state);
|
||||
out
|
||||
}
|
||||
*/
|
||||
|
||||
//==============================================================================
|
||||
// *** TESTS
|
||||
|
||||
/*
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
|
||||
@ -104,6 +166,7 @@ mod test {
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user