js-sha3 0.11.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +77 -0
- package/.github/workflows/publish.yml +32 -0
- package/CHANGELOG.md +16 -0
- package/LICENSE.txt +1 -1
- package/README.md +48 -9
- package/build/sha3.min.js +3 -3
- package/build/sha3.min.mjs +3 -3
- package/build/sha3.mjs +173 -50
- package/index.d.ts +93 -0
- package/package.json +14 -6
- package/src/sha3.js +158 -48
- package/src/sha3.mjs +14 -1
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- master
|
|
7
|
+
pull_request:
|
|
8
|
+
branches:
|
|
9
|
+
- master
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
build:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- name: Checkout code
|
|
16
|
+
uses: actions/checkout@v4
|
|
17
|
+
|
|
18
|
+
- name: Set up Node 24
|
|
19
|
+
uses: actions/setup-node@v4
|
|
20
|
+
with:
|
|
21
|
+
node-version: 24.x
|
|
22
|
+
|
|
23
|
+
- name: Install dependencies
|
|
24
|
+
run: npm ci
|
|
25
|
+
|
|
26
|
+
- name: Pack npm package
|
|
27
|
+
run: |
|
|
28
|
+
mkdir -p package-artifact
|
|
29
|
+
npm pack --pack-destination package-artifact
|
|
30
|
+
|
|
31
|
+
- name: Upload package artifact
|
|
32
|
+
uses: actions/upload-artifact@v4
|
|
33
|
+
with:
|
|
34
|
+
name: package-node-24
|
|
35
|
+
path: package-artifact/*.tgz
|
|
36
|
+
if-no-files-found: error
|
|
37
|
+
|
|
38
|
+
runtime-test:
|
|
39
|
+
needs: build
|
|
40
|
+
runs-on: ubuntu-latest
|
|
41
|
+
strategy:
|
|
42
|
+
matrix:
|
|
43
|
+
node-version: [18.x, 20.x, 22.x, 24.x]
|
|
44
|
+
steps:
|
|
45
|
+
- name: Checkout code
|
|
46
|
+
uses: actions/checkout@v4
|
|
47
|
+
|
|
48
|
+
- name: Set up Node ${{ matrix.node-version }}
|
|
49
|
+
uses: actions/setup-node@v4
|
|
50
|
+
with:
|
|
51
|
+
node-version: ${{ matrix.node-version }}
|
|
52
|
+
|
|
53
|
+
- name: Install dependencies
|
|
54
|
+
run: npm ci
|
|
55
|
+
|
|
56
|
+
- name: Download package artifact
|
|
57
|
+
uses: actions/download-artifact@v4
|
|
58
|
+
with:
|
|
59
|
+
name: package-node-24
|
|
60
|
+
path: package-artifact
|
|
61
|
+
|
|
62
|
+
- name: Extract package artifact
|
|
63
|
+
run: tar -xzf package-artifact/*.tgz --strip-components=1 -C .
|
|
64
|
+
|
|
65
|
+
- name: Run runtime tests
|
|
66
|
+
if: matrix.node-version != '24.x'
|
|
67
|
+
run: npm run test:runtime
|
|
68
|
+
|
|
69
|
+
- name: Run runtime tests with coverage
|
|
70
|
+
if: matrix.node-version == '24.x'
|
|
71
|
+
run: npm run test:coverage
|
|
72
|
+
|
|
73
|
+
- name: Upload to coveralls
|
|
74
|
+
if: matrix.node-version == '24.x'
|
|
75
|
+
uses: coverallsapp/github-action@v2
|
|
76
|
+
with:
|
|
77
|
+
file: ./coverage/lcov.info
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
name: Publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: read
|
|
9
|
+
id-token: write
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
publish:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
|
|
17
|
+
- uses: actions/setup-node@v4
|
|
18
|
+
with:
|
|
19
|
+
node-version: 24.x
|
|
20
|
+
registry-url: https://registry.npmjs.org
|
|
21
|
+
package-manager-cache: false
|
|
22
|
+
|
|
23
|
+
- run: npm ci
|
|
24
|
+
|
|
25
|
+
- name: Verify release version
|
|
26
|
+
run: |
|
|
27
|
+
PACKAGE_VERSION=$(node -p "require('./package.json').version")
|
|
28
|
+
test "$GITHUB_REF_NAME" = "v$PACKAGE_VERSION"
|
|
29
|
+
|
|
30
|
+
- run: npm run build
|
|
31
|
+
- run: npm test
|
|
32
|
+
- run: npm publish
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## v0.13.0 / 2026-08-07
|
|
4
|
+
### Added
|
|
5
|
+
- ParallelHash128, ParallelHash256, ParallelHashXOF128, and ParallelHashXOF256 (NIST SP 800-185)
|
|
6
|
+
- GitHub Actions CI across Node.js 18, 20, 22, and 24 against the packed npm artifact
|
|
7
|
+
- GitHub Actions publish workflow on release with npm trusted publishing
|
|
8
|
+
- `prepack` script to build distributions before `npm pack` / `npm publish`
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
- Replace Travis CI with GitHub Actions
|
|
12
|
+
- Update README badges to GitHub Actions, npm, and jsDelivr
|
|
13
|
+
- Upgrade mocha and pin vulnerable transitive dependencies via npm overrides
|
|
14
|
+
|
|
15
|
+
## v0.12.0 / 2026-07-18
|
|
16
|
+
### Added
|
|
17
|
+
- KMACXOF128 and KMACXOF256 (NIST SP 800-185)
|
|
18
|
+
|
|
3
19
|
## v0.11.0 / 2026-07-18
|
|
4
20
|
### Added
|
|
5
21
|
- TupleHash128, TupleHash256, TupleHashXOF128, and TupleHashXOF256 (NIST SP 800-185)
|
package/LICENSE.txt
CHANGED
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# js-sha3
|
|
2
|
+
[](https://github.com/emn178/js-sha3/actions/workflows/ci.yml)
|
|
3
|
+
[](https://coveralls.io/r/emn178/js-sha3?branch=master)
|
|
4
|
+
[](https://www.npmjs.com/package/js-sha3)
|
|
5
|
+
[](https://www.jsdelivr.com/package/npm/js-sha3)
|
|
2
6
|
|
|
3
|
-
|
|
4
|
-
[](https://coveralls.io/r/emn178/js-sha3?branch=master)
|
|
5
|
-
[](https://nodei.co/npm/js-sha3/)
|
|
6
|
-
|
|
7
|
-
A simple SHA-3 / Keccak / SHAKE / cSHAKE / KMAC / TupleHash hash function for JavaScript supports UTF-8 encoding.
|
|
7
|
+
A simple SHA-3 / Keccak / SHAKE / cSHAKE / KMAC / TupleHash / ParallelHash hash function for JavaScript supports UTF-8 encoding.
|
|
8
8
|
|
|
9
9
|
## Notice
|
|
10
10
|
* v0.8.0+ will throw an error if try to update hash after finalize.
|
|
@@ -20,8 +20,22 @@ A simple SHA-3 / Keccak / SHAKE / cSHAKE / KMAC / TupleHash hash function for Ja
|
|
|
20
20
|
[Keccak-384 Online](http://emn178.github.io/online-tools/keccak_384.html)
|
|
21
21
|
[Keccak-256 Online](http://emn178.github.io/online-tools/keccak_256.html)
|
|
22
22
|
[Keccak-224 Online](http://emn178.github.io/online-tools/keccak_224.html)
|
|
23
|
-
[Shake128 Online](http://emn178.github.io/online-tools/
|
|
24
|
-
[Shake256 Online](http://emn178.github.io/online-tools/
|
|
23
|
+
[Shake128 Online](http://emn178.github.io/online-tools/shake128/)
|
|
24
|
+
[Shake256 Online](http://emn178.github.io/online-tools/shake256/)
|
|
25
|
+
[cShake128 Online](http://emn178.github.io/online-tools/cshake128/)
|
|
26
|
+
[cShake256 Online](http://emn178.github.io/online-tools/cshake256/)
|
|
27
|
+
[KMAC128 Online](http://emn178.github.io/online-tools/kmac128/)
|
|
28
|
+
[KMAC256 Online](http://emn178.github.io/online-tools/kmac256/)
|
|
29
|
+
[KMACXOF128 Online](http://emn178.github.io/online-tools/kmacxof128/)
|
|
30
|
+
[KMACXOF256 Online](http://emn178.github.io/online-tools/kmacxof256/)
|
|
31
|
+
[TupleHash128 Online](http://emn178.github.io/online-tools/tuplehash128/)
|
|
32
|
+
[TupleHash256 Online](http://emn178.github.io/online-tools/tuplehash256/)
|
|
33
|
+
[TupleHashXOF128 Online](http://emn178.github.io/online-tools/tuplehashxof128/)
|
|
34
|
+
[TupleHashXOF256 Online](http://emn178.github.io/online-tools/tuplehashxof256/)
|
|
35
|
+
[ParallelHash128 Online](http://emn178.github.io/online-tools/parallelhash128/)
|
|
36
|
+
[ParallelHash256 Online](http://emn178.github.io/online-tools/parallelhash256/)
|
|
37
|
+
[ParallelHashXOF128 Online](http://emn178.github.io/online-tools/parallelhashxof128/)
|
|
38
|
+
[ParallelHashXOF256 Online](http://emn178.github.io/online-tools/parallelhashxof256/)
|
|
25
39
|
|
|
26
40
|
## Download
|
|
27
41
|
[Compress](https://raw.github.com/emn178/js-sha3/master/build/sha3.min.js)
|
|
@@ -53,10 +67,16 @@ cshake128('Message to hash', 256, 'function name', 'customization');
|
|
|
53
67
|
cshake256('Message to hash', 512, 'function name', 'customization');
|
|
54
68
|
kmac128('key', 'Message to hash', 256, 'customization');
|
|
55
69
|
kmac256('key', 'Message to hash', 512, 'customization');
|
|
70
|
+
kmacxof128('key', 'Message to hash', 256, 'customization');
|
|
71
|
+
kmacxof256('key', 'Message to hash', 512, 'customization');
|
|
56
72
|
tuplehash128(['abc', 'd'], 256, 'customization');
|
|
57
73
|
tuplehash256(['abc', 'd'], 512, 'customization');
|
|
58
74
|
tuplehashxof128(['abc', 'd'], 256, 'customization');
|
|
59
75
|
tuplehashxof256(['abc', 'd'], 512, 'customization');
|
|
76
|
+
parallelhash128('Message to hash', 8, 256, 'customization');
|
|
77
|
+
parallelhash256('Message to hash', 8, 512, 'customization');
|
|
78
|
+
parallelhashxof128('Message to hash', 8, 256, 'customization');
|
|
79
|
+
parallelhashxof256('Message to hash', 8, 512, 'customization');
|
|
60
80
|
|
|
61
81
|
// Support ArrayBuffer output
|
|
62
82
|
var arrayBuffer = keccak224.arrayBuffer('Message to hash');
|
|
@@ -110,6 +130,13 @@ tupleHash.updateChunk([0x63]);
|
|
|
110
130
|
tupleHash.beginInput(1);
|
|
111
131
|
tupleHash.updateChunk([0x64]);
|
|
112
132
|
tupleHash.hex();
|
|
133
|
+
|
|
134
|
+
// ParallelHash: hash one large input in fixed-size blocks.
|
|
135
|
+
parallelhash128('Message to hash', 8, 256, '');
|
|
136
|
+
parallelhash128.create(8, 256, '')
|
|
137
|
+
.update('Message ')
|
|
138
|
+
.update('to hash')
|
|
139
|
+
.hex();
|
|
113
140
|
```
|
|
114
141
|
### Node.js
|
|
115
142
|
If you use node.js, you should require the module first:
|
|
@@ -129,10 +156,16 @@ const {
|
|
|
129
156
|
cshake256,
|
|
130
157
|
kmac128,
|
|
131
158
|
kmac256,
|
|
159
|
+
kmacxof128,
|
|
160
|
+
kmacxof256,
|
|
132
161
|
tuplehash128,
|
|
133
162
|
tuplehash256,
|
|
134
163
|
tuplehashxof128,
|
|
135
|
-
tuplehashxof256
|
|
164
|
+
tuplehashxof256,
|
|
165
|
+
parallelhash128,
|
|
166
|
+
parallelhash256,
|
|
167
|
+
parallelhashxof128,
|
|
168
|
+
parallelhashxof256
|
|
136
169
|
} = require('js-sha3');
|
|
137
170
|
```
|
|
138
171
|
|
|
@@ -154,10 +187,16 @@ import {
|
|
|
154
187
|
cshake256,
|
|
155
188
|
kmac128,
|
|
156
189
|
kmac256,
|
|
190
|
+
kmacxof128,
|
|
191
|
+
kmacxof256,
|
|
157
192
|
tuplehash128,
|
|
158
193
|
tuplehash256,
|
|
159
194
|
tuplehashxof128,
|
|
160
|
-
tuplehashxof256
|
|
195
|
+
tuplehashxof256,
|
|
196
|
+
parallelhash128,
|
|
197
|
+
parallelhash256,
|
|
198
|
+
parallelhashxof128,
|
|
199
|
+
parallelhashxof256
|
|
161
200
|
} from 'js-sha3';
|
|
162
201
|
```
|
|
163
202
|
|
package/build/sha3.min.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* [js-sha3]{@link https://github.com/emn178/js-sha3}
|
|
3
3
|
*
|
|
4
|
-
* @version 0.
|
|
4
|
+
* @version 0.13.0
|
|
5
5
|
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
|
6
|
-
* @copyright Chen, Yi-Cyuan 2015-
|
|
6
|
+
* @copyright Chen, Yi-Cyuan 2015-2026
|
|
7
7
|
* @license MIT
|
|
8
8
|
*/
|
|
9
|
-
!function(){"use strict";function t(t,e,r){this.blocks=[],this.s=[],this.padding=e,this.outputBits=r,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(t<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}function e(e,r,n){t.call(this,e,r,n)}function r(e,r,n,i){t.call(this,e,r,n),this.xof=!!i,this.inputActive=!1,this.inputBytesRemaining=0}var n="input is invalid type",i="finalize already called",o="tuple input is incomplete",u="object"==typeof window,a=u?window:{};a.JS_SHA3_NO_WINDOW&&(u=!1);var s=!u&&"object"==typeof self;!a.JS_SHA3_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node?a=global:s&&(a=self);for(var h=!a.JS_SHA3_NO_COMMON_JS&&"object"==typeof module&&module.exports,f="function"==typeof define&&define.amd,c=!a.JS_SHA3_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,p="0123456789abcdef".split(""),l=[4,1024,262144,67108864],d=[0,8,16,24],y=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],g=[224,256,384,512],v=[128,256],b=["hex","buffer","arrayBuffer","array","digest"],w={128:168,256:136},A=a.JS_SHA3_NO_NODE_JS||!Array.isArray?function(t){return"[object Array]"===Object.prototype.toString.call(t)}:Array.isArray,B=!c||!a.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView?ArrayBuffer.isView:function(t){return"object"==typeof t&&t.buffer&&t.buffer.constructor===ArrayBuffer},k=function(t){var e=typeof t;if("string"===e)return[t,!0];if("object"!==e||null===t)throw new Error(n);if(c&&t.constructor===ArrayBuffer)return[new Uint8Array(t),!1];if(!A(t)&&!B(t))throw new Error(n);return[t,!1]},_=function(t){return 0===k(t)[0].length},m=function(t){for(var e=[],r=0;r<t.length;++r)e[r]=t[r];return e},x=function(e,r,n){return function(i){return new t(e,r,e).update(i)[n]()}},S=function(e,r,n){return function(i,o){return new t(e,r,o).update(i)[n]()}},C=function(t,e,r){return function(e,n,i,o){return J["cshake"+t].update(e,n,i,o)[r]()}},z=function(t,e,r){return function(e,n,i,o){return J["kmac"+t].update(e,n,i,o)[r]()}},E=function(t,e,r,n){for(var i=0;i<b.length;++i){var o=b[i];t[o]=e(r,n,o)}return t},M=function(e,r){var n=x(e,r,"hex");return n.create=function(){return new t(e,r,e)},n.update=function(t){return n.create().update(t)},E(n,x,e,r)},O=function(t,e,r,n){return function(e,i,o){return J[(r?"tuplehashxof":"tuplehash")+t].update(e,i,o)[n]()}},R=function(t,e,i){var o=w[t],u=O(t,0,i,"hex");return u.create=function(n,u){return new r(t,e,n,i).bytepad(["TupleHash",u],o)},u.update=function(t,e,r){if(!A(t))throw new Error(n);for(var i=u.create(e,r),o=0;o<t.length;++o)i.update(t[o]);return i},E(u,function(t,e,r){return O(t,0,i,r)},t,e)},N=[{name:"keccak",padding:[1,256,65536,16777216],bits:g,createMethod:M},{name:"sha3",padding:[6,1536,393216,100663296],bits:g,createMethod:M},{name:"shake",padding:[31,7936,2031616,520093696],bits:v,createMethod:function(e,r){var n=S(e,r,"hex");return n.create=function(n){return new t(e,r,n)},n.update=function(t,e){return n.create(e).update(t)},E(n,S,e,r)}},{name:"cshake",padding:l,bits:v,createMethod:function(e,r){var n=w[e],i=C(e,0,"hex");return i.create=function(i,o,u){return _(o)&&_(u)?J["shake"+e].create(i):new t(e,r,i).bytepad([o,u],n)},i.update=function(t,e,r,n){return i.create(e,r,n).update(t)},E(i,C,e,r)}},{name:"kmac",padding:l,bits:v,createMethod:function(t,r){var n=w[t],i=z(t,0,"hex");return i.create=function(i,o,u){return new e(t,r,o).bytepad(["KMAC",u],n).bytepad([i],n)},i.update=function(t,e,r,n){return i.create(t,r,n).update(e)},E(i,z,t,r)}},{name:"tuplehash",padding:l,bits:v,createMethod:function(t,e){return R(t,e,!1)}},{name:"tuplehashxof",padding:l,bits:v,createMethod:function(t,e){return R(t,e,!0)}}],J={},j=[],I=0;I<N.length;++I)for(var H=N[I],F=H.bits,U=0;U<F.length;++U){var D=H.name+"_"+F[U];if(j.push(D),J[D]=H.createMethod(F[U],H.padding),"sha3"!==H.name){var L=H.name+F[U];j.push(L),J[L]=J[D]}}t.prototype.update=function(t){if(this.finalized)throw new Error(i);var e=k(t);t=e[0];for(var r,n,o=e[1],u=this.blocks,a=this.byteCount,s=t.length,h=this.blockCount,f=0,c=this.s;f<s;){if(this.reset)for(this.reset=!1,u[0]=this.block,r=1;r<h+1;++r)u[r]=0;if(o)for(r=this.start;f<s&&r<a;++f)(n=t.charCodeAt(f))<128?u[r>>2]|=n<<d[3&r++]:n<2048?(u[r>>2]|=(192|n>>6)<<d[3&r++],u[r>>2]|=(128|63&n)<<d[3&r++]):n<55296||n>=57344?(u[r>>2]|=(224|n>>12)<<d[3&r++],u[r>>2]|=(128|n>>6&63)<<d[3&r++],u[r>>2]|=(128|63&n)<<d[3&r++]):(n=65536+((1023&n)<<10|1023&t.charCodeAt(++f)),u[r>>2]|=(240|n>>18)<<d[3&r++],u[r>>2]|=(128|n>>12&63)<<d[3&r++],u[r>>2]|=(128|n>>6&63)<<d[3&r++],u[r>>2]|=(128|63&n)<<d[3&r++]);else for(r=this.start;f<s&&r<a;++f)u[r>>2]|=t[f]<<d[3&r++];if(this.lastByteIndex=r,r>=a){for(this.start=r-a,this.block=u[h],r=0;r<h;++r)c[r]^=u[r];V(c),this.reset=!0}else this.start=r}return this},t.prototype.encode=function(e,r){var n=255&e,i=1,o=[n];for(n=255&(e>>=8);n>0;)o.unshift(n),n=255&(e>>=8),++i;return r?o.push(i):o.unshift(i),t.prototype.update.call(this,o),o.length},t.prototype.encodeString=function(e){var r=k(e);e=r[0];var n=r[1],i=0,o=e.length;if(n)for(var u=0;u<e.length;++u){var a=e.charCodeAt(u);a<128?i+=1:a<2048?i+=2:a<55296||a>=57344?i+=3:(a=65536+((1023&a)<<10|1023&e.charCodeAt(++u)),i+=4)}else i=o;return i+=this.encode(8*i),t.prototype.update.call(this,e),i},t.prototype.bytepad=function(e,r){for(var n=this.encode(r),i=0;i<e.length;++i)n+=this.encodeString(e[i]);var o=(r-n%r)%r,u=[];return u.length=o,t.prototype.update.call(this,u),this},t.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,e=this.lastByteIndex,r=this.blockCount,n=this.s;if(t[e>>2]|=this.padding[3&e],this.lastByteIndex===this.byteCount)for(t[0]=t[r],e=1;e<r+1;++e)t[e]=0;for(t[r-1]|=2147483648,e=0;e<r;++e)n[e]^=t[e];V(n)}},t.prototype.toString=t.prototype.hex=function(){this.finalize();for(var t,e=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,u=0,a="";u<n;){for(o=0;o<e&&u<n;++o,++u)t=r[o],a+=p[t>>4&15]+p[15&t]+p[t>>12&15]+p[t>>8&15]+p[t>>20&15]+p[t>>16&15]+p[t>>28&15]+p[t>>24&15];u%e==0&&(r=m(r),V(r),o=0)}return i&&(t=r[o],a+=p[t>>4&15]+p[15&t],i>1&&(a+=p[t>>12&15]+p[t>>8&15]),i>2&&(a+=p[t>>20&15]+p[t>>16&15])),a},t.prototype.arrayBuffer=function(){this.finalize();var t,e=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,u=0,a=this.outputBits>>3;t=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(a);for(var s=new Uint32Array(t);u<n;){for(o=0;o<e&&u<n;++o,++u)s[u]=r[o];u%e==0&&(r=m(r),V(r))}return i&&(s[u]=r[o],t=t.slice(0,a)),t},t.prototype.buffer=t.prototype.arrayBuffer,t.prototype.digest=t.prototype.array=function(){this.finalize();for(var t,e,r=this.blockCount,n=this.s,i=this.outputBlocks,o=this.extraBytes,u=0,a=0,s=[];a<i;){for(u=0;u<r&&a<i;++u,++a)t=a<<2,e=n[u],s[t]=255&e,s[t+1]=e>>8&255,s[t+2]=e>>16&255,s[t+3]=e>>24&255;a%r==0&&(n=m(n),V(n))}return o&&(t=a<<2,e=n[u],s[t]=255&e,o>1&&(s[t+1]=e>>8&255),o>2&&(s[t+2]=e>>16&255)),s},(e.prototype=new t).finalize=function(){return this.finalized||this.encode(this.outputBits,!0),t.prototype.finalize.call(this)},(r.prototype=new t).getMessageByteLength=function(t){var e=k(t);if(t=e[0],!e[1])return t.length;for(var r=0,n=0;n<t.length;++n){var i=t.charCodeAt(n);i<128?r+=1:i<2048?r+=2:i<55296||i>=57344?r+=3:(++n,r+=4)}return r},r.prototype.beginInput=function(t){if(this.finalized)throw new Error(i);if(this.inputActive)throw new Error(o);if("number"!=typeof t||!isFinite(t)||t<0||Math.floor(t)!==t||t>268435455)throw new Error("tuple input byte length is invalid");return this.encode(8*t,!1),0===t?(this.inputActive=!1,this.inputBytesRemaining=0):(this.inputActive=!0,this.inputBytesRemaining=t),this},r.prototype.updateChunk=function(e){if(this.finalized)throw new Error(i);if(!this.inputActive)throw new Error("no active tuple input");var r=this.getMessageByteLength(e);if(r>this.inputBytesRemaining)throw new Error("tuple input exceeds declared length");return t.prototype.update.call(this,e),this.inputBytesRemaining-=r,0===this.inputBytesRemaining&&(this.inputActive=!1),this},r.prototype.update=function(t){if(this.finalized)throw new Error(i);if(this.inputActive)throw new Error(o);var e=this.getMessageByteLength(t);return this.beginInput(e),0===e?this:this.updateChunk(t)},r.prototype.finalize=function(){if(this.inputActive)throw new Error(o);return this.finalized||this.encode(this.xof?0:this.outputBits,!0),t.prototype.finalize.call(this)};var V=function(t){var e,r,n,i,o,u,a,s,h,f,c,p,l,d,g,v,b,w,A,B,k,_,m,x,S,C,z,E,M,O,R,N,J,j,I,H,F,U,D,L,V,W,Y,K,T,q,G,P,Q,X,Z,$,tt,et,rt,nt,it,ot,ut,at,st,ht,ft;for(n=0;n<48;n+=2)i=t[0]^t[10]^t[20]^t[30]^t[40],o=t[1]^t[11]^t[21]^t[31]^t[41],u=t[2]^t[12]^t[22]^t[32]^t[42],a=t[3]^t[13]^t[23]^t[33]^t[43],s=t[4]^t[14]^t[24]^t[34]^t[44],h=t[5]^t[15]^t[25]^t[35]^t[45],f=t[6]^t[16]^t[26]^t[36]^t[46],c=t[7]^t[17]^t[27]^t[37]^t[47],e=(p=t[8]^t[18]^t[28]^t[38]^t[48])^(u<<1|a>>>31),r=(l=t[9]^t[19]^t[29]^t[39]^t[49])^(a<<1|u>>>31),t[0]^=e,t[1]^=r,t[10]^=e,t[11]^=r,t[20]^=e,t[21]^=r,t[30]^=e,t[31]^=r,t[40]^=e,t[41]^=r,e=i^(s<<1|h>>>31),r=o^(h<<1|s>>>31),t[2]^=e,t[3]^=r,t[12]^=e,t[13]^=r,t[22]^=e,t[23]^=r,t[32]^=e,t[33]^=r,t[42]^=e,t[43]^=r,e=u^(f<<1|c>>>31),r=a^(c<<1|f>>>31),t[4]^=e,t[5]^=r,t[14]^=e,t[15]^=r,t[24]^=e,t[25]^=r,t[34]^=e,t[35]^=r,t[44]^=e,t[45]^=r,e=s^(p<<1|l>>>31),r=h^(l<<1|p>>>31),t[6]^=e,t[7]^=r,t[16]^=e,t[17]^=r,t[26]^=e,t[27]^=r,t[36]^=e,t[37]^=r,t[46]^=e,t[47]^=r,e=f^(i<<1|o>>>31),r=c^(o<<1|i>>>31),t[8]^=e,t[9]^=r,t[18]^=e,t[19]^=r,t[28]^=e,t[29]^=r,t[38]^=e,t[39]^=r,t[48]^=e,t[49]^=r,d=t[0],g=t[1],q=t[11]<<4|t[10]>>>28,G=t[10]<<4|t[11]>>>28,E=t[20]<<3|t[21]>>>29,M=t[21]<<3|t[20]>>>29,at=t[31]<<9|t[30]>>>23,st=t[30]<<9|t[31]>>>23,W=t[40]<<18|t[41]>>>14,Y=t[41]<<18|t[40]>>>14,j=t[2]<<1|t[3]>>>31,I=t[3]<<1|t[2]>>>31,v=t[13]<<12|t[12]>>>20,b=t[12]<<12|t[13]>>>20,P=t[22]<<10|t[23]>>>22,Q=t[23]<<10|t[22]>>>22,O=t[33]<<13|t[32]>>>19,R=t[32]<<13|t[33]>>>19,ht=t[42]<<2|t[43]>>>30,ft=t[43]<<2|t[42]>>>30,et=t[5]<<30|t[4]>>>2,rt=t[4]<<30|t[5]>>>2,H=t[14]<<6|t[15]>>>26,F=t[15]<<6|t[14]>>>26,w=t[25]<<11|t[24]>>>21,A=t[24]<<11|t[25]>>>21,X=t[34]<<15|t[35]>>>17,Z=t[35]<<15|t[34]>>>17,N=t[45]<<29|t[44]>>>3,J=t[44]<<29|t[45]>>>3,x=t[6]<<28|t[7]>>>4,S=t[7]<<28|t[6]>>>4,nt=t[17]<<23|t[16]>>>9,it=t[16]<<23|t[17]>>>9,U=t[26]<<25|t[27]>>>7,D=t[27]<<25|t[26]>>>7,B=t[36]<<21|t[37]>>>11,k=t[37]<<21|t[36]>>>11,$=t[47]<<24|t[46]>>>8,tt=t[46]<<24|t[47]>>>8,K=t[8]<<27|t[9]>>>5,T=t[9]<<27|t[8]>>>5,C=t[18]<<20|t[19]>>>12,z=t[19]<<20|t[18]>>>12,ot=t[29]<<7|t[28]>>>25,ut=t[28]<<7|t[29]>>>25,L=t[38]<<8|t[39]>>>24,V=t[39]<<8|t[38]>>>24,_=t[48]<<14|t[49]>>>18,m=t[49]<<14|t[48]>>>18,t[0]=d^~v&w,t[1]=g^~b&A,t[10]=x^~C&E,t[11]=S^~z&M,t[20]=j^~H&U,t[21]=I^~F&D,t[30]=K^~q&P,t[31]=T^~G&Q,t[40]=et^~nt&ot,t[41]=rt^~it&ut,t[2]=v^~w&B,t[3]=b^~A&k,t[12]=C^~E&O,t[13]=z^~M&R,t[22]=H^~U&L,t[23]=F^~D&V,t[32]=q^~P&X,t[33]=G^~Q&Z,t[42]=nt^~ot&at,t[43]=it^~ut&st,t[4]=w^~B&_,t[5]=A^~k&m,t[14]=E^~O&N,t[15]=M^~R&J,t[24]=U^~L&W,t[25]=D^~V&Y,t[34]=P^~X&$,t[35]=Q^~Z&tt,t[44]=ot^~at&ht,t[45]=ut^~st&ft,t[6]=B^~_&d,t[7]=k^~m&g,t[16]=O^~N&x,t[17]=R^~J&S,t[26]=L^~W&j,t[27]=V^~Y&I,t[36]=X^~$&K,t[37]=Z^~tt&T,t[46]=at^~ht&et,t[47]=st^~ft&rt,t[8]=_^~d&v,t[9]=m^~g&b,t[18]=N^~x&C,t[19]=J^~S&z,t[28]=W^~j&H,t[29]=Y^~I&F,t[38]=$^~K&q,t[39]=tt^~T&G,t[48]=ht^~et&nt,t[49]=ft^~rt&it,t[0]^=y[n],t[1]^=y[n+1]};if(h)module.exports=J;else{for(I=0;I<j.length;++I)a[j[I]]=J[j[I]];f&&define(function(){return J})}}();
|
|
9
|
+
!function(){"use strict";function t(t,e,n){this.blocks=[],this.s=[],this.padding=e,this.outputBits=n,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(t<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=n>>5,this.extraBytes=(31&n)>>3;for(var r=0;r<50;++r)this.s[r]=0}function e(e,n,r,i){t.call(this,e,n,r),this.xof=i}function n(t,n,r,i){e.call(this,t,n,r,i),this.inputActive=!1,this.inputBytesRemaining=0}function r(t,n,r,i,o){e.call(this,t,n,r,i),this.bits=t,this.blockSize=o,this.inner=null,this.innerBytes=0,this.blockNumber=0}var i="input is invalid type",o="finalize already called",a="tuple input is incomplete",u="object"==typeof window,s=u?window:{};s.JS_SHA3_NO_WINDOW&&(u=!1);var h=!u&&"object"==typeof self;!s.JS_SHA3_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node?s=global:h&&(s=self);for(var f=!s.JS_SHA3_NO_COMMON_JS&&"object"==typeof module&&module.exports,c="function"==typeof define&&define.amd,p=!s.JS_SHA3_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,l="0123456789abcdef".split(""),d=[31,7936,2031616,520093696],y=[4,1024,262144,67108864],b=[0,8,16,24],v=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],g=[224,256,384,512],w=[128,256],B=["hex","buffer","arrayBuffer","array","digest"],A={128:168,256:136},k=s.JS_SHA3_NO_NODE_JS||!Array.isArray?function(t){return"[object Array]"===Object.prototype.toString.call(t)}:Array.isArray,_=!p||!s.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView?ArrayBuffer.isView:function(t){return"object"==typeof t&&t.buffer&&t.buffer.constructor===ArrayBuffer},m=function(t){var e=typeof t;if("string"===e)return[t,!0];if("object"!==e||null===t)throw new Error(i);if(p&&t.constructor===ArrayBuffer)return[new Uint8Array(t),!1];if(!k(t)&&!_(t))throw new Error(i);return[t,!1]},x=function(t){return 0===m(t)[0].length},C=function(t){for(var e=[],n=0;n<t.length;++n)e[n]=t[n];return e},S=function(e,n,r){return function(i){return new t(e,n,e).update(i)[r]()}},z=function(e,n,r){return function(i,o){return new t(e,n,o).update(i)[r]()}},M=function(t,e,n){return function(e,r,i,o){return U["cshake"+t].update(e,r,i,o)[n]()}},E=function(t,e,n,r){return function(e,i,o,a){return U[(n?"kmacxof":"kmac")+t].update(e,i,o,a)[r]()}},N=function(t,e,n,r){return function(e,i,o){return U[(n?"tuplehashxof":"tuplehash")+t].update(e,i,o)[r]()}},O=function(t,e,n,r){return function(e,i,o,a){return U[(n?"parallelhashxof":"parallelhash")+t].update(e,i,o,a)[r]()}},I=function(t,e,n,r){for(var i=0;i<B.length;++i){var o=B[i];t[o]=e(n,r,o)}return t},R=function(e,n){var r=S(e,n,"hex");return r.create=function(){return new t(e,n,e)},r.update=function(t){return r.create().update(t)},I(r,S,e,n)},J=function(t,n,r){var i=A[t],o=E(t,0,r,"hex");return o.create=function(o,a,u){return new e(t,n,a,r).bytepad(["KMAC",u],i).bytepad([o],i)},o.update=function(t,e,n,r){return o.create(t,n,r).update(e)},I(o,function(t,e,n){return E(t,0,r,n)},t,n)},j=function(t,e,r){var o=A[t],a=N(t,0,r,"hex");return a.create=function(i,a){return new n(t,e,i,r).bytepad(["TupleHash",a],o)},a.update=function(t,e,n){if(!k(t))throw new Error(i);for(var r=a.create(e,n),o=0;o<t.length;++o)r.update(t[o]);return r},I(a,function(t,e,n){return N(t,0,r,n)},t,e)},H=function(t,e,n){var i=A[t],o=O(t,0,n,"hex");return o.create=function(o,a,u){if("number"!=typeof o||!isFinite(o)||o<1||Math.floor(o)!==o||o>268435455)throw new Error("block size is invalid");var s=new r(t,e,a,n,o).bytepad(["ParallelHash",u],i);return s.encode(o,!1),s},o.update=function(t,e,n,r){return o.create(e,n,r).update(t)},I(o,function(t,e,r){return O(t,0,n,r)},t,e)},F=[{name:"keccak",padding:[1,256,65536,16777216],bits:g,createMethod:R},{name:"sha3",padding:[6,1536,393216,100663296],bits:g,createMethod:R},{name:"shake",padding:d,bits:w,createMethod:function(e,n){var r=z(e,n,"hex");return r.create=function(r){return new t(e,n,r)},r.update=function(t,e){return r.create(e).update(t)},I(r,z,e,n)}},{name:"cshake",padding:y,bits:w,createMethod:function(e,n){var r=A[e],i=M(e,0,"hex");return i.create=function(i,o,a){return x(o)&&x(a)?U["shake"+e].create(i):new t(e,n,i).bytepad([o,a],r)},i.update=function(t,e,n,r){return i.create(e,n,r).update(t)},I(i,M,e,n)}},{name:"kmac",padding:y,bits:w,createMethod:function(t,e){return J(t,e,!1)}},{name:"kmacxof",padding:y,bits:w,createMethod:function(t,e){return J(t,e,!0)}},{name:"tuplehash",padding:y,bits:w,createMethod:function(t,e){return j(t,e,!1)}},{name:"tuplehashxof",padding:y,bits:w,createMethod:function(t,e){return j(t,e,!0)}},{name:"parallelhash",padding:y,bits:w,createMethod:function(t,e){return H(t,e,!1)}},{name:"parallelhashxof",padding:y,bits:w,createMethod:function(t,e){return H(t,e,!0)}}],U={},D=[],L=0;L<F.length;++L)for(var V=F[L],W=V.bits,Y=0;Y<W.length;++Y){var K=V.name+"_"+W[Y];if(D.push(K),U[K]=V.createMethod(W[Y],V.padding),"sha3"!==V.name){var P=V.name+W[Y];D.push(P),U[P]=U[K]}}t.prototype.update=function(t){if(this.finalized)throw new Error(o);var e=m(t);t=e[0];for(var n,r,i=e[1],a=this.blocks,u=this.byteCount,s=t.length,h=this.blockCount,f=0,c=this.s;f<s;){if(this.reset)for(this.reset=!1,a[0]=this.block,n=1;n<h+1;++n)a[n]=0;if(i)for(n=this.start;f<s&&n<u;++f)(r=t.charCodeAt(f))<128?a[n>>2]|=r<<b[3&n++]:r<2048?(a[n>>2]|=(192|r>>6)<<b[3&n++],a[n>>2]|=(128|63&r)<<b[3&n++]):r<55296||r>=57344?(a[n>>2]|=(224|r>>12)<<b[3&n++],a[n>>2]|=(128|r>>6&63)<<b[3&n++],a[n>>2]|=(128|63&r)<<b[3&n++]):(r=65536+((1023&r)<<10|1023&t.charCodeAt(++f)),a[n>>2]|=(240|r>>18)<<b[3&n++],a[n>>2]|=(128|r>>12&63)<<b[3&n++],a[n>>2]|=(128|r>>6&63)<<b[3&n++],a[n>>2]|=(128|63&r)<<b[3&n++]);else for(n=this.start;f<s&&n<u;++f)a[n>>2]|=t[f]<<b[3&n++];if(this.lastByteIndex=n,n>=u){for(this.start=n-u,this.block=a[h],n=0;n<h;++n)c[n]^=a[n];T(c),this.reset=!0}else this.start=n}return this},t.prototype.encode=function(e,n){var r=255&e,i=1,o=[r];for(r=255&(e>>=8);r>0;)o.unshift(r),r=255&(e>>=8),++i;return n?o.push(i):o.unshift(i),t.prototype.update.call(this,o),o.length},t.prototype.encodeString=function(e){var n=m(e);e=n[0];var r=n[1],i=0,o=e.length;if(r)for(var a=0;a<e.length;++a){var u=e.charCodeAt(a);u<128?i+=1:u<2048?i+=2:u<55296||u>=57344?i+=3:(u=65536+((1023&u)<<10|1023&e.charCodeAt(++a)),i+=4)}else i=o;return i+=this.encode(8*i),t.prototype.update.call(this,e),i},t.prototype.bytepad=function(e,n){for(var r=this.encode(n),i=0;i<e.length;++i)r+=this.encodeString(e[i]);var o=(n-r%n)%n,a=[];return a.length=o,t.prototype.update.call(this,a),this},t.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,e=this.lastByteIndex,n=this.blockCount,r=this.s;if(t[e>>2]|=this.padding[3&e],this.lastByteIndex===this.byteCount)for(t[0]=t[n],e=1;e<n+1;++e)t[e]=0;for(t[n-1]|=2147483648,e=0;e<n;++e)r[e]^=t[e];T(r)}},t.prototype.toString=t.prototype.hex=function(){this.finalize();for(var t,e=this.blockCount,n=this.s,r=this.outputBlocks,i=this.extraBytes,o=0,a=0,u="";a<r;){for(o=0;o<e&&a<r;++o,++a)t=n[o],u+=l[t>>4&15]+l[15&t]+l[t>>12&15]+l[t>>8&15]+l[t>>20&15]+l[t>>16&15]+l[t>>28&15]+l[t>>24&15];a%e==0&&(n=C(n),T(n),o=0)}return i&&(t=n[o],u+=l[t>>4&15]+l[15&t],i>1&&(u+=l[t>>12&15]+l[t>>8&15]),i>2&&(u+=l[t>>20&15]+l[t>>16&15])),u},t.prototype.arrayBuffer=function(){this.finalize();var t,e=this.blockCount,n=this.s,r=this.outputBlocks,i=this.extraBytes,o=0,a=0,u=this.outputBits>>3;t=i?new ArrayBuffer(r+1<<2):new ArrayBuffer(u);for(var s=new Uint32Array(t);a<r;){for(o=0;o<e&&a<r;++o,++a)s[a]=n[o];a%e==0&&(n=C(n),T(n))}return i&&(s[a]=n[o],t=t.slice(0,u)),t},t.prototype.buffer=t.prototype.arrayBuffer,t.prototype.digest=t.prototype.array=function(){this.finalize();for(var t,e,n=this.blockCount,r=this.s,i=this.outputBlocks,o=this.extraBytes,a=0,u=0,s=[];u<i;){for(a=0;a<n&&u<i;++a,++u)t=u<<2,e=r[a],s[t]=255&e,s[t+1]=e>>8&255,s[t+2]=e>>16&255,s[t+3]=e>>24&255;u%n==0&&(r=C(r),T(r))}return o&&(t=u<<2,e=r[a],s[t]=255&e,o>1&&(s[t+1]=e>>8&255),o>2&&(s[t+2]=e>>16&255)),s},(e.prototype=new t).finalize=function(){return this.finalized||this.encode(this.xof?0:this.outputBits,!0),t.prototype.finalize.call(this)},(n.prototype=new e).getMessageByteLength=function(t){var e=m(t);if(t=e[0],!e[1])return t.length;for(var n=0,r=0;r<t.length;++r){var i=t.charCodeAt(r);i<128?n+=1:i<2048?n+=2:i<55296||i>=57344?n+=3:(++r,n+=4)}return n},n.prototype.beginInput=function(t){if(this.inputActive)throw new Error(a);if("number"!=typeof t||!isFinite(t)||t<0||Math.floor(t)!==t||t>268435455)throw new Error("tuple input byte length is invalid");return this.encode(8*t,!1),0!==t&&(this.inputActive=!0,this.inputBytesRemaining=t),this},n.prototype._updateChunk=function(t,n){return e.prototype.update.call(this,t),this.inputBytesRemaining-=n,0===this.inputBytesRemaining&&(this.inputActive=!1),this},n.prototype.updateChunk=function(t){if(!this.inputActive)throw new Error("no active tuple input");var e=this.getMessageByteLength(t);if(e>this.inputBytesRemaining)throw new Error("tuple input exceeds declared length");return this._updateChunk(t,e)},n.prototype.update=function(t){var e=this.getMessageByteLength(t);return this.beginInput(e),this._updateChunk(t,e)},n.prototype.finalize=function(){if(this.inputActive)throw new Error(a);return e.prototype.finalize.call(this)},(r.prototype=new e)._finishInner=function(){e.prototype.update.call(this,this.inner.array()),this.inner=null,this.innerBytes=0,++this.blockNumber},r.prototype._updateBytes=function(e){var n=e.length;if(n)for(var r=e.subarray||e.slice,i=this.blockSize,o=0;o<n;){this.inner||(this.inner=new t(this.bits,d,this.bits<<1));var a=i-this.innerBytes;n-o<a&&(a=n-o),this.inner.update(r.call(e,o,o+a)),this.innerBytes+=a,o+=a,this.innerBytes===i&&this._finishInner()}},r.prototype.update=function(t){if(this.finalized)throw new Error(o);var e=m(t);if(t=e[0],e[1]){var n,r,i=[],a=t.length,u=0;for(r=0;r<a;++r)(n=t.charCodeAt(r))<128?i[u++]=n:n<2048?(i[u++]=192|n>>>6,i[u++]=128|63&n):n<55296||n>=57344?(i[u++]=224|n>>>12,i[u++]=128|n>>>6&63,i[u++]=128|63&n):(n=65536+((1023&n)<<10|1023&t.charCodeAt(++r)),i[u++]=240|n>>>18,i[u++]=128|n>>>12&63,i[u++]=128|n>>>6&63,i[u++]=128|63&n);t=i}return this._updateBytes(t),this},r.prototype.finalize=function(){return this.finalized||(this.inner&&this._finishInner(),this.encode(this.blockNumber,!0)),e.prototype.finalize.call(this)};var T=function(t){var e,n,r,i,o,a,u,s,h,f,c,p,l,d,y,b,g,w,B,A,k,_,m,x,C,S,z,M,E,N,O,I,R,J,j,H,F,U,D,L,V,W,Y,K,P,T,q,G,Q,X,Z,$,tt,et,nt,rt,it,ot,at,ut,st,ht,ft;for(r=0;r<48;r+=2)i=t[0]^t[10]^t[20]^t[30]^t[40],o=t[1]^t[11]^t[21]^t[31]^t[41],a=t[2]^t[12]^t[22]^t[32]^t[42],u=t[3]^t[13]^t[23]^t[33]^t[43],s=t[4]^t[14]^t[24]^t[34]^t[44],h=t[5]^t[15]^t[25]^t[35]^t[45],f=t[6]^t[16]^t[26]^t[36]^t[46],c=t[7]^t[17]^t[27]^t[37]^t[47],e=(p=t[8]^t[18]^t[28]^t[38]^t[48])^(a<<1|u>>>31),n=(l=t[9]^t[19]^t[29]^t[39]^t[49])^(u<<1|a>>>31),t[0]^=e,t[1]^=n,t[10]^=e,t[11]^=n,t[20]^=e,t[21]^=n,t[30]^=e,t[31]^=n,t[40]^=e,t[41]^=n,e=i^(s<<1|h>>>31),n=o^(h<<1|s>>>31),t[2]^=e,t[3]^=n,t[12]^=e,t[13]^=n,t[22]^=e,t[23]^=n,t[32]^=e,t[33]^=n,t[42]^=e,t[43]^=n,e=a^(f<<1|c>>>31),n=u^(c<<1|f>>>31),t[4]^=e,t[5]^=n,t[14]^=e,t[15]^=n,t[24]^=e,t[25]^=n,t[34]^=e,t[35]^=n,t[44]^=e,t[45]^=n,e=s^(p<<1|l>>>31),n=h^(l<<1|p>>>31),t[6]^=e,t[7]^=n,t[16]^=e,t[17]^=n,t[26]^=e,t[27]^=n,t[36]^=e,t[37]^=n,t[46]^=e,t[47]^=n,e=f^(i<<1|o>>>31),n=c^(o<<1|i>>>31),t[8]^=e,t[9]^=n,t[18]^=e,t[19]^=n,t[28]^=e,t[29]^=n,t[38]^=e,t[39]^=n,t[48]^=e,t[49]^=n,d=t[0],y=t[1],T=t[11]<<4|t[10]>>>28,q=t[10]<<4|t[11]>>>28,M=t[20]<<3|t[21]>>>29,E=t[21]<<3|t[20]>>>29,ut=t[31]<<9|t[30]>>>23,st=t[30]<<9|t[31]>>>23,W=t[40]<<18|t[41]>>>14,Y=t[41]<<18|t[40]>>>14,J=t[2]<<1|t[3]>>>31,j=t[3]<<1|t[2]>>>31,b=t[13]<<12|t[12]>>>20,g=t[12]<<12|t[13]>>>20,G=t[22]<<10|t[23]>>>22,Q=t[23]<<10|t[22]>>>22,N=t[33]<<13|t[32]>>>19,O=t[32]<<13|t[33]>>>19,ht=t[42]<<2|t[43]>>>30,ft=t[43]<<2|t[42]>>>30,et=t[5]<<30|t[4]>>>2,nt=t[4]<<30|t[5]>>>2,H=t[14]<<6|t[15]>>>26,F=t[15]<<6|t[14]>>>26,w=t[25]<<11|t[24]>>>21,B=t[24]<<11|t[25]>>>21,X=t[34]<<15|t[35]>>>17,Z=t[35]<<15|t[34]>>>17,I=t[45]<<29|t[44]>>>3,R=t[44]<<29|t[45]>>>3,x=t[6]<<28|t[7]>>>4,C=t[7]<<28|t[6]>>>4,rt=t[17]<<23|t[16]>>>9,it=t[16]<<23|t[17]>>>9,U=t[26]<<25|t[27]>>>7,D=t[27]<<25|t[26]>>>7,A=t[36]<<21|t[37]>>>11,k=t[37]<<21|t[36]>>>11,$=t[47]<<24|t[46]>>>8,tt=t[46]<<24|t[47]>>>8,K=t[8]<<27|t[9]>>>5,P=t[9]<<27|t[8]>>>5,S=t[18]<<20|t[19]>>>12,z=t[19]<<20|t[18]>>>12,ot=t[29]<<7|t[28]>>>25,at=t[28]<<7|t[29]>>>25,L=t[38]<<8|t[39]>>>24,V=t[39]<<8|t[38]>>>24,_=t[48]<<14|t[49]>>>18,m=t[49]<<14|t[48]>>>18,t[0]=d^~b&w,t[1]=y^~g&B,t[10]=x^~S&M,t[11]=C^~z&E,t[20]=J^~H&U,t[21]=j^~F&D,t[30]=K^~T&G,t[31]=P^~q&Q,t[40]=et^~rt&ot,t[41]=nt^~it&at,t[2]=b^~w&A,t[3]=g^~B&k,t[12]=S^~M&N,t[13]=z^~E&O,t[22]=H^~U&L,t[23]=F^~D&V,t[32]=T^~G&X,t[33]=q^~Q&Z,t[42]=rt^~ot&ut,t[43]=it^~at&st,t[4]=w^~A&_,t[5]=B^~k&m,t[14]=M^~N&I,t[15]=E^~O&R,t[24]=U^~L&W,t[25]=D^~V&Y,t[34]=G^~X&$,t[35]=Q^~Z&tt,t[44]=ot^~ut&ht,t[45]=at^~st&ft,t[6]=A^~_&d,t[7]=k^~m&y,t[16]=N^~I&x,t[17]=O^~R&C,t[26]=L^~W&J,t[27]=V^~Y&j,t[36]=X^~$&K,t[37]=Z^~tt&P,t[46]=ut^~ht&et,t[47]=st^~ft&nt,t[8]=_^~d&b,t[9]=m^~y&g,t[18]=I^~x&S,t[19]=R^~C&z,t[28]=W^~J&H,t[29]=Y^~j&F,t[38]=$^~K&T,t[39]=tt^~P&q,t[48]=ht^~et&rt,t[49]=ft^~nt&it,t[0]^=v[r],t[1]^=v[r+1]};if(f)module.exports=U;else{for(L=0;L<D.length;++L)s[D[L]]=U[D[L]];c&&define(function(){return U})}}();
|
package/build/sha3.min.mjs
CHANGED
|
@@ -2,8 +2,8 @@ var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?windo
|
|
|
2
2
|
/**
|
|
3
3
|
* [js-sha3]{@link https://github.com/emn178/js-sha3}
|
|
4
4
|
*
|
|
5
|
-
* @version 0.
|
|
5
|
+
* @version 0.13.0
|
|
6
6
|
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
|
7
|
-
* @copyright Chen, Yi-Cyuan 2015-
|
|
7
|
+
* @copyright Chen, Yi-Cyuan 2015-2026
|
|
8
8
|
* @license MIT
|
|
9
|
-
*/r=n,function(){var e="input is invalid type",n="finalize already called",i="tuple input is incomplete",o="object"==typeof window,a=o?window:{};a.JS_SHA3_NO_WINDOW&&(o=!1);var s=!o&&"object"==typeof self;!a.JS_SHA3_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node?a=t:s&&(a=self);for(var u=!a.JS_SHA3_NO_COMMON_JS&&r.exports,h=!a.JS_SHA3_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,f="0123456789abcdef".split(""),c=[4,1024,262144,67108864],p=[0,8,16,24],l=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],d=[224,256,384,512],y=[128,256],g=["hex","buffer","arrayBuffer","array","digest"],k={128:168,256:136},v=a.JS_SHA3_NO_NODE_JS||!Array.isArray?function(t){return"[object Array]"===Object.prototype.toString.call(t)}:Array.isArray,b=!h||!a.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView?ArrayBuffer.isView:function(t){return"object"==typeof t&&t.buffer&&t.buffer.constructor===ArrayBuffer},w=function(t){var r=typeof t;if("string"===r)return[t,!0];if("object"!==r||null===t)throw new Error(e);if(h&&t.constructor===ArrayBuffer)return[new Uint8Array(t),!1];if(!v(t)&&!b(t))throw new Error(e);return[t,!1]},_=function(t){return 0===w(t)[0].length},A=function(t){for(var e=[],r=0;r<t.length;++r)e[r]=t[r];return e},B=function(t,e,r){return function(n){return new D(t,e,t).update(n)[r]()}},x=function(t,e,r){return function(n,i){return new D(t,e,i).update(n)[r]()}},m=function(t,e,r){return function(e,n,i,o){return R["cshake"+t].update(e,n,i,o)[r]()}},S=function(t,e,r){return function(e,n,i,o){return R["kmac"+t].update(e,n,i,o)[r]()}},C=function(t,e,r,n){for(var i=0;i<g.length;++i){var o=g[i];t[o]=e(r,n,o)}return t},z=function(t,e){var r=B(t,e,"hex");return r.create=function(){return new D(t,e,t)},r.update=function(t){return r.create().update(t)},C(r,B,t,e)},E=function(t,e,r,n){return function(e,i,o){return R[(r?"tuplehashxof":"tuplehash")+t].update(e,i,o)[n]()}},M=function(t,r,n){var i=k[t],o=E(t,0,n,"hex");return o.create=function(e,o){return new T(t,r,e,n).bytepad(["TupleHash",o],i)},o.update=function(t,r,n){if(!v(t))throw new Error(e);for(var i=o.create(r,n),a=0;a<t.length;++a)i.update(t[a]);return i},C(o,function(t,e,r){return E(t,0,n,r)},t,r)},O=[{name:"keccak",padding:[1,256,65536,16777216],bits:d,createMethod:z},{name:"sha3",padding:[6,1536,393216,100663296],bits:d,createMethod:z},{name:"shake",padding:[31,7936,2031616,520093696],bits:y,createMethod:function(t,e){var r=x(t,e,"hex");return r.create=function(r){return new D(t,e,r)},r.update=function(t,e){return r.create(e).update(t)},C(r,x,t,e)}},{name:"cshake",padding:c,bits:y,createMethod:function(t,e){var r=k[t],n=m(t,0,"hex");return n.create=function(n,i,o){return _(i)&&_(o)?R["shake"+t].create(n):new D(t,e,n).bytepad([i,o],r)},n.update=function(t,e,r,i){return n.create(e,r,i).update(t)},C(n,m,t,e)}},{name:"kmac",padding:c,bits:y,createMethod:function(t,e){var r=k[t],n=S(t,0,"hex");return n.create=function(n,i,o){return new L(t,e,i).bytepad(["KMAC",o],r).bytepad([n],r)},n.update=function(t,e,r,i){return n.create(t,r,i).update(e)},C(n,S,t,e)}},{name:"tuplehash",padding:c,bits:y,createMethod:function(t,e){return M(t,e,!1)}},{name:"tuplehashxof",padding:c,bits:y,createMethod:function(t,e){return M(t,e,!0)}}],R={},N=[],J=0;J<O.length;++J)for(var j=O[J],I=j.bits,H=0;H<I.length;++H){var F=j.name+"_"+I[H];if(N.push(F),R[F]=j.createMethod(I[H],j.padding),"sha3"!==j.name){var U=j.name+I[H];N.push(U),R[U]=R[F]}}function D(t,e,r){this.blocks=[],this.s=[],this.padding=e,this.outputBits=r,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(t<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}function L(t,e,r){D.call(this,t,e,r)}function T(t,e,r,n){D.call(this,t,e,r),this.xof=!!n,this.inputActive=!1,this.inputBytesRemaining=0}D.prototype.update=function(t){if(this.finalized)throw new Error(n);var e=w(t);t=e[0];for(var r,i,o=e[1],a=this.blocks,s=this.byteCount,u=t.length,h=this.blockCount,f=0,c=this.s;f<u;){if(this.reset)for(this.reset=!1,a[0]=this.block,r=1;r<h+1;++r)a[r]=0;if(o)for(r=this.start;f<u&&r<s;++f)(i=t.charCodeAt(f))<128?a[r>>2]|=i<<p[3&r++]:i<2048?(a[r>>2]|=(192|i>>6)<<p[3&r++],a[r>>2]|=(128|63&i)<<p[3&r++]):i<55296||i>=57344?(a[r>>2]|=(224|i>>12)<<p[3&r++],a[r>>2]|=(128|i>>6&63)<<p[3&r++],a[r>>2]|=(128|63&i)<<p[3&r++]):(i=65536+((1023&i)<<10|1023&t.charCodeAt(++f)),a[r>>2]|=(240|i>>18)<<p[3&r++],a[r>>2]|=(128|i>>12&63)<<p[3&r++],a[r>>2]|=(128|i>>6&63)<<p[3&r++],a[r>>2]|=(128|63&i)<<p[3&r++]);else for(r=this.start;f<u&&r<s;++f)a[r>>2]|=t[f]<<p[3&r++];if(this.lastByteIndex=r,r>=s){for(this.start=r-s,this.block=a[h],r=0;r<h;++r)c[r]^=a[r];V(c),this.reset=!0}else this.start=r}return this},D.prototype.encode=function(t,e){var r=255&t,n=1,i=[r];for(r=255&(t>>=8);r>0;)i.unshift(r),r=255&(t>>=8),++n;return e?i.push(n):i.unshift(n),D.prototype.update.call(this,i),i.length},D.prototype.encodeString=function(t){var e=w(t);t=e[0];var r=e[1],n=0,i=t.length;if(r)for(var o=0;o<t.length;++o){var a=t.charCodeAt(o);a<128?n+=1:a<2048?n+=2:a<55296||a>=57344?n+=3:(a=65536+((1023&a)<<10|1023&t.charCodeAt(++o)),n+=4)}else n=i;return n+=this.encode(8*n),D.prototype.update.call(this,t),n},D.prototype.bytepad=function(t,e){for(var r=this.encode(e),n=0;n<t.length;++n)r+=this.encodeString(t[n]);var i=(e-r%e)%e,o=[];return o.length=i,D.prototype.update.call(this,o),this},D.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,e=this.lastByteIndex,r=this.blockCount,n=this.s;if(t[e>>2]|=this.padding[3&e],this.lastByteIndex===this.byteCount)for(t[0]=t[r],e=1;e<r+1;++e)t[e]=0;for(t[r-1]|=2147483648,e=0;e<r;++e)n[e]^=t[e];V(n)}},D.prototype.toString=D.prototype.hex=function(){this.finalize();for(var t,e=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,a=0,s="";a<n;){for(o=0;o<e&&a<n;++o,++a)t=r[o],s+=f[t>>4&15]+f[15&t]+f[t>>12&15]+f[t>>8&15]+f[t>>20&15]+f[t>>16&15]+f[t>>28&15]+f[t>>24&15];a%e===0&&(r=A(r),V(r),o=0)}return i&&(t=r[o],s+=f[t>>4&15]+f[15&t],i>1&&(s+=f[t>>12&15]+f[t>>8&15]),i>2&&(s+=f[t>>20&15]+f[t>>16&15])),s},D.prototype.arrayBuffer=function(){this.finalize();var t,e=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,a=0,s=this.outputBits>>3;t=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(s);for(var u=new Uint32Array(t);a<n;){for(o=0;o<e&&a<n;++o,++a)u[a]=r[o];a%e===0&&(r=A(r),V(r))}return i&&(u[a]=r[o],t=t.slice(0,s)),t},D.prototype.buffer=D.prototype.arrayBuffer,D.prototype.digest=D.prototype.array=function(){this.finalize();for(var t,e,r=this.blockCount,n=this.s,i=this.outputBlocks,o=this.extraBytes,a=0,s=0,u=[];s<i;){for(a=0;a<r&&s<i;++a,++s)t=s<<2,e=n[a],u[t]=255&e,u[t+1]=e>>8&255,u[t+2]=e>>16&255,u[t+3]=e>>24&255;s%r===0&&(n=A(n),V(n))}return o&&(t=s<<2,e=n[a],u[t]=255&e,o>1&&(u[t+1]=e>>8&255),o>2&&(u[t+2]=e>>16&255)),u},L.prototype=new D,L.prototype.finalize=function(){return this.finalized||this.encode(this.outputBits,!0),D.prototype.finalize.call(this)},T.prototype=new D,T.prototype.getMessageByteLength=function(t){var e=w(t);if(t=e[0],!e[1])return t.length;for(var r=0,n=0;n<t.length;++n){var i=t.charCodeAt(n);i<128?r+=1:i<2048?r+=2:i<55296||i>=57344?r+=3:(++n,r+=4)}return r},T.prototype.beginInput=function(t){if(this.finalized)throw new Error(n);if(this.inputActive)throw new Error(i);if("number"!=typeof t||!isFinite(t)||t<0||Math.floor(t)!==t||t>268435455)throw new Error("tuple input byte length is invalid");return this.encode(8*t,!1),0===t?(this.inputActive=!1,this.inputBytesRemaining=0):(this.inputActive=!0,this.inputBytesRemaining=t),this},T.prototype.updateChunk=function(t){if(this.finalized)throw new Error(n);if(!this.inputActive)throw new Error("no active tuple input");var e=this.getMessageByteLength(t);if(e>this.inputBytesRemaining)throw new Error("tuple input exceeds declared length");return D.prototype.update.call(this,t),this.inputBytesRemaining-=e,0===this.inputBytesRemaining&&(this.inputActive=!1),this},T.prototype.update=function(t){if(this.finalized)throw new Error(n);if(this.inputActive)throw new Error(i);var e=this.getMessageByteLength(t);return this.beginInput(e),0===e?this:this.updateChunk(t)},T.prototype.finalize=function(){if(this.inputActive)throw new Error(i);return this.finalized||this.encode(this.xof?0:this.outputBits,!0),D.prototype.finalize.call(this)};var V=function(t){var e,r,n,i,o,a,s,u,h,f,c,p,d,y,g,k,v,b,w,_,A,B,x,m,S,C,z,E,M,O,R,N,J,j,I,H,F,U,D,L,T,V,W,Y,K,P,q,G,Q,X,Z,$,tt,et,rt,nt,it,ot,at,st,ut,ht,ft;for(n=0;n<48;n+=2)i=t[0]^t[10]^t[20]^t[30]^t[40],o=t[1]^t[11]^t[21]^t[31]^t[41],a=t[2]^t[12]^t[22]^t[32]^t[42],s=t[3]^t[13]^t[23]^t[33]^t[43],u=t[4]^t[14]^t[24]^t[34]^t[44],h=t[5]^t[15]^t[25]^t[35]^t[45],f=t[6]^t[16]^t[26]^t[36]^t[46],c=t[7]^t[17]^t[27]^t[37]^t[47],e=(p=t[8]^t[18]^t[28]^t[38]^t[48])^(a<<1|s>>>31),r=(d=t[9]^t[19]^t[29]^t[39]^t[49])^(s<<1|a>>>31),t[0]^=e,t[1]^=r,t[10]^=e,t[11]^=r,t[20]^=e,t[21]^=r,t[30]^=e,t[31]^=r,t[40]^=e,t[41]^=r,e=i^(u<<1|h>>>31),r=o^(h<<1|u>>>31),t[2]^=e,t[3]^=r,t[12]^=e,t[13]^=r,t[22]^=e,t[23]^=r,t[32]^=e,t[33]^=r,t[42]^=e,t[43]^=r,e=a^(f<<1|c>>>31),r=s^(c<<1|f>>>31),t[4]^=e,t[5]^=r,t[14]^=e,t[15]^=r,t[24]^=e,t[25]^=r,t[34]^=e,t[35]^=r,t[44]^=e,t[45]^=r,e=u^(p<<1|d>>>31),r=h^(d<<1|p>>>31),t[6]^=e,t[7]^=r,t[16]^=e,t[17]^=r,t[26]^=e,t[27]^=r,t[36]^=e,t[37]^=r,t[46]^=e,t[47]^=r,e=f^(i<<1|o>>>31),r=c^(o<<1|i>>>31),t[8]^=e,t[9]^=r,t[18]^=e,t[19]^=r,t[28]^=e,t[29]^=r,t[38]^=e,t[39]^=r,t[48]^=e,t[49]^=r,y=t[0],g=t[1],P=t[11]<<4|t[10]>>>28,q=t[10]<<4|t[11]>>>28,E=t[20]<<3|t[21]>>>29,M=t[21]<<3|t[20]>>>29,st=t[31]<<9|t[30]>>>23,ut=t[30]<<9|t[31]>>>23,V=t[40]<<18|t[41]>>>14,W=t[41]<<18|t[40]>>>14,j=t[2]<<1|t[3]>>>31,I=t[3]<<1|t[2]>>>31,k=t[13]<<12|t[12]>>>20,v=t[12]<<12|t[13]>>>20,G=t[22]<<10|t[23]>>>22,Q=t[23]<<10|t[22]>>>22,O=t[33]<<13|t[32]>>>19,R=t[32]<<13|t[33]>>>19,ht=t[42]<<2|t[43]>>>30,ft=t[43]<<2|t[42]>>>30,et=t[5]<<30|t[4]>>>2,rt=t[4]<<30|t[5]>>>2,H=t[14]<<6|t[15]>>>26,F=t[15]<<6|t[14]>>>26,b=t[25]<<11|t[24]>>>21,w=t[24]<<11|t[25]>>>21,X=t[34]<<15|t[35]>>>17,Z=t[35]<<15|t[34]>>>17,N=t[45]<<29|t[44]>>>3,J=t[44]<<29|t[45]>>>3,m=t[6]<<28|t[7]>>>4,S=t[7]<<28|t[6]>>>4,nt=t[17]<<23|t[16]>>>9,it=t[16]<<23|t[17]>>>9,U=t[26]<<25|t[27]>>>7,D=t[27]<<25|t[26]>>>7,_=t[36]<<21|t[37]>>>11,A=t[37]<<21|t[36]>>>11,$=t[47]<<24|t[46]>>>8,tt=t[46]<<24|t[47]>>>8,Y=t[8]<<27|t[9]>>>5,K=t[9]<<27|t[8]>>>5,C=t[18]<<20|t[19]>>>12,z=t[19]<<20|t[18]>>>12,ot=t[29]<<7|t[28]>>>25,at=t[28]<<7|t[29]>>>25,L=t[38]<<8|t[39]>>>24,T=t[39]<<8|t[38]>>>24,B=t[48]<<14|t[49]>>>18,x=t[49]<<14|t[48]>>>18,t[0]=y^~k&b,t[1]=g^~v&w,t[10]=m^~C&E,t[11]=S^~z&M,t[20]=j^~H&U,t[21]=I^~F&D,t[30]=Y^~P&G,t[31]=K^~q&Q,t[40]=et^~nt&ot,t[41]=rt^~it&at,t[2]=k^~b&_,t[3]=v^~w&A,t[12]=C^~E&O,t[13]=z^~M&R,t[22]=H^~U&L,t[23]=F^~D&T,t[32]=P^~G&X,t[33]=q^~Q&Z,t[42]=nt^~ot&st,t[43]=it^~at&ut,t[4]=b^~_&B,t[5]=w^~A&x,t[14]=E^~O&N,t[15]=M^~R&J,t[24]=U^~L&V,t[25]=D^~T&W,t[34]=G^~X&$,t[35]=Q^~Z&tt,t[44]=ot^~st&ht,t[45]=at^~ut&ft,t[6]=_^~B&y,t[7]=A^~x&g,t[16]=O^~N&m,t[17]=R^~J&S,t[26]=L^~V&j,t[27]=T^~W&I,t[36]=X^~$&Y,t[37]=Z^~tt&K,t[46]=st^~ht&et,t[47]=ut^~ft&rt,t[8]=B^~y&k,t[9]=x^~g&v,t[18]=N^~m&C,t[19]=J^~S&z,t[28]=V^~j&H,t[29]=W^~I&F,t[38]=$^~Y&P,t[39]=tt^~K&q,t[48]=ht^~et&nt,t[49]=ft^~rt&it,t[0]^=l[n],t[1]^=l[n+1]};if(u)r.exports=R;else for(J=0;J<N.length;++J)a[N[J]]=R[N[J]]}();var i=e(n.exports);const{sha3_224:o,sha3_256:a,sha3_384:s,sha3_512:u,keccak_224:h,keccak_256:f,keccak_384:c,keccak_512:p,keccak224:l,keccak256:d,keccak384:y,keccak512:g,shake_128:k,shake_256:v,shake128:b,shake256:w,cshake_128:_,cshake_256:A,cshake128:B,cshake256:x,kmac_128:m,kmac_256:S,kmac128:C,kmac256:z,tuplehash_128:E,tuplehash_256:M,tuplehash128:O,tuplehash256:R,tuplehashxof_128:N,tuplehashxof_256:J,tuplehashxof128:j,tuplehashxof256:I}=i;export{B as cshake128,x as cshake256,_ as cshake_128,A as cshake_256,i as default,l as keccak224,d as keccak256,y as keccak384,g as keccak512,h as keccak_224,f as keccak_256,c as keccak_384,p as keccak_512,C as kmac128,z as kmac256,m as kmac_128,S as kmac_256,o as sha3_224,a as sha3_256,s as sha3_384,u as sha3_512,b as shake128,w as shake256,k as shake_128,v as shake_256,O as tuplehash128,R as tuplehash256,E as tuplehash_128,M as tuplehash_256,j as tuplehashxof128,I as tuplehashxof256,N as tuplehashxof_128,J as tuplehashxof_256};
|
|
9
|
+
*/r=n,function(){var e="input is invalid type",n="finalize already called",i="tuple input is incomplete",a="object"==typeof window,o=a?window:{};o.JS_SHA3_NO_WINDOW&&(a=!1);var s=!a&&"object"==typeof self;!o.JS_SHA3_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node?o=t:s&&(o=self);for(var u=!o.JS_SHA3_NO_COMMON_JS&&r.exports,h=!o.JS_SHA3_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,f="0123456789abcdef".split(""),c=[31,7936,2031616,520093696],p=[4,1024,262144,67108864],l=[0,8,16,24],d=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],y=[224,256,384,512],k=[128,256],b=["hex","buffer","arrayBuffer","array","digest"],v={128:168,256:136},_=o.JS_SHA3_NO_NODE_JS||!Array.isArray?function(t){return"[object Array]"===Object.prototype.toString.call(t)}:Array.isArray,g=!h||!o.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView?ArrayBuffer.isView:function(t){return"object"==typeof t&&t.buffer&&t.buffer.constructor===ArrayBuffer},w=function(t){var r=typeof t;if("string"===r)return[t,!0];if("object"!==r||null===t)throw new Error(e);if(h&&t.constructor===ArrayBuffer)return[new Uint8Array(t),!1];if(!_(t)&&!g(t))throw new Error(e);return[t,!1]},x=function(t){return 0===w(t)[0].length},B=function(t){for(var e=[],r=0;r<t.length;++r)e[r]=t[r];return e},A=function(t,e,r){return function(n){return new W(t,e,t).update(n)[r]()}},m=function(t,e,r){return function(n,i){return new W(t,e,i).update(n)[r]()}},C=function(t,e,r){return function(e,n,i,a){return j["cshake"+t].update(e,n,i,a)[r]()}},S=function(t,e,r,n){return function(e,i,a,o){return j[(r?"kmacxof":"kmac")+t].update(e,i,a,o)[n]()}},z=function(t,e,r,n){return function(e,i,a){return j[(r?"tuplehashxof":"tuplehash")+t].update(e,i,a)[n]()}},M=function(t,e,r,n){return function(e,i,a,o){return j[(r?"parallelhashxof":"parallelhash")+t].update(e,i,a,o)[n]()}},E=function(t,e,r,n){for(var i=0;i<b.length;++i){var a=b[i];t[a]=e(r,n,a)}return t},O=function(t,e){var r=A(t,e,"hex");return r.create=function(){return new W(t,e,t)},r.update=function(t){return r.create().update(t)},E(r,A,t,e)},N=function(t,e,r){var n=v[t],i=S(t,0,r,"hex");return i.create=function(i,a,o){return new P(t,e,a,r).bytepad(["KMAC",o],n).bytepad([i],n)},i.update=function(t,e,r,n){return i.create(t,r,n).update(e)},E(i,function(t,e,n){return S(t,0,r,n)},t,e)},I=function(t,r,n){var i=v[t],a=z(t,0,n,"hex");return a.create=function(e,a){return new Y(t,r,e,n).bytepad(["TupleHash",a],i)},a.update=function(t,r,n){if(!_(t))throw new Error(e);for(var i=a.create(r,n),o=0;o<t.length;++o)i.update(t[o]);return i},E(a,function(t,e,r){return z(t,0,n,r)},t,r)},R=function(t,e,r){var n=v[t],i=M(t,0,r,"hex");return i.create=function(i,a,o){if("number"!=typeof i||!isFinite(i)||i<1||Math.floor(i)!==i||i>268435455)throw new Error("block size is invalid");var s=new K(t,e,a,r,i).bytepad(["ParallelHash",o],n);return s.encode(i,!1),s},i.update=function(t,e,r,n){return i.create(e,r,n).update(t)},E(i,function(t,e,n){return M(t,0,r,n)},t,e)},J=[{name:"keccak",padding:[1,256,65536,16777216],bits:y,createMethod:O},{name:"sha3",padding:[6,1536,393216,100663296],bits:y,createMethod:O},{name:"shake",padding:c,bits:k,createMethod:function(t,e){var r=m(t,e,"hex");return r.create=function(r){return new W(t,e,r)},r.update=function(t,e){return r.create(e).update(t)},E(r,m,t,e)}},{name:"cshake",padding:p,bits:k,createMethod:function(t,e){var r=v[t],n=C(t,0,"hex");return n.create=function(n,i,a){return x(i)&&x(a)?j["shake"+t].create(n):new W(t,e,n).bytepad([i,a],r)},n.update=function(t,e,r,i){return n.create(e,r,i).update(t)},E(n,C,t,e)}},{name:"kmac",padding:p,bits:k,createMethod:function(t,e){return N(t,e,!1)}},{name:"kmacxof",padding:p,bits:k,createMethod:function(t,e){return N(t,e,!0)}},{name:"tuplehash",padding:p,bits:k,createMethod:function(t,e){return I(t,e,!1)}},{name:"tuplehashxof",padding:p,bits:k,createMethod:function(t,e){return I(t,e,!0)}},{name:"parallelhash",padding:p,bits:k,createMethod:function(t,e){return R(t,e,!1)}},{name:"parallelhashxof",padding:p,bits:k,createMethod:function(t,e){return R(t,e,!0)}}],j={},H=[],F=0;F<J.length;++F)for(var U=J[F],D=U.bits,L=0;L<D.length;++L){var T=U.name+"_"+D[L];if(H.push(T),j[T]=U.createMethod(D[L],U.padding),"sha3"!==U.name){var V=U.name+D[L];H.push(V),j[V]=j[T]}}function W(t,e,r){this.blocks=[],this.s=[],this.padding=e,this.outputBits=r,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(t<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}function P(t,e,r,n){W.call(this,t,e,r),this.xof=n}function Y(t,e,r,n){P.call(this,t,e,r,n),this.inputActive=!1,this.inputBytesRemaining=0}function K(t,e,r,n,i){P.call(this,t,e,r,n),this.bits=t,this.blockSize=i,this.inner=null,this.innerBytes=0,this.blockNumber=0}W.prototype.update=function(t){if(this.finalized)throw new Error(n);var e=w(t);t=e[0];for(var r,i,a=e[1],o=this.blocks,s=this.byteCount,u=t.length,h=this.blockCount,f=0,c=this.s;f<u;){if(this.reset)for(this.reset=!1,o[0]=this.block,r=1;r<h+1;++r)o[r]=0;if(a)for(r=this.start;f<u&&r<s;++f)(i=t.charCodeAt(f))<128?o[r>>2]|=i<<l[3&r++]:i<2048?(o[r>>2]|=(192|i>>6)<<l[3&r++],o[r>>2]|=(128|63&i)<<l[3&r++]):i<55296||i>=57344?(o[r>>2]|=(224|i>>12)<<l[3&r++],o[r>>2]|=(128|i>>6&63)<<l[3&r++],o[r>>2]|=(128|63&i)<<l[3&r++]):(i=65536+((1023&i)<<10|1023&t.charCodeAt(++f)),o[r>>2]|=(240|i>>18)<<l[3&r++],o[r>>2]|=(128|i>>12&63)<<l[3&r++],o[r>>2]|=(128|i>>6&63)<<l[3&r++],o[r>>2]|=(128|63&i)<<l[3&r++]);else for(r=this.start;f<u&&r<s;++f)o[r>>2]|=t[f]<<l[3&r++];if(this.lastByteIndex=r,r>=s){for(this.start=r-s,this.block=o[h],r=0;r<h;++r)c[r]^=o[r];q(c),this.reset=!0}else this.start=r}return this},W.prototype.encode=function(t,e){var r=255&t,n=1,i=[r];for(r=255&(t>>=8);r>0;)i.unshift(r),r=255&(t>>=8),++n;return e?i.push(n):i.unshift(n),W.prototype.update.call(this,i),i.length},W.prototype.encodeString=function(t){var e=w(t);t=e[0];var r=e[1],n=0,i=t.length;if(r)for(var a=0;a<t.length;++a){var o=t.charCodeAt(a);o<128?n+=1:o<2048?n+=2:o<55296||o>=57344?n+=3:(o=65536+((1023&o)<<10|1023&t.charCodeAt(++a)),n+=4)}else n=i;return n+=this.encode(8*n),W.prototype.update.call(this,t),n},W.prototype.bytepad=function(t,e){for(var r=this.encode(e),n=0;n<t.length;++n)r+=this.encodeString(t[n]);var i=(e-r%e)%e,a=[];return a.length=i,W.prototype.update.call(this,a),this},W.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,e=this.lastByteIndex,r=this.blockCount,n=this.s;if(t[e>>2]|=this.padding[3&e],this.lastByteIndex===this.byteCount)for(t[0]=t[r],e=1;e<r+1;++e)t[e]=0;for(t[r-1]|=2147483648,e=0;e<r;++e)n[e]^=t[e];q(n)}},W.prototype.toString=W.prototype.hex=function(){this.finalize();for(var t,e=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,a=0,o=0,s="";o<n;){for(a=0;a<e&&o<n;++a,++o)t=r[a],s+=f[t>>4&15]+f[15&t]+f[t>>12&15]+f[t>>8&15]+f[t>>20&15]+f[t>>16&15]+f[t>>28&15]+f[t>>24&15];o%e===0&&(r=B(r),q(r),a=0)}return i&&(t=r[a],s+=f[t>>4&15]+f[15&t],i>1&&(s+=f[t>>12&15]+f[t>>8&15]),i>2&&(s+=f[t>>20&15]+f[t>>16&15])),s},W.prototype.arrayBuffer=function(){this.finalize();var t,e=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,a=0,o=0,s=this.outputBits>>3;t=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(s);for(var u=new Uint32Array(t);o<n;){for(a=0;a<e&&o<n;++a,++o)u[o]=r[a];o%e===0&&(r=B(r),q(r))}return i&&(u[o]=r[a],t=t.slice(0,s)),t},W.prototype.buffer=W.prototype.arrayBuffer,W.prototype.digest=W.prototype.array=function(){this.finalize();for(var t,e,r=this.blockCount,n=this.s,i=this.outputBlocks,a=this.extraBytes,o=0,s=0,u=[];s<i;){for(o=0;o<r&&s<i;++o,++s)t=s<<2,e=n[o],u[t]=255&e,u[t+1]=e>>8&255,u[t+2]=e>>16&255,u[t+3]=e>>24&255;s%r===0&&(n=B(n),q(n))}return a&&(t=s<<2,e=n[o],u[t]=255&e,a>1&&(u[t+1]=e>>8&255),a>2&&(u[t+2]=e>>16&255)),u},P.prototype=new W,P.prototype.finalize=function(){return this.finalized||this.encode(this.xof?0:this.outputBits,!0),W.prototype.finalize.call(this)},Y.prototype=new P,Y.prototype.getMessageByteLength=function(t){var e=w(t);if(t=e[0],!e[1])return t.length;for(var r=0,n=0;n<t.length;++n){var i=t.charCodeAt(n);i<128?r+=1:i<2048?r+=2:i<55296||i>=57344?r+=3:(++n,r+=4)}return r},Y.prototype.beginInput=function(t){if(this.inputActive)throw new Error(i);if("number"!=typeof t||!isFinite(t)||t<0||Math.floor(t)!==t||t>268435455)throw new Error("tuple input byte length is invalid");return this.encode(8*t,!1),0!==t&&(this.inputActive=!0,this.inputBytesRemaining=t),this},Y.prototype._updateChunk=function(t,e){return P.prototype.update.call(this,t),this.inputBytesRemaining-=e,0===this.inputBytesRemaining&&(this.inputActive=!1),this},Y.prototype.updateChunk=function(t){if(!this.inputActive)throw new Error("no active tuple input");var e=this.getMessageByteLength(t);if(e>this.inputBytesRemaining)throw new Error("tuple input exceeds declared length");return this._updateChunk(t,e)},Y.prototype.update=function(t){var e=this.getMessageByteLength(t);return this.beginInput(e),this._updateChunk(t,e)},Y.prototype.finalize=function(){if(this.inputActive)throw new Error(i);return P.prototype.finalize.call(this)},K.prototype=new P,K.prototype._finishInner=function(){P.prototype.update.call(this,this.inner.array()),this.inner=null,this.innerBytes=0,++this.blockNumber},K.prototype._updateBytes=function(t){var e=t.length;if(e)for(var r=t.subarray||t.slice,n=this.blockSize,i=0;i<e;){this.inner||(this.inner=new W(this.bits,c,this.bits<<1));var a=n-this.innerBytes;e-i<a&&(a=e-i),this.inner.update(r.call(t,i,i+a)),this.innerBytes+=a,i+=a,this.innerBytes===n&&this._finishInner()}},K.prototype.update=function(t){if(this.finalized)throw new Error(n);var e=w(t);if(t=e[0],e[1]){var r,i,a=[],o=t.length,s=0;for(i=0;i<o;++i)(r=t.charCodeAt(i))<128?a[s++]=r:r<2048?(a[s++]=192|r>>>6,a[s++]=128|63&r):r<55296||r>=57344?(a[s++]=224|r>>>12,a[s++]=128|r>>>6&63,a[s++]=128|63&r):(r=65536+((1023&r)<<10|1023&t.charCodeAt(++i)),a[s++]=240|r>>>18,a[s++]=128|r>>>12&63,a[s++]=128|r>>>6&63,a[s++]=128|63&r);t=a}return this._updateBytes(t),this},K.prototype.finalize=function(){return this.finalized||(this.inner&&this._finishInner(),this.encode(this.blockNumber,!0)),P.prototype.finalize.call(this)};var q=function(t){var e,r,n,i,a,o,s,u,h,f,c,p,l,y,k,b,v,_,g,w,x,B,A,m,C,S,z,M,E,O,N,I,R,J,j,H,F,U,D,L,T,V,W,P,Y,K,q,G,Q,X,Z,$,tt,et,rt,nt,it,at,ot,st,ut,ht,ft;for(n=0;n<48;n+=2)i=t[0]^t[10]^t[20]^t[30]^t[40],a=t[1]^t[11]^t[21]^t[31]^t[41],o=t[2]^t[12]^t[22]^t[32]^t[42],s=t[3]^t[13]^t[23]^t[33]^t[43],u=t[4]^t[14]^t[24]^t[34]^t[44],h=t[5]^t[15]^t[25]^t[35]^t[45],f=t[6]^t[16]^t[26]^t[36]^t[46],c=t[7]^t[17]^t[27]^t[37]^t[47],e=(p=t[8]^t[18]^t[28]^t[38]^t[48])^(o<<1|s>>>31),r=(l=t[9]^t[19]^t[29]^t[39]^t[49])^(s<<1|o>>>31),t[0]^=e,t[1]^=r,t[10]^=e,t[11]^=r,t[20]^=e,t[21]^=r,t[30]^=e,t[31]^=r,t[40]^=e,t[41]^=r,e=i^(u<<1|h>>>31),r=a^(h<<1|u>>>31),t[2]^=e,t[3]^=r,t[12]^=e,t[13]^=r,t[22]^=e,t[23]^=r,t[32]^=e,t[33]^=r,t[42]^=e,t[43]^=r,e=o^(f<<1|c>>>31),r=s^(c<<1|f>>>31),t[4]^=e,t[5]^=r,t[14]^=e,t[15]^=r,t[24]^=e,t[25]^=r,t[34]^=e,t[35]^=r,t[44]^=e,t[45]^=r,e=u^(p<<1|l>>>31),r=h^(l<<1|p>>>31),t[6]^=e,t[7]^=r,t[16]^=e,t[17]^=r,t[26]^=e,t[27]^=r,t[36]^=e,t[37]^=r,t[46]^=e,t[47]^=r,e=f^(i<<1|a>>>31),r=c^(a<<1|i>>>31),t[8]^=e,t[9]^=r,t[18]^=e,t[19]^=r,t[28]^=e,t[29]^=r,t[38]^=e,t[39]^=r,t[48]^=e,t[49]^=r,y=t[0],k=t[1],K=t[11]<<4|t[10]>>>28,q=t[10]<<4|t[11]>>>28,M=t[20]<<3|t[21]>>>29,E=t[21]<<3|t[20]>>>29,st=t[31]<<9|t[30]>>>23,ut=t[30]<<9|t[31]>>>23,V=t[40]<<18|t[41]>>>14,W=t[41]<<18|t[40]>>>14,J=t[2]<<1|t[3]>>>31,j=t[3]<<1|t[2]>>>31,b=t[13]<<12|t[12]>>>20,v=t[12]<<12|t[13]>>>20,G=t[22]<<10|t[23]>>>22,Q=t[23]<<10|t[22]>>>22,O=t[33]<<13|t[32]>>>19,N=t[32]<<13|t[33]>>>19,ht=t[42]<<2|t[43]>>>30,ft=t[43]<<2|t[42]>>>30,et=t[5]<<30|t[4]>>>2,rt=t[4]<<30|t[5]>>>2,H=t[14]<<6|t[15]>>>26,F=t[15]<<6|t[14]>>>26,_=t[25]<<11|t[24]>>>21,g=t[24]<<11|t[25]>>>21,X=t[34]<<15|t[35]>>>17,Z=t[35]<<15|t[34]>>>17,I=t[45]<<29|t[44]>>>3,R=t[44]<<29|t[45]>>>3,m=t[6]<<28|t[7]>>>4,C=t[7]<<28|t[6]>>>4,nt=t[17]<<23|t[16]>>>9,it=t[16]<<23|t[17]>>>9,U=t[26]<<25|t[27]>>>7,D=t[27]<<25|t[26]>>>7,w=t[36]<<21|t[37]>>>11,x=t[37]<<21|t[36]>>>11,$=t[47]<<24|t[46]>>>8,tt=t[46]<<24|t[47]>>>8,P=t[8]<<27|t[9]>>>5,Y=t[9]<<27|t[8]>>>5,S=t[18]<<20|t[19]>>>12,z=t[19]<<20|t[18]>>>12,at=t[29]<<7|t[28]>>>25,ot=t[28]<<7|t[29]>>>25,L=t[38]<<8|t[39]>>>24,T=t[39]<<8|t[38]>>>24,B=t[48]<<14|t[49]>>>18,A=t[49]<<14|t[48]>>>18,t[0]=y^~b&_,t[1]=k^~v&g,t[10]=m^~S&M,t[11]=C^~z&E,t[20]=J^~H&U,t[21]=j^~F&D,t[30]=P^~K&G,t[31]=Y^~q&Q,t[40]=et^~nt&at,t[41]=rt^~it&ot,t[2]=b^~_&w,t[3]=v^~g&x,t[12]=S^~M&O,t[13]=z^~E&N,t[22]=H^~U&L,t[23]=F^~D&T,t[32]=K^~G&X,t[33]=q^~Q&Z,t[42]=nt^~at&st,t[43]=it^~ot&ut,t[4]=_^~w&B,t[5]=g^~x&A,t[14]=M^~O&I,t[15]=E^~N&R,t[24]=U^~L&V,t[25]=D^~T&W,t[34]=G^~X&$,t[35]=Q^~Z&tt,t[44]=at^~st&ht,t[45]=ot^~ut&ft,t[6]=w^~B&y,t[7]=x^~A&k,t[16]=O^~I&m,t[17]=N^~R&C,t[26]=L^~V&J,t[27]=T^~W&j,t[36]=X^~$&P,t[37]=Z^~tt&Y,t[46]=st^~ht&et,t[47]=ut^~ft&rt,t[8]=B^~y&b,t[9]=A^~k&v,t[18]=I^~m&S,t[19]=R^~C&z,t[28]=V^~J&H,t[29]=W^~j&F,t[38]=$^~P&K,t[39]=tt^~Y&q,t[48]=ht^~et&nt,t[49]=ft^~rt&it,t[0]^=d[n],t[1]^=d[n+1]};if(u)r.exports=j;else for(F=0;F<H.length;++F)o[H[F]]=j[H[F]]}();var i=e(n.exports);const{sha3_224:a,sha3_256:o,sha3_384:s,sha3_512:u,keccak_224:h,keccak_256:f,keccak_384:c,keccak_512:p,keccak224:l,keccak256:d,keccak384:y,keccak512:k,shake_128:b,shake_256:v,shake128:_,shake256:g,cshake_128:w,cshake_256:x,cshake128:B,cshake256:A,kmac_128:m,kmac_256:C,kmac128:S,kmac256:z,kmacxof_128:M,kmacxof_256:E,kmacxof128:O,kmacxof256:N,tuplehash_128:I,tuplehash_256:R,tuplehash128:J,tuplehash256:j,tuplehashxof_128:H,tuplehashxof_256:F,tuplehashxof128:U,tuplehashxof256:D,parallelhash_128:L,parallelhash_256:T,parallelhash128:V,parallelhash256:W,parallelhashxof_128:P,parallelhashxof_256:Y,parallelhashxof128:K,parallelhashxof256:q}=i;export{B as cshake128,A as cshake256,w as cshake_128,x as cshake_256,i as default,l as keccak224,d as keccak256,y as keccak384,k as keccak512,h as keccak_224,f as keccak_256,c as keccak_384,p as keccak_512,S as kmac128,z as kmac256,m as kmac_128,C as kmac_256,O as kmacxof128,N as kmacxof256,M as kmacxof_128,E as kmacxof_256,V as parallelhash128,W as parallelhash256,L as parallelhash_128,T as parallelhash_256,K as parallelhashxof128,q as parallelhashxof256,P as parallelhashxof_128,Y as parallelhashxof_256,a as sha3_224,o as sha3_256,s as sha3_384,u as sha3_512,_ as shake128,g as shake256,b as shake_128,v as shake_256,J as tuplehash128,j as tuplehash256,I as tuplehash_128,R as tuplehash_256,U as tuplehashxof128,D as tuplehashxof256,H as tuplehashxof_128,F as tuplehashxof_256};
|
package/build/sha3.mjs
CHANGED
|
@@ -9,9 +9,9 @@ var sha3$1 = {exports: {}};
|
|
|
9
9
|
/**
|
|
10
10
|
* [js-sha3]{@link https://github.com/emn178/js-sha3}
|
|
11
11
|
*
|
|
12
|
-
* @version 0.
|
|
12
|
+
* @version 0.13.0
|
|
13
13
|
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
|
14
|
-
* @copyright Chen, Yi-Cyuan 2015-
|
|
14
|
+
* @copyright Chen, Yi-Cyuan 2015-2026
|
|
15
15
|
* @license MIT
|
|
16
16
|
*/
|
|
17
17
|
|
|
@@ -25,6 +25,7 @@ var sha3$1 = {exports: {}};
|
|
|
25
25
|
var TUPLE_INCOMPLETE_ERROR = 'tuple input is incomplete';
|
|
26
26
|
var TUPLE_LENGTH_ERROR = 'tuple input exceeds declared length';
|
|
27
27
|
var TUPLE_BYTE_LENGTH_ERROR = 'tuple input byte length is invalid';
|
|
28
|
+
var BLOCK_SIZE_ERROR = 'block size is invalid';
|
|
28
29
|
var WINDOW = typeof window === 'object';
|
|
29
30
|
var root = WINDOW ? window : {};
|
|
30
31
|
if (root.JS_SHA3_NO_WINDOW) {
|
|
@@ -119,9 +120,21 @@ var sha3$1 = {exports: {}};
|
|
|
119
120
|
};
|
|
120
121
|
};
|
|
121
122
|
|
|
122
|
-
var createKmacOutputMethod = function (bits, padding, outputType) {
|
|
123
|
+
var createKmacOutputMethod = function (bits, padding, xof, outputType) {
|
|
123
124
|
return function (key, message, outputBits, s) {
|
|
124
|
-
return methods['kmac' + bits].update(key, message, outputBits, s)[outputType]();
|
|
125
|
+
return methods[(xof ? 'kmacxof' : 'kmac') + bits].update(key, message, outputBits, s)[outputType]();
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
var createTupleHashOutputMethod = function (bits, padding, xof, outputType) {
|
|
130
|
+
return function (inputs, outputBits, s) {
|
|
131
|
+
return methods[(xof ? 'tuplehashxof' : 'tuplehash') + bits].update(inputs, outputBits, s)[outputType]();
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
var createParallelHashOutputMethod = function (bits, padding, xof, outputType) {
|
|
136
|
+
return function (message, blockSize, outputBits, s) {
|
|
137
|
+
return methods[(xof ? 'parallelhashxof' : 'parallelhash') + bits].update(message, blockSize, outputBits, s)[outputType]();
|
|
125
138
|
};
|
|
126
139
|
};
|
|
127
140
|
|
|
@@ -171,22 +184,18 @@ var sha3$1 = {exports: {}};
|
|
|
171
184
|
return createOutputMethods(method, createCshakeOutputMethod, bits, padding);
|
|
172
185
|
};
|
|
173
186
|
|
|
174
|
-
var createKmacMethod = function (bits, padding) {
|
|
187
|
+
var createKmacMethod = function (bits, padding, xof) {
|
|
175
188
|
var w = CSHAKE_BYTEPAD[bits];
|
|
176
|
-
var method = createKmacOutputMethod(bits, padding, 'hex');
|
|
189
|
+
var method = createKmacOutputMethod(bits, padding, xof, 'hex');
|
|
177
190
|
method.create = function (key, outputBits, s) {
|
|
178
|
-
return new Kmac(bits, padding, outputBits).bytepad(['KMAC', s], w).bytepad([key], w);
|
|
191
|
+
return new Kmac(bits, padding, outputBits, xof).bytepad(['KMAC', s], w).bytepad([key], w);
|
|
179
192
|
};
|
|
180
193
|
method.update = function (key, message, outputBits, s) {
|
|
181
194
|
return method.create(key, outputBits, s).update(message);
|
|
182
195
|
};
|
|
183
|
-
return createOutputMethods(method,
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
var createTupleHashOutputMethod = function (bits, padding, xof, outputType) {
|
|
187
|
-
return function (inputs, outputBits, s) {
|
|
188
|
-
return methods[(xof ? 'tuplehashxof' : 'tuplehash') + bits].update(inputs, outputBits, s)[outputType]();
|
|
189
|
-
};
|
|
196
|
+
return createOutputMethods(method, function (b, p, outputType) {
|
|
197
|
+
return createKmacOutputMethod(b, p, xof, outputType);
|
|
198
|
+
}, bits, padding);
|
|
190
199
|
};
|
|
191
200
|
|
|
192
201
|
var createTupleHashMethod = function (bits, padding, xof) {
|
|
@@ -210,17 +219,48 @@ var sha3$1 = {exports: {}};
|
|
|
210
219
|
}, bits, padding);
|
|
211
220
|
};
|
|
212
221
|
|
|
222
|
+
var createParallelHashMethod = function (bits, padding, xof) {
|
|
223
|
+
var w = CSHAKE_BYTEPAD[bits];
|
|
224
|
+
var method = createParallelHashOutputMethod(bits, padding, xof, 'hex');
|
|
225
|
+
method.create = function (blockSize, outputBits, s) {
|
|
226
|
+
if (typeof blockSize !== 'number' || !isFinite(blockSize) || blockSize < 1 ||
|
|
227
|
+
Math.floor(blockSize) !== blockSize || blockSize > 0x0fffffff) {
|
|
228
|
+
throw new Error(BLOCK_SIZE_ERROR);
|
|
229
|
+
}
|
|
230
|
+
var hash = new ParallelHash(bits, padding, outputBits, xof, blockSize).bytepad(['ParallelHash', s], w);
|
|
231
|
+
hash.encode(blockSize, false);
|
|
232
|
+
return hash;
|
|
233
|
+
};
|
|
234
|
+
method.update = function (message, blockSize, outputBits, s) {
|
|
235
|
+
return method.create(blockSize, outputBits, s).update(message);
|
|
236
|
+
};
|
|
237
|
+
return createOutputMethods(method, function (b, p, outputType) {
|
|
238
|
+
return createParallelHashOutputMethod(b, p, xof, outputType);
|
|
239
|
+
}, bits, padding);
|
|
240
|
+
};
|
|
241
|
+
|
|
213
242
|
var algorithms = [
|
|
214
243
|
{ name: 'keccak', padding: KECCAK_PADDING, bits: BITS, createMethod: createMethod },
|
|
215
244
|
{ name: 'sha3', padding: PADDING, bits: BITS, createMethod: createMethod },
|
|
216
245
|
{ name: 'shake', padding: SHAKE_PADDING, bits: SHAKE_BITS, createMethod: createShakeMethod },
|
|
217
246
|
{ name: 'cshake', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createCshakeMethod },
|
|
218
|
-
{ name: 'kmac', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod:
|
|
247
|
+
{ name: 'kmac', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: function (bits, padding) {
|
|
248
|
+
return createKmacMethod(bits, padding, false);
|
|
249
|
+
}},
|
|
250
|
+
{ name: 'kmacxof', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: function (bits, padding) {
|
|
251
|
+
return createKmacMethod(bits, padding, true);
|
|
252
|
+
}},
|
|
219
253
|
{ name: 'tuplehash', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: function (bits, padding) {
|
|
220
254
|
return createTupleHashMethod(bits, padding, false);
|
|
221
255
|
}},
|
|
222
256
|
{ name: 'tuplehashxof', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: function (bits, padding) {
|
|
223
257
|
return createTupleHashMethod(bits, padding, true);
|
|
258
|
+
}},
|
|
259
|
+
{ name: 'parallelhash', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: function (bits, padding) {
|
|
260
|
+
return createParallelHashMethod(bits, padding, false);
|
|
261
|
+
}},
|
|
262
|
+
{ name: 'parallelhashxof', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: function (bits, padding) {
|
|
263
|
+
return createParallelHashMethod(bits, padding, true);
|
|
224
264
|
}}
|
|
225
265
|
];
|
|
226
266
|
|
|
@@ -496,27 +536,27 @@ var sha3$1 = {exports: {}};
|
|
|
496
536
|
return array;
|
|
497
537
|
};
|
|
498
538
|
|
|
499
|
-
function Kmac(bits, padding, outputBits) {
|
|
539
|
+
function Kmac(bits, padding, outputBits, xof) {
|
|
500
540
|
Keccak.call(this, bits, padding, outputBits);
|
|
541
|
+
this.xof = xof;
|
|
501
542
|
}
|
|
502
543
|
|
|
503
544
|
Kmac.prototype = new Keccak();
|
|
504
545
|
|
|
505
546
|
Kmac.prototype.finalize = function () {
|
|
506
547
|
if (!this.finalized) {
|
|
507
|
-
this.encode(this.outputBits, true);
|
|
548
|
+
this.encode(this.xof ? 0 : this.outputBits, true);
|
|
508
549
|
}
|
|
509
550
|
return Keccak.prototype.finalize.call(this);
|
|
510
551
|
};
|
|
511
552
|
|
|
512
553
|
function TupleHash(bits, padding, outputBits, xof) {
|
|
513
|
-
|
|
514
|
-
this.xof = !!xof;
|
|
554
|
+
Kmac.call(this, bits, padding, outputBits, xof);
|
|
515
555
|
this.inputActive = false;
|
|
516
556
|
this.inputBytesRemaining = 0;
|
|
517
557
|
}
|
|
518
558
|
|
|
519
|
-
TupleHash.prototype = new
|
|
559
|
+
TupleHash.prototype = new Kmac();
|
|
520
560
|
|
|
521
561
|
TupleHash.prototype.getMessageByteLength = function (message) {
|
|
522
562
|
var result = formatMessage(message);
|
|
@@ -542,9 +582,6 @@ var sha3$1 = {exports: {}};
|
|
|
542
582
|
};
|
|
543
583
|
|
|
544
584
|
TupleHash.prototype.beginInput = function (byteLength) {
|
|
545
|
-
if (this.finalized) {
|
|
546
|
-
throw new Error(FINALIZE_ERROR);
|
|
547
|
-
}
|
|
548
585
|
if (this.inputActive) {
|
|
549
586
|
throw new Error(TUPLE_INCOMPLETE_ERROR);
|
|
550
587
|
}
|
|
@@ -553,20 +590,23 @@ var sha3$1 = {exports: {}};
|
|
|
553
590
|
throw new Error(TUPLE_BYTE_LENGTH_ERROR);
|
|
554
591
|
}
|
|
555
592
|
this.encode(byteLength * 8, false);
|
|
556
|
-
if (byteLength
|
|
557
|
-
this.inputActive = false;
|
|
558
|
-
this.inputBytesRemaining = 0;
|
|
559
|
-
} else {
|
|
593
|
+
if (byteLength !== 0) {
|
|
560
594
|
this.inputActive = true;
|
|
561
595
|
this.inputBytesRemaining = byteLength;
|
|
562
596
|
}
|
|
563
597
|
return this;
|
|
564
598
|
};
|
|
565
599
|
|
|
566
|
-
TupleHash.prototype.
|
|
567
|
-
|
|
568
|
-
|
|
600
|
+
TupleHash.prototype._updateChunk = function (message, byteLength) {
|
|
601
|
+
Kmac.prototype.update.call(this, message);
|
|
602
|
+
this.inputBytesRemaining -= byteLength;
|
|
603
|
+
if (this.inputBytesRemaining === 0) {
|
|
604
|
+
this.inputActive = false;
|
|
569
605
|
}
|
|
606
|
+
return this;
|
|
607
|
+
};
|
|
608
|
+
|
|
609
|
+
TupleHash.prototype.updateChunk = function (message) {
|
|
570
610
|
if (!this.inputActive) {
|
|
571
611
|
throw new Error(TUPLE_ACTIVE_ERROR);
|
|
572
612
|
}
|
|
@@ -574,37 +614,107 @@ var sha3$1 = {exports: {}};
|
|
|
574
614
|
if (byteLength > this.inputBytesRemaining) {
|
|
575
615
|
throw new Error(TUPLE_LENGTH_ERROR);
|
|
576
616
|
}
|
|
577
|
-
|
|
578
|
-
this.inputBytesRemaining -= byteLength;
|
|
579
|
-
if (this.inputBytesRemaining === 0) {
|
|
580
|
-
this.inputActive = false;
|
|
581
|
-
}
|
|
582
|
-
return this;
|
|
617
|
+
return this._updateChunk(message, byteLength);
|
|
583
618
|
};
|
|
584
619
|
|
|
585
620
|
TupleHash.prototype.update = function (message) {
|
|
586
|
-
if (this.finalized) {
|
|
587
|
-
throw new Error(FINALIZE_ERROR);
|
|
588
|
-
}
|
|
589
|
-
if (this.inputActive) {
|
|
590
|
-
throw new Error(TUPLE_INCOMPLETE_ERROR);
|
|
591
|
-
}
|
|
592
621
|
var byteLength = this.getMessageByteLength(message);
|
|
593
622
|
this.beginInput(byteLength);
|
|
594
|
-
|
|
595
|
-
return this;
|
|
596
|
-
}
|
|
597
|
-
return this.updateChunk(message);
|
|
623
|
+
return this._updateChunk(message, byteLength);
|
|
598
624
|
};
|
|
599
625
|
|
|
600
626
|
TupleHash.prototype.finalize = function () {
|
|
601
627
|
if (this.inputActive) {
|
|
602
628
|
throw new Error(TUPLE_INCOMPLETE_ERROR);
|
|
603
629
|
}
|
|
630
|
+
return Kmac.prototype.finalize.call(this);
|
|
631
|
+
};
|
|
632
|
+
|
|
633
|
+
function ParallelHash(bits, padding, outputBits, xof, blockSize) {
|
|
634
|
+
Kmac.call(this, bits, padding, outputBits, xof);
|
|
635
|
+
this.bits = bits;
|
|
636
|
+
this.blockSize = blockSize;
|
|
637
|
+
this.inner = null;
|
|
638
|
+
this.innerBytes = 0;
|
|
639
|
+
this.blockNumber = 0;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
ParallelHash.prototype = new Kmac();
|
|
643
|
+
|
|
644
|
+
ParallelHash.prototype._finishInner = function () {
|
|
645
|
+
Kmac.prototype.update.call(this, this.inner.array());
|
|
646
|
+
this.inner = null;
|
|
647
|
+
this.innerBytes = 0;
|
|
648
|
+
++this.blockNumber;
|
|
649
|
+
};
|
|
650
|
+
|
|
651
|
+
ParallelHash.prototype._updateBytes = function (message) {
|
|
652
|
+
var length = message.length;
|
|
653
|
+
if (!length) {
|
|
654
|
+
return;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
var slice = message.subarray || message.slice;
|
|
658
|
+
var blockSize = this.blockSize;
|
|
659
|
+
var index = 0;
|
|
660
|
+
while (index < length) {
|
|
661
|
+
if (!this.inner) {
|
|
662
|
+
this.inner = new Keccak(this.bits, SHAKE_PADDING, this.bits << 1);
|
|
663
|
+
}
|
|
664
|
+
var take = blockSize - this.innerBytes;
|
|
665
|
+
if (length - index < take) {
|
|
666
|
+
take = length - index;
|
|
667
|
+
}
|
|
668
|
+
this.inner.update(slice.call(message, index, index + take));
|
|
669
|
+
this.innerBytes += take;
|
|
670
|
+
index += take;
|
|
671
|
+
if (this.innerBytes === blockSize) {
|
|
672
|
+
this._finishInner();
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
};
|
|
676
|
+
|
|
677
|
+
ParallelHash.prototype.update = function (message) {
|
|
678
|
+
if (this.finalized) {
|
|
679
|
+
throw new Error(FINALIZE_ERROR);
|
|
680
|
+
}
|
|
681
|
+
var result = formatMessage(message);
|
|
682
|
+
message = result[0];
|
|
683
|
+
if (result[1]) {
|
|
684
|
+
var bytes = [], length = message.length, index = 0, code, i;
|
|
685
|
+
for (i = 0; i < length; ++i) {
|
|
686
|
+
code = message.charCodeAt(i);
|
|
687
|
+
if (code < 0x80) {
|
|
688
|
+
bytes[index++] = code;
|
|
689
|
+
} else if (code < 0x800) {
|
|
690
|
+
bytes[index++] = (0xc0 | (code >>> 6));
|
|
691
|
+
bytes[index++] = (0x80 | (code & 0x3f));
|
|
692
|
+
} else if (code < 0xd800 || code >= 0xe000) {
|
|
693
|
+
bytes[index++] = (0xe0 | (code >>> 12));
|
|
694
|
+
bytes[index++] = (0x80 | ((code >>> 6) & 0x3f));
|
|
695
|
+
bytes[index++] = (0x80 | (code & 0x3f));
|
|
696
|
+
} else {
|
|
697
|
+
code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++i) & 0x3ff));
|
|
698
|
+
bytes[index++] = (0xf0 | (code >>> 18));
|
|
699
|
+
bytes[index++] = (0x80 | ((code >>> 12) & 0x3f));
|
|
700
|
+
bytes[index++] = (0x80 | ((code >>> 6) & 0x3f));
|
|
701
|
+
bytes[index++] = (0x80 | (code & 0x3f));
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
message = bytes;
|
|
705
|
+
}
|
|
706
|
+
this._updateBytes(message);
|
|
707
|
+
return this;
|
|
708
|
+
};
|
|
709
|
+
|
|
710
|
+
ParallelHash.prototype.finalize = function () {
|
|
604
711
|
if (!this.finalized) {
|
|
605
|
-
|
|
712
|
+
if (this.inner) {
|
|
713
|
+
this._finishInner();
|
|
714
|
+
}
|
|
715
|
+
this.encode(this.blockNumber, true);
|
|
606
716
|
}
|
|
607
|
-
return
|
|
717
|
+
return Kmac.prototype.finalize.call(this);
|
|
608
718
|
};
|
|
609
719
|
|
|
610
720
|
var f = function (s) {
|
|
@@ -834,6 +944,10 @@ const {
|
|
|
834
944
|
kmac_256,
|
|
835
945
|
kmac128,
|
|
836
946
|
kmac256,
|
|
947
|
+
kmacxof_128,
|
|
948
|
+
kmacxof_256,
|
|
949
|
+
kmacxof128,
|
|
950
|
+
kmacxof256,
|
|
837
951
|
|
|
838
952
|
tuplehash_128,
|
|
839
953
|
tuplehash_256,
|
|
@@ -842,7 +956,16 @@ const {
|
|
|
842
956
|
tuplehashxof_128,
|
|
843
957
|
tuplehashxof_256,
|
|
844
958
|
tuplehashxof128,
|
|
845
|
-
tuplehashxof256
|
|
959
|
+
tuplehashxof256,
|
|
960
|
+
|
|
961
|
+
parallelhash_128,
|
|
962
|
+
parallelhash_256,
|
|
963
|
+
parallelhash128,
|
|
964
|
+
parallelhash256,
|
|
965
|
+
parallelhashxof_128,
|
|
966
|
+
parallelhashxof_256,
|
|
967
|
+
parallelhashxof128,
|
|
968
|
+
parallelhashxof256
|
|
846
969
|
} = sha3;
|
|
847
970
|
|
|
848
|
-
export { cshake128, cshake256, cshake_128, cshake_256, sha3 as default, keccak224, keccak256, keccak384, keccak512, keccak_224, keccak_256, keccak_384, keccak_512, kmac128, kmac256, kmac_128, kmac_256, sha3_224, sha3_256, sha3_384, sha3_512, shake128, shake256, shake_128, shake_256, tuplehash128, tuplehash256, tuplehash_128, tuplehash_256, tuplehashxof128, tuplehashxof256, tuplehashxof_128, tuplehashxof_256 };
|
|
971
|
+
export { cshake128, cshake256, cshake_128, cshake_256, sha3 as default, keccak224, keccak256, keccak384, keccak512, keccak_224, keccak_256, keccak_384, keccak_512, kmac128, kmac256, kmac_128, kmac_256, kmacxof128, kmacxof256, kmacxof_128, kmacxof_256, parallelhash128, parallelhash256, parallelhash_128, parallelhash_256, parallelhashxof128, parallelhashxof256, parallelhashxof_128, parallelhashxof_256, sha3_224, sha3_256, sha3_384, sha3_512, shake128, shake256, shake_128, shake_256, tuplehash128, tuplehash256, tuplehash_128, tuplehash_256, tuplehashxof128, tuplehashxof256, tuplehashxof_128, tuplehashxof_256 };
|
package/index.d.ts
CHANGED
|
@@ -405,6 +405,10 @@ export var kmac_128: KmacHash;
|
|
|
405
405
|
export var kmac_256: KmacHash;
|
|
406
406
|
export var kmac128: KmacHash;
|
|
407
407
|
export var kmac256: KmacHash;
|
|
408
|
+
export var kmacxof_128: KmacHash;
|
|
409
|
+
export var kmacxof_256: KmacHash;
|
|
410
|
+
export var kmacxof128: KmacHash;
|
|
411
|
+
export var kmacxof256: KmacHash;
|
|
408
412
|
export var tuplehash_128: TupleHashMethod;
|
|
409
413
|
export var tuplehash_256: TupleHashMethod;
|
|
410
414
|
export var tuplehash128: TupleHashMethod;
|
|
@@ -413,3 +417,92 @@ export var tuplehashxof_128: TupleHashMethod;
|
|
|
413
417
|
export var tuplehashxof_256: TupleHashMethod;
|
|
414
418
|
export var tuplehashxof128: TupleHashMethod;
|
|
415
419
|
export var tuplehashxof256: TupleHashMethod;
|
|
420
|
+
|
|
421
|
+
interface ParallelHash extends Hasher {
|
|
422
|
+
/**
|
|
423
|
+
* Absorb message bytes into ParallelHash blocks.
|
|
424
|
+
*
|
|
425
|
+
* @param message The next message chunk.
|
|
426
|
+
*/
|
|
427
|
+
update(message: Message): ParallelHash;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
interface ParallelHashMethod {
|
|
431
|
+
/**
|
|
432
|
+
* Hash and return hex string.
|
|
433
|
+
*
|
|
434
|
+
* @param message The message you want to hash.
|
|
435
|
+
* @param blockSize The ParallelHash block size in bytes.
|
|
436
|
+
* @param outputBits The length of output.
|
|
437
|
+
* @param customization The customization string.
|
|
438
|
+
*/
|
|
439
|
+
(message: Message, blockSize: number, outputBits: number, customization: Message): string;
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Hash and return hex string.
|
|
443
|
+
*
|
|
444
|
+
* @param message The message you want to hash.
|
|
445
|
+
* @param blockSize The ParallelHash block size in bytes.
|
|
446
|
+
* @param outputBits The length of output.
|
|
447
|
+
* @param customization The customization string.
|
|
448
|
+
*/
|
|
449
|
+
hex(message: Message, blockSize: number, outputBits: number, customization: Message): string;
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Hash and return ArrayBuffer.
|
|
453
|
+
*
|
|
454
|
+
* @param message The message you want to hash.
|
|
455
|
+
* @param blockSize The ParallelHash block size in bytes.
|
|
456
|
+
* @param outputBits The length of output.
|
|
457
|
+
* @param customization The customization string.
|
|
458
|
+
*/
|
|
459
|
+
arrayBuffer(message: Message, blockSize: number, outputBits: number, customization: Message): ArrayBuffer;
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Hash and return integer array.
|
|
463
|
+
*
|
|
464
|
+
* @param message The message you want to hash.
|
|
465
|
+
* @param blockSize The ParallelHash block size in bytes.
|
|
466
|
+
* @param outputBits The length of output.
|
|
467
|
+
* @param customization The customization string.
|
|
468
|
+
*/
|
|
469
|
+
digest(message: Message, blockSize: number, outputBits: number, customization: Message): number[];
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Hash and return integer array.
|
|
473
|
+
*
|
|
474
|
+
* @param message The message you want to hash.
|
|
475
|
+
* @param blockSize The ParallelHash block size in bytes.
|
|
476
|
+
* @param outputBits The length of output.
|
|
477
|
+
* @param customization The customization string.
|
|
478
|
+
*/
|
|
479
|
+
array(message: Message, blockSize: number, outputBits: number, customization: Message): number[];
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* Create a ParallelHash object.
|
|
483
|
+
*
|
|
484
|
+
* @param blockSize The ParallelHash block size in bytes.
|
|
485
|
+
* @param outputBits The length of output.
|
|
486
|
+
* @param customization The customization string.
|
|
487
|
+
*/
|
|
488
|
+
create(blockSize: number, outputBits: number, customization: Message): ParallelHash;
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* Create a ParallelHash object and hash message.
|
|
492
|
+
*
|
|
493
|
+
* @param message The message you want to hash.
|
|
494
|
+
* @param blockSize The ParallelHash block size in bytes.
|
|
495
|
+
* @param outputBits The length of output.
|
|
496
|
+
* @param customization The customization string.
|
|
497
|
+
*/
|
|
498
|
+
update(message: Message, blockSize: number, outputBits: number, customization: Message): ParallelHash;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
export var parallelhash_128: ParallelHashMethod;
|
|
502
|
+
export var parallelhash_256: ParallelHashMethod;
|
|
503
|
+
export var parallelhash128: ParallelHashMethod;
|
|
504
|
+
export var parallelhash256: ParallelHashMethod;
|
|
505
|
+
export var parallelhashxof_128: ParallelHashMethod;
|
|
506
|
+
export var parallelhashxof_256: ParallelHashMethod;
|
|
507
|
+
export var parallelhashxof128: ParallelHashMethod;
|
|
508
|
+
export var parallelhashxof256: ParallelHashMethod;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "js-sha3",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "A simple SHA-3 / Keccak / SHAKE / cSHAKE / KMAC / TupleHash hash function for JavaScript supports UTF-8 encoding.",
|
|
3
|
+
"version": "0.13.0",
|
|
4
|
+
"description": "A simple SHA-3 / Keccak / SHAKE / cSHAKE / KMAC / TupleHash / ParallelHash hash function for JavaScript supports UTF-8 encoding.",
|
|
5
5
|
"main": "src/sha3.js",
|
|
6
6
|
"module": "build/sha3.mjs",
|
|
7
7
|
"exports": {
|
|
@@ -22,17 +22,20 @@
|
|
|
22
22
|
"@rollup/plugin-commonjs": "^28.0.5",
|
|
23
23
|
"@rollup/plugin-terser": "^1.0.0",
|
|
24
24
|
"expect.js": "~0.3.1",
|
|
25
|
-
"mocha": "^11.
|
|
26
|
-
"nyc": "^
|
|
25
|
+
"mocha": "^11.8.0",
|
|
26
|
+
"nyc": "^18.0.0",
|
|
27
27
|
"rollup": "^4.43.0",
|
|
28
28
|
"tiny-worker": "^2.3.0",
|
|
29
29
|
"uglify-js": "^3.1.9"
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|
|
32
|
-
"test": "
|
|
32
|
+
"test": "npm run build && npm run test:coverage",
|
|
33
|
+
"test:runtime": "mocha tests/node-test.js",
|
|
34
|
+
"test:coverage": "nyc --reporter=text --reporter=html --reporter=lcov mocha tests/node-test.js",
|
|
33
35
|
"report": "nyc --reporter=html --reporter=text mocha tests/node-test.js",
|
|
34
36
|
"coveralls": "nyc report --reporter=text-lcov | coveralls",
|
|
35
|
-
"build": "rollup -c && uglifyjs src/sha3.js -c -m --comments --output build/sha3.min.js"
|
|
37
|
+
"build": "rollup -c && uglifyjs src/sha3.js -c -m --comments --output build/sha3.min.js",
|
|
38
|
+
"prepack": "npm run build"
|
|
36
39
|
},
|
|
37
40
|
"repository": {
|
|
38
41
|
"type": "git",
|
|
@@ -45,6 +48,7 @@
|
|
|
45
48
|
"cshake",
|
|
46
49
|
"kmac",
|
|
47
50
|
"tuplehash",
|
|
51
|
+
"parallelhash",
|
|
48
52
|
"hash",
|
|
49
53
|
"encryption",
|
|
50
54
|
"cryptography",
|
|
@@ -60,5 +64,9 @@
|
|
|
60
64
|
"exclude": [
|
|
61
65
|
"tests"
|
|
62
66
|
]
|
|
67
|
+
},
|
|
68
|
+
"overrides": {
|
|
69
|
+
"diff": "^8.0.3",
|
|
70
|
+
"serialize-javascript": "^7.0.7"
|
|
63
71
|
}
|
|
64
72
|
}
|
package/src/sha3.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* [js-sha3]{@link https://github.com/emn178/js-sha3}
|
|
3
3
|
*
|
|
4
|
-
* @version 0.
|
|
4
|
+
* @version 0.13.0
|
|
5
5
|
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
|
6
|
-
* @copyright Chen, Yi-Cyuan 2015-
|
|
6
|
+
* @copyright Chen, Yi-Cyuan 2015-2026
|
|
7
7
|
* @license MIT
|
|
8
8
|
*/
|
|
9
9
|
/*jslint bitwise: true */
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
var TUPLE_INCOMPLETE_ERROR = 'tuple input is incomplete';
|
|
17
17
|
var TUPLE_LENGTH_ERROR = 'tuple input exceeds declared length';
|
|
18
18
|
var TUPLE_BYTE_LENGTH_ERROR = 'tuple input byte length is invalid';
|
|
19
|
+
var BLOCK_SIZE_ERROR = 'block size is invalid';
|
|
19
20
|
var WINDOW = typeof window === 'object';
|
|
20
21
|
var root = WINDOW ? window : {};
|
|
21
22
|
if (root.JS_SHA3_NO_WINDOW) {
|
|
@@ -111,9 +112,21 @@
|
|
|
111
112
|
};
|
|
112
113
|
};
|
|
113
114
|
|
|
114
|
-
var createKmacOutputMethod = function (bits, padding, outputType) {
|
|
115
|
+
var createKmacOutputMethod = function (bits, padding, xof, outputType) {
|
|
115
116
|
return function (key, message, outputBits, s) {
|
|
116
|
-
return methods['kmac' + bits].update(key, message, outputBits, s)[outputType]();
|
|
117
|
+
return methods[(xof ? 'kmacxof' : 'kmac') + bits].update(key, message, outputBits, s)[outputType]();
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
var createTupleHashOutputMethod = function (bits, padding, xof, outputType) {
|
|
122
|
+
return function (inputs, outputBits, s) {
|
|
123
|
+
return methods[(xof ? 'tuplehashxof' : 'tuplehash') + bits].update(inputs, outputBits, s)[outputType]();
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
var createParallelHashOutputMethod = function (bits, padding, xof, outputType) {
|
|
128
|
+
return function (message, blockSize, outputBits, s) {
|
|
129
|
+
return methods[(xof ? 'parallelhashxof' : 'parallelhash') + bits].update(message, blockSize, outputBits, s)[outputType]();
|
|
117
130
|
};
|
|
118
131
|
};
|
|
119
132
|
|
|
@@ -163,22 +176,18 @@
|
|
|
163
176
|
return createOutputMethods(method, createCshakeOutputMethod, bits, padding);
|
|
164
177
|
};
|
|
165
178
|
|
|
166
|
-
var createKmacMethod = function (bits, padding) {
|
|
179
|
+
var createKmacMethod = function (bits, padding, xof) {
|
|
167
180
|
var w = CSHAKE_BYTEPAD[bits];
|
|
168
|
-
var method = createKmacOutputMethod(bits, padding, 'hex');
|
|
181
|
+
var method = createKmacOutputMethod(bits, padding, xof, 'hex');
|
|
169
182
|
method.create = function (key, outputBits, s) {
|
|
170
|
-
return new Kmac(bits, padding, outputBits).bytepad(['KMAC', s], w).bytepad([key], w);
|
|
183
|
+
return new Kmac(bits, padding, outputBits, xof).bytepad(['KMAC', s], w).bytepad([key], w);
|
|
171
184
|
};
|
|
172
185
|
method.update = function (key, message, outputBits, s) {
|
|
173
186
|
return method.create(key, outputBits, s).update(message);
|
|
174
187
|
};
|
|
175
|
-
return createOutputMethods(method,
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
var createTupleHashOutputMethod = function (bits, padding, xof, outputType) {
|
|
179
|
-
return function (inputs, outputBits, s) {
|
|
180
|
-
return methods[(xof ? 'tuplehashxof' : 'tuplehash') + bits].update(inputs, outputBits, s)[outputType]();
|
|
181
|
-
};
|
|
188
|
+
return createOutputMethods(method, function (b, p, outputType) {
|
|
189
|
+
return createKmacOutputMethod(b, p, xof, outputType);
|
|
190
|
+
}, bits, padding);
|
|
182
191
|
};
|
|
183
192
|
|
|
184
193
|
var createTupleHashMethod = function (bits, padding, xof) {
|
|
@@ -202,17 +211,48 @@
|
|
|
202
211
|
}, bits, padding);
|
|
203
212
|
};
|
|
204
213
|
|
|
214
|
+
var createParallelHashMethod = function (bits, padding, xof) {
|
|
215
|
+
var w = CSHAKE_BYTEPAD[bits];
|
|
216
|
+
var method = createParallelHashOutputMethod(bits, padding, xof, 'hex');
|
|
217
|
+
method.create = function (blockSize, outputBits, s) {
|
|
218
|
+
if (typeof blockSize !== 'number' || !isFinite(blockSize) || blockSize < 1 ||
|
|
219
|
+
Math.floor(blockSize) !== blockSize || blockSize > 0x0fffffff) {
|
|
220
|
+
throw new Error(BLOCK_SIZE_ERROR);
|
|
221
|
+
}
|
|
222
|
+
var hash = new ParallelHash(bits, padding, outputBits, xof, blockSize).bytepad(['ParallelHash', s], w);
|
|
223
|
+
hash.encode(blockSize, false);
|
|
224
|
+
return hash;
|
|
225
|
+
};
|
|
226
|
+
method.update = function (message, blockSize, outputBits, s) {
|
|
227
|
+
return method.create(blockSize, outputBits, s).update(message);
|
|
228
|
+
};
|
|
229
|
+
return createOutputMethods(method, function (b, p, outputType) {
|
|
230
|
+
return createParallelHashOutputMethod(b, p, xof, outputType);
|
|
231
|
+
}, bits, padding);
|
|
232
|
+
};
|
|
233
|
+
|
|
205
234
|
var algorithms = [
|
|
206
235
|
{ name: 'keccak', padding: KECCAK_PADDING, bits: BITS, createMethod: createMethod },
|
|
207
236
|
{ name: 'sha3', padding: PADDING, bits: BITS, createMethod: createMethod },
|
|
208
237
|
{ name: 'shake', padding: SHAKE_PADDING, bits: SHAKE_BITS, createMethod: createShakeMethod },
|
|
209
238
|
{ name: 'cshake', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createCshakeMethod },
|
|
210
|
-
{ name: 'kmac', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod:
|
|
239
|
+
{ name: 'kmac', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: function (bits, padding) {
|
|
240
|
+
return createKmacMethod(bits, padding, false);
|
|
241
|
+
}},
|
|
242
|
+
{ name: 'kmacxof', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: function (bits, padding) {
|
|
243
|
+
return createKmacMethod(bits, padding, true);
|
|
244
|
+
}},
|
|
211
245
|
{ name: 'tuplehash', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: function (bits, padding) {
|
|
212
246
|
return createTupleHashMethod(bits, padding, false);
|
|
213
247
|
}},
|
|
214
248
|
{ name: 'tuplehashxof', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: function (bits, padding) {
|
|
215
249
|
return createTupleHashMethod(bits, padding, true);
|
|
250
|
+
}},
|
|
251
|
+
{ name: 'parallelhash', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: function (bits, padding) {
|
|
252
|
+
return createParallelHashMethod(bits, padding, false);
|
|
253
|
+
}},
|
|
254
|
+
{ name: 'parallelhashxof', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: function (bits, padding) {
|
|
255
|
+
return createParallelHashMethod(bits, padding, true);
|
|
216
256
|
}}
|
|
217
257
|
];
|
|
218
258
|
|
|
@@ -488,27 +528,27 @@
|
|
|
488
528
|
return array;
|
|
489
529
|
};
|
|
490
530
|
|
|
491
|
-
function Kmac(bits, padding, outputBits) {
|
|
531
|
+
function Kmac(bits, padding, outputBits, xof) {
|
|
492
532
|
Keccak.call(this, bits, padding, outputBits);
|
|
533
|
+
this.xof = xof;
|
|
493
534
|
}
|
|
494
535
|
|
|
495
536
|
Kmac.prototype = new Keccak();
|
|
496
537
|
|
|
497
538
|
Kmac.prototype.finalize = function () {
|
|
498
539
|
if (!this.finalized) {
|
|
499
|
-
this.encode(this.outputBits, true);
|
|
540
|
+
this.encode(this.xof ? 0 : this.outputBits, true);
|
|
500
541
|
}
|
|
501
542
|
return Keccak.prototype.finalize.call(this);
|
|
502
543
|
};
|
|
503
544
|
|
|
504
545
|
function TupleHash(bits, padding, outputBits, xof) {
|
|
505
|
-
|
|
506
|
-
this.xof = !!xof;
|
|
546
|
+
Kmac.call(this, bits, padding, outputBits, xof);
|
|
507
547
|
this.inputActive = false;
|
|
508
548
|
this.inputBytesRemaining = 0;
|
|
509
549
|
}
|
|
510
550
|
|
|
511
|
-
TupleHash.prototype = new
|
|
551
|
+
TupleHash.prototype = new Kmac();
|
|
512
552
|
|
|
513
553
|
TupleHash.prototype.getMessageByteLength = function (message) {
|
|
514
554
|
var result = formatMessage(message);
|
|
@@ -534,9 +574,6 @@
|
|
|
534
574
|
};
|
|
535
575
|
|
|
536
576
|
TupleHash.prototype.beginInput = function (byteLength) {
|
|
537
|
-
if (this.finalized) {
|
|
538
|
-
throw new Error(FINALIZE_ERROR);
|
|
539
|
-
}
|
|
540
577
|
if (this.inputActive) {
|
|
541
578
|
throw new Error(TUPLE_INCOMPLETE_ERROR);
|
|
542
579
|
}
|
|
@@ -545,20 +582,23 @@
|
|
|
545
582
|
throw new Error(TUPLE_BYTE_LENGTH_ERROR);
|
|
546
583
|
}
|
|
547
584
|
this.encode(byteLength * 8, false);
|
|
548
|
-
if (byteLength
|
|
549
|
-
this.inputActive = false;
|
|
550
|
-
this.inputBytesRemaining = 0;
|
|
551
|
-
} else {
|
|
585
|
+
if (byteLength !== 0) {
|
|
552
586
|
this.inputActive = true;
|
|
553
587
|
this.inputBytesRemaining = byteLength;
|
|
554
588
|
}
|
|
555
589
|
return this;
|
|
556
590
|
};
|
|
557
591
|
|
|
558
|
-
TupleHash.prototype.
|
|
559
|
-
|
|
560
|
-
|
|
592
|
+
TupleHash.prototype._updateChunk = function (message, byteLength) {
|
|
593
|
+
Kmac.prototype.update.call(this, message);
|
|
594
|
+
this.inputBytesRemaining -= byteLength;
|
|
595
|
+
if (this.inputBytesRemaining === 0) {
|
|
596
|
+
this.inputActive = false;
|
|
561
597
|
}
|
|
598
|
+
return this;
|
|
599
|
+
};
|
|
600
|
+
|
|
601
|
+
TupleHash.prototype.updateChunk = function (message) {
|
|
562
602
|
if (!this.inputActive) {
|
|
563
603
|
throw new Error(TUPLE_ACTIVE_ERROR);
|
|
564
604
|
}
|
|
@@ -566,37 +606,107 @@
|
|
|
566
606
|
if (byteLength > this.inputBytesRemaining) {
|
|
567
607
|
throw new Error(TUPLE_LENGTH_ERROR);
|
|
568
608
|
}
|
|
569
|
-
|
|
570
|
-
this.inputBytesRemaining -= byteLength;
|
|
571
|
-
if (this.inputBytesRemaining === 0) {
|
|
572
|
-
this.inputActive = false;
|
|
573
|
-
}
|
|
574
|
-
return this;
|
|
609
|
+
return this._updateChunk(message, byteLength);
|
|
575
610
|
};
|
|
576
611
|
|
|
577
612
|
TupleHash.prototype.update = function (message) {
|
|
578
|
-
if (this.finalized) {
|
|
579
|
-
throw new Error(FINALIZE_ERROR);
|
|
580
|
-
}
|
|
581
|
-
if (this.inputActive) {
|
|
582
|
-
throw new Error(TUPLE_INCOMPLETE_ERROR);
|
|
583
|
-
}
|
|
584
613
|
var byteLength = this.getMessageByteLength(message);
|
|
585
614
|
this.beginInput(byteLength);
|
|
586
|
-
|
|
587
|
-
return this;
|
|
588
|
-
}
|
|
589
|
-
return this.updateChunk(message);
|
|
615
|
+
return this._updateChunk(message, byteLength);
|
|
590
616
|
};
|
|
591
617
|
|
|
592
618
|
TupleHash.prototype.finalize = function () {
|
|
593
619
|
if (this.inputActive) {
|
|
594
620
|
throw new Error(TUPLE_INCOMPLETE_ERROR);
|
|
595
621
|
}
|
|
622
|
+
return Kmac.prototype.finalize.call(this);
|
|
623
|
+
};
|
|
624
|
+
|
|
625
|
+
function ParallelHash(bits, padding, outputBits, xof, blockSize) {
|
|
626
|
+
Kmac.call(this, bits, padding, outputBits, xof);
|
|
627
|
+
this.bits = bits;
|
|
628
|
+
this.blockSize = blockSize;
|
|
629
|
+
this.inner = null;
|
|
630
|
+
this.innerBytes = 0;
|
|
631
|
+
this.blockNumber = 0;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
ParallelHash.prototype = new Kmac();
|
|
635
|
+
|
|
636
|
+
ParallelHash.prototype._finishInner = function () {
|
|
637
|
+
Kmac.prototype.update.call(this, this.inner.array());
|
|
638
|
+
this.inner = null;
|
|
639
|
+
this.innerBytes = 0;
|
|
640
|
+
++this.blockNumber;
|
|
641
|
+
};
|
|
642
|
+
|
|
643
|
+
ParallelHash.prototype._updateBytes = function (message) {
|
|
644
|
+
var length = message.length;
|
|
645
|
+
if (!length) {
|
|
646
|
+
return;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
var slice = message.subarray || message.slice;
|
|
650
|
+
var blockSize = this.blockSize;
|
|
651
|
+
var index = 0;
|
|
652
|
+
while (index < length) {
|
|
653
|
+
if (!this.inner) {
|
|
654
|
+
this.inner = new Keccak(this.bits, SHAKE_PADDING, this.bits << 1);
|
|
655
|
+
}
|
|
656
|
+
var take = blockSize - this.innerBytes;
|
|
657
|
+
if (length - index < take) {
|
|
658
|
+
take = length - index;
|
|
659
|
+
}
|
|
660
|
+
this.inner.update(slice.call(message, index, index + take));
|
|
661
|
+
this.innerBytes += take;
|
|
662
|
+
index += take;
|
|
663
|
+
if (this.innerBytes === blockSize) {
|
|
664
|
+
this._finishInner();
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
};
|
|
668
|
+
|
|
669
|
+
ParallelHash.prototype.update = function (message) {
|
|
670
|
+
if (this.finalized) {
|
|
671
|
+
throw new Error(FINALIZE_ERROR);
|
|
672
|
+
}
|
|
673
|
+
var result = formatMessage(message);
|
|
674
|
+
message = result[0];
|
|
675
|
+
if (result[1]) {
|
|
676
|
+
var bytes = [], length = message.length, index = 0, code, i;
|
|
677
|
+
for (i = 0; i < length; ++i) {
|
|
678
|
+
code = message.charCodeAt(i);
|
|
679
|
+
if (code < 0x80) {
|
|
680
|
+
bytes[index++] = code;
|
|
681
|
+
} else if (code < 0x800) {
|
|
682
|
+
bytes[index++] = (0xc0 | (code >>> 6));
|
|
683
|
+
bytes[index++] = (0x80 | (code & 0x3f));
|
|
684
|
+
} else if (code < 0xd800 || code >= 0xe000) {
|
|
685
|
+
bytes[index++] = (0xe0 | (code >>> 12));
|
|
686
|
+
bytes[index++] = (0x80 | ((code >>> 6) & 0x3f));
|
|
687
|
+
bytes[index++] = (0x80 | (code & 0x3f));
|
|
688
|
+
} else {
|
|
689
|
+
code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++i) & 0x3ff));
|
|
690
|
+
bytes[index++] = (0xf0 | (code >>> 18));
|
|
691
|
+
bytes[index++] = (0x80 | ((code >>> 12) & 0x3f));
|
|
692
|
+
bytes[index++] = (0x80 | ((code >>> 6) & 0x3f));
|
|
693
|
+
bytes[index++] = (0x80 | (code & 0x3f));
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
message = bytes;
|
|
697
|
+
}
|
|
698
|
+
this._updateBytes(message);
|
|
699
|
+
return this;
|
|
700
|
+
};
|
|
701
|
+
|
|
702
|
+
ParallelHash.prototype.finalize = function () {
|
|
596
703
|
if (!this.finalized) {
|
|
597
|
-
|
|
704
|
+
if (this.inner) {
|
|
705
|
+
this._finishInner();
|
|
706
|
+
}
|
|
707
|
+
this.encode(this.blockNumber, true);
|
|
598
708
|
}
|
|
599
|
-
return
|
|
709
|
+
return Kmac.prototype.finalize.call(this);
|
|
600
710
|
};
|
|
601
711
|
|
|
602
712
|
var f = function (s) {
|
package/src/sha3.mjs
CHANGED
|
@@ -29,6 +29,10 @@ export const {
|
|
|
29
29
|
kmac_256,
|
|
30
30
|
kmac128,
|
|
31
31
|
kmac256,
|
|
32
|
+
kmacxof_128,
|
|
33
|
+
kmacxof_256,
|
|
34
|
+
kmacxof128,
|
|
35
|
+
kmacxof256,
|
|
32
36
|
|
|
33
37
|
tuplehash_128,
|
|
34
38
|
tuplehash_256,
|
|
@@ -37,7 +41,16 @@ export const {
|
|
|
37
41
|
tuplehashxof_128,
|
|
38
42
|
tuplehashxof_256,
|
|
39
43
|
tuplehashxof128,
|
|
40
|
-
tuplehashxof256
|
|
44
|
+
tuplehashxof256,
|
|
45
|
+
|
|
46
|
+
parallelhash_128,
|
|
47
|
+
parallelhash_256,
|
|
48
|
+
parallelhash128,
|
|
49
|
+
parallelhash256,
|
|
50
|
+
parallelhashxof_128,
|
|
51
|
+
parallelhashxof_256,
|
|
52
|
+
parallelhashxof128,
|
|
53
|
+
parallelhashxof256
|
|
41
54
|
} = sha3;
|
|
42
55
|
|
|
43
56
|
export default sha3;
|