You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
808 B
25 lines
808 B
import { getAddress } from "../address/index.js"; |
|
import { keccak256, SigningKey } from "../crypto/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) { |
|
let pubkey; |
|
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, signature) { |
|
return computeAddress(SigningKey.recoverPublicKey(digest, signature)); |
|
} |
|
//# sourceMappingURL=address.js.map
|