-
Notifications
You must be signed in to change notification settings - Fork 10
chore: add back tests with poseidon #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 9 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
090a200
resolve issue #3
0xKarl98 dee2803
cargo fmt
0xKarl98 ee1a6c4
remove commented-out SHA tests
0xKarl98 11337fe
Revert "resolve issue #3"
0xKarl98 8e992b7
Remove Winternitz encoding
0xKarl98 335e8ec
remove commented-out sha tests
0xKarl98 269d088
revert numbers back
0xKarl98 861fdfd
clean up
0xKarl98 419b628
optimize
0xKarl98 cad926f
apply thomas suggestions
0xKarl98 f5dbf6c
revert back to 10
0xKarl98 88cbde3
revert again
0xKarl98 cec71aa
clean up
0xKarl98 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -587,7 +587,10 @@ mod tests { | |||||
| inc_encoding::target_sum::TargetSumEncoding, | ||||||
| signature::test_templates::test_signature_scheme_correctness, | ||||||
| symmetric::{ | ||||||
| message_hash::{MessageHash, poseidon::PoseidonMessageHashW1}, | ||||||
| message_hash::{ | ||||||
| MessageHash, | ||||||
| poseidon::{PoseidonMessageHash, PoseidonMessageHashW1}, | ||||||
| }, | ||||||
| prf::shake_to_field::ShakePRFtoF, | ||||||
| tweak_hash::poseidon::PoseidonTweakW1L5, | ||||||
| }, | ||||||
|
|
@@ -602,6 +605,32 @@ mod tests { | |||||
|
|
||||||
| type TestTH = PoseidonTweakHash<5, 7, 2, 9, 155>; | ||||||
|
|
||||||
| fn compress_prf_output<const OUT_LEN: usize>(value: [F; 24]) -> FieldArray<OUT_LEN> { | ||||||
| assert!( | ||||||
| OUT_LEN <= 24, | ||||||
| "Poseidon compression output length must be <= 24" | ||||||
| ); | ||||||
| let hash = crate::symmetric::tweak_hash::poseidon::poseidon_compress::<F, _, 24, OUT_LEN>( | ||||||
| &crate::poseidon2_24(), | ||||||
| value.as_slice(), | ||||||
| ); | ||||||
| FieldArray(hash) | ||||||
| } | ||||||
|
|
||||||
| // Compress a wide PRF output down to the four-field-element domain used by PoseidonTweakHash. | ||||||
| impl From<[F; 24]> for FieldArray<4> { | ||||||
| fn from(value: [F; 24]) -> Self { | ||||||
| compress_prf_output::<4>(value) | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| // Compress a wide PRF output down to the eight-field-element domain used by PoseidonTweakHash. | ||||||
| impl From<[F; 24]> for FieldArray<8> { | ||||||
| fn from(value: [F; 24]) -> Self { | ||||||
| compress_prf_output::<8>(value) | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| #[test] | ||||||
| pub fn test_target_sum_poseidon() { | ||||||
| // Note: do not use these parameters, they are just for testing | ||||||
|
|
@@ -613,7 +642,7 @@ mod tests { | |||||
| const MAX_CHUNK_VALUE: usize = BASE - 1; | ||||||
| const EXPECTED_SUM: usize = NUM_CHUNKS * MAX_CHUNK_VALUE / 2; | ||||||
| type IE = TargetSumEncoding<MH, EXPECTED_SUM>; | ||||||
| const LOG_LIFETIME: usize = 6; | ||||||
| const LOG_LIFETIME: usize = 10; | ||||||
0xKarl98 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| type Sig = GeneralizedXMSSSignatureScheme<PRF, IE, TH, LOG_LIFETIME>; | ||||||
|
|
||||||
| Sig::internal_consistency_check(); | ||||||
|
|
@@ -635,7 +664,7 @@ mod tests { | |||||
| const MAX_CHUNK_VALUE: usize = BASE - 1; | ||||||
| const EXPECTED_SUM: usize = NUM_CHUNKS * MAX_CHUNK_VALUE / 2; | ||||||
| type IE = TargetSumEncoding<MH, EXPECTED_SUM>; | ||||||
| const LOG_LIFETIME: usize = 6; | ||||||
| const LOG_LIFETIME: usize = 10; | ||||||
0xKarl98 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| type Sig = GeneralizedXMSSSignatureScheme<PRF, IE, TH, LOG_LIFETIME>; | ||||||
|
|
||||||
| Sig::internal_consistency_check(); | ||||||
|
|
@@ -666,15 +695,13 @@ mod tests { | |||||
| assert_eq!(rho1, rho2); | ||||||
| } | ||||||
|
|
||||||
| /*#[test] | ||||||
| pub fn test_large_base_sha() { | ||||||
| #[test] | ||||||
| pub fn test_large_base_poseidon() { | ||||||
| // Note: do not use these parameters, they are just for testing | ||||||
| type PRF = ShaPRF<24, 8>; | ||||||
| type TH = ShaTweak192192; | ||||||
|
|
||||||
| // use chunk size 8 | ||||||
| type MH = ShaMessageHash<24, 8, 32, 8>; | ||||||
| const TARGET_SUM: usize = 1 << 12; | ||||||
| type PRF = ShakePRFtoF<24, 8>; | ||||||
| type TH = PoseidonTweakHash<4, 4, 2, 8, 8>; | ||||||
| type MH = PoseidonMessageHash<4, 8, 2, 8, 256, 2, 9>; | ||||||
| const TARGET_SUM: usize = 8 * (256 - 1) / 2; | ||||||
|
||||||
| const TARGET_SUM: usize = 8 * (256 - 1) / 2; | |
| const TARGET_SUM: usize = 1 << 12; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need this