]> git.codecow.com Git - nano-pow.git/commitdiff
Deprecate unused functions.
authorChris Duncan <chris@codecow.com>
Sun, 21 Jun 2026 05:27:21 +0000 (22:27 -0700)
committerChris Duncan <chris@codecow.com>
Sun, 21 Jun 2026 05:27:21 +0000 (22:27 -0700)
src/utils/bigint.ts

index 3360b88cd77373c5106c52a20549527c5627a765..10db9ee45395792066db86f7de136325b9985a24 100644 (file)
@@ -22,15 +22,6 @@ export function bigintAsUintNArray (int: bigint, bits: number, length: number =
        return uintArray
 }
 
-export function bigintBitLength (int: bigint): bigint {
-       let bitLength = 1n
-       while (int > 1n || int < -1n) {
-               bitLength++
-               int >>= 1n
-       }
-       return bitLength
-}
-
 export function bigintByteLength (int: bigint): number {
        let byteLength = 0
        while (int > 0n || int < -1n) {
@@ -66,26 +57,6 @@ export function bigintFrom (value: bigint | boolean | number | string | unknown,
        throw new TypeError(`can't convert string to BigInt`)
 }
 
-export function bigintRandom (max: bigint = 0xFFFFFFFFFFFFFFFFn): bigint {
-       if (typeof max !== 'bigint' || max < 1n) {
-               throw new TypeError('Invalid max value')
-       }
-       const randomUint8Array = new Uint8Array(bigintByteLength(max))
-       const mask = (1n << bigintBitLength(max)) - 1n
-       let output = 0n
-       do {
-               output = 0n
-               crypto.getRandomValues(randomUint8Array)
-               output = BigInt(randomUint8Array[0])
-               for (let i = 1; i < randomUint8Array.length; i++) {
-                       output <<= 8n
-                       output += BigInt(randomUint8Array[i])
-               }
-               output &= mask
-       } while (output > max)
-       return output
-}
-
 export function bigintToHex (int: bigint, length: unknown = 0): string {
        if (typeof length !== 'number') {
                throw new TypeError('invalid length')