Skip to content

Commit

Permalink
feat: move non-simd aware code to AssemblyScript for hashInto and bat…
Browse files Browse the repository at this point in the history
…chHash4UintArray64s
  • Loading branch information
matthewkeil committed Jan 9, 2025
1 parent c09534b commit e3362ac
Show file tree
Hide file tree
Showing 9 changed files with 894 additions and 851 deletions.
14 changes: 2 additions & 12 deletions packages/as-sha256/assembly/index.simd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,12 @@ import {
store32,
load32be,
wPtr,
inputPtr
inputPtr,
} from "./common";

export const HAS_SIMD = true;

export {
INPUT_LENGTH,
PARALLEL_FACTOR,
input,
output,
init,
update,
final,
digest,
digest64
};
export {INPUT_LENGTH, PARALLEL_FACTOR, input, output, init, update, final, digest, digest64};

/**
* Hash 4 inputs of exactly 64 bytes each
Expand Down
22 changes: 11 additions & 11 deletions packages/as-sha256/assembly/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {INPUT_LENGTH, PARALLEL_FACTOR, input, output, init, update, final, digest, digest64, inputPtr} from "./common";

export const HAS_SIMD = false;

export {
INPUT_LENGTH,
PARALLEL_FACTOR,
input,
output,
init,
update,
final,
digest,
digest64
} from "./common";
export {INPUT_LENGTH, PARALLEL_FACTOR, input, output, init, update, final, digest, digest64};

export function batchHash4UintArray64s(outPtr: usize): void {
for (let i = 0; i < 4; i++) {
const inOffset = changetype<usize>(i * 64);
const outOffset = changetype<usize>(i * 32);
digest64(inputPtr + inOffset, outPtr + outOffset);
}
}
Binary file modified packages/as-sha256/build/optimized.wasm
Binary file not shown.
Loading

0 comments on commit e3362ac

Please sign in to comment.