mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-19 19:55:51 +00:00
Switch to using `@noble/hashes`, `@noble/curves`, `@scure/base`, `@scure/bip32`, and `@scure/bip39`. This replaces `crypto` polyfills (such as `crypto-browserify`), `create-hash`, `elliptic`, `hash.js`, `bn.js` (both versions), and their many dependencies. This also means there are 33 less dependencies downloaded when running a fresh `npm install` and will make the project much easier to maintain. This reduces the bundle size by 44% (82kb minified and gzipped) over the current 3.0 branch as well as reducing the amount of configuration required to bundle. Closes #1814, #1817, #2272, and #2306 Co-authored-by: Caleb Kniffen <ckniffen@ripple.com>
18 lines
563 B
TypeScript
18 lines
563 B
TypeScript
import { sha512 } from '@xrplf/isomorphic/sha512'
|
|
import { bytesToHex } from '@xrplf/isomorphic/utils'
|
|
|
|
describe('sha512', () => {
|
|
it('hashes', () => {
|
|
const hashA = sha512('abc')
|
|
const hashB = sha512
|
|
.create()
|
|
.update(Uint8Array.from([97, 98, 99]))
|
|
.digest()
|
|
const expectedHash =
|
|
'DDAF35A193617ABACC417349AE20413112E6FA4E89A97EA20A9EEEE64B55D39A2192992A274FC1A836BA3C23A3FEEBBD454D4423643CE80E2A9AC94FA54CA49F'
|
|
|
|
expect(bytesToHex(hashA)).toEqual(expectedHash)
|
|
expect(bytesToHex(hashB)).toEqual(expectedHash)
|
|
})
|
|
})
|