2022-09-05 16:57:11 -04:00
|
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
exports.recoverAddress = exports.computeAddress = void 0;
|
|
|
|
const index_js_1 = require("../address/index.js");
|
|
|
|
const index_js_2 = require("../crypto/index.js");
|
2023-01-28 01:53:29 -05:00
|
|
|
/**
|
|
|
|
* Returns the address for the %%key%%.
|
|
|
|
*
|
|
|
|
* The key may be any standard form of public key or a private key.
|
|
|
|
*/
|
2022-09-05 16:57:11 -04:00
|
|
|
function computeAddress(key) {
|
2022-10-20 05:03:32 -04:00
|
|
|
let pubkey;
|
|
|
|
if (typeof (key) === "string") {
|
|
|
|
pubkey = index_js_2.SigningKey.computePublicKey(key, false);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
pubkey = key.publicKey;
|
|
|
|
}
|
|
|
|
return (0, index_js_1.getAddress)((0, index_js_2.keccak256)("0x" + pubkey.substring(4)).substring(26));
|
2022-09-05 16:57:11 -04:00
|
|
|
}
|
|
|
|
exports.computeAddress = computeAddress;
|
2023-01-28 01:53:29 -05:00
|
|
|
/**
|
|
|
|
* Returns the recovered address for the private key that was
|
|
|
|
* used to sign %%digest%% that resulted in %%signature%%.
|
|
|
|
*/
|
2022-09-05 16:57:11 -04:00
|
|
|
function recoverAddress(digest, signature) {
|
|
|
|
return computeAddress(index_js_2.SigningKey.recoverPublicKey(digest, signature));
|
|
|
|
}
|
|
|
|
exports.recoverAddress = recoverAddress;
|
|
|
|
//# sourceMappingURL=address.js.map
|