Skip to content

Commit 05c47d5

Browse files
committed
↔️ Add zkSync Era contract address support
1 parent 2ddad70 commit 05c47d5

10 files changed

+123
-82
lines changed

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "lib"]
2+
path = lib
3+
url = https://github.com/KimlikDAO/kimlikdao-js

Dispatcher.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include "Mode.hpp"
2121

2222
#define PROFANITY_SPEEDSAMPLES 20
23-
#define PROFANITY_MAX_SCORE 40
23+
#define PROFANITY_MAX_SCORE 200
2424

2525
class Dispatcher {
2626
private:

Mode.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ Mode Mode::KimlikDAO() {
1919
return r;
2020
}
2121

22+
Mode Mode::DobbyInu() {
23+
Mode r;
24+
r.name = "DobbyInu";
25+
r.kernel = "profanity_score_DobbyInu";
26+
return r;
27+
}
28+
2229
Mode Mode::zeros() {
2330
Mode r = range(0, 0);
2431
r.name = "zeros";
@@ -109,6 +116,8 @@ std::string Mode::transformKernel() const {
109116
return "";
110117
case CONTRACT:
111118
return "profanity_transform_contract";
119+
case ZKSYNC_ERA_CONTRACT:
120+
return "profanity_transform_zksyncera_contract";
112121
default:
113122
throw "No kernel for target";
114123
}
@@ -120,6 +129,8 @@ std::string Mode::transformName() const {
120129
return "Address";
121130
case CONTRACT:
122131
return "Contract";
132+
case ZKSYNC_ERA_CONTRACT:
133+
return "zkSync Era Contract";
123134
default:
124135
throw "No name for target";
125136
}

Mode.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
enum HashTarget {
1313
ADDRESS,
1414
CONTRACT,
15+
ZKSYNC_ERA_CONTRACT,
1516
HASH_TARGET_COUNT
1617
};
1718

@@ -32,6 +33,7 @@ class Mode {
3233
static Mode numbers();
3334
static Mode doubles();
3435
static Mode KimlikDAO();
36+
static Mode DobbyInu();
3537

3638
std::string name;
3739

README.md

+13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
# eulogy
2+
Profanity but with flowers 🌸🌼🌸🌼.
3+
4+
Eulogy differs from profanity in that:
5+
- search is seeded with 256-bits of true randomness from `/dev/random`.
6+
- zkSync Era contract address computation is supported
7+
8+
```shell
9+
usage: bun eulogy.js [OPTIONS]
10+
11+
--contract
12+
--zksyncera
13+
```
114
# profanity
215
Profanity is a high performance (probably the fastest!) vanity address generator for Ethereum. Create cool customized addresses that you never realized you needed! Recieve Ether in style! Wow!
316

eulogy.js

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { spawn } from 'child_process';
2+
import { getCreateAddress } from "./lib/ethereum/eravm";
3+
import evm from "./lib/ethereum/evm";
4+
import vm from "./lib/testing/vm";
5+
6+
let Count = 0;
7+
let Started = false;
8+
9+
/** @const {?string} */
10+
const dobby = process.argv.includes("--dobby");
11+
12+
const f = (priv) => {
13+
if (priv.length != 64) {
14+
console.log("invalid priv:", priv);
15+
return;
16+
}
17+
Count++;
18+
const deployer = vm.addr(BigInt("0x" + priv));
19+
const deployed = evm.adresDüzelt(getCreateAddress(deployer, 0));
20+
21+
const isHit = dobby
22+
? deployed.startsWith("0xD0BB7")
23+
: deployed.startsWith('0xcCc') && deployed.endsWith('cCc');
24+
25+
console.log(`C: ${("" + Count).padStart(3, " ")} ` +
26+
`${isHit ? " hit" : "miss"}: ${deployed} ${priv} ${deployer}`);
27+
};
28+
29+
const cmd = spawn('./profanity', process.argv.slice(2));
30+
31+
cmd.stdout.on('data', (data) => {
32+
const line = data.toString().trim();
33+
if (line.includes('START'))
34+
Started = true;
35+
if (Started)
36+
f(line);
37+
});
38+
39+
cmd.stderr.on('data', (data) => console.error(`stderr: ${data}`));
40+
cmd.on('close', (code) => console.log(`child process exited with code ${code}`));

eulogy.py

-36
This file was deleted.

lib

Submodule lib added at a93af28

profanity.cl

+39
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,37 @@ void profanity_result_update(const size_t id, __global const uchar * const hash,
676676
}
677677
}
678678

679+
__kernel void profanity_transform_zksyncera_contract(__global mp_number *const pInverse) {
680+
const size_t id = get_global_id(0);
681+
__global const uchar *const hash = pInverse[id].d;
682+
683+
ethhash h;
684+
for (int i = 8; i < 50; ++i) {
685+
h.d[i] = 0;
686+
}
687+
// set up keccak(CreatePrefix, address, nonce)
688+
h.d[0] = 2850273891;
689+
h.d[1] = 3895991701;
690+
h.d[2] = 3082288035;
691+
h.d[3] = 3249473801;
692+
h.d[4] = 4228908576;
693+
h.d[5] = 3730490715;
694+
h.d[6] = 1501638436;
695+
h.d[7] = 592406388;
696+
for (int i = 0; i < 20; i++) {
697+
h.b[i + 32 + 12] = hash[i];
698+
}
699+
700+
h.b[96] ^= 0x01; // length 96
701+
sha3_keccakf(&h);
702+
703+
pInverse[id].d[0] = h.d[3];
704+
pInverse[id].d[1] = h.d[4];
705+
pInverse[id].d[2] = h.d[5];
706+
pInverse[id].d[3] = h.d[6];
707+
pInverse[id].d[4] = h.d[7];
708+
}
709+
679710
__kernel void profanity_transform_contract(__global mp_number * const pInverse) {
680711
const size_t id = get_global_id(0);
681712
__global const uchar * const hash = pInverse[id].d;
@@ -718,6 +749,14 @@ __kernel void profanity_score_KimlikDAO(__global mp_number * const pInverse, __g
718749
profanity_result_update(id, hash, pResult, scoreMax + 1, scoreMax);
719750
}
720751

752+
__kernel void profanity_score_DobbyInu(__global mp_number * const pInverse, __global result * const pResult, __constant const uchar * const data1, __constant const uchar * const data2, const uchar scoreMax) {
753+
const size_t id = get_global_id(0);
754+
__global const uchar * const hash = pInverse[id].d;
755+
756+
if (hash[0] == 208 && hash[1] == 187 && hash[2] == 7 * 16 /* && hash[18] == 208 && hash[19]== 183 */)
757+
profanity_result_update(id, hash, pResult, scoreMax + 1, scoreMax);
758+
}
759+
721760
__kernel void profanity_score_matching(__global mp_number * const pInverse, __global result * const pResult, __constant const uchar * const data1, __constant const uchar * const data2, const uchar scoreMax) {
722761
const size_t id = get_global_id(0);
723762
__global const uchar * const hash = pInverse[id].d;

profanity.cpp

+13-45
Original file line numberDiff line numberDiff line change
@@ -143,66 +143,34 @@ std::string getDeviceCacheFilename(cl_device_id & d, const size_t & inverseSize)
143143
int main(int argc, char * * argv) {
144144
try {
145145
ArgParser argp(argc, argv);
146-
bool bHelp = false;
147-
bool bModeBenchmark = false;
148-
bool bModeZeros = false;
149-
bool bModeLetters = false;
150-
bool bModeNumbers = false;
151146
std::string strModeLeading;
152-
std::string strModeMatching;
153-
bool bModeLeadingRange = false;
154-
bool bModeRange = false;
155-
bool bModeMirror = false;
156-
bool bModeDoubles = false;
157-
int rangeMin = 0;
158-
int rangeMax = 0;
147+
std::string strModeMatching;;
159148
std::vector<size_t> vDeviceSkipIndex;
160149
size_t worksizeLocal = 64;
161150
size_t worksizeMax = 0; // Will be automatically determined later if not overriden by user
162151
bool bNoCache = false;
163152
size_t inverseSize = 255;
164153
size_t inverseMultiple = 16384;
165-
bool bMineContract = true;
166-
167-
argp.addSwitch('h', "help", bHelp);
168-
argp.addSwitch('0', "benchmark", bModeBenchmark);
169-
argp.addSwitch('1', "zeros", bModeZeros);
170-
argp.addSwitch('2', "letters", bModeLetters);
171-
argp.addSwitch('3', "numbers", bModeNumbers);
172-
argp.addSwitch('4', "leading", strModeLeading);
173-
argp.addSwitch('5', "matching", strModeMatching);
174-
argp.addSwitch('6', "leading-range", bModeLeadingRange);
175-
argp.addSwitch('7', "range", bModeRange);
176-
argp.addSwitch('8', "mirror", bModeMirror);
177-
argp.addSwitch('9', "leading-doubles", bModeDoubles);
178-
argp.addSwitch('m', "min", rangeMin);
179-
argp.addSwitch('M', "max", rangeMax);
180-
argp.addMultiSwitch('s', "skip", vDeviceSkipIndex);
181-
argp.addSwitch('w', "work", worksizeLocal);
182-
argp.addSwitch('W', "work-max", worksizeMax);
183-
argp.addSwitch('n', "no-cache", bNoCache);
184-
argp.addSwitch('i', "inverse-size", inverseSize);
185-
argp.addSwitch('I', "inverse-multiple", inverseMultiple);
186-
argp.addSwitch('c', "contract", bMineContract);
154+
// bool bMineContract = true;
155+
bool bzkSyncEra = false;
156+
bool bDobbyInu = false;
157+
bool bContract = true;
158+
159+
argp.addSwitch('c', "contract", bContract);
160+
argp.addSwitch('z', "zksyncera", bzkSyncEra);
161+
argp.addSwitch('d', "dobby", bDobbyInu);
187162

188163
if (!argp.parse()) {
189164
std::cout << "error: bad arguments, try again :<" << std::endl;
190165
return 1;
191166
}
192167

193-
if (bHelp) {
194-
std::cout << g_strHelp << std::endl;
195-
return 0;
196-
}
168+
Mode mode = bDobbyInu ? Mode::DobbyInu() : Mode::KimlikDAO();
169+
mode.target = bContract
170+
? bzkSyncEra ? ZKSYNC_ERA_CONTRACT : CONTRACT
171+
: ADDRESS;
197172

198-
Mode mode = Mode::KimlikDAO();
199173
std::cout << "Mode: " << mode.name << std::endl;
200-
201-
if (bMineContract) {
202-
mode.target = CONTRACT;
203-
} else {
204-
mode.target = ADDRESS;
205-
}
206174
std::cout << "Target: " << mode.transformName() << std:: endl;
207175

208176
std::vector<cl_device_id> vFoundDevices = getAllDevices();

0 commit comments

Comments
 (0)