Skip to content

Commit df6c410

Browse files
committed
fix(algo): use js-sha512
As crypto-browserify doesn't support sha512/256 yet. See browserify/sha.js#67
1 parent 529b4b7 commit df6c410

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"ethereumjs-util": "^7.1.4",
6868
"hi-base32": "^0.5.1",
6969
"js-conflux-sdk": "^1.7.1",
70+
"js-sha512": "^0.8.0",
7071
"timeout-signal": "^1.1.0",
7172
"tweetnacl": "^1.0.3",
7273
"whatwg-url": "^11.0.0"

src/provider/chains/algo/sdk/naclWrappers.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
/* Copyright (c) 2019 Algorand, llc */
22

3-
import * as crypto from 'crypto';
4-
3+
import sha512 from 'js-sha512';
54
import nacl from 'tweetnacl';
65

7-
export function genericHash(arr: crypto.BinaryLike): Uint8Array {
8-
return new Uint8Array(crypto.createHash('sha512-256').update(arr).digest());
6+
export function genericHash(arr: sha512.Message) {
7+
return sha512.sha512_256.array(arr);
98
}
109

1110
// constants

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4017,6 +4017,11 @@ [email protected], js-sha3@^0.8.0:
40174017
resolved "https://registry.npmjs.org/js-sha3/-/js-sha3-0.8.0.tgz#b9b7a5da73afad7dedd0f8c463954cbde6818840"
40184018
integrity sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q==
40194019

4020+
js-sha512@^0.8.0:
4021+
version "0.8.0"
4022+
resolved "https://registry.yarnpkg.com/js-sha512/-/js-sha512-0.8.0.tgz#dd22db8d02756faccf19f218e3ed61ec8249f7d4"
4023+
integrity sha512-PWsmefG6Jkodqt+ePTvBZCSMFgN7Clckjd0O7su3I0+BW2QWUTJNzjktHsztGLhncP2h8mcF9V9Y2Ha59pAViQ==
4024+
40204025
js-tokens@^4.0.0:
40214026
version "4.0.0"
40224027
resolved "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"

0 commit comments

Comments
 (0)