How to use the @waves/waves-transactions.libs.crypto function in @waves/waves-transactions

To help you get started, we’ve selected a few @waves/waves-transactions 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 wavesplatform / WavesGUI / src / modules / fromBackup / controllers / FromBackupCtrl.js View on Github external
() => {
                            const fileData = libs.crypto
                                .bytesToString(libs.crypto.base64Decode(reader.result.split(',')[1]));

                            this.backup = FromBackupCtrl.parseUsers(fileData);
                            this.readError = null;
                        }
                    ).catch(() => {
github wavesplatform / waveskeeper / src / controllers / Statistics.js View on Github external
static createUserId() {
        const date = Date.now();
        const random = Math.round(Math.random() * 1000000000);
        return libs.crypto.base58Encode(libs.crypto.sha256(libs.crypto.stringToBytes(`${date}-${random}`)));
    }
github wavesplatform / WavesGUI / src / modules / utils / modals / settings / SettingsCtrl.js View on Github external
]).then(([seed, privateKey, publicKey, encodedSeed]) => {

                    let canSeed = encodedSeed && seed && typeof seed === 'string';

                    try {
                        canSeed = canSeed && libs.crypto.stringToBytes(seed)
                            .join(',') === libs.crypto.base58Decode(encodedSeed).join(',');
                    } catch (e) {
                        canSeed = false;
                    }

                    this.phrase = canSeed ? seed : null;
                    this.encodedSeed = encodedSeed;
                    this.privateKey = privateKey;
                    this.publicKey = publicKey;
                    this.allowParing = canSeed;
                    $scope.$digest();
                });
            }
github wavesplatform / waveskeeper / src / ui / utils / waves.ts View on Github external
export function networkByteFromAddress(address: string): string {
    return String.fromCharCode(libs.crypto.base58Decode(address)[1]);
}
github wavesplatform / WavesGUI / src / modules / app / services / MultiAccount.js View on Github external
(() => {
    'use strict';

    const { libs } = require('@waves/waves-transactions');
    const {
        encryptSeed,
        decryptSeed,
        base58Encode,
        base58Decode,
        blake2b,
        stringToBytes,
        address: buildAddress,
        publicKey: buildPublicKey
    } = libs.crypto;

    let _password;
    let _rounds;
    let _users = {};

    class MultiAccount {

        get isSignedIn() {
            return !!_password;
        }

        signUp(password, rounds) {
            _password = password;
            _rounds = rounds;
            _users = {};
github wavesplatform / WavesGUI / src / modules / app / initialize / AppRun.js View on Github external
(function () {
    'use strict';

    const onContentLoad = new Promise((resolve) => {
        document.addEventListener('DOMContentLoaded', resolve);
    });

    const { Money } = require('@waves/data-entities');
    const { libs } = require('@waves/waves-transactions');
    const { base64Encode, blake2b, stringToBytes } = libs.crypto;

    const locationHref = location.href;
    const i18next = require('i18next');
    const ds = require('data-service');
    const { propEq, where, gte, lte, equals, __ } = require('ramda');

    const i18nextReady = new Promise(resolve => {
        const handler = data => {
            resolve(data);
            i18next.off('initialized', handler);
        };
        i18next.on('initialized', handler);
    });

    const PROGRESS_MAP = {
        RUN_SCRIPT: 10,
github wavesplatform / WavesGUI / src / modules / app / services / waves / matcher / Matcher.js View on Github external
(function () {
    'use strict';

    const ds = require('data-service');
    const { Money } = require('@waves/data-entities');
    const { BigNumber } = require('@waves/bignumber');
    const { currentCreateOrderFactory } = require('@waves/signature-adapter');
    const { libs } = require('@waves/waves-transactions');
    const { address } = libs.crypto;

    /**
     * @param {app.utils} utils
     * @param {app.utils.decorators} decorators
     * @param {User} user
     * @param {PollCache} PollCache
     * @param {ConfigService} configService
     * @return {Matcher}
     */
    const factory = function (utils, decorators, user, PollCache, configService) {

        /**
         * @class
         */
        class Matcher {
github wavesplatform / WavesGUI / src / modules / utils / services / utils.js View on Github external
(function () {
    'use strict';

    const { isEmpty, getPaths, get, Signal } = require('ts-utils');
    const tsApiValidator = require('ts-api-validator');
    const { splitEvery, pipe, path, map, ifElse, concat, defaultTo, identity, isNil, propEq } = require('ramda');
    const { WindowAdapter, Bus } = require('@waves/waves-browser-bus');
    const { libs } = require('@waves/waves-transactions');
    const { base58Decode, base58Encode, stringToBytes, bytesToString } = libs.crypto;
    const ds = require('data-service');
    const { SIGN_TYPE } = require('@waves/signature-adapter');
    const { Money } = require('@waves/data-entities');
    const { STATUS_LIST } = require('@waves/oracle-data');
    const { BigNumber } = require('@waves/bignumber');

    const GOOD_COLORS_LIST = [
        '#39a12c',
        '#6a737b',
        '#e49616',
        '#008ca7',
        '#ff5b38',
        '#ff6a00',
        '#c74124',
        '#00a78e',
        '#b01e53',
github wavesplatform / WavesGUI / src / modules / fromBackup / controllers / FromBackupCtrl.js View on Github external
const backup = JSON.parse(data);

                if (!backup || (backup.type !== 'wavesBackup' || !backup.lastOpenVersion)) {
                    throw new Error('wrongFile');
                }

                const dataObject = JSON.parse(
                    libs.crypto.bytesToString(libs.crypto.base64Decode(backup.data))
                );

                const hashSum = dataObject.hashSum;

                delete dataObject.hashSum;

                const savedDataHash = libs.crypto.base58Encode(
                    libs.crypto.sha256(libs.crypto.stringToBytes(JSON.stringify(dataObject)))
                );

                if (savedDataHash !== hashSum) {
                    throw new Error('Fail is corrupted');
                }

                return {
                    ...dataObject,
                    type: backup.type,
                    lastOpenVersion: backup.lastOpenVersion
                };
            }