Skip to content

Commit

Permalink
chore: add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
twoeths committed Nov 6, 2024
1 parent 3447aa0 commit cc9f73c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion packages/persistent-merkle-tree/src/hasher/as-sha256.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import {Node} from "../node";
import type {HashComputationLevel} from "../hashComputation";
import {BLOCK_SIZE, doDigestNLevel, doMerkleizeBlockArray, doMerkleizeBlocksBytes} from "./util";

/** hashInto() function of as-sha256 loop through every 256 bytes */
/**
* hashInto() function of as-sha256 loop through every 256 bytes
* This is the same to hashInto() function of as-sha256 https://github.com/ChainSafe/ssz/blob/cf3e1f038c8bf7cba1bb27c38540e50b0391d0e6/packages/as-sha256/src/index.ts#L270
*/
const buffer = new Uint8Array(4 * BLOCK_SIZE);

export const hasher: Hasher = {
Expand Down
1 change: 1 addition & 0 deletions packages/persistent-merkle-tree/src/hasher/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export type Hasher = {
merkleizeBlocksBytes(blocksBytes: Uint8Array, padFor: number, output: Uint8Array, offset: number): void;
/**
* Merkleize n SHA256 blocks, each is 64 bytes Uint8Array
* blockLimit is the number of blocks to hash, should be <= blocks.length
* padFor is maxChunkCount, use it to compute layers to hash
* blocks are mutated after the function
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/persistent-merkle-tree/src/hasher/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ export function doMerkleizeBlocksBytes(

/**
* Merkleize multiple SHA256 blocks into ${output} at ${offset}
* @param blockLimit number of blocks, should be <= blocks.length so that consumer can reuse memory
* @param padFor is maxChunkCount, should be >= 2
* @param blocks is unsafe because it's modified
* @param blockLimit number of blocks, should be <= blocks.length so that consumer can reuse memory
*/
export function doMerkleizeBlockArray(
blocks: Uint8Array[],
Expand Down

0 comments on commit cc9f73c

Please sign in to comment.