1 | /// <reference types="node" />
|
2 | import { BNLike } from './types';
|
3 | export interface ECDSASignature {
|
4 | v: number;
|
5 | r: Buffer;
|
6 | s: Buffer;
|
7 | }
|
8 | export interface ECDSASignatureBuffer {
|
9 | v: Buffer;
|
10 | r: Buffer;
|
11 | s: Buffer;
|
12 | }
|
13 | /**
|
14 | * Returns the ECDSA signature of a message hash.
|
15 | */
|
16 | export declare function ecsign(msgHash: Buffer, privateKey: Buffer, chainId?: number): ECDSASignature;
|
17 | export declare function ecsign(msgHash: Buffer, privateKey: Buffer, chainId: BNLike): ECDSASignatureBuffer;
|
18 | /**
|
19 | * ECDSA public key recovery from signature.
|
20 | * NOTE: Accepts `v == 0 | v == 1` for EIP1559 transactions
|
21 | * @returns Recovered public key
|
22 | */
|
23 | export declare const ecrecover: (msgHash: Buffer, v: BNLike, r: Buffer, s: Buffer, chainId?: BNLike) => Buffer;
|
24 | /**
|
25 | * Convert signature parameters into the format of `eth_sign` RPC method.
|
26 | * NOTE: Accepts `v == 0 | v == 1` for EIP1559 transactions
|
27 | * @returns Signature
|
28 | */
|
29 | export declare const toRpcSig: (v: BNLike, r: Buffer, s: Buffer, chainId?: BNLike) => string;
|
30 | /**
|
31 | * Convert signature parameters into the format of Compact Signature Representation (EIP-2098).
|
32 | * NOTE: Accepts `v == 0 | v == 1` for EIP1559 transactions
|
33 | * @returns Signature
|
34 | */
|
35 | export declare const toCompactSig: (v: BNLike, r: Buffer, s: Buffer, chainId?: BNLike) => string;
|
36 | /**
|
37 | * Convert signature format of the `eth_sign` RPC method to signature parameters
|
38 | * NOTE: all because of a bug in geth: https://github.com/ethereum/go-ethereum/issues/2053
|
39 | * NOTE: After EIP1559, `v` could be `0` or `1` but this function assumes
|
40 | * it's a signed message (EIP-191 or EIP-712) adding `27` at the end. Remove if needed.
|
41 | */
|
42 | export declare const fromRpcSig: (sig: string) => ECDSASignature;
|
43 | /**
|
44 | * Validate a ECDSA signature.
|
45 | * NOTE: Accepts `v == 0 | v == 1` for EIP1559 transactions
|
46 | * @param homesteadOrLater Indicates whether this is being used on either the homestead hardfork or a later one
|
47 | */
|
48 | export declare const isValidSignature: (v: BNLike, r: Buffer, s: Buffer, homesteadOrLater?: boolean, chainId?: BNLike) => boolean;
|
49 | /**
|
50 | * Returns the keccak-256 hash of `message`, prefixed with the header used by the `eth_sign` RPC call.
|
51 | * The output of this function can be fed into `ecsign` to produce the same signature as the `eth_sign`
|
52 | * call for a given `message`, or fed to `ecrecover` along with a signature to recover the public key
|
53 | * used to produce the signature.
|
54 | */
|
55 | export declare const hashPersonalMessage: (message: Buffer) => Buffer;
|