-
Notifications
You must be signed in to change notification settings - Fork 105
Implementation of CryptographicSponge
for Merlin
#136
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 5 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
7fc117b
Add Merlin, `squeeze_bits` does not work
autquis 1837580
Fix bug
autquis 746e62e
Apply suggestions from code review
mmagician 5515787
Rename the merlin directory
autquis 7e798f6
Fix `Cargo.toml`
autquis c899a53
Add link to Merlin page
autquis 6cbaad7
Remove redundant imports, nightly check
autquis c18e37c
Merge branch 'main' into merlin-sponge
autquis 3854f20
Merge branch 'main' into merlin-sponge
autquis e1a54f6
Undo a mistake
autquis 705a938
Fix Merlin sponge
autquis 12796fd
Merge branch 'arkworks-rs:main' into merlin-sponge
Cesar199999 0960300
Fix nightly check errors
Cesar199999 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
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use crate::sponge::{Absorb, CryptographicSponge}; | ||
use crate::Vec; | ||
pub use merlin::Transcript; | ||
|
||
impl CryptographicSponge for Transcript { | ||
type Config = &'static [u8]; | ||
|
||
fn new(params: &Self::Config) -> Self { | ||
Transcript::new(*params) | ||
} | ||
|
||
fn absorb(&mut self, input: &impl Absorb) { | ||
self.append_message(b"", &input.to_sponge_bytes_as_vec()); | ||
} | ||
|
||
fn squeeze_bytes(&mut self, num_bytes: usize) -> Vec<u8> { | ||
let mut dest = vec![0; num_bytes]; | ||
self.challenge_bytes(b"", &mut dest); | ||
dest | ||
} | ||
|
||
fn squeeze_bits(&mut self, num_bits: usize) -> Vec<bool> { | ||
let num_bytes = (num_bits + 7) / 8; | ||
let mut tmp = vec![0; num_bytes]; | ||
self.challenge_bytes(b"", &mut tmp); | ||
let dest = tmp | ||
.iter() | ||
.flat_map(|byte| (0..8u32).rev().map(move |i| (byte >> i) & 1 == 1)) | ||
.collect::<Vec<_>>(); | ||
dest[..num_bits].to_vec() | ||
} | ||
} |
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
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.
Uh oh!
There was an error while loading. Please reload this page.