diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 02c2991f..f439efb2 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -25,7 +25,7 @@ jobs: - uses: actions/setup-node@v3 with: cache: yarn - node-version: 18 + node-version: 20 - run: yarn --immutable && yarn build && yarn generate - name: Run benchmarks diff --git a/packages/as-sha256/assembly/index.ts b/packages/as-sha256/assembly/index.ts index bb9142e7..c46874e0 100644 --- a/packages/as-sha256/assembly/index.ts +++ b/packages/as-sha256/assembly/index.ts @@ -43,11 +43,11 @@ const W64: u32[] = [ const w64Ptr = W64.dataStart; // intermediate hash values stored in H0-H7 -var H0: u32, H1: u32, H2: u32, H3: u32, H4: u32, H5: u32, H6: u32, H7: u32; +let H0: u32, H1: u32, H2: u32, H3: u32, H4: u32, H5: u32, H6: u32, H7: u32; // hash registers -var a: u32, b: u32, c: u32, d: u32, e: u32, f: u32, g: u32, h: u32, i: u32, t1: u32, t2: u32; +let a: u32, b: u32, c: u32, d: u32, e: u32, f: u32, g: u32, h: u32, i: u32, t1: u32, t2: u32; // 16 32bit message blocks const M = new ArrayBuffer(64); @@ -66,10 +66,10 @@ export const output = new ArrayBuffer(DIGEST_LENGTH); const outputPtr = changetype(output); // number of bytes in M buffer -var mLength = 0; +let mLength = 0; // number of total bytes hashed -var bytesHashed = 0; +let bytesHashed = 0; @inline function load32(ptr: usize, offset: usize): u32 { @@ -141,6 +141,7 @@ function SIG1(x: u32): u32 { return rotr(x, 17) ^ rotr(x, 19) ^ (x >>> 10); } +let tmpW: u32; /** * Expand message blocks (16 32bit blocks), into extended message blocks (64 32bit blocks), * Apply SHA256 compression function on extended message blocks @@ -158,25 +159,17 @@ function hashBlocks(wPtr: usize, mPtr: usize): void { g = H6; h = H7; - // Load message blocks into first 16 expanded message blocks - for (i = 0; i < 16; i++) { - store32(wPtr, i, - load32be(mPtr, i) - ); - } - // Expand message blocks 17-64 - for (i = 16; i < 64; i++) { - store32(wPtr, i, - SIG1(load32(wPtr, i - 2)) + - load32(wPtr, i - 7) + - SIG0(load32(wPtr, i - 15)) + - load32(wPtr, i - 16) - ); - } + // 16 first u32 of expanded message block are same as message block + // rest of the 48 u32 are computed from the first 16 u32 + // instead of computing expanded messsage blocks in a separate for loop, + // chain it to the below for loop to improve performance // Apply SHA256 compression function on expanded message blocks for (i = 0; i < 64; i++) { - t1 = h + EP1(e) + CH(e, f, g) + load32(kPtr, i) + load32(wPtr, i); + tmpW = i < 16 ? load32be(mPtr, i) : SIG1(load32(wPtr, i - 2)) + load32(wPtr, i - 7) + + SIG0(load32(wPtr, i - 15)) + load32(wPtr, i - 16); + store32(wPtr, i, tmpW); + t1 = h + EP1(e) + CH(e, f, g) + load32(kPtr, i) + tmpW; t2 = EP0(a) + MAJ(a, b, c); h = g; g = f; diff --git a/packages/as-sha256/build/optimized.wasm b/packages/as-sha256/build/optimized.wasm index 97f5d0da..f81113a1 100644 Binary files a/packages/as-sha256/build/optimized.wasm and b/packages/as-sha256/build/optimized.wasm differ diff --git a/packages/as-sha256/build/optimized.wat b/packages/as-sha256/build/optimized.wat index 24cd1564..a782754f 100644 --- a/packages/as-sha256/build/optimized.wat +++ b/packages/as-sha256/build/optimized.wat @@ -42,6 +42,7 @@ (global $assembly/index/outputPtr (mut i32) (i32.const 0)) (global $assembly/index/mLength (mut i32) (i32.const 0)) (global $assembly/index/bytesHashed (mut i32) (i32.const 0)) + (global $assembly/index/tmpW (mut i32) (i32.const 0)) (memory $0 1) (data $0 (i32.const 1036) "\1c\01") (data $0.1 (i32.const 1048) "\01\00\00\00\00\01\00\00\98/\8aB\91D7q\cf\fb\c0\b5\a5\db\b5\e9[\c2V9\f1\11\f1Y\a4\82?\92\d5^\1c\ab\98\aa\07\d8\01[\83\12\be\851$\c3}\0cUt]\ber\fe\b1\de\80\a7\06\dc\9bt\f1\9b\c1\c1i\9b\e4\86G\be\ef\c6\9d\c1\0f\cc\a1\0c$o,\e9-\aa\84tJ\dc\a9\b0\\\da\88\f9vRQ>\98m\c61\a8\c8\'\03\b0\c7\7fY\bf\f3\0b\e0\c6G\91\a7\d5Qc\ca\06g))\14\85\n\b7\'8!\1b.\fcm,M\13\r8STs\ne\bb\njv.\c9\c2\81\85,r\92\a1\e8\bf\a2Kf\1a\a8p\8bK\c2\a3Ql\c7\19\e8\92\d1$\06\99\d6\855\0e\f4p\a0j\10\16\c1\a4\19\08l7\1eLwH\'\b5\bc\b04\b3\0c\1c9J\aa\d8NO\ca\9c[\f3o.h\ee\82\8ftoc\a5x\14x\c8\84\08\02\c7\8c\fa\ff\be\90\eblP\a4\f7\a3\f9\be\f2xq\c6") @@ -880,6 +881,7 @@ ) (func $assembly/index/hashBlocks (param $0 i32) (param $1 i32) (local $2 i32) + (local $3 i32) global.get $assembly/index/H0 global.set $assembly/index/a global.get $assembly/index/H1 @@ -899,170 +901,141 @@ i32.const 0 global.set $assembly/index/i loop $for-loop|0 - global.get $assembly/index/i - i32.const 16 - i32.lt_u - if - local.get $0 - global.get $assembly/index/i - i32.const 2 - i32.shl - local.tee $2 - i32.add - local.get $1 - local.get $2 - i32.const 3 - i32.add - i32.add - i32.load8_u - local.get $1 - local.get $2 - i32.add - i32.load8_u - i32.const 24 - i32.shl - local.get $1 - local.get $2 - i32.const 1 - i32.add - i32.add - i32.load8_u - i32.const 16 - i32.shl - i32.or - local.get $1 - local.get $2 - i32.const 2 - i32.add - i32.add - i32.load8_u - i32.const 8 - i32.shl - i32.or - i32.or - i32.store - global.get $assembly/index/i - i32.const 1 - i32.add - global.set $assembly/index/i - br $for-loop|0 - end - end - i32.const 16 - global.set $assembly/index/i - loop $for-loop|1 global.get $assembly/index/i i32.const 64 i32.lt_u if - local.get $0 - global.get $assembly/index/i - i32.const 2 - i32.shl - i32.add - local.get $0 global.get $assembly/index/i i32.const 16 - i32.sub - i32.const 2 - i32.shl - i32.add - i32.load - local.get $0 - global.get $assembly/index/i - i32.const 7 - i32.sub - i32.const 2 - i32.shl - i32.add - i32.load - local.get $0 - global.get $assembly/index/i - i32.const 2 - i32.sub - i32.const 2 - i32.shl - i32.add - i32.load - local.tee $1 - i32.const 17 - i32.rotr - local.get $1 - i32.const 19 - i32.rotr - i32.xor - local.get $1 - i32.const 10 - i32.shr_u - i32.xor - i32.add + i32.lt_u + if (result i32) + local.get $1 + global.get $assembly/index/i + i32.const 2 + i32.shl + local.tee $2 + i32.const 3 + i32.add + i32.add + i32.load8_u + local.get $1 + local.get $2 + i32.add + i32.load8_u + i32.const 24 + i32.shl + local.get $1 + local.get $2 + i32.const 1 + i32.add + i32.add + i32.load8_u + i32.const 16 + i32.shl + i32.or + local.get $1 + local.get $2 + i32.const 2 + i32.add + i32.add + i32.load8_u + i32.const 8 + i32.shl + i32.or + i32.or + else + local.get $0 + global.get $assembly/index/i + i32.const 16 + i32.sub + i32.const 2 + i32.shl + i32.add + i32.load + local.get $0 + global.get $assembly/index/i + i32.const 7 + i32.sub + i32.const 2 + i32.shl + i32.add + i32.load + local.get $0 + global.get $assembly/index/i + i32.const 2 + i32.sub + i32.const 2 + i32.shl + i32.add + i32.load + local.tee $2 + i32.const 17 + i32.rotr + local.get $2 + i32.const 19 + i32.rotr + i32.xor + local.get $2 + i32.const 10 + i32.shr_u + i32.xor + i32.add + local.get $0 + global.get $assembly/index/i + i32.const 15 + i32.sub + i32.const 2 + i32.shl + i32.add + i32.load + local.tee $2 + i32.const 7 + i32.rotr + local.get $2 + i32.const 18 + i32.rotr + i32.xor + local.get $2 + i32.const 3 + i32.shr_u + i32.xor + i32.add + i32.add + end + global.set $assembly/index/tmpW local.get $0 global.get $assembly/index/i - i32.const 15 - i32.sub i32.const 2 i32.shl + local.tee $2 i32.add - i32.load - local.tee $1 - i32.const 7 - i32.rotr - local.get $1 - i32.const 18 - i32.rotr - i32.xor - local.get $1 - i32.const 3 - i32.shr_u - i32.xor - i32.add - i32.add + global.get $assembly/index/tmpW i32.store - global.get $assembly/index/i - i32.const 1 - i32.add - global.set $assembly/index/i - br $for-loop|1 - end - end - i32.const 0 - global.set $assembly/index/i - loop $for-loop|2 - global.get $assembly/index/i - i32.const 64 - i32.lt_u - if - local.get $0 - global.get $assembly/index/i - i32.const 2 - i32.shl - local.tee $1 - i32.add - i32.load - local.get $1 + global.get $assembly/index/tmpW + local.get $2 global.get $assembly/index/kPtr i32.add i32.load global.get $assembly/index/h global.get $assembly/index/e - local.tee $1 + local.tee $2 i32.const 6 i32.rotr - local.get $1 + local.get $2 i32.const 11 i32.rotr i32.xor - local.get $1 + local.get $2 i32.const 25 i32.rotr i32.xor i32.add global.get $assembly/index/e - local.tee $1 + local.tee $2 global.get $assembly/index/f i32.and global.get $assembly/index/g - local.get $1 + local.get $2 i32.const -1 i32.xor i32.and @@ -1072,28 +1045,28 @@ i32.add global.set $assembly/index/t1 global.get $assembly/index/a - local.tee $1 + local.tee $2 i32.const 2 i32.rotr - local.get $1 + local.get $2 i32.const 13 i32.rotr i32.xor - local.get $1 + local.get $2 i32.const 22 i32.rotr i32.xor global.get $assembly/index/b - local.tee $1 - global.get $assembly/index/c local.tee $2 + global.get $assembly/index/c + local.tee $3 i32.and - local.get $1 + local.get $2 global.get $assembly/index/a - local.tee $1 + local.tee $2 i32.and - local.get $1 local.get $2 + local.get $3 i32.and i32.xor i32.xor @@ -1123,7 +1096,7 @@ i32.const 1 i32.add global.set $assembly/index/i - br $for-loop|2 + br $for-loop|0 end end global.get $assembly/index/H0 diff --git a/packages/as-sha256/build/untouched.wasm b/packages/as-sha256/build/untouched.wasm index a409f9f3..217912c6 100644 Binary files a/packages/as-sha256/build/untouched.wasm and b/packages/as-sha256/build/untouched.wasm differ diff --git a/packages/as-sha256/build/untouched.wat b/packages/as-sha256/build/untouched.wat index c28450e7..e762062b 100644 --- a/packages/as-sha256/build/untouched.wat +++ b/packages/as-sha256/build/untouched.wat @@ -52,6 +52,7 @@ (global $assembly/index/outputPtr (mut i32) (i32.const 0)) (global $assembly/index/mLength (mut i32) (i32.const 0)) (global $assembly/index/bytesHashed (mut i32) (i32.const 0)) + (global $assembly/index/tmpW (mut i32) (i32.const 0)) (global $~lib/memory/__heap_base i32 (i32.const 1012)) (memory $0 1) (data $0 (i32.const 12) "\1c\01\00\00\00\00\00\00\00\00\00\00\01\00\00\00\00\01\00\00\98/\8aB\91D7q\cf\fb\c0\b5\a5\db\b5\e9[\c2V9\f1\11\f1Y\a4\82?\92\d5^\1c\ab\98\aa\07\d8\01[\83\12\be\851$\c3}\0cUt]\ber\fe\b1\de\80\a7\06\dc\9bt\f1\9b\c1\c1i\9b\e4\86G\be\ef\c6\9d\c1\0f\cc\a1\0c$o,\e9-\aa\84tJ\dc\a9\b0\\\da\88\f9vRQ>\98m\c61\a8\c8\'\03\b0\c7\7fY\bf\f3\0b\e0\c6G\91\a7\d5Qc\ca\06g))\14\85\n\b7\'8!\1b.\fcm,M\13\r8STs\ne\bb\njv.\c9\c2\81\85,r\92\a1\e8\bf\a2Kf\1a\a8p\8bK\c2\a3Ql\c7\19\e8\92\d1$\06\99\d6\855\0e\f4p\a0j\10\16\c1\a4\19\08l7\1eLwH\'\b5\bc\b04\b3\0c\1c9J\aa\d8NO\ca\9c[\f3o.h\ee\82\8ftoc\a5x\14x\c8\84\08\02\c7\8c\fa\ff\be\90\eblP\a4\f7\a3\f9\be\f2xq\c6\00\00\00\00\00\00\00\00\00\00\00\00") @@ -1797,11 +1798,6 @@ (local $33 i32) (local $34 i32) (local $35 i32) - (local $36 i32) - (local $37 i32) - (local $38 i32) - (local $39 i32) - (local $40 i32) global.get $assembly/index/H0 global.set $assembly/index/a global.get $assembly/index/H1 @@ -1822,127 +1818,131 @@ global.set $assembly/index/i loop $for-loop|0 global.get $assembly/index/i - i32.const 16 + i32.const 64 i32.lt_u if - local.get $0 - local.set $13 global.get $assembly/index/i - local.set $14 - block $assembly/index/load32be|inlined.0 (result i32) - local.get $1 - local.set $2 - global.get $assembly/index/i - local.set $3 - local.get $3 - i32.const 2 - i32.shl - local.set $4 - block $assembly/index/load8|inlined.0 (result i32) - local.get $2 - local.set $5 - local.get $4 - i32.const 0 - i32.add - local.set $6 - local.get $5 - local.get $6 - i32.add - i32.load8_u - br $assembly/index/load8|inlined.0 - end - i32.const 255 - i32.and - i32.const 24 - i32.shl - block $assembly/index/load8|inlined.1 (result i32) - local.get $2 - local.set $7 - local.get $4 - i32.const 1 - i32.add - local.set $8 - local.get $7 - local.get $8 - i32.add - i32.load8_u - br $assembly/index/load8|inlined.1 - end - i32.const 255 - i32.and - i32.const 16 - i32.shl - i32.or - block $assembly/index/load8|inlined.2 (result i32) - local.get $2 - local.set $9 - local.get $4 + i32.const 16 + i32.lt_u + if (result i32) + block $assembly/index/load32be|inlined.0 (result i32) + local.get $1 + local.set $2 + global.get $assembly/index/i + local.set $3 + local.get $3 i32.const 2 - i32.add - local.set $10 - local.get $9 - local.get $10 - i32.add - i32.load8_u - br $assembly/index/load8|inlined.2 + i32.shl + local.set $4 + block $assembly/index/load8|inlined.0 (result i32) + local.get $2 + local.set $5 + local.get $4 + i32.const 0 + i32.add + local.set $6 + local.get $5 + local.get $6 + i32.add + i32.load8_u + br $assembly/index/load8|inlined.0 + end + i32.const 255 + i32.and + i32.const 24 + i32.shl + block $assembly/index/load8|inlined.1 (result i32) + local.get $2 + local.set $7 + local.get $4 + i32.const 1 + i32.add + local.set $8 + local.get $7 + local.get $8 + i32.add + i32.load8_u + br $assembly/index/load8|inlined.1 + end + i32.const 255 + i32.and + i32.const 16 + i32.shl + i32.or + block $assembly/index/load8|inlined.2 (result i32) + local.get $2 + local.set $9 + local.get $4 + i32.const 2 + i32.add + local.set $10 + local.get $9 + local.get $10 + i32.add + i32.load8_u + br $assembly/index/load8|inlined.2 + end + i32.const 255 + i32.and + i32.const 8 + i32.shl + i32.or + block $assembly/index/load8|inlined.3 (result i32) + local.get $2 + local.set $11 + local.get $4 + i32.const 3 + i32.add + local.set $12 + local.get $11 + local.get $12 + i32.add + i32.load8_u + br $assembly/index/load8|inlined.3 + end + i32.const 255 + i32.and + i32.const 0 + i32.shl + i32.or + br $assembly/index/load32be|inlined.0 end - i32.const 255 - i32.and - i32.const 8 - i32.shl - i32.or - block $assembly/index/load8|inlined.3 (result i32) - local.get $2 - local.set $11 - local.get $4 - i32.const 3 - i32.add - local.set $12 - local.get $11 - local.get $12 - i32.add - i32.load8_u - br $assembly/index/load8|inlined.3 + else + block $assembly/index/SIG1|inlined.0 (result i32) + block $assembly/index/load32|inlined.0 (result i32) + local.get $0 + local.set $13 + global.get $assembly/index/i + i32.const 2 + i32.sub + local.set $14 + local.get $13 + local.get $14 + i32.const 2 + i32.shl + i32.add + i32.load + br $assembly/index/load32|inlined.0 + end + local.set $15 + local.get $15 + i32.const 17 + i32.rotr + local.get $15 + i32.const 19 + i32.rotr + i32.xor + local.get $15 + i32.const 10 + i32.shr_u + i32.xor + br $assembly/index/SIG1|inlined.0 end - i32.const 255 - i32.and - i32.const 0 - i32.shl - i32.or - br $assembly/index/load32be|inlined.0 - end - local.set $15 - local.get $13 - local.get $14 - i32.const 2 - i32.shl - i32.add - local.get $15 - i32.store - global.get $assembly/index/i - i32.const 1 - i32.add - global.set $assembly/index/i - br $for-loop|0 - end - end - i32.const 16 - global.set $assembly/index/i - loop $for-loop|1 - global.get $assembly/index/i - i32.const 64 - i32.lt_u - if - local.get $0 - local.set $26 - global.get $assembly/index/i - local.set $27 - block $assembly/index/SIG1|inlined.0 (result i32) - block $assembly/index/load32|inlined.0 (result i32) + block $assembly/index/load32|inlined.1 (result i32) local.get $0 local.set $16 global.get $assembly/index/i - i32.const 2 + i32.const 7 i32.sub local.set $17 local.get $16 @@ -1951,44 +1951,45 @@ i32.shl i32.add i32.load - br $assembly/index/load32|inlined.0 + br $assembly/index/load32|inlined.1 end - local.set $18 - local.get $18 - i32.const 17 - i32.rotr - local.get $18 - i32.const 19 - i32.rotr - i32.xor - local.get $18 - i32.const 10 - i32.shr_u - i32.xor - br $assembly/index/SIG1|inlined.0 - end - block $assembly/index/load32|inlined.1 (result i32) - local.get $0 - local.set $19 - global.get $assembly/index/i - i32.const 7 - i32.sub - local.set $20 - local.get $19 - local.get $20 - i32.const 2 - i32.shl i32.add - i32.load - br $assembly/index/load32|inlined.1 - end - i32.add - block $assembly/index/SIG0|inlined.0 (result i32) - block $assembly/index/load32|inlined.2 (result i32) + block $assembly/index/SIG0|inlined.0 (result i32) + block $assembly/index/load32|inlined.2 (result i32) + local.get $0 + local.set $18 + global.get $assembly/index/i + i32.const 15 + i32.sub + local.set $19 + local.get $18 + local.get $19 + i32.const 2 + i32.shl + i32.add + i32.load + br $assembly/index/load32|inlined.2 + end + local.set $20 + local.get $20 + i32.const 7 + i32.rotr + local.get $20 + i32.const 18 + i32.rotr + i32.xor + local.get $20 + i32.const 3 + i32.shr_u + i32.xor + br $assembly/index/SIG0|inlined.0 + end + i32.add + block $assembly/index/load32|inlined.3 (result i32) local.get $0 local.set $21 global.get $assembly/index/i - i32.const 15 + i32.const 16 i32.sub local.set $22 local.get $21 @@ -1997,73 +1998,36 @@ i32.shl i32.add i32.load - br $assembly/index/load32|inlined.2 + br $assembly/index/load32|inlined.3 end - local.set $23 - local.get $23 - i32.const 7 - i32.rotr - local.get $23 - i32.const 18 - i32.rotr - i32.xor - local.get $23 - i32.const 3 - i32.shr_u - i32.xor - br $assembly/index/SIG0|inlined.0 - end - i32.add - block $assembly/index/load32|inlined.3 (result i32) - local.get $0 - local.set $24 - global.get $assembly/index/i - i32.const 16 - i32.sub - local.set $25 - local.get $24 - local.get $25 - i32.const 2 - i32.shl i32.add - i32.load - br $assembly/index/load32|inlined.3 end - i32.add - local.set $28 - local.get $26 - local.get $27 + global.set $assembly/index/tmpW + local.get $0 + local.set $23 + global.get $assembly/index/i + local.set $24 + global.get $assembly/index/tmpW + local.set $25 + local.get $23 + local.get $24 i32.const 2 i32.shl i32.add - local.get $28 + local.get $25 i32.store - global.get $assembly/index/i - i32.const 1 - i32.add - global.set $assembly/index/i - br $for-loop|1 - end - end - i32.const 0 - global.set $assembly/index/i - loop $for-loop|2 - global.get $assembly/index/i - i32.const 64 - i32.lt_u - if global.get $assembly/index/h block $assembly/index/EP1|inlined.0 (result i32) global.get $assembly/index/e - local.set $29 - local.get $29 + local.set $26 + local.get $26 i32.const 6 i32.rotr - local.get $29 + local.get $26 i32.const 11 i32.rotr i32.xor - local.get $29 + local.get $26 i32.const 25 i32.rotr i32.xor @@ -2072,18 +2036,18 @@ i32.add block $assembly/index/CH|inlined.0 (result i32) global.get $assembly/index/e - local.set $30 + local.set $27 global.get $assembly/index/f - local.set $31 + local.set $28 global.get $assembly/index/g - local.set $32 - local.get $30 - local.get $31 + local.set $29 + local.get $27 + local.get $28 i32.and - local.get $30 + local.get $27 i32.const -1 i32.xor - local.get $32 + local.get $29 i32.and i32.xor br $assembly/index/CH|inlined.0 @@ -2091,11 +2055,11 @@ i32.add block $assembly/index/load32|inlined.4 (result i32) global.get $assembly/index/kPtr - local.set $33 + local.set $30 global.get $assembly/index/i - local.set $34 - local.get $33 - local.get $34 + local.set $31 + local.get $30 + local.get $31 i32.const 2 i32.shl i32.add @@ -2103,32 +2067,20 @@ br $assembly/index/load32|inlined.4 end i32.add - block $assembly/index/load32|inlined.5 (result i32) - local.get $0 - local.set $35 - global.get $assembly/index/i - local.set $36 - local.get $35 - local.get $36 - i32.const 2 - i32.shl - i32.add - i32.load - br $assembly/index/load32|inlined.5 - end + global.get $assembly/index/tmpW i32.add global.set $assembly/index/t1 block $assembly/index/EP0|inlined.0 (result i32) global.get $assembly/index/a - local.set $37 - local.get $37 + local.set $32 + local.get $32 i32.const 2 i32.rotr - local.get $37 + local.get $32 i32.const 13 i32.rotr i32.xor - local.get $37 + local.get $32 i32.const 22 i32.rotr i32.xor @@ -2136,20 +2088,20 @@ end block $assembly/index/MAJ|inlined.0 (result i32) global.get $assembly/index/a - local.set $38 + local.set $33 global.get $assembly/index/b - local.set $39 + local.set $34 global.get $assembly/index/c - local.set $40 - local.get $38 - local.get $39 + local.set $35 + local.get $33 + local.get $34 i32.and - local.get $38 - local.get $40 + local.get $33 + local.get $35 i32.and i32.xor - local.get $39 - local.get $40 + local.get $34 + local.get $35 i32.and i32.xor br $assembly/index/MAJ|inlined.0 @@ -2180,7 +2132,7 @@ i32.const 1 i32.add global.set $assembly/index/i - br $for-loop|2 + br $for-loop|0 end end global.get $assembly/index/H0 @@ -2759,7 +2711,7 @@ br $assembly/index/CH|inlined.1 end i32.add - block $assembly/index/load32|inlined.6 (result i32) + block $assembly/index/load32|inlined.5 (result i32) local.get $0 local.set $5 global.get $assembly/index/i @@ -2770,7 +2722,7 @@ i32.shl i32.add i32.load - br $assembly/index/load32|inlined.6 + br $assembly/index/load32|inlined.5 end i32.add global.set $assembly/index/t1 diff --git a/packages/as-sha256/src/index.ts b/packages/as-sha256/src/index.ts index 6fa451bd..fc6014d4 100644 --- a/packages/as-sha256/src/index.ts +++ b/packages/as-sha256/src/index.ts @@ -18,9 +18,7 @@ export function digest(data: Uint8Array): Uint8Array { if (data.length <= ctx.INPUT_LENGTH) { inputUint8Array.set(data); ctx.digest(data.length); - const output = new Uint8Array(32); - output.set(outputUint8Array); - return output; + return outputUint8Array.slice(0, 32); } ctx.init(); @@ -32,9 +30,7 @@ export function digest64(data: Uint8Array): Uint8Array { if (data.length === 64) { inputUint8Array.set(data); ctx.digest64(wasmInputValue, wasmOutputValue); - const output = new Uint8Array(32); - output.set(outputUint8Array); - return output; + return outputUint8Array.slice(0, 32); } throw new Error("InvalidLengthForDigest64"); } @@ -44,9 +40,7 @@ export function digest2Bytes32(bytes1: Uint8Array, bytes2: Uint8Array): Uint8Arr inputUint8Array.set(bytes1); inputUint8Array.set(bytes2, 32); ctx.digest64(wasmInputValue, wasmOutputValue); - const output = new Uint8Array(32); - output.set(outputUint8Array); - return output; + return outputUint8Array.slice(0, 32); } throw new Error("InvalidLengthForDigest64"); } @@ -98,7 +92,5 @@ function update(data: Uint8Array): void { function final(): Uint8Array { ctx.final(wasmOutputValue); - const output = new Uint8Array(32); - output.set(outputUint8Array); - return output; + return outputUint8Array.slice(0, 32); } diff --git a/packages/as-sha256/src/wasmCode.ts b/packages/as-sha256/src/wasmCode.ts index 5b06b4c3..d7e2de80 100644 --- a/packages/as-sha256/src/wasmCode.ts +++ b/packages/as-sha256/src/wasmCode.ts @@ -2,4 +2,4 @@ // DO NOT modify this file by hand! // eslint-disable-next-line prettier/prettier -export const wasmCode = Uint8Array.from([0,97,115,109,1,0,0,0,1,37,7,96,2,127,127,0,96,1,127,1,127,96,1,127,0,96,2,127,127,1,127,96,0,0,96,4,127,127,127,127,0,96,3,127,127,126,0,2,13,1,3,101,110,118,5,97,98,111,114,116,0,5,3,20,19,0,0,0,0,0,6,1,3,3,1,4,0,0,1,2,2,2,0,4,5,3,1,0,1,6,177,1,35,127,0,65,128,4,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,7,86,9,12,73,78,80,85,84,95,76,69,78,71,84,72,3,0,5,105,110,112,117,116,3,29,6,111,117,116,112,117,116,3,31,4,105,110,105,116,0,11,6,117,112,100,97,116,101,0,13,5,102,105,110,97,108,0,15,6,100,105,103,101,115,116,0,16,8,100,105,103,101,115,116,54,52,0,18,6,109,101,109,111,114,121,2,0,8,1,19,12,1,18,10,209,22,19,9,0,32,0,32,1,54,2,0,11,9,0,32,0,32,1,54,2,4,11,9,0,32,0,32,1,54,2,8,11,192,1,1,4,127,32,1,40,2,0,65,124,113,34,3,65,128,2,73,4,127,32,3,65,4,118,5,65,31,65,252,255,255,255,3,32,3,32,3,65,252,255,255,255,3,79,27,34,3,103,107,34,4,65,7,107,33,2,32,3,32,4,65,4,107,118,65,16,115,11,33,3,32,1,40,2,8,33,5,32,1,40,2,4,34,4,4,64,32,4,32,5,16,3,11,32,5,4,64,32,5,32,4,16,2,11,32,1,32,0,32,2,65,4,116,32,3,106,65,2,116,106,34,1,40,2,96,70,4,64,32,1,32,5,54,2,96,32,5,69,4,64,32,0,32,2,65,2,116,106,34,1,40,2,4,65,126,32,3,119,113,33,3,32,1,32,3,54,2,4,32,3,69,4,64,32,0,32,0,40,2,0,65,126,32,2,119,113,16,1,11,11,11,11,181,2,1,5,127,32,1,40,2,0,33,3,32,1,65,4,106,32,1,40,2,0,65,124,113,106,34,4,40,2,0,34,2,65,1,113,4,64,32,0,32,4,16,4,32,1,32,3,65,4,106,32,2,65,124,113,106,34,3,16,1,32,1,65,4,106,32,1,40,2,0,65,124,113,106,34,4,40,2,0,33,2,11,32,3,65,2,113,4,64,32,1,65,4,107,40,2,0,34,1,40,2,0,33,6,32,0,32,1,16,4,32,1,32,6,65,4,106,32,3,65,124,113,106,34,3,16,1,11,32,4,32,2,65,2,114,16,1,32,4,65,4,107,32,1,54,2,0,32,0,32,3,65,124,113,34,2,65,128,2,73,4,127,32,2,65,4,118,5,65,31,65,252,255,255,255,3,32,2,32,2,65,252,255,255,255,3,79,27,34,2,103,107,34,3,65,7,107,33,5,32,2,32,3,65,4,107,118,65,16,115,11,34,2,32,5,65,4,116,106,65,2,116,106,40,2,96,33,3,32,1,65,0,16,2,32,1,32,3,16,3,32,3,4,64,32,3,32,1,16,2,11,32,0,32,5,65,4,116,32,2,106,65,2,116,106,32,1,54,2,96,32,0,32,0,40,2,0,65,1,32,5,116,114,16,1,32,0,32,5,65,2,116,106,34,0,32,0,40,2,4,65,1,32,2,116,114,54,2,4,11,130,1,1,3,127,32,1,65,19,106,65,112,113,65,4,107,33,1,32,0,40,2,160,12,34,3,4,64,32,3,32,1,65,16,107,34,5,70,4,64,32,3,40,2,0,33,4,32,5,33,1,11,11,32,2,167,65,112,113,32,1,107,34,3,65,20,73,4,64,15,11,32,1,32,4,65,2,113,32,3,65,8,107,34,3,65,1,114,114,16,1,32,1,65,0,16,2,32,1,65,0,16,3,32,1,65,4,106,32,3,106,34,3,65,2,16,1,32,0,32,3,54,2,160,12,32,0,32,1,16,5,11,29,0,32,0,65,1,65,27,32,0,103,107,116,106,65,1,107,32,0,32,0,65,254,255,255,255,1,73,27,11,142,1,1,2,127,32,1,65,128,2,73,4,127,32,1,65,4,118,5,65,31,32,1,16,7,34,1,103,107,34,3,65,7,107,33,2,32,1,32,3,65,4,107,118,65,16,115,11,33,1,32,0,32,2,65,2,116,106,40,2,4,65,127,32,1,116,113,34,1,4,127,32,0,32,1,104,32,2,65,4,116,106,65,2,116,106,40,2,96,5,32,0,40,2,0,65,127,32,2,65,1,106,116,113,34,1,4,127,32,0,32,0,32,1,104,34,0,65,2,116,106,40,2,4,104,32,0,65,4,116,106,65,2,116,106,40,2,96,5,65,0,11,11,11,148,2,1,3,127,32,1,65,252,255,255,255,3,75,4,64,65,176,14,65,176,15,65,205,3,65,29,16,0,0,11,32,0,65,12,32,1,65,19,106,65,112,113,65,4,107,32,1,65,12,77,27,34,1,16,8,34,2,69,4,64,32,1,65,128,2,79,4,127,32,1,16,7,5,32,1,11,33,2,63,0,34,3,32,2,65,4,32,0,40,2,160,12,32,3,65,16,116,65,4,107,71,116,106,65,255,255,3,106,65,128,128,124,113,65,16,118,34,2,32,2,32,3,72,27,64,0,65,0,72,4,64,32,2,64,0,65,0,72,4,64,0,11,11,32,0,32,3,65,16,116,63,0,172,66,16,134,16,6,32,0,32,1,16,8,33,2,11,32,2,40,2,0,26,32,0,32,2,16,4,32,2,40,2,0,34,3,65,124,113,32,1,107,34,4,65,16,79,4,64,32,2,32,1,32,3,65,2,113,114,16,1,32,2,65,4,106,32,1,106,34,1,32,4,65,4,107,65,1,114,16,1,32,0,32,1,16,5,5,32,2,32,3,65,126,113,16,1,32,2,65,4,106,32,2,40,2,0,65,124,113,106,34,0,32,0,40,2,0,65,125,113,16,1,11,32,2,11,169,2,1,3,127,32,0,65,252,255,255,255,3,75,4,64,65,192,13,65,240,13,65,52,65,43,16,0,0,11,32,0,65,236,255,255,255,3,75,4,64,65,176,14,65,240,14,65,253,0,65,30,16,0,0,11,35,22,69,4,64,63,0,34,2,65,0,76,4,127,65,1,32,2,107,64,0,65,0,72,5,65,0,11,4,64,0,11,65,128,16,65,0,16,1,65,160,28,65,0,54,2,0,3,64,32,1,65,23,73,4,64,32,1,65,2,116,65,128,16,106,65,0,54,2,4,65,0,33,2,3,64,32,2,65,16,73,4,64,32,1,65,4,116,32,2,106,65,2,116,65,128,16,106,65,0,54,2,96,32,2,65,1,106,33,2,12,1,11,11,32,1,65,1,106,33,1,12,1,11,11,65,128,16,65,164,28,63,0,172,66,16,134,16,6,65,128,16,36,22,11,35,22,32,0,65,16,106,16,9,34,2,65,1,54,2,12,32,2,32,0,54,2,16,35,23,34,3,40,2,8,33,1,32,2,32,3,16,2,32,2,32,1,16,3,32,1,32,2,32,1,40,2,4,65,3,113,114,16,2,32,3,32,2,16,3,35,24,32,2,40,2,0,65,124,113,65,4,106,106,36,24,32,2,65,20,106,34,1,65,0,32,0,252,11,0,32,1,11,74,0,65,231,204,167,208,6,36,3,65,133,221,158,219,123,36,4,65,242,230,187,227,3,36,5,65,186,234,191,170,122,36,6,65,255,164,185,136,5,36,7,65,140,209,149,216,121,36,8,65,171,179,143,252,1,36,9,65,153,154,131,223,5,36,10,65,0,36,33,65,0,36,34,11,227,3,1,1,127,35,3,36,11,35,4,36,12,35,5,36,13,35,6,36,14,35,7,36,15,35,8,36,16,35,9,36,17,35,10,36,18,65,0,36,19,3,64,35,19,65,16,73,4,64,32,0,35,19,65,2,116,34,2,106,32,1,32,2,65,3,106,106,45,0,0,32,1,32,2,106,45,0,0,65,24,116,32,1,32,2,65,1,106,106,45,0,0,65,16,116,114,32,1,32,2,65,2,106,106,45,0,0,65,8,116,114,114,54,2,0,35,19,65,1,106,36,19,12,1,11,11,65,16,36,19,3,64,35,19,65,192,0,73,4,64,32,0,35,19,65,2,116,106,32,0,35,19,65,16,107,65,2,116,106,40,2,0,32,0,35,19,65,7,107,65,2,116,106,40,2,0,32,0,35,19,65,2,107,65,2,116,106,40,2,0,34,1,65,17,120,32,1,65,19,120,115,32,1,65,10,118,115,106,32,0,35,19,65,15,107,65,2,116,106,40,2,0,34,1,65,7,120,32,1,65,18,120,115,32,1,65,3,118,115,106,106,54,2,0,35,19,65,1,106,36,19,12,1,11,11,65,0,36,19,3,64,35,19,65,192,0,73,4,64,32,0,35,19,65,2,116,34,1,106,40,2,0,32,1,35,1,106,40,2,0,35,18,35,15,34,1,65,6,120,32,1,65,11,120,115,32,1,65,25,120,115,106,35,15,34,1,35,16,113,35,17,32,1,65,127,115,113,115,106,106,106,36,20,35,11,34,1,65,2,120,32,1,65,13,120,115,32,1,65,22,120,115,35,12,34,1,35,13,34,2,113,32,1,35,11,34,1,113,32,1,32,2,113,115,115,106,36,21,35,17,36,18,35,16,36,17,35,15,36,16,35,14,35,20,106,36,15,35,13,36,14,35,12,36,13,35,11,36,12,35,20,35,21,106,36,11,35,19,65,1,106,36,19,12,1,11,11,35,3,35,11,106,36,3,35,4,35,12,106,36,4,35,5,35,13,106,36,5,35,6,35,14,106,36,6,35,7,35,15,106,36,7,35,8,35,16,106,36,8,35,9,35,17,106,36,9,35,10,35,18,106,36,10,11,174,1,1,2,127,35,34,32,1,106,36,34,35,33,4,64,65,192,0,35,33,107,34,2,32,1,76,4,64,35,26,35,33,106,32,0,32,2,252,10,0,0,35,33,32,2,106,36,33,65,192,0,35,33,107,33,2,32,1,65,192,0,35,33,107,107,33,1,35,28,35,26,16,12,65,0,36,33,5,35,26,35,33,106,32,0,32,1,252,10,0,0,35,33,32,1,106,36,33,15,11,11,3,64,32,3,32,1,65,192,0,109,72,4,64,35,28,32,0,32,2,106,16,12,32,3,65,1,106,33,3,32,2,65,64,107,33,2,12,1,11,11,32,1,65,63,113,34,1,4,64,35,26,35,33,106,32,0,32,2,106,32,1,252,10,0,0,35,33,32,1,106,36,33,11,11,25,0,32,0,65,128,254,131,120,113,65,8,119,32,0,65,255,129,252,7,113,65,8,120,114,11,146,2,1,2,127,35,34,65,63,113,65,63,73,4,64,35,26,35,33,106,65,128,1,58,0,0,35,33,65,1,106,36,33,11,35,34,65,63,113,65,56,79,4,64,35,26,35,33,106,34,1,65,192,0,35,33,107,106,33,2,3,64,32,1,32,2,73,4,64,32,1,65,0,58,0,0,32,1,65,1,106,33,1,12,1,11,11,35,28,35,26,16,12,65,0,36,33,11,35,34,65,63,113,65,63,79,4,64,35,26,35,33,106,65,128,1,58,0,0,35,33,65,1,106,36,33,11,35,26,35,33,106,34,1,65,56,35,33,107,106,33,2,3,64,32,1,32,2,73,4,64,32,1,65,0,58,0,0,32,1,65,1,106,33,1,12,1,11,11,35,26,35,34,65,128,128,128,128,2,109,16,14,54,2,56,35,26,35,34,65,3,116,16,14,54,2,60,35,28,35,26,16,12,32,0,35,3,16,14,54,2,0,32,0,35,4,16,14,54,2,4,32,0,35,5,16,14,54,2,8,32,0,35,6,16,14,54,2,12,32,0,35,7,16,14,54,2,16,32,0,35,8,16,14,54,2,20,32,0,35,9,16,14,54,2,24,32,0,35,10,16,14,54,2,28,11,14,0,16,11,35,30,32,0,16,13,35,32,16,15,11,253,1,1,2,127,35,3,36,11,35,4,36,12,35,5,36,13,35,6,36,14,35,7,36,15,35,8,36,16,35,9,36,17,35,10,36,18,65,0,36,19,3,64,35,19,65,192,0,73,4,64,32,0,35,19,65,2,116,106,40,2,0,35,18,35,15,34,1,65,6,120,32,1,65,11,120,115,32,1,65,25,120,115,106,35,15,34,1,35,16,113,35,17,32,1,65,127,115,113,115,106,106,36,20,35,11,34,1,65,2,120,32,1,65,13,120,115,32,1,65,22,120,115,35,12,34,2,35,13,34,1,113,32,2,35,11,34,2,113,32,1,32,2,113,115,115,106,36,21,35,17,36,18,35,16,36,17,35,15,36,16,35,14,35,20,106,36,15,35,13,36,14,35,12,36,13,35,11,36,12,35,20,35,21,106,36,11,35,19,65,1,106,36,19,12,1,11,11,35,3,35,11,106,36,3,35,4,35,12,106,36,4,35,5,35,13,106,36,5,35,6,35,14,106,36,6,35,7,35,15,106,36,7,35,8,35,16,106,36,8,35,9,35,17,106,36,9,35,10,35,18,106,36,10,11,86,0,16,11,35,28,32,0,16,12,35,2,16,17,32,1,35,3,16,14,54,2,0,32,1,35,4,16,14,54,2,4,32,1,35,5,16,14,54,2,8,32,1,35,6,16,14,54,2,12,32,1,35,7,16,14,54,2,16,32,1,35,8,16,14,54,2,20,32,1,35,9,16,14,54,2,24,32,1,35,10,16,14,54,2,28,11,82,0,65,196,10,40,2,0,36,1,65,148,13,40,2,0,36,2,65,224,15,65,224,15,16,2,65,224,15,65,224,15,16,3,65,224,15,36,23,65,192,0,16,10,36,25,35,25,36,26,65,128,2,16,10,36,27,35,27,36,28,65,128,4,16,10,36,29,35,29,36,30,65,32,16,10,36,31,35,31,36,32,11,11,253,6,18,0,65,140,8,11,2,28,1,0,65,152,8,11,136,2,1,0,0,0,0,1,0,0,152,47,138,66,145,68,55,113,207,251,192,181,165,219,181,233,91,194,86,57,241,17,241,89,164,130,63,146,213,94,28,171,152,170,7,216,1,91,131,18,190,133,49,36,195,125,12,85,116,93,190,114,254,177,222,128,167,6,220,155,116,241,155,193,193,105,155,228,134,71,190,239,198,157,193,15,204,161,12,36,111,44,233,45,170,132,116,74,220,169,176,92,218,136,249,118,82,81,62,152,109,198,49,168,200,39,3,176,199,127,89,191,243,11,224,198,71,145,167,213,81,99,202,6,103,41,41,20,133,10,183,39,56,33,27,46,252,109,44,77,19,13,56,83,84,115,10,101,187,10,106,118,46,201,194,129,133,44,114,146,161,232,191,162,75,102,26,168,112,139,75,194,163,81,108,199,25,232,146,209,36,6,153,214,133,53,14,244,112,160,106,16,22,193,164,25,8,108,55,30,76,119,72,39,181,188,176,52,179,12,28,57,74,170,216,78,79,202,156,91,243,111,46,104,238,130,143,116,111,99,165,120,20,120,200,132,8,2,199,140,250,255,190,144,235,108,80,164,247,163,249,190,242,120,113,198,0,65,172,10,11,1,44,0,65,184,10,11,21,4,0,0,0,16,0,0,0,32,4,0,0,32,4,0,0,0,1,0,0,64,0,65,220,10,11,2,28,1,0,65,232,10,11,136,2,1,0,0,0,0,1,0,0,152,47,138,194,145,68,55,113,207,251,192,181,165,219,181,233,91,194,86,57,241,17,241,89,164,130,63,146,213,94,28,171,152,170,7,216,1,91,131,18,190,133,49,36,195,125,12,85,116,93,190,114,254,177,222,128,167,6,220,155,116,243,155,193,193,105,155,100,134,71,254,240,198,237,225,15,84,242,12,36,111,52,233,79,190,132,201,108,30,65,185,97,250,136,249,22,82,81,198,242,109,90,142,168,101,252,25,176,199,158,217,185,195,49,18,154,160,234,14,231,43,35,177,253,176,62,53,199,213,186,105,48,95,109,151,203,143,17,15,90,253,238,30,220,137,182,53,10,4,122,11,222,157,202,244,88,22,91,93,225,134,62,127,0,128,137,8,55,50,234,7,165,55,149,171,111,16,97,64,23,241,214,140,13,109,59,170,205,55,190,187,192,218,59,97,131,99,163,72,219,49,233,2,11,167,92,209,111,202,250,26,82,49,132,51,49,149,26,212,110,144,120,67,109,242,145,156,195,189,171,204,158,230,160,201,181,60,182,47,83,198,65,199,210,163,126,35,7,104,75,149,164,118,29,25,76,0,65,252,12,11,1,44,0,65,136,13,11,21,4,0,0,0,16,0,0,0,112,5,0,0,112,5,0,0,0,1,0,0,64,0,65,172,13,11,1,44,0,65,184,13,11,35,2,0,0,0,28,0,0,0,73,0,110,0,118,0,97,0,108,0,105,0,100,0,32,0,108,0,101,0,110,0,103,0,116,0,104,0,65,220,13,11,1,60,0,65,232,13,11,45,2,0,0,0,38,0,0,0,126,0,108,0,105,0,98,0,47,0,97,0,114,0,114,0,97,0,121,0,98,0,117,0,102,0,102,0,101,0,114,0,46,0,116,0,115,0,65,156,14,11,1,60,0,65,168,14,11,47,2,0,0,0,40,0,0,0,65,0,108,0,108,0,111,0,99,0,97,0,116,0,105,0,111,0,110,0,32,0,116,0,111,0,111,0,32,0,108,0,97,0,114,0,103,0,101,0,65,220,14,11,1,60,0,65,232,14,11,37,2,0,0,0,30,0,0,0,126,0,108,0,105,0,98,0,47,0,114,0,116,0,47,0,116,0,99,0,109,0,115,0,46,0,116,0,115,0,65,156,15,11,1,60,0,65,168,15,11,37,2,0,0,0,30,0,0,0,126,0,108,0,105,0,98,0,47,0,114,0,116,0,47,0,116,0,108,0,115,0,102,0,46,0,116,0,115]); +export const wasmCode = Uint8Array.from([0,97,115,109,1,0,0,0,1,37,7,96,2,127,127,0,96,1,127,1,127,96,1,127,0,96,2,127,127,1,127,96,0,0,96,4,127,127,127,127,0,96,3,127,127,126,0,2,13,1,3,101,110,118,5,97,98,111,114,116,0,5,3,20,19,0,0,0,0,0,6,1,3,3,1,4,0,0,1,2,2,2,0,4,5,3,1,0,1,6,182,1,36,127,0,65,128,4,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,7,86,9,12,73,78,80,85,84,95,76,69,78,71,84,72,3,0,5,105,110,112,117,116,3,29,6,111,117,116,112,117,116,3,31,4,105,110,105,116,0,11,6,117,112,100,97,116,101,0,13,5,102,105,110,97,108,0,15,6,100,105,103,101,115,116,0,16,8,100,105,103,101,115,116,54,52,0,18,6,109,101,109,111,114,121,2,0,8,1,19,12,1,18,10,156,22,19,9,0,32,0,32,1,54,2,0,11,9,0,32,0,32,1,54,2,4,11,9,0,32,0,32,1,54,2,8,11,192,1,1,4,127,32,1,40,2,0,65,124,113,34,3,65,128,2,73,4,127,32,3,65,4,118,5,65,31,65,252,255,255,255,3,32,3,32,3,65,252,255,255,255,3,79,27,34,3,103,107,34,4,65,7,107,33,2,32,3,32,4,65,4,107,118,65,16,115,11,33,3,32,1,40,2,8,33,5,32,1,40,2,4,34,4,4,64,32,4,32,5,16,3,11,32,5,4,64,32,5,32,4,16,2,11,32,1,32,0,32,2,65,4,116,32,3,106,65,2,116,106,34,1,40,2,96,70,4,64,32,1,32,5,54,2,96,32,5,69,4,64,32,0,32,2,65,2,116,106,34,1,40,2,4,65,126,32,3,119,113,33,3,32,1,32,3,54,2,4,32,3,69,4,64,32,0,32,0,40,2,0,65,126,32,2,119,113,16,1,11,11,11,11,181,2,1,5,127,32,1,40,2,0,33,3,32,1,65,4,106,32,1,40,2,0,65,124,113,106,34,4,40,2,0,34,2,65,1,113,4,64,32,0,32,4,16,4,32,1,32,3,65,4,106,32,2,65,124,113,106,34,3,16,1,32,1,65,4,106,32,1,40,2,0,65,124,113,106,34,4,40,2,0,33,2,11,32,3,65,2,113,4,64,32,1,65,4,107,40,2,0,34,1,40,2,0,33,6,32,0,32,1,16,4,32,1,32,6,65,4,106,32,3,65,124,113,106,34,3,16,1,11,32,4,32,2,65,2,114,16,1,32,4,65,4,107,32,1,54,2,0,32,0,32,3,65,124,113,34,2,65,128,2,73,4,127,32,2,65,4,118,5,65,31,65,252,255,255,255,3,32,2,32,2,65,252,255,255,255,3,79,27,34,2,103,107,34,3,65,7,107,33,5,32,2,32,3,65,4,107,118,65,16,115,11,34,2,32,5,65,4,116,106,65,2,116,106,40,2,96,33,3,32,1,65,0,16,2,32,1,32,3,16,3,32,3,4,64,32,3,32,1,16,2,11,32,0,32,5,65,4,116,32,2,106,65,2,116,106,32,1,54,2,96,32,0,32,0,40,2,0,65,1,32,5,116,114,16,1,32,0,32,5,65,2,116,106,34,0,32,0,40,2,4,65,1,32,2,116,114,54,2,4,11,130,1,1,3,127,32,1,65,19,106,65,112,113,65,4,107,33,1,32,0,40,2,160,12,34,3,4,64,32,3,32,1,65,16,107,34,5,70,4,64,32,3,40,2,0,33,4,32,5,33,1,11,11,32,2,167,65,112,113,32,1,107,34,3,65,20,73,4,64,15,11,32,1,32,4,65,2,113,32,3,65,8,107,34,3,65,1,114,114,16,1,32,1,65,0,16,2,32,1,65,0,16,3,32,1,65,4,106,32,3,106,34,3,65,2,16,1,32,0,32,3,54,2,160,12,32,0,32,1,16,5,11,29,0,32,0,65,1,65,27,32,0,103,107,116,106,65,1,107,32,0,32,0,65,254,255,255,255,1,73,27,11,142,1,1,2,127,32,1,65,128,2,73,4,127,32,1,65,4,118,5,65,31,32,1,16,7,34,1,103,107,34,3,65,7,107,33,2,32,1,32,3,65,4,107,118,65,16,115,11,33,1,32,0,32,2,65,2,116,106,40,2,4,65,127,32,1,116,113,34,1,4,127,32,0,32,1,104,32,2,65,4,116,106,65,2,116,106,40,2,96,5,32,0,40,2,0,65,127,32,2,65,1,106,116,113,34,1,4,127,32,0,32,0,32,1,104,34,0,65,2,116,106,40,2,4,104,32,0,65,4,116,106,65,2,116,106,40,2,96,5,65,0,11,11,11,148,2,1,3,127,32,1,65,252,255,255,255,3,75,4,64,65,176,14,65,176,15,65,205,3,65,29,16,0,0,11,32,0,65,12,32,1,65,19,106,65,112,113,65,4,107,32,1,65,12,77,27,34,1,16,8,34,2,69,4,64,32,1,65,128,2,79,4,127,32,1,16,7,5,32,1,11,33,2,63,0,34,3,32,2,65,4,32,0,40,2,160,12,32,3,65,16,116,65,4,107,71,116,106,65,255,255,3,106,65,128,128,124,113,65,16,118,34,2,32,2,32,3,72,27,64,0,65,0,72,4,64,32,2,64,0,65,0,72,4,64,0,11,11,32,0,32,3,65,16,116,63,0,172,66,16,134,16,6,32,0,32,1,16,8,33,2,11,32,2,40,2,0,26,32,0,32,2,16,4,32,2,40,2,0,34,3,65,124,113,32,1,107,34,4,65,16,79,4,64,32,2,32,1,32,3,65,2,113,114,16,1,32,2,65,4,106,32,1,106,34,1,32,4,65,4,107,65,1,114,16,1,32,0,32,1,16,5,5,32,2,32,3,65,126,113,16,1,32,2,65,4,106,32,2,40,2,0,65,124,113,106,34,0,32,0,40,2,0,65,125,113,16,1,11,32,2,11,169,2,1,3,127,32,0,65,252,255,255,255,3,75,4,64,65,192,13,65,240,13,65,52,65,43,16,0,0,11,32,0,65,236,255,255,255,3,75,4,64,65,176,14,65,240,14,65,253,0,65,30,16,0,0,11,35,22,69,4,64,63,0,34,2,65,0,76,4,127,65,1,32,2,107,64,0,65,0,72,5,65,0,11,4,64,0,11,65,128,16,65,0,16,1,65,160,28,65,0,54,2,0,3,64,32,1,65,23,73,4,64,32,1,65,2,116,65,128,16,106,65,0,54,2,4,65,0,33,2,3,64,32,2,65,16,73,4,64,32,1,65,4,116,32,2,106,65,2,116,65,128,16,106,65,0,54,2,96,32,2,65,1,106,33,2,12,1,11,11,32,1,65,1,106,33,1,12,1,11,11,65,128,16,65,164,28,63,0,172,66,16,134,16,6,65,128,16,36,22,11,35,22,32,0,65,16,106,16,9,34,2,65,1,54,2,12,32,2,32,0,54,2,16,35,23,34,3,40,2,8,33,1,32,2,32,3,16,2,32,2,32,1,16,3,32,1,32,2,32,1,40,2,4,65,3,113,114,16,2,32,3,32,2,16,3,35,24,32,2,40,2,0,65,124,113,65,4,106,106,36,24,32,2,65,20,106,34,1,65,0,32,0,252,11,0,32,1,11,74,0,65,231,204,167,208,6,36,3,65,133,221,158,219,123,36,4,65,242,230,187,227,3,36,5,65,186,234,191,170,122,36,6,65,255,164,185,136,5,36,7,65,140,209,149,216,121,36,8,65,171,179,143,252,1,36,9,65,153,154,131,223,5,36,10,65,0,36,33,65,0,36,34,11,174,3,1,2,127,35,3,36,11,35,4,36,12,35,5,36,13,35,6,36,14,35,7,36,15,35,8,36,16,35,9,36,17,35,10,36,18,65,0,36,19,3,64,35,19,65,192,0,73,4,64,35,19,65,16,73,4,127,32,1,35,19,65,2,116,34,2,65,3,106,106,45,0,0,32,1,32,2,106,45,0,0,65,24,116,32,1,32,2,65,1,106,106,45,0,0,65,16,116,114,32,1,32,2,65,2,106,106,45,0,0,65,8,116,114,114,5,32,0,35,19,65,16,107,65,2,116,106,40,2,0,32,0,35,19,65,7,107,65,2,116,106,40,2,0,32,0,35,19,65,2,107,65,2,116,106,40,2,0,34,2,65,17,120,32,2,65,19,120,115,32,2,65,10,118,115,106,32,0,35,19,65,15,107,65,2,116,106,40,2,0,34,2,65,7,120,32,2,65,18,120,115,32,2,65,3,118,115,106,106,11,36,35,32,0,35,19,65,2,116,34,2,106,35,35,54,2,0,35,35,32,2,35,1,106,40,2,0,35,18,35,15,34,2,65,6,120,32,2,65,11,120,115,32,2,65,25,120,115,106,35,15,34,2,35,16,113,35,17,32,2,65,127,115,113,115,106,106,106,36,20,35,11,34,2,65,2,120,32,2,65,13,120,115,32,2,65,22,120,115,35,12,34,2,35,13,34,3,113,32,2,35,11,34,2,113,32,2,32,3,113,115,115,106,36,21,35,17,36,18,35,16,36,17,35,15,36,16,35,14,35,20,106,36,15,35,13,36,14,35,12,36,13,35,11,36,12,35,20,35,21,106,36,11,35,19,65,1,106,36,19,12,1,11,11,35,3,35,11,106,36,3,35,4,35,12,106,36,4,35,5,35,13,106,36,5,35,6,35,14,106,36,6,35,7,35,15,106,36,7,35,8,35,16,106,36,8,35,9,35,17,106,36,9,35,10,35,18,106,36,10,11,174,1,1,2,127,35,34,32,1,106,36,34,35,33,4,64,65,192,0,35,33,107,34,2,32,1,76,4,64,35,26,35,33,106,32,0,32,2,252,10,0,0,35,33,32,2,106,36,33,65,192,0,35,33,107,33,2,32,1,65,192,0,35,33,107,107,33,1,35,28,35,26,16,12,65,0,36,33,5,35,26,35,33,106,32,0,32,1,252,10,0,0,35,33,32,1,106,36,33,15,11,11,3,64,32,3,32,1,65,192,0,109,72,4,64,35,28,32,0,32,2,106,16,12,32,3,65,1,106,33,3,32,2,65,64,107,33,2,12,1,11,11,32,1,65,63,113,34,1,4,64,35,26,35,33,106,32,0,32,2,106,32,1,252,10,0,0,35,33,32,1,106,36,33,11,11,25,0,32,0,65,128,254,131,120,113,65,8,119,32,0,65,255,129,252,7,113,65,8,120,114,11,146,2,1,2,127,35,34,65,63,113,65,63,73,4,64,35,26,35,33,106,65,128,1,58,0,0,35,33,65,1,106,36,33,11,35,34,65,63,113,65,56,79,4,64,35,26,35,33,106,34,1,65,192,0,35,33,107,106,33,2,3,64,32,1,32,2,73,4,64,32,1,65,0,58,0,0,32,1,65,1,106,33,1,12,1,11,11,35,28,35,26,16,12,65,0,36,33,11,35,34,65,63,113,65,63,79,4,64,35,26,35,33,106,65,128,1,58,0,0,35,33,65,1,106,36,33,11,35,26,35,33,106,34,1,65,56,35,33,107,106,33,2,3,64,32,1,32,2,73,4,64,32,1,65,0,58,0,0,32,1,65,1,106,33,1,12,1,11,11,35,26,35,34,65,128,128,128,128,2,109,16,14,54,2,56,35,26,35,34,65,3,116,16,14,54,2,60,35,28,35,26,16,12,32,0,35,3,16,14,54,2,0,32,0,35,4,16,14,54,2,4,32,0,35,5,16,14,54,2,8,32,0,35,6,16,14,54,2,12,32,0,35,7,16,14,54,2,16,32,0,35,8,16,14,54,2,20,32,0,35,9,16,14,54,2,24,32,0,35,10,16,14,54,2,28,11,14,0,16,11,35,30,32,0,16,13,35,32,16,15,11,253,1,1,2,127,35,3,36,11,35,4,36,12,35,5,36,13,35,6,36,14,35,7,36,15,35,8,36,16,35,9,36,17,35,10,36,18,65,0,36,19,3,64,35,19,65,192,0,73,4,64,32,0,35,19,65,2,116,106,40,2,0,35,18,35,15,34,1,65,6,120,32,1,65,11,120,115,32,1,65,25,120,115,106,35,15,34,1,35,16,113,35,17,32,1,65,127,115,113,115,106,106,36,20,35,11,34,1,65,2,120,32,1,65,13,120,115,32,1,65,22,120,115,35,12,34,2,35,13,34,1,113,32,2,35,11,34,2,113,32,1,32,2,113,115,115,106,36,21,35,17,36,18,35,16,36,17,35,15,36,16,35,14,35,20,106,36,15,35,13,36,14,35,12,36,13,35,11,36,12,35,20,35,21,106,36,11,35,19,65,1,106,36,19,12,1,11,11,35,3,35,11,106,36,3,35,4,35,12,106,36,4,35,5,35,13,106,36,5,35,6,35,14,106,36,6,35,7,35,15,106,36,7,35,8,35,16,106,36,8,35,9,35,17,106,36,9,35,10,35,18,106,36,10,11,86,0,16,11,35,28,32,0,16,12,35,2,16,17,32,1,35,3,16,14,54,2,0,32,1,35,4,16,14,54,2,4,32,1,35,5,16,14,54,2,8,32,1,35,6,16,14,54,2,12,32,1,35,7,16,14,54,2,16,32,1,35,8,16,14,54,2,20,32,1,35,9,16,14,54,2,24,32,1,35,10,16,14,54,2,28,11,82,0,65,196,10,40,2,0,36,1,65,148,13,40,2,0,36,2,65,224,15,65,224,15,16,2,65,224,15,65,224,15,16,3,65,224,15,36,23,65,192,0,16,10,36,25,35,25,36,26,65,128,2,16,10,36,27,35,27,36,28,65,128,4,16,10,36,29,35,29,36,30,65,32,16,10,36,31,35,31,36,32,11,11,253,6,18,0,65,140,8,11,2,28,1,0,65,152,8,11,136,2,1,0,0,0,0,1,0,0,152,47,138,66,145,68,55,113,207,251,192,181,165,219,181,233,91,194,86,57,241,17,241,89,164,130,63,146,213,94,28,171,152,170,7,216,1,91,131,18,190,133,49,36,195,125,12,85,116,93,190,114,254,177,222,128,167,6,220,155,116,241,155,193,193,105,155,228,134,71,190,239,198,157,193,15,204,161,12,36,111,44,233,45,170,132,116,74,220,169,176,92,218,136,249,118,82,81,62,152,109,198,49,168,200,39,3,176,199,127,89,191,243,11,224,198,71,145,167,213,81,99,202,6,103,41,41,20,133,10,183,39,56,33,27,46,252,109,44,77,19,13,56,83,84,115,10,101,187,10,106,118,46,201,194,129,133,44,114,146,161,232,191,162,75,102,26,168,112,139,75,194,163,81,108,199,25,232,146,209,36,6,153,214,133,53,14,244,112,160,106,16,22,193,164,25,8,108,55,30,76,119,72,39,181,188,176,52,179,12,28,57,74,170,216,78,79,202,156,91,243,111,46,104,238,130,143,116,111,99,165,120,20,120,200,132,8,2,199,140,250,255,190,144,235,108,80,164,247,163,249,190,242,120,113,198,0,65,172,10,11,1,44,0,65,184,10,11,21,4,0,0,0,16,0,0,0,32,4,0,0,32,4,0,0,0,1,0,0,64,0,65,220,10,11,2,28,1,0,65,232,10,11,136,2,1,0,0,0,0,1,0,0,152,47,138,194,145,68,55,113,207,251,192,181,165,219,181,233,91,194,86,57,241,17,241,89,164,130,63,146,213,94,28,171,152,170,7,216,1,91,131,18,190,133,49,36,195,125,12,85,116,93,190,114,254,177,222,128,167,6,220,155,116,243,155,193,193,105,155,100,134,71,254,240,198,237,225,15,84,242,12,36,111,52,233,79,190,132,201,108,30,65,185,97,250,136,249,22,82,81,198,242,109,90,142,168,101,252,25,176,199,158,217,185,195,49,18,154,160,234,14,231,43,35,177,253,176,62,53,199,213,186,105,48,95,109,151,203,143,17,15,90,253,238,30,220,137,182,53,10,4,122,11,222,157,202,244,88,22,91,93,225,134,62,127,0,128,137,8,55,50,234,7,165,55,149,171,111,16,97,64,23,241,214,140,13,109,59,170,205,55,190,187,192,218,59,97,131,99,163,72,219,49,233,2,11,167,92,209,111,202,250,26,82,49,132,51,49,149,26,212,110,144,120,67,109,242,145,156,195,189,171,204,158,230,160,201,181,60,182,47,83,198,65,199,210,163,126,35,7,104,75,149,164,118,29,25,76,0,65,252,12,11,1,44,0,65,136,13,11,21,4,0,0,0,16,0,0,0,112,5,0,0,112,5,0,0,0,1,0,0,64,0,65,172,13,11,1,44,0,65,184,13,11,35,2,0,0,0,28,0,0,0,73,0,110,0,118,0,97,0,108,0,105,0,100,0,32,0,108,0,101,0,110,0,103,0,116,0,104,0,65,220,13,11,1,60,0,65,232,13,11,45,2,0,0,0,38,0,0,0,126,0,108,0,105,0,98,0,47,0,97,0,114,0,114,0,97,0,121,0,98,0,117,0,102,0,102,0,101,0,114,0,46,0,116,0,115,0,65,156,14,11,1,60,0,65,168,14,11,47,2,0,0,0,40,0,0,0,65,0,108,0,108,0,111,0,99,0,97,0,116,0,105,0,111,0,110,0,32,0,116,0,111,0,111,0,32,0,108,0,97,0,114,0,103,0,101,0,65,220,14,11,1,60,0,65,232,14,11,37,2,0,0,0,30,0,0,0,126,0,108,0,105,0,98,0,47,0,114,0,116,0,47,0,116,0,99,0,109,0,115,0,46,0,116,0,115,0,65,156,15,11,1,60,0,65,168,15,11,37,2,0,0,0,30,0,0,0,126,0,108,0,105,0,98,0,47,0,114,0,116,0,47,0,116,0,108,0,115,0,102,0,46,0,116,0,115]); diff --git a/packages/as-sha256/test/perf/index.test.ts b/packages/as-sha256/test/perf/index.test.ts index dfcd296e..a5926b75 100644 --- a/packages/as-sha256/test/perf/index.test.ts +++ b/packages/as-sha256/test/perf/index.test.ts @@ -1,11 +1,11 @@ import {itBench, setBenchOpts} from "@dapplion/benchmark"; import * as sha256 from "../../src"; -// Feb 2024 Mac M1 +// Mar 2024 Mac M1 // digestTwoHashObjects vs digest64 vs digest -// ✓ digestTwoHashObjects 50023 times 28.82303 ops/s 34.69448 ms/op x1.002 1715 runs 60.0 s -// ✓ digest64 50023 times 27.30382 ops/s 36.62491 ms/op x1.003 1625 runs 60.0 s -// ✓ digest 50023 times 27.31207 ops/s 36.61385 ms/op x0.999 1624 runs 60.0 s +// ✓ digestTwoHashObjects 50023 times 29.88107 ops/s 33.46601 ms/op - 1777 runs 60.0 s +// ✓ digest64 50023 times 28.76283 ops/s 34.76710 ms/op - 1711 runs 60.0 s +// ✓ digest 50023 times 28.27148 ops/s 35.37133 ms/op - 1682 runs 60.0 s describe("digestTwoHashObjects vs digest64 vs digest", () => { setBenchOpts({ minMs: 60000,