1import * as secp256k1 from 'secp256k1';
3import { keccak256, WALLET_TYPES } from './wallet';
5const MESSAGE = 'Bridge Authentication Token';
7function signMessage(privateKey) {
8 const { signature } = secp256k1.sign(
9 keccak256('\x19Ethereum Signed Message:\n' + MESSAGE.length + MESSAGE),
12 // add key recovery parameter
13 const ethSignature = new Uint8Array(65);
14 ethSignature.set(signature);
15 const v = (ethSignature[32] & 1) + 27;
21export const getAuthToken = ({ wallet, walletType, walletHdPath, web3 }) => {
22 if (walletType === WALLET_TYPES.METAMASK) {
23 return web3.eth.personal.sign(MESSAGE, wallet.address, '');
26 const signature = signMessage(wallet.privateKey);
28 const token = `0x${Buffer.from(signature).toString('hex')}`;
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list