feat: replace js-sha512 with @noble/hashes for SHA-512 implementation and update related logic

This commit is contained in:
2026-01-03 06:47:45 +00:00
parent 4f90f50033
commit 7b41852938
5 changed files with 62 additions and 12 deletions
+2 -3
View File
@@ -1,9 +1,8 @@
import type { RNG } from './RNG.js';
import { sha512 } from 'js-sha512';
import { convertBytesLikeToUint8Array } from './convertBytesLikeToUint8Array.js';
import type { BytesLike } from './BytesLike.js';
import { sha512ArrayBuffer } from './sha512.js';
const maxRngSupportBit = 53;
const maxInt = 0x1f_ffff_ffff_ffff; // NOTE: b 0, 10000110011, 11...11
@@ -111,7 +110,7 @@ export class LiteHashDRBG implements RNG {
protected genNextBlock(): void {
this.hq.setUint32(this.hqIdxPos, this.stateIdx, true);
const digest = sha512.arrayBuffer(this.hq.buffer as ArrayBuffer);
const digest = sha512ArrayBuffer(this.hq.buffer as ArrayBuffer);
this.buffer = digest;
this.bufferIdx = 0;
this.stateIdx += 1;