PHP WebShell

Текущая директория: /opt/BitGoJS/node_modules/@polkadot/keyring/cjs/pair

Просмотр файла: encode.js

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.encodePair = encodePair;
const util_1 = require("@polkadot/util");
const util_crypto_1 = require("@polkadot/util-crypto");
const defaults_js_1 = require("./defaults.js");
/**
 * Encode a pair with the latest generation format (generation 3)
 **/
function encodePair({ publicKey, secretKey }, passphrase) {
    if (!secretKey) {
        throw new Error('Expected a valid secretKey to be passed to encode');
    }
    const encoded = (0, util_1.u8aConcat)(defaults_js_1.PAIR_HDR, secretKey, defaults_js_1.PAIR_DIV, publicKey);
    if (!passphrase) {
        return encoded;
    }
    // this is only for generation 3 (previous generations are only handled in decoding)
    const { params, password, salt } = (0, util_crypto_1.scryptEncode)(passphrase);
    const { encrypted, nonce } = (0, util_crypto_1.naclEncrypt)(encoded, password.subarray(0, 32));
    return (0, util_1.u8aConcat)((0, util_crypto_1.scryptToU8a)(salt, params), nonce, encrypted);
}

Выполнить команду


Для локальной разработки. Не используйте в интернете!