-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
54 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,2 @@ | ||
out | ||
target |
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,29 @@ | ||
[[package]] | ||
name = "core" | ||
source = "path+from-root-0DAF035ABF1276AD" | ||
|
||
[[package]] | ||
name = "library" | ||
source = "member" | ||
dependencies = [ | ||
"std", | ||
"sway_libs", | ||
] | ||
|
||
[[package]] | ||
name = "standards" | ||
source = "git+https://github.com/FuelLabs/sway-standards?tag=v0.5.0#348f7175df4c012b23c86cdb18aab79025ca1f18" | ||
dependencies = ["std"] | ||
|
||
[[package]] | ||
name = "std" | ||
source = "git+https://github.com/fuellabs/sway?rev#4c2c38430264472221dd4c68142013d819843b01" | ||
dependencies = ["core"] | ||
|
||
[[package]] | ||
name = "sway_libs" | ||
source = "git+https://github.com/FuelLabs/sway-libs?tag=v0.22.0#172adbbcc36e561a56c5820209445f86f0856bfc" | ||
dependencies = [ | ||
"standards", | ||
"std", | ||
] |
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,8 @@ | ||
[project] | ||
authors = ["Nazeeh Vahora"] | ||
entry = "main.sw" | ||
license = "Apache-2.0" | ||
name = "library" | ||
|
||
[dependencies] | ||
sway_libs = { git = "https://github.com/FuelLabs/sway-libs", tag = "v0.22.0" } |
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,15 @@ | ||
library; | ||
|
||
use std::hash::sha256; | ||
use std::hash::Hash; | ||
|
||
/// Generates a SHA-256 hash of the input. | ||
pub fn generate_sha256<T: Hash>(input: T) -> b256 { | ||
sha256(input) | ||
} | ||
|
||
/// Verifies if the SHA-256 hash of the input matches the provided hash. | ||
pub fn verify_sha256<T: Hash>(input: T, expected_hash: b256) -> bool { | ||
let computed_hash = sha256(input); | ||
computed_hash == expected_hash | ||
} |