altcha-lib 0.1.4 → 0.1.5
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/README.md +9 -11
- package/cjs/dist/index.d.ts +7 -0
- package/cjs/dist/index.js +6 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +6 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ ALTCHA JS Library is a lightweight, zero-dependency library designed for creatin
|
|
|
4
4
|
|
|
5
5
|
## Compatibility
|
|
6
6
|
|
|
7
|
-
This library utilizes [Web Crypto](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto) and
|
|
7
|
+
This library utilizes [Web Crypto](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto) and is intended for server-side use.
|
|
8
8
|
|
|
9
9
|
- Node.js 16+
|
|
10
10
|
- Bun 1+
|
|
@@ -103,18 +103,16 @@ const solution = await solveChallengeWorkers(
|
|
|
103
103
|
|
|
104
104
|
```
|
|
105
105
|
> solveChallenge()
|
|
106
|
-
- n = 1,000...............................
|
|
107
|
-
- n = 10,000..............................
|
|
108
|
-
- n =
|
|
109
|
-
- n =
|
|
110
|
-
- n = 500,000............................. 0 ops/s ±0.36%
|
|
106
|
+
- n = 1,000............................... 317 ops/s ±2.63%
|
|
107
|
+
- n = 10,000.............................. 32 ops/s ±1.88%
|
|
108
|
+
- n = 100,000............................. 3 ops/s ±0.34%
|
|
109
|
+
- n = 500,000............................. 0 ops/s ±0.32%
|
|
111
110
|
|
|
112
111
|
> solveChallengeWorkers() (8 workers)
|
|
113
|
-
- n = 1,000...............................
|
|
114
|
-
- n = 10,000..............................
|
|
115
|
-
- n =
|
|
116
|
-
- n =
|
|
117
|
-
- n = 500,000............................. 1 ops/s ±2.22%
|
|
112
|
+
- n = 1,000............................... 66 ops/s ±3.44%
|
|
113
|
+
- n = 10,000.............................. 31 ops/s ±4.28%
|
|
114
|
+
- n = 100,000............................. 7 ops/s ±4.40%
|
|
115
|
+
- n = 500,000............................. 1 ops/s ±2.49%
|
|
118
116
|
```
|
|
119
117
|
|
|
120
118
|
Run with Bun on MacBook Pro M3-Pro. See [/benchmark](/benchmark/) folder for more details.
|
package/cjs/dist/index.d.ts
CHANGED
|
@@ -6,3 +6,10 @@ export declare function solveChallenge(challenge: string, salt: string, algorith
|
|
|
6
6
|
controller: AbortController;
|
|
7
7
|
};
|
|
8
8
|
export declare function solveChallengeWorkers(workerScript: string | URL | (() => Worker), concurrency: number, challenge: string, salt: string, algorithm?: string, max?: number, startNumber?: number): Promise<Solution | null>;
|
|
9
|
+
declare const _default: {
|
|
10
|
+
createChallenge: typeof createChallenge;
|
|
11
|
+
verifySolution: typeof verifySolution;
|
|
12
|
+
solveChallenge: typeof solveChallenge;
|
|
13
|
+
solveChallengeWorkers: typeof solveChallengeWorkers;
|
|
14
|
+
};
|
|
15
|
+
export default _default;
|
package/cjs/dist/index.js
CHANGED
|
@@ -120,3 +120,9 @@ exports.solveChallengeWorkers = solveChallengeWorkers;
|
|
|
120
120
|
async function hashChallenge(salt, num, algorithm) {
|
|
121
121
|
return (0, helpers_js_1.ab2hex)(await crypto.subtle.digest(algorithm.toUpperCase(), helpers_js_1.encoder.encode(salt + num)));
|
|
122
122
|
}
|
|
123
|
+
exports.default = {
|
|
124
|
+
createChallenge,
|
|
125
|
+
verifySolution,
|
|
126
|
+
solveChallenge,
|
|
127
|
+
solveChallengeWorkers,
|
|
128
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -6,3 +6,10 @@ export declare function solveChallenge(challenge: string, salt: string, algorith
|
|
|
6
6
|
controller: AbortController;
|
|
7
7
|
};
|
|
8
8
|
export declare function solveChallengeWorkers(workerScript: string | URL | (() => Worker), concurrency: number, challenge: string, salt: string, algorithm?: string, max?: number, startNumber?: number): Promise<Solution | null>;
|
|
9
|
+
declare const _default: {
|
|
10
|
+
createChallenge: typeof createChallenge;
|
|
11
|
+
verifySolution: typeof verifySolution;
|
|
12
|
+
solveChallenge: typeof solveChallenge;
|
|
13
|
+
solveChallengeWorkers: typeof solveChallengeWorkers;
|
|
14
|
+
};
|
|
15
|
+
export default _default;
|
package/dist/index.js
CHANGED
|
@@ -113,3 +113,9 @@ export async function solveChallengeWorkers(workerScript, concurrency, challenge
|
|
|
113
113
|
async function hashChallenge(salt, num, algorithm) {
|
|
114
114
|
return ab2hex(await crypto.subtle.digest(algorithm.toUpperCase(), encoder.encode(salt + num)));
|
|
115
115
|
}
|
|
116
|
+
export default {
|
|
117
|
+
createChallenge,
|
|
118
|
+
verifySolution,
|
|
119
|
+
solveChallenge,
|
|
120
|
+
solveChallengeWorkers,
|
|
121
|
+
};
|