}
}
- static async work (approach: 'converge' | 'distribute', name: string, data: object[]): Promise<any> {
- if (approach !== 'converge' && approach !== 'distribute')
- throw new TypeError('Invalid work approach')
+ static async work (name: string, data: object[]): Promise<any> {
if (!Array.isArray(data)) data = [data]
return new Promise((resolve, reject) => {
const job: Job = {
let results = await this.ckd(indexes)\r
const data: any = []\r
results.forEach(r => data.push({ privateKey: r.privateKey, index: r.index }))\r
- const keypairs: KeyPair[] = await Pool.work('distribute', 'nano-nacl', data)\r
+ const keypairs: KeyPair[] = await Pool.work('nano-nacl', data)\r
for (const keypair of keypairs) {\r
if (keypair.privateKey == null) throw new RangeError('Account private key missing')\r
if (keypair.publicKey == null) throw new RangeError('Account public key missing')\r
async ckd (indexes: number[]): Promise<KeyPair[]> {\r
const data: any = []\r
indexes.forEach(i => data.push({ seed: this.seed, index: i }))\r
- const privateKeys: KeyPair[] = await Pool.work('distribute', 'bip44-cdk', data)\r
+ const privateKeys: KeyPair[] = await Pool.work('bip44-cdk', data)\r
return privateKeys\r
}\r
}\r
// Both width and height must be multiple of 256, (one byte)
// but do not need to be the same,
// matching GPU capabilities is the aim
- static webglWidth = 256 * 4
- static webglHeight = 256 * 4
+ static webglWidth = 256 * 1
+ static webglHeight = 256 * 1
static hexify (arr: number[] | Uint8Array): string {
let out = ''
v[b + 1] = (xor0 >> 31) ^ (xor1 << 1);
}
- void main() {
+ bool found = false;
+ void find() {
int i;
uint uv_x = uint(uv_pos.x * ${canvas.width - 1}.);
uint uv_y = uint(uv_pos.y * ${canvas.height - 1}.);
// only calculate digest of the second 4 bytes
if((BLAKE2B_IV32_1 ^ v[1] ^ v[17]) > ` + threshold + `u) {
// Success found, return pixel data so work value can be constructed
+ found = true;
fragColor = vec4(
float(x_index + 1u)/255., // +1 to distinguish from 0 (unsuccessful) pixels
float(y_index + 1u)/255., // Same as previous
float(y_pos)/255. // Second custom byte
);
}
+ }
+
+ void main() {
+ int count = 0;
+ do {
+ count++;
+ find();
+ } while (!found && count < 200);
}`
const vertexShader = gl.createShader(gl.VERTEX_SHADER)
gl.clear(gl.COLOR_BUFFER_BIT)
gl.drawArrays(gl.TRIANGLES, 0, 6)
const pixels = new Uint8Array(gl.drawingBufferWidth * gl.drawingBufferHeight * 4)
- performance.mark('readPixels start')
gl.readPixels(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight, gl.RGBA, gl.UNSIGNED_BYTE, pixels)
- performance.mark('readPixels end')
- for (const e of performance.getEntries()) console.dir(e.toJSON())
- performance.clearMarks()
// Check the pixels for any success
for (let i = 0; i < pixels.length; i += 4) {