Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 111294x 111294x 111294x 111294x 111294x 111294x 1x 1x 1x 1x 1x 1x 77580x 77580x | import { getAddress } from "../address/index.js"; import { keccak256, SigningKey } from "../crypto/index.js"; import type { SignatureLike } from "../crypto/index.js"; import type { BytesLike } from "../utils/index.js"; /** * Returns the address for the %%key%%. * * The key may be any standard form of public key or a private key. */ export function computeAddress(key: string | SigningKey): string { let pubkey: string; if (typeof(key) === "string") { pubkey = SigningKey.computePublicKey(key, false); } else { pubkey = key.publicKey; } return getAddress(keccak256("0x" + pubkey.substring(4)).substring(26)); } /** * Returns the recovered address for the private key that was * used to sign %%digest%% that resulted in %%signature%%. */ export function recoverAddress(digest: BytesLike, signature: SignatureLike): string { return computeAddress(SigningKey.recoverPublicKey(digest, signature)); } |