Remove useless analytics events

This commit is contained in:
Boris Kubiak 2022-02-08 16:21:59 +01:00
parent 1450647150
commit 1c4271a4f3
4 changed files with 89 additions and 71 deletions

View file

@ -37,7 +37,7 @@
async async
defer defer
data-website-id="9086c519-8c4a-4f8e-9dfe-daee3739238a" data-website-id="9086c519-8c4a-4f8e-9dfe-daee3739238a"
src="https://metrics.vanity-eth.tk/umami.js" src="https://metrics.vanity-eth.tk/umami-script.js"
></script> ></script>
</head> </head>
<body> <body>

View file

@ -21,14 +21,23 @@
<div class="row"> <div class="row">
<!--User input--> <!--User input-->
<div class="col-md-6"> <div class="col-md-6">
<userInput :running="running" :cores="cores" <userInput
@start="startGen" @stop="stopGen" @input-change="setInput"></userInput> :running="running"
:cores="cores"
@start="startGen"
@stop="stopGen"
@input-change="setInput"
></userInput>
</div> </div>
<!--Statistics--> <!--Statistics-->
<div class="col-md-6"> <div class="col-md-6">
<statistics :hex="input.hex" :checksum="input.checksum" :status="status" <statistics
:first-tick="firstTick"></statistics> :hex="input.hex"
:checksum="input.checksum"
:status="status"
:first-tick="firstTick"
></statistics>
</div> </div>
</div> </div>
@ -65,7 +74,7 @@
import Foot from './vue/Footer'; import Foot from './vue/Footer';
export default { export default {
components: {Headline, Description, Err, UserInput, Statistics, Result, Save, Corner, Foot}, components: { Headline, Description, Err, UserInput, Statistics, Result, Save, Corner, Foot },
data: function () { data: function () {
return { return {
running: false, running: false,
@ -73,10 +82,10 @@
workers: [], workers: [],
threads: 4, threads: 4,
cores: 0, cores: 0,
result: {address: '', privateKey: ''}, result: { address: '', privateKey: '' },
input: {hex: '', checksum: true, suffix: false}, input: { hex: '', checksum: true, suffix: false },
firstTick: null, firstTick: null,
error: null error: null,
}; };
}, },
watch: { watch: {
@ -84,23 +93,23 @@
if (!this.running) { if (!this.running) {
this.initWorkers(); this.initWorkers();
} }
} },
}, },
methods: { methods: {
setInput: function (inputType, value) { setInput: function (inputType, value) {
// eslint-disable-next-line default-case // eslint-disable-next-line default-case
switch (inputType) { switch (inputType) {
case 'hex': case 'hex':
this.input.hex = value; this.input.hex = value;
break; break;
case 'checksum': case 'checksum':
this.input.checksum = value; this.input.checksum = value;
break; break;
case 'suffix': case 'suffix':
this.input.suffix = value; this.input.suffix = value;
break; break;
case 'threads': case 'threads':
this.threads = value; this.threads = value;
} }
}, },
@ -224,7 +233,7 @@
let attempts = 0; let attempts = 0;
const times = []; const times = [];
const durations = []; const durations = [];
const timeTaken = (a, d) => Math.round(1000 * a / d); const timeTaken = (a, d) => Math.round((1000 * a) / d);
worker.onmessage = () => { worker.onmessage = () => {
times.push(performance.now()); times.push(performance.now());
if (times.length === 1) { if (times.length === 1) {
@ -232,18 +241,25 @@
} }
durations.push(times[times.length - 1] - times[times.length - 2]); durations.push(times[times.length - 1] - times[times.length - 2]);
attempts += step; attempts += step;
console.info(attempts + '/' + max + '...' + timeTaken(step, durations[durations.length - 1]) + ' addr/s'); console.info(
if(attempts >= max) { attempts + '/' + max + '...' + timeTaken(step, durations[durations.length - 1]) + ' addr/s'
console.info('\nSpeed range: ' + timeTaken(step, Math.max(...durations)) );
+ ' - ' + timeTaken(step, Math.min(...durations)) +' addr/s'); if (attempts >= max) {
console.info('Average: ' + timeTaken(attempts, (times[times.length - 1] - times[0])) + ' addr/s'); console.info(
'\nSpeed range: ' +
timeTaken(step, Math.max(...durations)) +
' - ' +
timeTaken(step, Math.min(...durations)) +
' addr/s'
);
console.info('Average: ' + timeTaken(attempts, times[times.length - 1] - times[0]) + ' addr/s');
worker.terminate(); worker.terminate();
} }
}; };
const input = {checksum: true, hex: 'f'.repeat(5), suffix: false}; const input = { checksum: true, hex: 'f'.repeat(5), suffix: false };
console.info('Starting benchmark with 1 core...'); console.info('Starting benchmark with 1 core...');
worker.postMessage(input); worker.postMessage(input);
} },
}, },
created: function () { created: function () {
@ -251,15 +267,8 @@
this.countCores(); this.countCores();
this.initWorkers(); this.initWorkers();
window['benchmark'] = this.benchmark; window['benchmark'] = this.benchmark;
},
this.$root.$on('event', (name) => {
if (window['umami']) {
window['umami'].trackEvent(name, 'click');
}
});
}
}; };
</script> </script>
<style lang="sass"> <style lang="sass">

View file

@ -4,12 +4,18 @@
<div class="float-left" id="identicon"></div> <div class="float-left" id="identicon"></div>
<div class="col"> <div class="col">
<div>Address: <span class="output" v-text="address"></span></div> <div>Address: <span class="output" v-text="address"></span></div>
<div>Private key: <div>
<span class="output" v-if="privateKey" v-text="reveal ? privateKey : 'Click to reveal'" @click="revealKey()"></span> Private key:
<span
class="output"
v-if="privateKey"
v-text="reveal ? privateKey : 'Click to reveal'"
@click="revealKey()"
></span>
</div> </div>
</div> </div>
<div class="col-lg-2 col-12"> <div class="col-lg-2 col-12">
<button data-remodal-target="modal" class="save button-large" :disabled="!privateKey" @click="openSave()"> <button data-remodal-target="modal" class="save button-large" :disabled="!privateKey">
<i class="icon-lock"></i>&nbsp;&nbsp;&nbsp;Save <i class="icon-lock"></i>&nbsp;&nbsp;&nbsp;Save
</button> </button>
</div> </div>
@ -23,11 +29,11 @@
export default { export default {
props: { props: {
address: String, address: String,
privateKey: String privateKey: String,
}, },
data: function () { data: function () {
return { return {
reveal: false reveal: false,
}; };
}, },
watch: { watch: {
@ -36,19 +42,15 @@
const id = document.getElementById('identicon'); const id = document.getElementById('identicon');
id.innerHTML = ''; id.innerHTML = '';
if (addr) { if (addr) {
id.appendChild(blockies({seed: addr.toLocaleLowerCase(), scale: 6})); id.appendChild(blockies({ seed: addr.toLocaleLowerCase(), scale: 6 }));
} }
} },
}, },
methods: { methods: {
revealKey() { revealKey() {
this.reveal = true; this.reveal = true;
this.$root.$emit('event', 'Reveal');
}, },
openSave() { },
this.$root.$emit('event', 'Save');
}
}
}; };
</script> </script>
@ -76,5 +78,4 @@
@media screen and (min-width: 992px) @media screen and (min-width: 992px)
.save .save
margin-top: 0 margin-top: 0
</style> </style>

View file

@ -4,16 +4,26 @@
<h3 class="title">Create encrypted keystore file (UTC / JSON)</h3> <h3 class="title">Create encrypted keystore file (UTC / JSON)</h3>
<form @submit.prevent="save"> <form @submit.prevent="save">
<div> <div>
<input class="hidden" type="text" autocomplete="username"> <input class="hidden" type="text" autocomplete="username" />
<input :type="showPassword ? 'text' : 'password'" autocomplete="new-password" class="text-input-large" v-model="password" <input
placeholder="Password"> :type="showPassword ? 'text' : 'password'"
autocomplete="new-password"
class="text-input-large"
v-model="password"
placeholder="Password"
/>
<button type="button" class="show-password" @click="showPassword = !showPassword"> <button type="button" class="show-password" @click="showPassword = !showPassword">
<i :class="showPassword ? 'icon-eye-off' : 'icon-eye-on'"></i> <i :class="showPassword ? 'icon-eye-off' : 'icon-eye-on'"></i>
</button> </button>
</div> </div>
<div> <div>
<button type="button" class="button-large" @click="save" :disabled="!password || !privateKey || loading" <button
v-text="loading ? 'Generating...' : 'Download'"></button> type="button"
class="button-large"
@click="save"
:disabled="!password || !privateKey || loading"
v-text="loading ? 'Generating...' : 'Download'"
></button>
</div> </div>
</form> </form>
</div> </div>
@ -24,32 +34,30 @@
import 'randombytes'; import 'randombytes';
import * as download from 'downloadjs'; import * as download from 'downloadjs';
import {v4} from 'uuid'; import { v4 } from 'uuid';
import CryptoJS from 'crypto-js'; import CryptoJS from 'crypto-js';
export default { export default {
props: { props: {
privateKey: String, privateKey: String,
address: String address: String,
}, },
data: function () { data: function () {
return { return {
showPassword: false, showPassword: false,
password: '', password: '',
loading: false loading: false,
}; };
}, },
watch: { watch: {
privateKey: function () { privateKey: function () {
this.password = ''; // Reset password when new address is generated this.password = ''; // Reset password when new address is generated
} },
}, },
methods: { methods: {
save() { save() {
if (this.password) { if (this.password) {
this.loading = true; this.loading = true;
this.$root.$emit('event', 'Download');
setTimeout(() => { setTimeout(() => {
const wallet = this.generateWallet(this.privateKey, this.password); const wallet = this.generateWallet(this.privateKey, this.password);
const fileName = 'UTC--' + new Date().toISOString().replace(/:/g, '-') + '--' + this.address; const fileName = 'UTC--' + new Date().toISOString().replace(/:/g, '-') + '--' + this.address;
@ -66,7 +74,7 @@
address: this.address, address: this.address,
crypto: this.encryptPrivateKey(privateKey, password), crypto: this.encryptPrivateKey(privateKey, password),
id: v4(), id: v4(),
version: 3 version: 3,
}; };
}, },
@ -80,10 +88,10 @@
encryptPrivateKey(privateKey, password) { encryptPrivateKey(privateKey, password) {
const iv = CryptoJS.lib.WordArray.random(16); const iv = CryptoJS.lib.WordArray.random(16);
const salt = CryptoJS.lib.WordArray.random(32); const salt = CryptoJS.lib.WordArray.random(32);
const key = CryptoJS.PBKDF2(password, salt, { // eslint-disable-line new-cap const key = CryptoJS.PBKDF2(password, salt, {
keySize: 8, keySize: 8,
hasher: CryptoJS.algo.SHA256, hasher: CryptoJS.algo.SHA256,
iterations: 262144 iterations: 262144,
}); });
const cipher = CryptoJS.AES.encrypt( const cipher = CryptoJS.AES.encrypt(
CryptoJS.enc.Hex.parse(privateKey.toString('hex')), CryptoJS.enc.Hex.parse(privateKey.toString('hex')),
@ -91,24 +99,24 @@
{ {
iv: iv, iv: iv,
mode: CryptoJS.mode.CTR, mode: CryptoJS.mode.CTR,
padding: CryptoJS.pad.NoPadding padding: CryptoJS.pad.NoPadding,
} }
); );
// eslint-disable-next-line new-cap // eslint-disable-next-line new-cap
const mac = CryptoJS.SHA3(this.sliceWordArray(key, 4, 8).concat(cipher.ciphertext), { const mac = CryptoJS.SHA3(this.sliceWordArray(key, 4, 8).concat(cipher.ciphertext), {
outputLength: 256 outputLength: 256,
}); });
return { return {
kdf: 'pbkdf2', kdf: 'pbkdf2',
kdfparams: {c: 262144, dklen: 32, prf: 'hmac-sha256', salt: salt.toString()}, kdfparams: { c: 262144, dklen: 32, prf: 'hmac-sha256', salt: salt.toString() },
cipher: 'aes-128-ctr', cipher: 'aes-128-ctr',
ciphertext: cipher.ciphertext.toString(), ciphertext: cipher.ciphertext.toString(),
cipherparams: {iv: iv.toString()}, cipherparams: { iv: iv.toString() },
mac: mac.toString() mac: mac.toString(),
}; };
} },
} },
}; };
</script> </script>