How to use the @arkecosystem/crypto.crypto.getKeys function in @arkecosystem/crypto

To help you get started, we’ve selected a few @arkecosystem/crypto examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ArkEcosystem / core / packages / core-test-utils / fixtures / testnet / delegates.js View on Github external
module.exports = delegatesConfig.secrets.map(secret => {
  const publicKey = crypto.getKeys(secret).publicKey
  const address = crypto.getAddress(publicKey)
  const balance = genesisTransactions.find(
    transaction =>
      transaction.recipientId === address && transaction.type === 0,
  ).amount
  return {
    secret,
    passphrase: secret, // just an alias for delegate secret
    publicKey,
    address,
    balance,
  }
})
github ArkEcosystem / core / packages / core-tester-cli / src / commands / debug / identity.ts View on Github external
public async run(): Promise {
        const { flags } = this.parse(IdentityCommand);

        configManager.setFromPreset(flags.network as NetworkName);

        let output;

        if (flags.type === "passphrase") {
            const keys = crypto.getKeys(flags.data);
            output = {
                passphrase: flags.data,
                publicKey: keys.publicKey,
                privateKey: keys.privateKey,
                address: crypto.getAddress(keys.publicKey),
            };
        } else if (flags.type === "privateKey") {
            const keys = crypto.getKeysByPrivateKey(flags.data);
            output = {
                publicKey: keys.publicKey,
                privateKey: keys.privateKey,
                address: crypto.getAddress(keys.publicKey),
            };
        } else if (flags.type === "publicKey") {
            output = {
                publicKey: flags.data,
github ArkEcosystem / core / packages / core-tester-cli / lib / commands / transfer.js View on Github external
async run(options) {
    this.options = { ...this.options, ...options }

    const primaryAddress = crypto.getAddress(
      crypto.getKeys(this.config.passphrase).publicKey,
      this.config.network.version,
    )

    let wallets = this.options.wallets
    if (wallets === undefined) {
      wallets = this.generateWallets()
    }

    logger.info(
      `Sending ${wallets.length} transfer ${pluralize(
        'transaction',
        wallets.length,
        true,
      )}`,
    )
github ArkEcosystem / core / __tests__ / utils / generators / transactions.ts View on Github external
let secondPassphrase;
    if (typeof passphrase === "object") {
        secondPassphrase = passphrase.secondPassphrase;
        passphrase = passphrase.passphrase;
    }

    client.getConfigManager().setFromPreset(network);

    const transactions = [];
    for (let i = 0; i < quantity; i++) {
        let builder: any = client.getBuilder();
        switch (type) {
            case Transfer: {
                if (!addressOrPublicKeyOrUsername) {
                    addressOrPublicKeyOrUsername = crypto.getAddress(crypto.getKeys(passphrase).publicKey);
                }
                builder = builder
                    .transfer()
                    .recipientId(addressOrPublicKeyOrUsername)
                    .amount(amount)
                    .vendorField(`Test Transaction ${i + 1}`);
                break;
            }
            case SecondSignature: {
                builder = builder.secondSignature().signatureAsset(passphrase);
                break;
            }
            case DelegateRegistration: {
                const username =
                    addressOrPublicKeyOrUsername ||
                    superheroes
github ArkEcosystem / core / packages / core-tester-cli / src / commands / transfer.ts View on Github external
public async run(): Promise {
        await this.initialize(TransferCommand);

        const primaryAddress = crypto.getAddress(
            crypto.getKeys(this.config.passphrase).publicKey,
            this.config.network.version,
        );

        let wallets = this.options.wallets;
        if (wallets === undefined) {
            wallets = this.generateWallets();
        }

        logger.info(`Sending ${wallets.length} transfer ${pluralize("transaction", wallets.length)}`);

        const walletBalance = await this.getWalletBalance(primaryAddress);

        if (!this.options.skipValidation) {
            logger.info(`Sender starting balance: ${satoshiToArk(walletBalance)}`);
        }
github ArkEcosystem / core / __tests__ / utils / generators / wallets.ts View on Github external
export const generateWallets = (network, quantity = 10) => {
    network = network || "testnet";
    if (!["testnet", "mainnet", "devnet", "unitnet"].includes(network)) {
        throw new Error("Invalid network");
    }

    client.getConfigManager().setFromPreset(network);

    const wallets = [];
    for (let i = 0; i < quantity; i++) {
        const passphrase = bip39.generateMnemonic();
        const publicKey = crypto.getKeys(passphrase).publicKey;
        const address = crypto.getAddress(publicKey);

        wallets.push({ address, passphrase, publicKey });
    }

    return wallets;
};
github ArkEcosystem / core / packages / core-deployer / src / builder / genesis-block.ts View on Github external
public __createWallet() {
        const passphrase = bip39.generateMnemonic();
        const keys = crypto.getKeys(passphrase);

        return {
            address: crypto.getAddress(keys.publicKey, this.prefixHash),
            passphrase,
            keys,
        };
    }
github ArkEcosystem / core / packages / core-json-rpc / src / server / methods / wallets / bip38 / create.ts View on Github external
async method(params) {
        try {
            const { keys, wif } = await getBIP38Wallet(params.userId, params.bip38);

            return {
                publicKey: keys.publicKey,
                address: crypto.getAddress(keys.publicKey),
                wif,
            };
        } catch (error) {
            const { publicKey, privateKey } = crypto.getKeys(bip39.generateMnemonic());

            const encryptedWIF = bip38.encrypt(Buffer.from(privateKey, "hex"), true, params.bip38 + params.userId);
            await database.set(HashAlgorithms.sha256(Buffer.from(params.userId)).toString("hex"), encryptedWIF);

            const { wif } = decryptWIF(encryptedWIF, params.userId, params.bip38);

            return {
                publicKey,
                address: crypto.getAddress(publicKey),
                wif,
            };
        }
    },
    schema: {