ethereumjs-util#toRpcSig TypeScript Examples
The following examples show how to use
ethereumjs-util#toRpcSig.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ethsign.page.ts From Elastos.Essentials.App with MIT License | 6 votes |
async confirmSign(): Promise<void> {
const payPassword = await this.authService.getWalletPassword(this.networkWallet.masterWallet.id, true, true);
if (payPassword === null) { // cancelled by user
await this.cancelOperation();
return;
}
let privateKeyHexNoprefix = await this.walletManager.spvBridge.exportETHSCPrivateKey(jsToSpvWalletId(this.networkWallet.masterWallet.id), this.evmSubWallet.id, payPassword);
let privateKey = Buffer.from(privateKeyHexNoprefix, "hex");
// Implementation taken from Metamask unsafe signing:
// https://github.com/MetaMask/eth-simple-keyring/blob/main/index.js
try {
const message = stripHexPrefix(this.payloadToBeSigned);
const msgSig = ecsign(Buffer.from(message, 'hex'), privateKey);
const rawMsgSig = toRpcSig(msgSig.v, msgSig.r, msgSig.s);
void this.sendIntentResponse({
signedData: rawMsgSig
}, this.receivedIntent.intentId);
}
catch (e) {
// Sign method can throw exception in case some provided content has an invalid format
// i.e.: array value, with "address" type. In such case, we fail silently.
Logger.warn('wallet', 'eth_sign intent error:', e)
await this.sendIntentResponse(
{ data: null },
this.receivedIntent.intentId
);
}
}
Example #2
Source File: BloomVaultStorageService.ts From affinidi-core-sdk with Apache License 2.0 | 5 votes |
/* istanbul ignore next: ethereumjs-util */
private _signByVaultKeys(message: string, privateKey: string) {
const sig = ecsign(hashPersonalMessage(Buffer.from(message)), Buffer.from(privateKey, 'hex'))
return toRpcSig(sig.v, sig.r, sig.s)
}