-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1154 from 0xPolygonMiden/andrew-hashing-examples
Add examples for hashing with `sha256` and `blake3`
- Loading branch information
Showing
4 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,3 @@ | ||
{ | ||
"operand_stack": ["4294967295", "4294967295", "4294967295", "4294967295", "4294967295", "4294967295", "4294967295", "4294967295", "4294967295", "4294967295", "4294967295", "4294967295", "4294967295", "4294967295", "4294967295", "4294967295"] | ||
} |
This file contains 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,17 @@ | ||
use.std::crypto::hashes::blake3 | ||
|
||
begin | ||
# hash_2to1 pops top 16 elements (64 bytes) from the stack, compute their hash and puts the | ||
# resulting 8 elements (32 bytes) back to the stack. | ||
exec.blake3::hash_2to1 | ||
|
||
# Check the correctness of the hashing result by comparing it with precomputed correct values. | ||
# This hash is a result of applying a blake3 hashing function to the binary value consisting of | ||
# only ones. | ||
push.0xD9696D27.0xF209D66E.0xD0DFDEB9.0x7D5992E2.0x44DDA9CB.0xD6FFB5E5.0x8CD0CAA6.0xF0270FA9 | ||
|
||
# compare results | ||
movupw.2 | ||
assert_eqw | ||
assert_eqw | ||
end |
This file contains 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,3 @@ | ||
{ | ||
"operand_stack": ["4294967295", "4294967295", "4294967295", "4294967295", "4294967295", "4294967295", "4294967295", "4294967295", "4294967295", "4294967295", "4294967295", "4294967295", "4294967295", "4294967295", "4294967295", "4294967295"] | ||
} |
This file contains 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,17 @@ | ||
use.std::crypto::hashes::sha256 | ||
|
||
begin | ||
# hash_2to1 pops top 16 elements (64 bytes) from the stack, compute their hash and puts the | ||
# resulting 8 elements (32 bytes) back to the stack. | ||
exec.sha256::hash_2to1 | ||
|
||
# Check the correctness of the hashing result by comparing it with precomputed correct values. | ||
# This hash is a result of applying a sha256 hashing function to the binary value consisting of | ||
# only ones. | ||
push.0x85E1D1F7.0x8643E4A2.0x2DAD7274.0x1F764AAD.0xBA3EEB20.0xF1D30600.0x294E9E0D.0x8667E718 | ||
|
||
# compare results | ||
movupw.2 | ||
assert_eqw | ||
assert_eqw | ||
end |