Skip to content

Commit 951d6c8

Browse files
committed
.
1 parent f2c87fd commit 951d6c8

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/sha256.nr

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ unconstrained fn __sha256_var<let N: u32>(msg: [u8; N], message_size: u32) -> HA
108108
pub(crate) fn process_full_blocks<let N: u32>(
109109
msg: [u8; N],
110110
message_size: u32,
111-
mut h: STATE,
111+
h: STATE,
112112
) -> (STATE, MSG_BLOCK) {
113113
let num_blocks = N / BLOCK_SIZE;
114114

@@ -129,12 +129,11 @@ pub(crate) fn process_full_blocks<let N: u32>(
129129
// Similarly, we place an empty block in `blocks[N/BLOCK_SIZE]` as in the case where the `message_size == N` then the padding bits will be written to an empty block.
130130
let mut blocks: [MSG_BLOCK; N / BLOCK_SIZE + 1] = std::mem::zeroed();
131131
let mut states: [STATE; N / BLOCK_SIZE + 1] = [h; N / BLOCK_SIZE + 1];
132-
states[0] = h;
133132

134133
// Optimization for small messages. If the largest possible message is smaller than a block then we know that the first block is partially filled
135134
// no matter the value of `message_size`.
136135
//
137-
// Note that the condition `N >= BLOCK_SIZE` is known during monomorphization so this has no runtime cost.
136+
// Note that the condition `N >= BLOCK_SIZE` is known during monomorphization so this has no runtime cost.
138137
let first_partially_filled_block_index = if N >= BLOCK_SIZE {
139138
message_size / BLOCK_SIZE
140139
} else {
@@ -157,8 +156,7 @@ pub(crate) fn process_full_blocks<let N: u32>(
157156
(states[first_partially_filled_block_index], blocks[first_partially_filled_block_index])
158157
}
159158

160-
// Take `BLOCK_SIZE` number of bytes from `msg` starting at `msg_start`.
161-
// Returns the block and the length that has been copied rather than padded with zeros.
159+
// Take `BLOCK_SIZE` number of bytes from `msg` starting at `msg_start` and pack them into a `MSG_BLOCK`.
162160
pub(crate) unconstrained fn build_msg_block<let N: u32>(
163161
msg: [u8; N],
164162
message_size: u32,
@@ -202,7 +200,7 @@ pub(crate) unconstrained fn build_msg_block<let N: u32>(
202200
}
203201

204202
// Verify the block we are compressing was appropriately constructed by `build_msg_block`
205-
// and matches the input data. Returns the index of the first unset item.
203+
// and matches the input data.
206204
// If `message_size` is less than `msg_start` then this is called with the old non-empty block;
207205
// in that case we can skip verification, ie. no need to check that everything is zero.
208206
fn verify_msg_block<let N: u32>(

0 commit comments

Comments
 (0)