Skip to content
Snippets Groups Projects
Commit 6873ee80 authored by Millicent Billette's avatar Millicent Billette
Browse files

vanityLike.mjs more thread space

parent bef67c11
No related branches found
No related tags found
No related merge requests found
import * as app from "../src/crypto.mjs"; import * as duniCrypto from "../src/crypto.mjs";
// For thread use : https://github.com/darionco/WebCPU // For thread use : https://github.com/darionco/WebCPU
const fillChr=' '; const fillChr=' ';
...@@ -11,17 +11,17 @@ function main() { ...@@ -11,17 +11,17 @@ function main() {
let PARALLEL_INDEX = 0; let PARALLEL_INDEX = 0;
if(process.argv[2]) PARALLEL_INDEX = parseInt(process.argv[2]); if(process.argv[2]) PARALLEL_INDEX = parseInt(process.argv[2]);
const PARALLEL_THREAD = 4; const PARALLEL_THREAD = 42;
const startTime = Date.now(); // performance.now() const startTime = Date.now(); // performance.now()
let partialLevel = 0; let partialLevel = 0;
for (let x = PARALLEL_INDEX; true; x+=PARALLEL_THREAD) { for (let x = PARALLEL_INDEX; true; x+=PARALLEL_THREAD) {
const strX = ('vanityDebugSeed' + x).replace(/0/g, 'z'); const strX = ('vanityDebugSeed' + x).replace(/0/g, 'z');
const keys = app.raw2b58(app.seed2keyPair(app.b58pubKey2bin(strX))); const keys = duniCrypto.raw2b58(duniCrypto.seed2keyPair(duniCrypto.b58pubKey2bin(strX)));
let pubKey = keys.publicKey; let pubKey = keys.publicKey;
if(pubKey[0]==='1'){ if(pubKey[0]==='1'){
pubKey = app.b58.encode(app.sliceInitialsZero(app.b58pubKey2bin(pubKey))); pubKey = duniCrypto.b58.encode(duniCrypto.sliceInitialsZero(duniCrypto.b58pubKey2bin(pubKey)));
const now = Date.now(); // performance.now() const now = Date.now(); // performance.now()
const elapsed = f(7,''+Math.trunc((now-startTime)/1000)); const elapsed = f(7,''+Math.trunc((now-startTime)/1000));
const speed = f(5,''+Math.trunc((x/PARALLEL_THREAD)/((now-startTime)/1000))); const speed = f(5,''+Math.trunc((x/PARALLEL_THREAD)/((now-startTime)/1000)));
...@@ -34,15 +34,15 @@ function main() { ...@@ -34,15 +34,15 @@ function main() {
partialLevel=2; partialLevel=2;
console.log(`${speed}/s écoulé: ${elapsed}s seed:${f(44,strX)} pubKey:${f(44,pubKey)}`); console.log(`${speed}/s écoulé: ${elapsed}s seed:${f(44,strX)} pubKey:${f(44,pubKey)}`);
} }
if(app.pubKey2checksum(pubKey)[0]==='1'){ if(duniCrypto.pubKey2checksum(pubKey)[0]==='1'){
if(partialLevel<4){ if(partialLevel<4){
partialLevel=3; partialLevel=3;
console.log(`${speed}/s écoulé: ${elapsed}s seed:${f(44,strX)} pubKey:${f(44,pubKey)} chk: ${app.pubKey2checksum(pubKey)} ${app.pubKey2checksum(pubKey, false, true)}`); console.log(`${speed}/s écoulé: ${elapsed}s seed:${f(44,strX)} pubKey:${f(44,pubKey)} chk: ${duniCrypto.pubKey2checksum(pubKey)} ${duniCrypto.pubKey2checksum(pubKey, false, true)}`);
} }
if(app.pubKey2checksum(pubKey,true)[0]==='1'){ if(duniCrypto.pubKey2checksum(pubKey,true)[0]==='1'){
console.log(`${speed}/s écoulé: ${elapsed}s seed:${f(44,strX)} pubKey:${f(44,pubKey) console.log(`${speed}/s écoulé: ${elapsed}s seed:${f(44,strX)} pubKey:${f(44,pubKey)
} chk: ${app.pubKey2checksum(pubKey)} ${app.pubKey2checksum(pubKey, false, true) } chk: ${duniCrypto.pubKey2checksum(pubKey)} ${duniCrypto.pubKey2checksum(pubKey, false, true)
} ${app.pubKey2checksum(pubKey,true)} ${app.pubKey2checksum(pubKey,true, true)}`); } ${duniCrypto.pubKey2checksum(pubKey,true)} ${duniCrypto.pubKey2checksum(pubKey,true, true)}`);
return; return;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment