Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench committed Feb 20, 2025
1 parent f9c2b30 commit 52006ec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,32 +1,19 @@
---
title: Hash methods
description:
Learn about the cryptographic primitives ready to use for any Noir project, including sha256,
blake2s and pedersen
Learn about the cryptographic primitives ready to use for any Noir project
keywords:
[cryptographic primitives, Noir project, sha256, blake2s, pedersen, hash]
sidebar_position: 0
---

import BlackBoxInfo from '@site/src/components/Notes/_blackbox';

## sha256
## sha256 compression

Given an array of bytes, returns the resulting sha256 hash.
Specify a message_size to hash only the first `message_size` bytes of the input.

#include_code sha256 noir_stdlib/src/hash/sha256.nr rust

example:
#include_code sha256_var test_programs/execution_success/sha256/src/main.nr rust

```rust
fn main() {
let x = [163, 117, 178, 149]; // some random bytes
let hash = std::sha256::sha256_var(x, 4);
}
```
Performs a sha256 compression on an input and initial state, returning the resulting state.

#include_code sha256_compression noir_stdlib/src/hash/sha256.nr rust

<BlackBoxInfo to="../black_box_fns"/>

Expand Down
2 changes: 2 additions & 0 deletions noir_stdlib/src/hash/mod.nr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ use crate::uint128::U128;

pub mod sha256 {
#[foreign(sha256_compression)]
// docs:start:sha256_compression
pub fn sha256_compression(input: [u32; 16], state: [u32; 8]) -> [u32; 8] {}
// docs:end:sha256_compression
}

pub mod keccak256 {
Expand Down

0 comments on commit 52006ec

Please sign in to comment.