hypow 0.0.0-stage → 0.1.0
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/dist/cli.html +103 -0
- package/dist/cli.js +1025 -0
- package/dist/hypow-miner.js +63 -0
- package/dist/search-worker.js +35 -0
- package/package.json +34 -4
- package/README.md +0 -3
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// src/search-worker.ts
|
|
2
|
+
import { parentPort, workerData } from "node:worker_threads";
|
|
3
|
+
|
|
4
|
+
// src/protocol.ts
|
|
5
|
+
import { keccak_256 } from "@noble/hashes/sha3.js";
|
|
6
|
+
import { bytesToHex, hexToBytes } from "viem";
|
|
7
|
+
function lessThan(a, b) {
|
|
8
|
+
for (let i = 0; i < 32; i++) if (a[i] !== b[i]) return a[i] < b[i];
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
function preimage(seed2, owner2) {
|
|
12
|
+
const buf = new Uint8Array(96);
|
|
13
|
+
buf.set(seed2, 0);
|
|
14
|
+
buf.set(hexToBytes(owner2), 44);
|
|
15
|
+
return buf;
|
|
16
|
+
}
|
|
17
|
+
function setNonce(buf, nonce) {
|
|
18
|
+
let n = nonce;
|
|
19
|
+
for (let i = 95; i >= 88; i--) {
|
|
20
|
+
buf[i] = n % 256;
|
|
21
|
+
n = Math.floor(n / 256);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function search(seed2, owner2, k2, target2) {
|
|
25
|
+
const buf = preimage(seed2, owner2);
|
|
26
|
+
for (let nonce = 1; nonce <= k2; nonce++) {
|
|
27
|
+
setNonce(buf, nonce);
|
|
28
|
+
if (lessThan(keccak_256(buf), target2)) return nonce;
|
|
29
|
+
}
|
|
30
|
+
return 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// src/search-worker.ts
|
|
34
|
+
var { seed, owner, k, target } = workerData;
|
|
35
|
+
parentPort.postMessage(search(seed, owner, k, target));
|
package/package.json
CHANGED
|
@@ -1,6 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hypow",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Reference Hypow miner: mines HYPOW from your Hyperliquid trading",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"hypow": "dist/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=22.18"
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"typecheck": "tsc --noEmit",
|
|
17
|
+
"test": "node --test test/*.test.ts",
|
|
18
|
+
"prepare": "npm run build",
|
|
19
|
+
"build": "node build.ts"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@noble/hashes": "^2.4.0",
|
|
23
|
+
"viem": "^2.56.8"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/node": "^24.13.6",
|
|
27
|
+
"esbuild": "^0.28.2",
|
|
28
|
+
"typescript": "5.9"
|
|
29
|
+
},
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "git+https://github.com/hypowtoshi/hypow.git",
|
|
34
|
+
"directory": "miner"
|
|
35
|
+
}
|
|
36
|
+
}
|
package/README.md
DELETED