Skip to content

Commit

Permalink
compressed public key
Browse files Browse the repository at this point in the history
  • Loading branch information
bokkypoobah committed Apr 16, 2024
1 parent 2634a4f commit dd0ffff
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions docs/offline.html
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@
<b-form-group label="Public Key:" label-for="output-publickey" label-size="sm" label-cols-sm="2" label-align-sm="right" class="mx-0 my-1 p-0">
<b-form-textarea size="sm" readonly id="output-publickey" :value="wallet.publicKey" rows="3" class="w-75"></b-form-textarea>
</b-form-group>
<b-form-group v-if="false" label="Compressed Public Key:" label-for="output-compressedpublickey" label-size="sm" label-cols-sm="2" label-align-sm="right" class="mx-0 my-1 p-0">
<b-form-group label="Compressed Public Key:" label-for="output-compressedpublickey" label-size="sm" label-cols-sm="2" label-align-sm="right" class="mx-0 my-1 p-0">
<b-form-input type="text" size="sm" readonly id="output-compressedpublickey" :value="wallet.compressedPublicKey" class="w-75"></b-form-input>
</b-form-group>
<b-form-group label="ETH Address:" label-for="output-address" label-size="sm" label-cols-sm="2" label-align-sm="right" class="mx-0 my-1 p-0">
Expand Down Expand Up @@ -503,13 +503,13 @@ <h5 class="mt-3">Troubleshooting</h5>
// --- DATA ---
data: {
wallet: {
type: 'mnemonics', // 'privatekey', 'keystorefile'
type: 'privatekey', // 'mnemonics', // 'privatekey', 'keystorefile'
mnemonics: null,
keystore: null,
privateKey: null,

publicKey: null,
// compressedPublicKey: null, // TODO: ethers.js returns a error
compressedPublicKey: null,
address: null,
},

Expand Down Expand Up @@ -954,27 +954,24 @@ <h5 class="mt-3">Troubleshooting</h5>
async recomputeWallet() {
console.log(moment().format("HH:mm:ss") + " recomputeWallet: " + JSON.stringify(this.wallet));
if (this.wallet.type == 'privatekey') {
console.log(moment().format("HH:mm:ss") + " recomputeWallet - privatekey: " + JSON.stringify(this.wallet));
try {
const wallet = new ethers.Wallet(this.wallet.privateKey);
this.wallet.address = wallet.address;
this.wallet.publicKey = wallet.publicKey;
// TODO: ethers.js returns an error
// this.wallet.compressedPublicKey = wallet.compressedPublicKey || 'ethers.js returning an error';
console.table(wallet);
this.wallet.compressedPublicKey = ethers.utils.computePublicKey(wallet.publicKey, true);
} catch (e) {
console.log(moment().format("HH:mm:ss") + " recomputeWallet ERROR: " + e.message);
console.log(moment().format("HH:mm:ss") + " recomputeWallet - privatekey ERROR: " + e.message);
}
} else if (this.wallet.type == 'mnemonics') {
console.log(moment().format("HH:mm:ss") + " recomputeWallet - mnemonics: " + JSON.stringify(this.wallet));
try {
const wallet = new ethers.Wallet.fromMnemonic(this.wallet.mnemonics);
this.wallet.address = wallet.address;
this.wallet.publicKey = wallet.publicKey;
// TODO: ethers.js returns an error
// this.wallet.compressedPublicKey = wallet.compressedPublicKey || 'ethers.js returning an error';
console.table(wallet);
this.wallet.compressedPublicKey = ethers.utils.computePublicKey(wallet.publicKey, true);
} catch (e) {
console.log(moment().format("HH:mm:ss") + " recomputeWallet ERROR: " + e.message);
console.log(moment().format("HH:mm:ss") + " recomputeWallet - mnemonics ERROR: " + e.message);
}
} else if (this.wallet.type == 'keystorefile'){
console.log(moment().format("HH:mm:ss") + " recomputeWallet - keystorefile: " + JSON.stringify(this.wallet));
Expand Down

0 comments on commit dd0ffff

Please sign in to comment.