Skip to content

Commit

Permalink
chore: fix after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
Al-Kindi-0 committed Sep 12, 2024
1 parent 2d232be commit e6222dd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/hash/rescue/rpo/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use core::ops::Range;

use super::{
add_constants, add_constants_and_apply_inv_sbox, add_constants_and_apply_sbox, apply_inv_sbox,
apply_mds, apply_sbox, Digest, ElementHasher, Felt, FieldElement, Hasher, StarkField, ARK1,
ARK2, BINARY_CHUNK_SIZE, CAPACITY_RANGE, DIGEST_BYTES, DIGEST_RANGE, DIGEST_SIZE, INPUT1_RANGE,
INPUT2_RANGE, MDS, NUM_ROUNDS, RATE_RANGE, RATE_WIDTH, STATE_WIDTH, ZERO,
};
use core::ops::Range;

mod digest;
pub use digest::{RpoDigest, RpoDigestError};
Expand Down Expand Up @@ -167,8 +168,8 @@ impl Hasher for Rpo256 {
// - seed is copied into the first 4 elements of the rate portion of the state.
// - if the value fits into a single field element, copy it into the fifth rate element and
// set the first capacity element to 5.
// - if the value doesn't fit into a single field element, split it into two field
// elements, copy them into rate elements 5 and 6 and set the first capacity element to 6.
// - if the value doesn't fit into a single field element, split it into two field elements,
// copy them into rate elements 5 and 6 and set the first capacity element to 6.
let mut state = [ZERO; STATE_WIDTH];
state[INPUT1_RANGE].copy_from_slice(seed.as_elements());
state[INPUT2_RANGE.start] = Felt::new(value);
Expand Down
9 changes: 6 additions & 3 deletions src/hash/rescue/rpx/tests.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use alloc::{collections::BTreeSet, vec::Vec};

use proptest::prelude::*;
use rand_utils::rand_value;

use super::{Felt, Hasher, Rpx256, StarkField, ZERO};
use crate::{hash::rescue::RpxDigest, ONE};
use alloc::{collections::BTreeSet, vec::Vec};

#[test]
fn hash_elements_vs_merge() {
Expand All @@ -29,15 +30,17 @@ fn merge_vs_merge_in_domain() {
];
let merge_result = Rpx256::merge(&digests);

// ------------- merge with domain = 0 ----------------------------------------------------------
// ------------- merge with domain = 0
// ----------------------------------------------------------

// set domain to ZERO. This should not change the result.
let domain = ZERO;

let merge_in_domain_result = Rpx256::merge_in_domain(&digests, domain);
assert_eq!(merge_result, merge_in_domain_result);

// ------------- merge with domain = 1 ----------------------------------------------------------
// ------------- merge with domain = 1
// ----------------------------------------------------------

// set domain to ONE. This should change the result.
let domain = ONE;
Expand Down

0 comments on commit e6222dd

Please sign in to comment.