Skip to content
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

Add examples for hashing with sha256 and blake3 #1154

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions miden/examples/hashing/blake3/blake3.inputs
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"]
}
17 changes: 17 additions & 0 deletions miden/examples/hashing/blake3/blake3.masm
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
3 changes: 3 additions & 0 deletions miden/examples/hashing/sha256/sha256.inputs
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"]
}
17 changes: 17 additions & 0 deletions miden/examples/hashing/sha256/sha256.masm
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
Loading