Website Summary Files Commits Branches @commit @diff @stats
path: root / guests / sha2 / src
diff options
context:
space:
mode:
Commit786ff15fb153a8164d116af128a9b6f6ffed2645 (patch)
Author
 Kamen Mladenov <kamen@syndamia.com>
2025-04-09 16:02:03 +0300
Committer
 Kamen Mladenov <kamen@syndamia.com>
2025-04-09 17:06:10 +0300
Files7eabc251a8d819b0633d4093ce030765169b34c1 /guests/sha2/src
zkVMs-benchmarks-786ff15fb153a8164d116af128a9b6f6ffed2645.tar
zkVMs-benchmarks-786ff15fb153a8164d116af128a9b6f6ffed2645.tar.gz
zkVMs-benchmarks-786ff15fb153a8164d116af128a9b6f6ffed2645.zip
Parent1f3ca1f4455c4dd98680ede689bbcfba2c8e4225 (diff)
feat(guests): Add SHA2 program
Simple program which tests the SHA256 hashing algorithm
1 files changed, 19 insertions, 0 deletions
-rw-r--r--guests/sha2/src/lib.rs19
diff --git a/guests/sha2/src/lib.rs b/guests/sha2/src/lib.rs
new file mode 100644
index 0000000..1ca7f72
--- /dev/null
+++ b/guests/sha2/src/lib.rs
@@ -0,0 +1,19 @@
+#![cfg_attr(feature = "no_std", no_std)]
+
+#[cfg(feature = "no_std")]
+extern crate alloc;
+#[cfg(feature = "no_std")]
+use alloc::vec::Vec;
+
+use sha2::{Digest, Sha256};
+
+#[guests_macro::proving_entrypoint]
+pub fn main(secret: Vec<u8>, hash: Vec<u8>) -> bool {
+ let mut hasher = Sha256::new();
+ hasher.update(secret);
+ let result = hasher.finalize();
+
+ let output: [u8; 32] = result.into();
+
+ output.to_vec() == hash
+}