forked from Qortal/qortal-ui
Remove use strict make api full esm compatible
This commit is contained in:
parent
3cc5d544a2
commit
0b2bceb842
@ -1,9 +1,9 @@
|
||||
import {Sha256} from 'asmcrypto.js'
|
||||
import { Sha256 } from 'asmcrypto.js'
|
||||
import Base58 from './api/deps/Base58'
|
||||
import Base64 from './api/deps/Base64'
|
||||
import {base58PublicKeyToAddress} from './api/wallet/base58PublicKeyToAddress'
|
||||
import {validateAddress} from './api/wallet/validateAddress'
|
||||
import {decryptChatMessage, decryptChatMessageBase64} from './api/transactions/chat/decryptChatMessage'
|
||||
import { base58PublicKeyToAddress } from './api/wallet/base58PublicKeyToAddress'
|
||||
import { validateAddress } from './api/wallet/validateAddress'
|
||||
import { decryptChatMessage, decryptChatMessageBase64 } from './api/transactions/chat/decryptChatMessage'
|
||||
import _ from 'lodash'
|
||||
|
||||
window.Sha256 = Sha256
|
||||
@ -15,8 +15,8 @@ window.validateAddress = validateAddress
|
||||
window.decryptChatMessage = decryptChatMessage
|
||||
window.decryptChatMessageBase64 = decryptChatMessageBase64
|
||||
|
||||
export { initApi, store } from './api_deps.js'
|
||||
export * from './api/deps/deps.js'
|
||||
export * from './api/api.js'
|
||||
export * from './api/registerUsername.js'
|
||||
export { createWallet } from './api/createWallet.js'
|
||||
export { initApi, store } from './api_deps'
|
||||
export * from './api/deps/deps'
|
||||
export * from './api/api'
|
||||
export * from './api/registerUsername'
|
||||
export { createWallet } from './api/createWallet'
|
||||
|
@ -1,15 +1,12 @@
|
||||
/*
|
||||
Copyright 2017-2018 @ irontiga and vbcs (original developer)
|
||||
*/
|
||||
'use strict'
|
||||
import Base58 from './deps/Base58.js'
|
||||
import {Sha256, Sha512} from 'asmcrypto.js'
|
||||
import nacl from './deps/nacl-fast.js'
|
||||
import utils from './deps/utils.js'
|
||||
|
||||
import {generateSaveWalletData} from './storeWallet.js'
|
||||
|
||||
import publicKeyToAddress from './wallet/publicKeyToAddress.js'
|
||||
import Base58 from './deps/Base58'
|
||||
import { Sha256, Sha512 } from 'asmcrypto.js'
|
||||
import nacl from './deps/nacl-fast'
|
||||
import utils from './deps/utils'
|
||||
import { generateSaveWalletData } from './storeWallet'
|
||||
import publicKeyToAddress from './wallet/publicKeyToAddress'
|
||||
import AltcoinHDWallet from "./bitcoin/AltcoinHDWallet"
|
||||
|
||||
export default class PhraseWallet {
|
||||
|
@ -1,5 +1,5 @@
|
||||
export { request } from './fetch-request.js'
|
||||
export { transactionTypes as transactions } from './transactions/transactions.js'
|
||||
export { processTransaction, processTransactionVersion2, createTransaction, computeChatNonce, signChatTransaction, signArbitraryTransaction, signArbitraryWithFeeTransaction } from './createTransaction.js'
|
||||
export { tradeBotCreateRequest, tradeBotRespondRequest, signTradeBotTxn, deleteTradeOffer, sendBtc, sendLtc, sendDoge, sendDgb, sendRvn, sendArrr } from './tradeRequest.js'
|
||||
export { cancelAllOffers } from './transactions/trade-portal/tradeoffer/cancelAllOffers.js'
|
||||
export { request } from './fetch-request'
|
||||
export { transactionTypes as transactions } from './transactions/transactions'
|
||||
export { processTransaction, processTransactionVersion2, createTransaction, computeChatNonce, signChatTransaction, signArbitraryTransaction, signArbitraryWithFeeTransaction } from './createTransaction'
|
||||
export { tradeBotCreateRequest, tradeBotRespondRequest, signTradeBotTxn, deleteTradeOffer, sendBtc, sendLtc, sendDoge, sendDgb, sendRvn, sendArrr } from './tradeRequest'
|
||||
export { cancelAllOffers } from './transactions/trade-portal/tradeoffer/cancelAllOffers'
|
||||
|
@ -1,10 +1,9 @@
|
||||
'use strict';
|
||||
import Base58 from '../deps/Base58.js'
|
||||
import {Sha256, Sha512} from 'asmcrypto.js'
|
||||
import Base58 from '../deps/Base58'
|
||||
import { Sha256, Sha512 } from 'asmcrypto.js'
|
||||
import jsSHA from 'jssha'
|
||||
import RIPEMD160 from '../deps/ripemd160.js'
|
||||
import utils from '../deps/utils.js'
|
||||
import {BigInteger, EllipticCurve} from './ecbn.js'
|
||||
import RIPEMD160 from '../deps/ripemd160'
|
||||
import utils from '../deps/utils'
|
||||
import { BigInteger, EllipticCurve } from './ecbn'
|
||||
|
||||
export default class AltcoinHDWallet {
|
||||
|
||||
@ -246,12 +245,11 @@ export default class AltcoinHDWallet {
|
||||
if (isBIP44) {
|
||||
buffer = utils.appendBuffer(seed.reverse(), utils.int32ToBytes(indicator))
|
||||
} else {
|
||||
if(indicator !== null) {
|
||||
if (indicator !== null) {
|
||||
const indicatorString = utils.stringtoUTF8Array(indicator)
|
||||
buffer = utils.appendBuffer(seed.reverse(), indicatorString)
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
buffer = seed.reverse()
|
||||
}
|
||||
}
|
||||
@ -335,8 +333,8 @@ export default class AltcoinHDWallet {
|
||||
s.push(0)
|
||||
|
||||
//if the private key length is less than 32 let's add leading zeros
|
||||
if(this.privateKey.length<32){
|
||||
for(let i=this.privateKey.length;i<32;i++){
|
||||
if (this.privateKey.length < 32) {
|
||||
for (let i = this.privateKey.length; i < 32; i++) {
|
||||
s.push(0)
|
||||
}
|
||||
}
|
||||
@ -506,7 +504,6 @@ export default class AltcoinHDWallet {
|
||||
const childPublicKeySHA256 = new Sha256().process(new Uint8Array(this.childPublicKey)).finish().result
|
||||
this.childPublicKeyHash = new RIPEMD160().update(Buffer.from(childPublicKeySHA256)).digest('hex')
|
||||
|
||||
|
||||
// Call deriveExtendedPublicChildKey // WIll be hardcoding the values...
|
||||
deriveExtendedPublicChildKey(1, 0)
|
||||
}
|
||||
@ -524,15 +521,12 @@ export default class AltcoinHDWallet {
|
||||
const _hmacSha512 = new jsSHA("SHA-512", "UINT8ARRAY", { numRounds: 1, hmacKey: { value: this.chainCode, format: "UINT8ARRAY" } })
|
||||
_hmacSha512.update(new Uint8Array(s))
|
||||
|
||||
|
||||
const IL = BigInteger.fromByteArrayUnsigned([..._hmacSha512.getHMAC('UINT8ARRAY').slice(0, 32)])
|
||||
this.childChainCode = _hmacSha512.getHMAC('UINT8ARRAY').slice(32, 64) // IR according to the SPEC
|
||||
|
||||
|
||||
// SECP256k1 init
|
||||
const epCurve = EllipticCurve.getSECCurveByName("secp256k1")
|
||||
|
||||
|
||||
const ki = IL.add(BigInteger.fromByteArrayUnsigned(this.privateKey)).mod(epCurve.getN()) // parse256(IL) + kpar (mod n) ==> ki
|
||||
this.childPrivateKey = ki.toByteArrayUnsigned()
|
||||
|
||||
@ -653,7 +647,6 @@ export default class AltcoinHDWallet {
|
||||
this.grandChildPublicKey.unshift(0x03) // append point indicator
|
||||
}
|
||||
|
||||
|
||||
// PublicKey Hash
|
||||
const grandChildPublicKeySHA256 = new Sha256().process(new Uint8Array(this.grandChildPublicKey)).finish().result
|
||||
this.grandChildPublicKeyHash = new RIPEMD160().update(Buffer.from(grandChildPublicKeySHA256)).digest('hex')
|
||||
@ -734,7 +727,6 @@ export default class AltcoinHDWallet {
|
||||
deriveExtendedPrivateGrandChildKey(2, 0)
|
||||
}
|
||||
|
||||
|
||||
const deriveExtendedPrivateGrandChildKey = (i, childIndex) => {
|
||||
|
||||
// Serialization Variable
|
||||
@ -816,8 +808,6 @@ export default class AltcoinHDWallet {
|
||||
this.xPublicGrandChildKey = Base58.encode(s)
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Hard Code value..
|
||||
let childIndex = 0
|
||||
|
||||
@ -845,10 +835,6 @@ export default class AltcoinHDWallet {
|
||||
_tDerivedMasterPrivateKey: this._tMasterPrivateKey,
|
||||
_tDerivedmasterPublicKey: this._tmasterPublicKey,
|
||||
seed58: this.seed58,
|
||||
// derivedPrivateChildKey: this.xPrivateChildKey,
|
||||
// derivedPublicChildKey: this.xPublicChildKey,
|
||||
// derivedPrivateGrandChildKey: this.xPrivateGrandChildKey,
|
||||
// derivedPublicGrandChildKey: this.xPublicGrandChildKey,
|
||||
address: this.litecoinLegacyAddress,
|
||||
_taddress: this._tlitecoinLegacyAddress
|
||||
}
|
||||
|
@ -6,8 +6,6 @@
|
||||
*/
|
||||
|
||||
(function () {
|
||||
|
||||
|
||||
// Copyright (c) 2005 Tom Wu
|
||||
// All Rights Reserved.
|
||||
// See "LICENSE" for details.
|
||||
@ -1862,8 +1860,6 @@
|
||||
}
|
||||
rng_pptr = 0;
|
||||
rng_seed_time();
|
||||
//rng_seed_int(window.screenX);
|
||||
//rng_seed_int(window.screenY);
|
||||
}
|
||||
|
||||
function rng_get_byte() {
|
||||
@ -1874,7 +1870,6 @@
|
||||
for (rng_pptr = 0; rng_pptr < rng_pool.length; ++rng_pptr)
|
||||
rng_pool[rng_pptr] = 0;
|
||||
rng_pptr = 0;
|
||||
//rng_pool = null;
|
||||
}
|
||||
// TODO: allow reseeding after first request
|
||||
return rng_state.next();
|
||||
@ -1890,7 +1885,6 @@
|
||||
SecureRandom.prototype.nextBytes = rng_get_bytes;
|
||||
|
||||
// prng4.js - uses Arcfour as a PRNG
|
||||
|
||||
function Arcfour() {
|
||||
this.i = 0;
|
||||
this.j = 0;
|
||||
@ -1934,9 +1928,6 @@
|
||||
// An array of bytes the size of the pool will be passed to init()
|
||||
var rng_psize = 256;
|
||||
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
* Basic Javascript Elliptic Curve implementation
|
||||
* Ported loosely from BouncyCastle's Java EC code
|
||||
@ -1949,7 +1940,6 @@
|
||||
// Constructor function of Global EllipticCurve object
|
||||
var ec = function () { };
|
||||
|
||||
|
||||
// ----------------
|
||||
// ECFieldElementFp constructor
|
||||
// q instanceof BigInteger
|
||||
@ -2391,7 +2381,6 @@
|
||||
|
||||
return R;
|
||||
};
|
||||
|
||||
ec.PointFp.prototype.isOnCurve = function () {
|
||||
var x = this.getX().toBigInteger();
|
||||
var y = this.getY().toBigInteger();
|
||||
@ -2444,9 +2433,6 @@
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
// ----------------
|
||||
// ECCurveFp constructor
|
||||
ec.CurveFp = function (q, a, b) {
|
||||
|
@ -1853,8 +1853,6 @@
|
||||
}
|
||||
rng_pptr = 0;
|
||||
rng_seed_time();
|
||||
//rng_seed_int(window.screenX);
|
||||
//rng_seed_int(window.screenY);
|
||||
}
|
||||
|
||||
function rng_get_byte() {
|
||||
@ -1865,7 +1863,6 @@
|
||||
for (rng_pptr = 0; rng_pptr < rng_pool.length; ++rng_pptr)
|
||||
rng_pool[rng_pptr] = 0;
|
||||
rng_pptr = 0;
|
||||
//rng_pool = null;
|
||||
}
|
||||
// TODO: allow reseeding after first request
|
||||
return rng_state.next();
|
||||
|
@ -1,5 +1,3 @@
|
||||
'use strict'
|
||||
|
||||
// Qortal TX types
|
||||
const TX_TYPES = {
|
||||
1: "Genesis",
|
||||
|
@ -1,9 +1,9 @@
|
||||
import {transactionTypes as transactions} from './transactions/transactions.js'
|
||||
import Base58 from './deps/Base58.js'
|
||||
import {request} from './fetch-request'
|
||||
import signChat from './transactions/chat/signChat.js'
|
||||
import signArbitrary from './transactions/arbitrary/signArbitrary.js'
|
||||
import signArbitraryWithFee from './transactions/arbitrary/signArbitraryWithFee.js'
|
||||
import { transactionTypes as transactions } from './transactions/transactions'
|
||||
import Base58 from './deps/Base58'
|
||||
import { request } from './fetch-request'
|
||||
import signChat from './transactions/chat/signChat'
|
||||
import signArbitrary from './transactions/arbitrary/signArbitrary'
|
||||
import signArbitraryWithFee from './transactions/arbitrary/signArbitraryWithFee'
|
||||
|
||||
export const createTransaction = (type, keyPair, params) => {
|
||||
const tx = new transactions[type]()
|
||||
|
@ -1,7 +1,7 @@
|
||||
import {kdf} from './kdf.js'
|
||||
import PhraseWallet from './PhraseWallet.js'
|
||||
import Base58 from './deps/Base58.js'
|
||||
import {decryptStoredWallet} from './decryptStoredWallet.js'
|
||||
import { kdf } from './kdf'
|
||||
import PhraseWallet from './PhraseWallet'
|
||||
import Base58 from './deps/Base58'
|
||||
import { decryptStoredWallet } from './decryptStoredWallet'
|
||||
|
||||
export const createWallet = async (sourceType, source, statusUpdateFn) => {
|
||||
let version, seed
|
||||
|
@ -1,7 +1,7 @@
|
||||
import Base58 from './deps/Base58.js'
|
||||
import {kdf} from './kdf.js'
|
||||
import {AES_CBC, HmacSha512} from 'asmcrypto.js'
|
||||
import {get, registerTranslateConfig} from '../../core/translate'
|
||||
import Base58 from './deps/Base58'
|
||||
import { kdf } from './kdf'
|
||||
import { AES_CBC, HmacSha512 } from 'asmcrypto.js'
|
||||
import { get, registerTranslateConfig } from '../../core/translate'
|
||||
|
||||
registerTranslateConfig({
|
||||
loader: lang => fetch(`/language/${lang}.json`).then(res => res.json())
|
||||
|
@ -1,10 +1,6 @@
|
||||
// Generated by CoffeeScript 1.8.0
|
||||
|
||||
// == Changed for ES6 modules == //
|
||||
//(function() {
|
||||
//var ALPHABET, ALPHABET_MAP, Base58, i;
|
||||
|
||||
//const Base58 = (typeof module !== "undefined" && module !== null ? module.exports : void 0) || (window.Base58 = {});
|
||||
const Base58 = {};
|
||||
|
||||
const ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
||||
@ -14,21 +10,21 @@ const ALPHABET_MAP = {};
|
||||
let i = 0;
|
||||
|
||||
while (i < ALPHABET.length) {
|
||||
ALPHABET_MAP[ALPHABET.charAt(i)] = i;
|
||||
i++;
|
||||
ALPHABET_MAP[ALPHABET.charAt(i)] = i;
|
||||
i++;
|
||||
}
|
||||
|
||||
Base58.encode = function(buffer) {
|
||||
buffer = new Uint8Array(buffer);
|
||||
var carry, digits, j;
|
||||
if (buffer.length === 0) {
|
||||
Base58.encode = function (buffer) {
|
||||
buffer = new Uint8Array(buffer);
|
||||
var carry, digits, j;
|
||||
if (buffer.length === 0) {
|
||||
return "";
|
||||
}
|
||||
i = void 0;
|
||||
j = void 0;
|
||||
digits = [0];
|
||||
i = 0;
|
||||
while (i < buffer.length) {
|
||||
}
|
||||
i = void 0;
|
||||
j = void 0;
|
||||
digits = [0];
|
||||
i = 0;
|
||||
while (i < buffer.length) {
|
||||
j = 0;
|
||||
while (j < digits.length) {
|
||||
digits[j] <<= 8;
|
||||
@ -48,27 +44,27 @@ while (i < buffer.length) {
|
||||
carry = (carry / 58) | 0;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
i = 0;
|
||||
while (buffer[i] === 0 && i < buffer.length - 1) {
|
||||
}
|
||||
i = 0;
|
||||
while (buffer[i] === 0 && i < buffer.length - 1) {
|
||||
digits.push(0);
|
||||
i++;
|
||||
}
|
||||
return digits.reverse().map(function(digit) {
|
||||
}
|
||||
return digits.reverse().map(function (digit) {
|
||||
return ALPHABET[digit];
|
||||
}).join("");
|
||||
}).join("");
|
||||
};
|
||||
|
||||
Base58.decode = function(string) {
|
||||
var bytes, c, carry, j;
|
||||
if (string.length === 0) {
|
||||
Base58.decode = function (string) {
|
||||
var bytes, c, carry, j;
|
||||
if (string.length === 0) {
|
||||
return new (typeof Uint8Array !== "undefined" && Uint8Array !== null ? Uint8Array : Buffer)(0);
|
||||
}
|
||||
i = void 0;
|
||||
j = void 0;
|
||||
bytes = [0];
|
||||
i = 0;
|
||||
while (i < string.length) {
|
||||
}
|
||||
i = void 0;
|
||||
j = void 0;
|
||||
bytes = [0];
|
||||
i = 0;
|
||||
while (i < string.length) {
|
||||
c = string[i];
|
||||
if (!(c in ALPHABET_MAP)) {
|
||||
throw "Base58.decode received unacceptable input. Character '" + c + "' is not in the Base58 alphabet.";
|
||||
@ -92,17 +88,14 @@ while (i < string.length) {
|
||||
carry >>= 8;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
i = 0;
|
||||
while (string[i] === "1" && i < string.length - 1) {
|
||||
}
|
||||
i = 0;
|
||||
while (string[i] === "1" && i < string.length - 1) {
|
||||
bytes.push(0);
|
||||
i++;
|
||||
}
|
||||
return new (typeof Uint8Array !== "undefined" && Uint8Array !== null ? Uint8Array : Buffer)(bytes.reverse());
|
||||
}
|
||||
return new (typeof Uint8Array !== "undefined" && Uint8Array !== null ? Uint8Array : Buffer)(bytes.reverse());
|
||||
};
|
||||
|
||||
|
||||
// == Changed for ES6 modules == //
|
||||
//}).call(this);
|
||||
|
||||
export default Base58;
|
@ -1,8 +1,6 @@
|
||||
|
||||
const Base64 = {};
|
||||
|
||||
|
||||
|
||||
Base64.decode = function (string) {
|
||||
|
||||
const binaryString = atob(string);
|
||||
@ -17,7 +15,4 @@ Base64.decode = function (string) {
|
||||
return decoder.decode(bytes);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
export default Base64;
|
||||
|
@ -31,7 +31,7 @@
|
||||
* Released under the Apache License, Version 2.0
|
||||
* see: https://github.com/dcodeIO/bcrypt.js for details
|
||||
*/
|
||||
(function(global, factory) {
|
||||
(function (global, factory) {
|
||||
|
||||
/* AMD */ if (typeof define === 'function' && define["amd"])
|
||||
define([], factory);
|
||||
@ -40,8 +40,9 @@
|
||||
/* Global */ else
|
||||
(global["dcodeIO"] = global["dcodeIO"] || {})["bcrypt"] = factory();
|
||||
|
||||
}(this, function() {
|
||||
"use strict";
|
||||
}(this, function () {
|
||||
// == Changed for ESM support == //
|
||||
// "use strict";
|
||||
|
||||
/**
|
||||
* bcrypt namespace.
|
||||
@ -68,11 +69,11 @@
|
||||
/* node */ if (typeof module !== 'undefined' && module && module['exports'])
|
||||
try {
|
||||
return require("crypto")['randomBytes'](len);
|
||||
} catch (e) {}
|
||||
} catch (e) { }
|
||||
/* WCA */ try {
|
||||
var a; (self['crypto']||self['msCrypto'])['getRandomValues'](a = new Uint32Array(len));
|
||||
var a; (self['crypto'] || self['msCrypto'])['getRandomValues'](a = new Uint32Array(len));
|
||||
return Array.prototype.slice.call(a);
|
||||
} catch (e) {}
|
||||
} catch (e) { }
|
||||
/* fallback */ if (!randomFallback)
|
||||
throw Error("Neither WebCryptoAPI nor a crypto module is available. Use bcrypt.setRandomFallback to set an alternative");
|
||||
return randomFallback(len);
|
||||
@ -83,7 +84,7 @@
|
||||
try {
|
||||
random(1);
|
||||
randomAvailable = true;
|
||||
} catch (e) {}
|
||||
} catch (e) { }
|
||||
|
||||
// Default fallback, if any
|
||||
randomFallback = null;
|
||||
@ -96,7 +97,7 @@
|
||||
* @see http://nodejs.org/api/crypto.html
|
||||
* @see http://www.w3.org/TR/WebCryptoAPI/
|
||||
*/
|
||||
bcrypt.setRandomFallback = function(random) {
|
||||
bcrypt.setRandomFallback = function (random) {
|
||||
randomFallback = random;
|
||||
};
|
||||
|
||||
@ -108,10 +109,10 @@
|
||||
* @throws {Error} If a random fallback is required but not set
|
||||
* @expose
|
||||
*/
|
||||
bcrypt.genSaltSync = function(rounds, seed_length) {
|
||||
bcrypt.genSaltSync = function (rounds, seed_length) {
|
||||
rounds = rounds || GENSALT_DEFAULT_LOG2_ROUNDS;
|
||||
if (typeof rounds !== 'number')
|
||||
throw Error("Illegal arguments: "+(typeof rounds)+", "+(typeof seed_length));
|
||||
throw Error("Illegal arguments: " + (typeof rounds) + ", " + (typeof seed_length));
|
||||
if (rounds < 4)
|
||||
rounds = 4;
|
||||
else if (rounds > 31)
|
||||
@ -135,7 +136,7 @@
|
||||
* @throws {Error} If `callback` is present but not a function
|
||||
* @expose
|
||||
*/
|
||||
bcrypt.genSalt = function(rounds, seed_length, callback) {
|
||||
bcrypt.genSalt = function (rounds, seed_length, callback) {
|
||||
if (typeof seed_length === 'function')
|
||||
callback = seed_length,
|
||||
seed_length = undefined; // Not supported.
|
||||
@ -145,10 +146,10 @@
|
||||
if (typeof rounds === 'undefined')
|
||||
rounds = GENSALT_DEFAULT_LOG2_ROUNDS;
|
||||
else if (typeof rounds !== 'number')
|
||||
throw Error("illegal arguments: "+(typeof rounds));
|
||||
throw Error("illegal arguments: " + (typeof rounds));
|
||||
|
||||
function _async(callback) {
|
||||
nextTick(function() { // Pretty thin, but salting is fast enough
|
||||
nextTick(function () { // Pretty thin, but salting is fast enough
|
||||
try {
|
||||
callback(null, bcrypt.genSaltSync(rounds));
|
||||
} catch (err) {
|
||||
@ -159,11 +160,11 @@
|
||||
|
||||
if (callback) {
|
||||
if (typeof callback !== 'function')
|
||||
throw Error("Illegal callback: "+typeof(callback));
|
||||
throw Error("Illegal callback: " + typeof (callback));
|
||||
_async(callback);
|
||||
} else
|
||||
return new Promise(function(resolve, reject) {
|
||||
_async(function(err, res) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
_async(function (err, res) {
|
||||
if (err) {
|
||||
reject(err);
|
||||
return;
|
||||
@ -180,13 +181,13 @@
|
||||
* @returns {string} Resulting hash
|
||||
* @expose
|
||||
*/
|
||||
bcrypt.hashSync = function(s, salt) {
|
||||
bcrypt.hashSync = function (s, salt) {
|
||||
if (typeof salt === 'undefined')
|
||||
salt = GENSALT_DEFAULT_LOG2_ROUNDS;
|
||||
if (typeof salt === 'number')
|
||||
salt = bcrypt.genSaltSync(salt);
|
||||
if (typeof s !== 'string' || typeof salt !== 'string')
|
||||
throw Error("Illegal arguments: "+(typeof s)+', '+(typeof salt));
|
||||
throw Error("Illegal arguments: " + (typeof s) + ', ' + (typeof salt));
|
||||
return _hash(s, salt);
|
||||
};
|
||||
|
||||
@ -201,26 +202,26 @@
|
||||
* @throws {Error} If `callback` is present but not a function
|
||||
* @expose
|
||||
*/
|
||||
bcrypt.hash = function(s, salt, callback, progressCallback) {
|
||||
bcrypt.hash = function (s, salt, callback, progressCallback) {
|
||||
|
||||
function _async(callback) {
|
||||
if (typeof s === 'string' && typeof salt === 'number')
|
||||
bcrypt.genSalt(salt, function(err, salt) {
|
||||
bcrypt.genSalt(salt, function (err, salt) {
|
||||
_hash(s, salt, callback, progressCallback);
|
||||
});
|
||||
else if (typeof s === 'string' && typeof salt === 'string')
|
||||
_hash(s, salt, callback, progressCallback);
|
||||
else
|
||||
nextTick(callback.bind(this, Error("Illegal arguments: "+(typeof s)+', '+(typeof salt))));
|
||||
nextTick(callback.bind(this, Error("Illegal arguments: " + (typeof s) + ', ' + (typeof salt))));
|
||||
}
|
||||
|
||||
if (callback) {
|
||||
if (typeof callback !== 'function')
|
||||
throw Error("Illegal callback: "+typeof(callback));
|
||||
throw Error("Illegal callback: " + typeof (callback));
|
||||
_async(callback);
|
||||
} else
|
||||
return new Promise(function(resolve, reject) {
|
||||
_async(function(err, res) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
_async(function (err, res) {
|
||||
if (err) {
|
||||
reject(err);
|
||||
return;
|
||||
@ -240,7 +241,7 @@
|
||||
function safeStringCompare(known, unknown) {
|
||||
var right = 0,
|
||||
wrong = 0;
|
||||
for (var i=0, k=known.length; i<k; ++i) {
|
||||
for (var i = 0, k = known.length; i < k; ++i) {
|
||||
if (known.charCodeAt(i) === unknown.charCodeAt(i))
|
||||
++right;
|
||||
else
|
||||
@ -260,12 +261,12 @@
|
||||
* @throws {Error} If an argument is illegal
|
||||
* @expose
|
||||
*/
|
||||
bcrypt.compareSync = function(s, hash) {
|
||||
bcrypt.compareSync = function (s, hash) {
|
||||
if (typeof s !== "string" || typeof hash !== "string")
|
||||
throw Error("Illegal arguments: "+(typeof s)+', '+(typeof hash));
|
||||
throw Error("Illegal arguments: " + (typeof s) + ', ' + (typeof hash));
|
||||
if (hash.length !== 60)
|
||||
return false;
|
||||
return safeStringCompare(bcrypt.hashSync(s, hash.substr(0, hash.length-31)), hash);
|
||||
return safeStringCompare(bcrypt.hashSync(s, hash.substr(0, hash.length - 31)), hash);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -279,18 +280,18 @@
|
||||
* @throws {Error} If `callback` is present but not a function
|
||||
* @expose
|
||||
*/
|
||||
bcrypt.compare = function(s, hash, callback, progressCallback) {
|
||||
bcrypt.compare = function (s, hash, callback, progressCallback) {
|
||||
|
||||
function _async(callback) {
|
||||
if (typeof s !== "string" || typeof hash !== "string") {
|
||||
nextTick(callback.bind(this, Error("Illegal arguments: "+(typeof s)+', '+(typeof hash))));
|
||||
nextTick(callback.bind(this, Error("Illegal arguments: " + (typeof s) + ', ' + (typeof hash))));
|
||||
return;
|
||||
}
|
||||
if (hash.length !== 60) {
|
||||
nextTick(callback.bind(this, null, false));
|
||||
return;
|
||||
}
|
||||
bcrypt.hash(s, hash.substr(0, 29), function(err, comp) {
|
||||
bcrypt.hash(s, hash.substr(0, 29), function (err, comp) {
|
||||
if (err)
|
||||
callback(err);
|
||||
else
|
||||
@ -300,11 +301,11 @@
|
||||
|
||||
if (callback) {
|
||||
if (typeof callback !== 'function')
|
||||
throw Error("Illegal callback: "+typeof(callback));
|
||||
throw Error("Illegal callback: " + typeof (callback));
|
||||
_async(callback);
|
||||
} else
|
||||
return new Promise(function(resolve, reject) {
|
||||
_async(function(err, res) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
_async(function (err, res) {
|
||||
if (err) {
|
||||
reject(err);
|
||||
return;
|
||||
@ -321,9 +322,9 @@
|
||||
* @throws {Error} If `hash` is not a string
|
||||
* @expose
|
||||
*/
|
||||
bcrypt.getRounds = function(hash) {
|
||||
bcrypt.getRounds = function (hash) {
|
||||
if (typeof hash !== "string")
|
||||
throw Error("Illegal arguments: "+(typeof hash));
|
||||
throw Error("Illegal arguments: " + (typeof hash));
|
||||
return parseInt(hash.split("$")[2], 10);
|
||||
};
|
||||
|
||||
@ -334,11 +335,11 @@
|
||||
* @throws {Error} If `hash` is not a string or otherwise invalid
|
||||
* @expose
|
||||
*/
|
||||
bcrypt.getSalt = function(hash) {
|
||||
bcrypt.getSalt = function (hash) {
|
||||
if (typeof hash !== 'string')
|
||||
throw Error("Illegal arguments: "+(typeof hash));
|
||||
throw Error("Illegal arguments: " + (typeof hash));
|
||||
if (hash.length !== 60)
|
||||
throw Error("Illegal hash length: "+hash.length+" != 60");
|
||||
throw Error("Illegal hash length: " + hash.length + " != 60");
|
||||
return hash.substring(0, 29);
|
||||
};
|
||||
|
||||
@ -361,10 +362,10 @@
|
||||
function stringToBytes(str) {
|
||||
var out = [],
|
||||
i = 0;
|
||||
utfx.encodeUTF16toUTF8(function() {
|
||||
utfx.encodeUTF16toUTF8(function () {
|
||||
if (i >= str.length) return null;
|
||||
return str.charCodeAt(i++);
|
||||
}, function(b) {
|
||||
}, function (b) {
|
||||
out.push(b);
|
||||
});
|
||||
return out;
|
||||
@ -412,7 +413,7 @@
|
||||
rs = [],
|
||||
c1, c2;
|
||||
if (len <= 0 || len > b.length)
|
||||
throw Error("Illegal len: "+len);
|
||||
throw Error("Illegal len: " + len);
|
||||
while (off < len) {
|
||||
c1 = b[off++] & 0xff;
|
||||
rs.push(BASE64_CODE[(c1 >> 2) & 0x3f]);
|
||||
@ -451,7 +452,7 @@
|
||||
rs = [],
|
||||
c1, c2, c3, c4, o, code;
|
||||
if (len <= 0)
|
||||
throw Error("Illegal len: "+len);
|
||||
throw Error("Illegal len: " + len);
|
||||
while (off < slen - 1 && olen < len) {
|
||||
code = s.charCodeAt(off++);
|
||||
c1 = code < BASE64_INDEX.length ? BASE64_INDEX[code] : -1;
|
||||
@ -481,7 +482,7 @@
|
||||
++olen;
|
||||
}
|
||||
var res = [];
|
||||
for (off = 0; off<olen; off++)
|
||||
for (off = 0; off < olen; off++)
|
||||
res.push(rs[off].charCodeAt(0));
|
||||
return res;
|
||||
}
|
||||
@ -491,8 +492,9 @@
|
||||
* Released under the Apache License, Version 2.0
|
||||
* see: https://github.com/dcodeIO/utfx for details
|
||||
*/
|
||||
var utfx = function() {
|
||||
"use strict";
|
||||
var utfx = function () {
|
||||
// == Changed for ESM support == //
|
||||
// "use strict";
|
||||
|
||||
/**
|
||||
* utfx namespace.
|
||||
@ -514,26 +516,26 @@
|
||||
* respectively `null` if there are no more code points left or a single numeric code point.
|
||||
* @param {!function(number)} dst Bytes destination as a function successively called with the next byte
|
||||
*/
|
||||
utfx.encodeUTF8 = function(src, dst) {
|
||||
utfx.encodeUTF8 = function (src, dst) {
|
||||
var cp = null;
|
||||
if (typeof src === 'number')
|
||||
cp = src,
|
||||
src = function() { return null; };
|
||||
src = function () { return null; };
|
||||
while (cp !== null || (cp = src()) !== null) {
|
||||
if (cp < 0x80)
|
||||
dst(cp&0x7F);
|
||||
dst(cp & 0x7F);
|
||||
else if (cp < 0x800)
|
||||
dst(((cp>>6)&0x1F)|0xC0),
|
||||
dst((cp&0x3F)|0x80);
|
||||
dst(((cp >> 6) & 0x1F) | 0xC0),
|
||||
dst((cp & 0x3F) | 0x80);
|
||||
else if (cp < 0x10000)
|
||||
dst(((cp>>12)&0x0F)|0xE0),
|
||||
dst(((cp>>6)&0x3F)|0x80),
|
||||
dst((cp&0x3F)|0x80);
|
||||
dst(((cp >> 12) & 0x0F) | 0xE0),
|
||||
dst(((cp >> 6) & 0x3F) | 0x80),
|
||||
dst((cp & 0x3F) | 0x80);
|
||||
else
|
||||
dst(((cp>>18)&0x07)|0xF0),
|
||||
dst(((cp>>12)&0x3F)|0x80),
|
||||
dst(((cp>>6)&0x3F)|0x80),
|
||||
dst((cp&0x3F)|0x80);
|
||||
dst(((cp >> 18) & 0x07) | 0xF0),
|
||||
dst(((cp >> 12) & 0x3F) | 0x80),
|
||||
dst(((cp >> 6) & 0x3F) | 0x80),
|
||||
dst((cp & 0x3F) | 0x80);
|
||||
cp = null;
|
||||
}
|
||||
};
|
||||
@ -547,8 +549,8 @@
|
||||
* @throws {Error} If the last sequence is truncated. Has an array property `bytes` holding the
|
||||
* remaining bytes.
|
||||
*/
|
||||
utfx.decodeUTF8 = function(src, dst) {
|
||||
var a, b, c, d, fail = function(b) {
|
||||
utfx.decodeUTF8 = function (src, dst) {
|
||||
var a, b, c, d, fail = function (b) {
|
||||
b = b.slice(0, b.indexOf(null));
|
||||
var err = Error(b.toString());
|
||||
err.name = "TruncatedError";
|
||||
@ -556,18 +558,18 @@
|
||||
throw err;
|
||||
};
|
||||
while ((a = src()) !== null) {
|
||||
if ((a&0x80) === 0)
|
||||
if ((a & 0x80) === 0)
|
||||
dst(a);
|
||||
else if ((a&0xE0) === 0xC0)
|
||||
else if ((a & 0xE0) === 0xC0)
|
||||
((b = src()) === null) && fail([a, b]),
|
||||
dst(((a&0x1F)<<6) | (b&0x3F));
|
||||
else if ((a&0xF0) === 0xE0)
|
||||
((b=src()) === null || (c=src()) === null) && fail([a, b, c]),
|
||||
dst(((a&0x0F)<<12) | ((b&0x3F)<<6) | (c&0x3F));
|
||||
else if ((a&0xF8) === 0xF0)
|
||||
((b=src()) === null || (c=src()) === null || (d=src()) === null) && fail([a, b, c ,d]),
|
||||
dst(((a&0x07)<<18) | ((b&0x3F)<<12) | ((c&0x3F)<<6) | (d&0x3F));
|
||||
else throw RangeError("Illegal starting byte: "+a);
|
||||
dst(((a & 0x1F) << 6) | (b & 0x3F));
|
||||
else if ((a & 0xF0) === 0xE0)
|
||||
((b = src()) === null || (c = src()) === null) && fail([a, b, c]),
|
||||
dst(((a & 0x0F) << 12) | ((b & 0x3F) << 6) | (c & 0x3F));
|
||||
else if ((a & 0xF8) === 0xF0)
|
||||
((b = src()) === null || (c = src()) === null || (d = src()) === null) && fail([a, b, c, d]),
|
||||
dst(((a & 0x07) << 18) | ((b & 0x3F) << 12) | ((c & 0x3F) << 6) | (d & 0x3F));
|
||||
else throw RangeError("Illegal starting byte: " + a);
|
||||
}
|
||||
};
|
||||
|
||||
@ -578,7 +580,7 @@
|
||||
* @param {!function(number)} dst Code points destination as a function successively called with each converted code
|
||||
* point.
|
||||
*/
|
||||
utfx.UTF16toUTF8 = function(src, dst) {
|
||||
utfx.UTF16toUTF8 = function (src, dst) {
|
||||
var c1, c2 = null;
|
||||
while (true) {
|
||||
if ((c1 = c2 !== null ? c2 : src()) === null)
|
||||
@ -586,7 +588,7 @@
|
||||
if (c1 >= 0xD800 && c1 <= 0xDFFF) {
|
||||
if ((c2 = src()) !== null) {
|
||||
if (c2 >= 0xDC00 && c2 <= 0xDFFF) {
|
||||
dst((c1-0xD800)*0x400+c2-0xDC00+0x10000);
|
||||
dst((c1 - 0xD800) * 0x400 + c2 - 0xDC00 + 0x10000);
|
||||
c2 = null; continue;
|
||||
}
|
||||
}
|
||||
@ -603,17 +605,17 @@
|
||||
* @param {!function(number)} dst Characters destination as a function successively called with each converted char code.
|
||||
* @throws {RangeError} If a code point is out of range
|
||||
*/
|
||||
utfx.UTF8toUTF16 = function(src, dst) {
|
||||
utfx.UTF8toUTF16 = function (src, dst) {
|
||||
var cp = null;
|
||||
if (typeof src === 'number')
|
||||
cp = src, src = function() { return null; };
|
||||
cp = src, src = function () { return null; };
|
||||
while (cp !== null || (cp = src()) !== null) {
|
||||
if (cp <= 0xFFFF)
|
||||
dst(cp);
|
||||
else
|
||||
cp -= 0x10000,
|
||||
dst((cp>>10)+0xD800),
|
||||
dst((cp%0x400)+0xDC00);
|
||||
dst((cp >> 10) + 0xD800),
|
||||
dst((cp % 0x400) + 0xDC00);
|
||||
cp = null;
|
||||
}
|
||||
};
|
||||
@ -624,8 +626,8 @@
|
||||
* if there are no more characters left.
|
||||
* @param {!function(number)} dst Bytes destination as a function successively called with the next byte.
|
||||
*/
|
||||
utfx.encodeUTF16toUTF8 = function(src, dst) {
|
||||
utfx.UTF16toUTF8(src, function(cp) {
|
||||
utfx.encodeUTF16toUTF8 = function (src, dst) {
|
||||
utfx.UTF16toUTF8(src, function (cp) {
|
||||
utfx.encodeUTF8(cp, dst);
|
||||
});
|
||||
};
|
||||
@ -638,8 +640,8 @@
|
||||
* @throws {RangeError} If a starting byte is invalid in UTF8
|
||||
* @throws {Error} If the last sequence is truncated. Has an array property `bytes` holding the remaining bytes.
|
||||
*/
|
||||
utfx.decodeUTF8toUTF16 = function(src, dst) {
|
||||
utfx.decodeUTF8(src, function(cp) {
|
||||
utfx.decodeUTF8toUTF16 = function (src, dst) {
|
||||
utfx.decodeUTF8(src, function (cp) {
|
||||
utfx.UTF8toUTF16(cp, dst);
|
||||
});
|
||||
};
|
||||
@ -649,7 +651,7 @@
|
||||
* @param {number} cp UTF8 code point
|
||||
* @returns {number} Byte length
|
||||
*/
|
||||
utfx.calculateCodePoint = function(cp) {
|
||||
utfx.calculateCodePoint = function (cp) {
|
||||
return (cp < 0x80) ? 1 : (cp < 0x800) ? 2 : (cp < 0x10000) ? 3 : 4;
|
||||
};
|
||||
|
||||
@ -659,8 +661,8 @@
|
||||
* `null` if there are no more code points left.
|
||||
* @returns {number} The number of UTF8 bytes required
|
||||
*/
|
||||
utfx.calculateUTF8 = function(src) {
|
||||
var cp, l=0;
|
||||
utfx.calculateUTF8 = function (src) {
|
||||
var cp, l = 0;
|
||||
while ((cp = src()) !== null)
|
||||
l += utfx.calculateCodePoint(cp);
|
||||
return l;
|
||||
@ -672,18 +674,18 @@
|
||||
* `null` if there are no more characters left.
|
||||
* @returns {!Array.<number>} The number of UTF8 code points at index 0 and the number of UTF8 bytes required at index 1.
|
||||
*/
|
||||
utfx.calculateUTF16asUTF8 = function(src) {
|
||||
var n=0, l=0;
|
||||
utfx.UTF16toUTF8(src, function(cp) {
|
||||
utfx.calculateUTF16asUTF8 = function (src) {
|
||||
var n = 0, l = 0;
|
||||
utfx.UTF16toUTF8(src, function (cp) {
|
||||
++n; l += utfx.calculateCodePoint(cp);
|
||||
});
|
||||
return [n,l];
|
||||
return [n, l];
|
||||
};
|
||||
|
||||
return utfx;
|
||||
}();
|
||||
|
||||
Date.now = Date.now || function() { return +new Date; };
|
||||
Date.now = Date.now || function () { return +new Date; };
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
@ -1172,7 +1174,7 @@
|
||||
|
||||
// Validate
|
||||
if (rounds < 4 || rounds > 31) {
|
||||
err = Error("Illegal number of rounds (4-31): "+rounds);
|
||||
err = Error("Illegal number of rounds (4-31): " + rounds);
|
||||
if (callback) {
|
||||
nextTick(callback.bind(this, err));
|
||||
return;
|
||||
@ -1180,7 +1182,7 @@
|
||||
throw err;
|
||||
}
|
||||
if (salt.length !== BCRYPT_SALT_LEN) {
|
||||
err =Error("Illegal salt length: "+salt.length+" != "+BCRYPT_SALT_LEN);
|
||||
err = Error("Illegal salt length: " + salt.length + " != " + BCRYPT_SALT_LEN);
|
||||
if (callback) {
|
||||
nextTick(callback.bind(this, err));
|
||||
return;
|
||||
@ -1247,7 +1249,7 @@
|
||||
} else {
|
||||
var res;
|
||||
while (true)
|
||||
if (typeof(res = next()) !== 'undefined')
|
||||
if (typeof (res = next()) !== 'undefined')
|
||||
return res || [];
|
||||
}
|
||||
}
|
||||
@ -1277,7 +1279,7 @@
|
||||
// Validate the salt
|
||||
var minor, offset;
|
||||
if (salt.charAt(0) !== '$' || salt.charAt(1) !== '2') {
|
||||
err = Error("Invalid salt version: "+salt.substring(0,2));
|
||||
err = Error("Invalid salt version: " + salt.substring(0, 2));
|
||||
if (callback) {
|
||||
nextTick(callback.bind(this, err));
|
||||
return;
|
||||
@ -1291,7 +1293,7 @@
|
||||
else {
|
||||
minor = salt.charAt(2);
|
||||
if ((minor !== 'a' && minor !== 'b' && minor !== 'y') || salt.charAt(3) !== '$') {
|
||||
err = Error("Invalid salt revision: "+salt.substring(2,4));
|
||||
err = Error("Invalid salt revision: " + salt.substring(2, 4));
|
||||
if (callback) {
|
||||
nextTick(callback.bind(this, err));
|
||||
return;
|
||||
@ -1346,7 +1348,7 @@
|
||||
|
||||
// Async
|
||||
else {
|
||||
_crypt(passwordb, saltb, rounds, function(err, bytes) {
|
||||
_crypt(passwordb, saltb, rounds, function (err, bytes) {
|
||||
if (err)
|
||||
callback(err, null);
|
||||
else
|
||||
|
@ -1,6 +1,5 @@
|
||||
// "Generated from Java with JSweet 1.0.0 - http://www.jsweet.org";
|
||||
// BAD IMPLEMENTATION. BROKEN, BUT MUST KEEP CAUSE OF NETWORK
|
||||
//const RIPEMD160 = (function () {
|
||||
// == Convert to ES6 module for export == //
|
||||
const RIPEMD160 = (function () {
|
||||
function RIPEMD160() {
|
||||
|
@ -1,3 +1,2 @@
|
||||
export { default as Base58 } from './Base58.js'
|
||||
|
||||
export { default as utils } from './utils.js'
|
||||
export { default as Base58 } from './Base58'
|
||||
export { default as utils } from './utils'
|
||||
|
@ -10,102 +10,94 @@
|
||||
Change to es6 import/export
|
||||
*/
|
||||
|
||||
import nacl from './nacl-fast.js'
|
||||
import nacl from './nacl-fast'
|
||||
|
||||
// (function(root, f) {
|
||||
// 'use strict';
|
||||
// if (typeof module !== 'undefined' && module.exports) module.exports = f(require('tweetnacl'));
|
||||
// else root.ed2curve = f(root.nacl);
|
||||
// }(this, function(nacl) {
|
||||
// 'use strict';
|
||||
// if (!nacl) throw new Error('tweetnacl not loaded');
|
||||
// -- Operations copied from TweetNaCl.js. --
|
||||
|
||||
// -- Operations copied from TweetNaCl.js. --
|
||||
|
||||
var gf = function(init) {
|
||||
var gf = function (init) {
|
||||
var i, r = new Float64Array(16);
|
||||
if (init) for (i = 0; i < init.length; i++) r[i] = init[i];
|
||||
return r;
|
||||
};
|
||||
};
|
||||
|
||||
var gf0 = gf(),
|
||||
var gf0 = gf(),
|
||||
gf1 = gf([1]),
|
||||
D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),
|
||||
I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);
|
||||
|
||||
function car25519(o) {
|
||||
function car25519(o) {
|
||||
var c;
|
||||
var i;
|
||||
for (i = 0; i < 16; i++) {
|
||||
o[i] += 65536;
|
||||
c = Math.floor(o[i] / 65536);
|
||||
o[(i+1)*(i<15?1:0)] += c - 1 + 37 * (c-1) * (i===15?1:0);
|
||||
o[(i + 1) * (i < 15 ? 1 : 0)] += c - 1 + 37 * (c - 1) * (i === 15 ? 1 : 0);
|
||||
o[i] -= (c * 65536);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function sel25519(p, q, b) {
|
||||
var t, c = ~(b-1);
|
||||
function sel25519(p, q, b) {
|
||||
var t, c = ~(b - 1);
|
||||
for (var i = 0; i < 16; i++) {
|
||||
t = c & (p[i] ^ q[i]);
|
||||
p[i] ^= t;
|
||||
q[i] ^= t;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function unpack25519(o, n) {
|
||||
function unpack25519(o, n) {
|
||||
var i;
|
||||
for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);
|
||||
for (i = 0; i < 16; i++) o[i] = n[2 * i] + (n[2 * i + 1] << 8);
|
||||
o[15] &= 0x7fff;
|
||||
}
|
||||
}
|
||||
|
||||
// addition
|
||||
function A(o, a, b) {
|
||||
// addition
|
||||
function A(o, a, b) {
|
||||
var i;
|
||||
for (i = 0; i < 16; i++) o[i] = (a[i] + b[i])|0;
|
||||
}
|
||||
for (i = 0; i < 16; i++) o[i] = (a[i] + b[i]) | 0;
|
||||
}
|
||||
|
||||
// subtraction
|
||||
function Z(o, a, b) {
|
||||
// subtraction
|
||||
function Z(o, a, b) {
|
||||
var i;
|
||||
for (i = 0; i < 16; i++) o[i] = (a[i] - b[i])|0;
|
||||
}
|
||||
for (i = 0; i < 16; i++) o[i] = (a[i] - b[i]) | 0;
|
||||
}
|
||||
|
||||
// multiplication
|
||||
function M(o, a, b) {
|
||||
// multiplication
|
||||
function M(o, a, b) {
|
||||
var i, j, t = new Float64Array(31);
|
||||
for (i = 0; i < 31; i++) t[i] = 0;
|
||||
for (i = 0; i < 16; i++) {
|
||||
for (j = 0; j < 16; j++) {
|
||||
t[i+j] += a[i] * b[j];
|
||||
t[i + j] += a[i] * b[j];
|
||||
}
|
||||
}
|
||||
for (i = 0; i < 15; i++) {
|
||||
t[i] += 38 * t[i+16];
|
||||
t[i] += 38 * t[i + 16];
|
||||
}
|
||||
for (i = 0; i < 16; i++) o[i] = t[i];
|
||||
car25519(o);
|
||||
car25519(o);
|
||||
}
|
||||
}
|
||||
|
||||
// squaring
|
||||
function S(o, a) {
|
||||
// squaring
|
||||
function S(o, a) {
|
||||
M(o, a, a);
|
||||
}
|
||||
}
|
||||
|
||||
// inversion
|
||||
function inv25519(o, i) {
|
||||
// inversion
|
||||
function inv25519(o, i) {
|
||||
var c = gf();
|
||||
var a;
|
||||
for (a = 0; a < 16; a++) c[a] = i[a];
|
||||
for (a = 253; a >= 0; a--) {
|
||||
S(c, c);
|
||||
if(a !== 2 && a !== 4) M(c, c, i);
|
||||
if (a !== 2 && a !== 4) M(c, c, i);
|
||||
}
|
||||
for (a = 0; a < 16; a++) o[a] = c[a];
|
||||
}
|
||||
}
|
||||
|
||||
function pack25519(o, n) {
|
||||
function pack25519(o, n) {
|
||||
var i, j, b;
|
||||
var m = gf(), t = gf();
|
||||
for (i = 0; i < 16; i++) t[i] = n[i];
|
||||
@ -115,44 +107,44 @@ import nacl from './nacl-fast.js'
|
||||
for (j = 0; j < 2; j++) {
|
||||
m[0] = t[0] - 0xffed;
|
||||
for (i = 1; i < 15; i++) {
|
||||
m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);
|
||||
m[i-1] &= 0xffff;
|
||||
m[i] = t[i] - 0xffff - ((m[i - 1] >> 16) & 1);
|
||||
m[i - 1] &= 0xffff;
|
||||
}
|
||||
m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);
|
||||
b = (m[15]>>16) & 1;
|
||||
m[15] = t[15] - 0x7fff - ((m[14] >> 16) & 1);
|
||||
b = (m[15] >> 16) & 1;
|
||||
m[14] &= 0xffff;
|
||||
sel25519(t, m, 1-b);
|
||||
sel25519(t, m, 1 - b);
|
||||
}
|
||||
for (i = 0; i < 16; i++) {
|
||||
o[2*i] = t[i] & 0xff;
|
||||
o[2*i+1] = t[i] >> 8;
|
||||
}
|
||||
o[2 * i] = t[i] & 0xff;
|
||||
o[2 * i + 1] = t[i] >> 8;
|
||||
}
|
||||
}
|
||||
|
||||
function par25519(a) {
|
||||
function par25519(a) {
|
||||
var d = new Uint8Array(32);
|
||||
pack25519(d, a);
|
||||
return d[0] & 1;
|
||||
}
|
||||
}
|
||||
|
||||
function vn(x, xi, y, yi, n) {
|
||||
function vn(x, xi, y, yi, n) {
|
||||
var i, d = 0;
|
||||
for (i = 0; i < n; i++) d |= x[xi + i] ^ y[yi + i];
|
||||
return (1 & ((d - 1) >>> 8)) - 1;
|
||||
}
|
||||
}
|
||||
|
||||
function crypto_verify_32(x, xi, y, yi) {
|
||||
function crypto_verify_32(x, xi, y, yi) {
|
||||
return vn(x, xi, y, yi, 32);
|
||||
}
|
||||
}
|
||||
|
||||
function neq25519(a, b) {
|
||||
function neq25519(a, b) {
|
||||
var c = new Uint8Array(32), d = new Uint8Array(32);
|
||||
pack25519(c, a);
|
||||
pack25519(d, b);
|
||||
return crypto_verify_32(c, 0, d, 0);
|
||||
}
|
||||
}
|
||||
|
||||
function pow2523(o, i) {
|
||||
function pow2523(o, i) {
|
||||
var c = gf();
|
||||
var a;
|
||||
for (a = 0; a < 16; a++) c[a] = i[a];
|
||||
@ -161,14 +153,14 @@ import nacl from './nacl-fast.js'
|
||||
if (a !== 1) M(c, c, i);
|
||||
}
|
||||
for (a = 0; a < 16; a++) o[a] = c[a];
|
||||
}
|
||||
}
|
||||
|
||||
function set25519(r, a) {
|
||||
function set25519(r, a) {
|
||||
var i;
|
||||
for (i = 0; i < 16; i++) r[i] = a[i] | 0;
|
||||
}
|
||||
}
|
||||
|
||||
function unpackneg(r, p) {
|
||||
function unpackneg(r, p) {
|
||||
var t = gf(), chk = gf(), num = gf(),
|
||||
den = gf(), den2 = gf(), den4 = gf(),
|
||||
den6 = gf();
|
||||
@ -204,13 +196,13 @@ import nacl from './nacl-fast.js'
|
||||
|
||||
M(r[3], r[0], r[1]);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// ----
|
||||
// ----
|
||||
|
||||
// Converts Ed25519 public key to Curve25519 public key.
|
||||
// montgomeryX = (edwardsY + 1)*inverse(1 - edwardsY) mod p
|
||||
function convertPublicKey(pk) {
|
||||
// Converts Ed25519 public key to Curve25519 public key.
|
||||
// montgomeryX = (edwardsY + 1)*inverse(1 - edwardsY) mod p
|
||||
function convertPublicKey(pk) {
|
||||
var z = new Uint8Array(32),
|
||||
q = [gf(), gf(), gf(), gf()],
|
||||
a = gf(), b = gf();
|
||||
@ -226,10 +218,10 @@ import nacl from './nacl-fast.js'
|
||||
|
||||
pack25519(z, a);
|
||||
return z;
|
||||
}
|
||||
}
|
||||
|
||||
// Converts Ed25519 secret key to Curve25519 secret key.
|
||||
function convertSecretKey(sk) {
|
||||
// Converts Ed25519 secret key to Curve25519 secret key.
|
||||
function convertSecretKey(sk) {
|
||||
var d = new Uint8Array(64), o = new Uint8Array(32), i;
|
||||
nacl.lowlevel.crypto_hash(d, sk, 32);
|
||||
d[0] &= 248;
|
||||
@ -238,27 +230,19 @@ import nacl from './nacl-fast.js'
|
||||
for (i = 0; i < 32; i++) o[i] = d[i];
|
||||
for (i = 0; i < 64; i++) d[i] = 0;
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
||||
function convertKeyPair(edKeyPair) {
|
||||
function convertKeyPair(edKeyPair) {
|
||||
var publicKey = convertPublicKey(edKeyPair.publicKey);
|
||||
if (!publicKey) return null;
|
||||
return {
|
||||
publicKey: publicKey,
|
||||
secretKey: convertSecretKey(edKeyPair.secretKey)
|
||||
};
|
||||
}
|
||||
|
||||
// return {
|
||||
// convertPublicKey: convertPublicKey,
|
||||
// convertSecretKey: convertSecretKey,
|
||||
// convertKeyPair: convertKeyPair,
|
||||
// };
|
||||
}
|
||||
|
||||
export default {
|
||||
convertPublicKey: convertPublicKey,
|
||||
convertSecretKey: convertSecretKey,
|
||||
convertKeyPair: convertKeyPair,
|
||||
}
|
||||
|
||||
// }));
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -26,9 +26,8 @@ const TYPES = {
|
||||
MESSAGE_TRANSACTION: 17
|
||||
};
|
||||
|
||||
function getKeyPairFromSeed(seed, returnBase58)
|
||||
{
|
||||
if(typeof(seed) == "string") {
|
||||
function getKeyPairFromSeed(seed, returnBase58) {
|
||||
if (typeof (seed) == "string") {
|
||||
seed = new Uint8Array(Base58.decode(seed));
|
||||
}
|
||||
|
||||
@ -36,7 +35,7 @@ function getKeyPairFromSeed(seed, returnBase58)
|
||||
|
||||
var base58privateKey = Base58.encode(keyPair.secretKey);
|
||||
var base58publicKey = Base58.encode(keyPair.publicKey);
|
||||
if(returnBase58) {
|
||||
if (returnBase58) {
|
||||
return {
|
||||
privateKey: Base58.encode(keyPair.secretKey),
|
||||
publicKey: Base58.encode(keyPair.publicKey)
|
||||
@ -60,7 +59,7 @@ function stringtoUTF8Array(message) {
|
||||
return message;
|
||||
}
|
||||
|
||||
function int32ToBytes (word) {
|
||||
function int32ToBytes(word) {
|
||||
var byteArray = [];
|
||||
for (var b = 0; b < 32; b += 8) {
|
||||
byteArray.push((word >>> (24 - b % 32)) & 0xFF);
|
||||
@ -68,20 +67,20 @@ function int32ToBytes (word) {
|
||||
return byteArray;
|
||||
}
|
||||
|
||||
function int64ToBytes (int64) {
|
||||
function int64ToBytes(int64) {
|
||||
// we want to represent the input as a 8-bytes array
|
||||
var byteArray = [0, 0, 0, 0, 0, 0, 0, 0];
|
||||
|
||||
for ( var index = 0; index < byteArray.length; index ++ ) {
|
||||
for (var index = 0; index < byteArray.length; index++) {
|
||||
var byte = int64 & 0xff;
|
||||
byteArray [ byteArray.length - index - 1 ] = byte;
|
||||
int64 = (int64 - byte) / 256 ;
|
||||
byteArray[byteArray.length - index - 1] = byte;
|
||||
int64 = (int64 - byte) / 256;
|
||||
}
|
||||
|
||||
return byteArray;
|
||||
}
|
||||
|
||||
function appendBuffer (buffer1, buffer2) {
|
||||
function appendBuffer(buffer1, buffer2) {
|
||||
buffer1 = new Uint8Array(buffer1);
|
||||
buffer2 = new Uint8Array(buffer2);
|
||||
var tmp = new Uint8Array(buffer1.byteLength + buffer2.byteLength);
|
||||
@ -90,21 +89,18 @@ function appendBuffer (buffer1, buffer2) {
|
||||
return tmp;
|
||||
}
|
||||
|
||||
function equal (buf1, buf2)
|
||||
{
|
||||
function equal(buf1, buf2) {
|
||||
if (buf1.byteLength != buf2.byteLength) return false;
|
||||
var dv1 = new Uint8Array(buf1);
|
||||
var dv2 = new Uint8Array(buf2);
|
||||
for (var i = 0; i != buf1.byteLength; i++)
|
||||
{
|
||||
for (var i = 0; i != buf1.byteLength; i++) {
|
||||
if (dv1[i] != dv2[i]) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function generateAccountSeed(seed, nonce, returnBase58)
|
||||
{
|
||||
if(typeof(seed) == "string") {
|
||||
function generateAccountSeed(seed, nonce, returnBase58) {
|
||||
if (typeof (seed) == "string") {
|
||||
seed = Base58.decode(seed);
|
||||
}
|
||||
|
||||
@ -116,7 +112,7 @@ function generateAccountSeed(seed, nonce, returnBase58)
|
||||
resultSeed = appendBuffer(resultSeed, seed);
|
||||
resultSeed = appendBuffer(resultSeed, nonceBytes);
|
||||
|
||||
if(returnBase58) {
|
||||
if (returnBase58) {
|
||||
return Base58.encode(SHA256.digest(SHA256.digest(resultSeed)));
|
||||
} else {
|
||||
return new SHA256.digest(SHA256.digest(resultSeed));
|
||||
@ -124,11 +120,10 @@ function generateAccountSeed(seed, nonce, returnBase58)
|
||||
|
||||
}
|
||||
|
||||
function getAccountAddressFromPublicKey(publicKey)
|
||||
{
|
||||
function getAccountAddressFromPublicKey(publicKey) {
|
||||
var ADDRESS_VERSION = 58; // Q
|
||||
|
||||
if(typeof(publicKey) == "string") {
|
||||
if (typeof (publicKey) == "string") {
|
||||
publicKey = Base58.decode(publicKey);
|
||||
}
|
||||
|
||||
@ -150,13 +145,12 @@ function getAccountAddressFromPublicKey(publicKey)
|
||||
return Base58.encode(addressArray);
|
||||
}
|
||||
|
||||
function getAccountAddressType(address)
|
||||
{
|
||||
function getAccountAddressType(address) {
|
||||
try {
|
||||
var ADDRESS_VERSION = 58; // Q
|
||||
var AT_ADDRESS_VERSION = 23; // A
|
||||
|
||||
if(typeof(address) == "string") {
|
||||
if (typeof (address) == "string") {
|
||||
address = Base58.decode(address);
|
||||
}
|
||||
|
||||
@ -166,14 +160,11 @@ function getAccountAddressType(address)
|
||||
var checkSumTwo = SHA256.digest(SHA256.digest(addressWitoutChecksum));
|
||||
checkSumTwo = checkSumTwo.subarray(0, 4);
|
||||
|
||||
if (equal(checkSum, checkSumTwo))
|
||||
{
|
||||
if(address[0] == ADDRESS_VERSION)
|
||||
{
|
||||
if (equal(checkSum, checkSumTwo)) {
|
||||
if (address[0] == ADDRESS_VERSION) {
|
||||
return "standard";
|
||||
}
|
||||
if(address[0] == AT_ADDRESS_VERSION)
|
||||
{
|
||||
if (address[0] == AT_ADDRESS_VERSION) {
|
||||
return "at";
|
||||
}
|
||||
}
|
||||
@ -185,8 +176,7 @@ function getAccountAddressType(address)
|
||||
}
|
||||
}
|
||||
|
||||
function isValidAddress(address)
|
||||
{
|
||||
function isValidAddress(address) {
|
||||
return (getAccountAddressType(address) != "invalid");
|
||||
}
|
||||
|
||||
@ -307,8 +297,8 @@ function generateSignatureRegisterNameTransaction(keyPair, lastReference, owner,
|
||||
}
|
||||
|
||||
function generateRegisterNameTransaction(keyPair, lastReference, owner, name, value, fee, timestamp, signature) {
|
||||
return appendBuffer( generateRegisterNameTransactionBase(keyPair.publicKey, lastReference, owner, name, value, fee, timestamp),
|
||||
signature );
|
||||
return appendBuffer(generateRegisterNameTransactionBase(keyPair.publicKey, lastReference, owner, name, value, fee, timestamp),
|
||||
signature);
|
||||
}
|
||||
|
||||
function generateRegisterNameTransactionBase(publicKey, lastReference, owner, name, value, fee, timestamp) {
|
||||
|
@ -1,5 +1,7 @@
|
||||
// Extracted from https://github.com/crypto-browserify/ripemd160
|
||||
|
||||
const ARRAY16 = new Array(16);
|
||||
|
||||
const zl = initU8Array([
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
||||
7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
|
||||
|
@ -21,7 +21,7 @@ SHA256.K = [
|
||||
// The digest function returns the hash value (digest)
|
||||
// as a 32 byte (typed) array.
|
||||
// message: the string or byte array to hash
|
||||
SHA256.digest = function(message) {
|
||||
SHA256.digest = function (message) {
|
||||
var h0 = 0x6a09e667;
|
||||
var h1 = 0xbb67ae85;
|
||||
var h2 = 0x3c6ef372;
|
||||
@ -127,7 +127,7 @@ SHA256.digest = function(message) {
|
||||
|
||||
// The hash function returns the hash value as a hex string.
|
||||
// message: the string or byte array to hash
|
||||
SHA256.hash = function(message) {
|
||||
SHA256.hash = function (message) {
|
||||
var digest = SHA256.digest(message);
|
||||
var hex = '';
|
||||
for (var i = 0; i < digest.length; i++) {
|
||||
@ -137,6 +137,5 @@ SHA256.hash = function(message) {
|
||||
return hex;
|
||||
}
|
||||
|
||||
|
||||
// == Convert to ES6 Module == //
|
||||
export default SHA256;
|
@ -1,4 +1,3 @@
|
||||
'use strict'
|
||||
const utils = {
|
||||
int32ToBytes(word) {
|
||||
var byteArray = []
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {waitForConfig, watchConfig} from '../config.js'
|
||||
import { waitForConfig, watchConfig } from '../config'
|
||||
|
||||
let config = {}
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
import {store} from '../api_deps.js'
|
||||
import {stateAwait} from './utils/stateAwait.js'
|
||||
import {Sha512} from 'asmcrypto.js'
|
||||
import utils from '../api/deps/utils.js'
|
||||
import {get, registerTranslateConfig} from '../../core/translate'
|
||||
import { store } from '../api_deps'
|
||||
import { stateAwait } from './utils/stateAwait'
|
||||
import { Sha512 } from 'asmcrypto.js'
|
||||
import utils from '../api/deps/utils'
|
||||
import { get, registerTranslateConfig } from '../../core/translate'
|
||||
|
||||
registerTranslateConfig({
|
||||
loader: lang => fetch(`/language/${lang}.json`).then(res => res.json())
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Not to be confused with register name...this is a special use case
|
||||
*/
|
||||
import {createTransaction, processTransaction, request} from './api.js'
|
||||
import { createTransaction, processTransaction, request } from './api'
|
||||
|
||||
const TX_TYPE = 3 // NAME_REGISTRATION
|
||||
const CHECK_LAST_REF_INTERVAL = 30 * 1000 // err 30 seconds
|
||||
|
@ -1,6 +1,6 @@
|
||||
import {AES_CBC, HmacSha512} from 'asmcrypto.js'
|
||||
import {kdf} from './kdf.js'
|
||||
import Base58 from './deps/Base58.js'
|
||||
import { AES_CBC, HmacSha512 } from 'asmcrypto.js'
|
||||
import { kdf } from './kdf'
|
||||
import Base58 from './deps/Base58'
|
||||
|
||||
const getRandomValues = window.crypto ? window.crypto.getRandomValues.bind(window.crypto) : window.msCrypto.getRandomValues.bind(window.msCrypto)
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
// Trade Bot
|
||||
import TradeBotCreateRequest from './transactions/trade-portal/tradebot/TradeBotCreateRequest.js'
|
||||
import TradeBotRespondRequest from './transactions/trade-portal/tradebot/TradeBotRespondRequest.js'
|
||||
import signTradeBotTransaction from './transactions/trade-portal/tradebot/signTradeBotTransaction.js'
|
||||
import DeleteTradeOffer from './transactions/trade-portal/tradeoffer/DeleteTradeOffer.js'
|
||||
import {request} from './fetch-request'
|
||||
import TradeBotCreateRequest from './transactions/trade-portal/tradebot/TradeBotCreateRequest'
|
||||
import TradeBotRespondRequest from './transactions/trade-portal/tradebot/TradeBotRespondRequest'
|
||||
import signTradeBotTransaction from './transactions/trade-portal/tradebot/signTradeBotTransaction'
|
||||
import DeleteTradeOffer from './transactions/trade-portal/tradeoffer/DeleteTradeOffer'
|
||||
import { request } from './fetch-request'
|
||||
|
||||
// TradeBotCreateRequest
|
||||
export const tradeBotCreateRequest = (requestObject) => {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import TransactionBase from './TransactionBase'
|
||||
import {QORT_DECIMALS} from '../constants'
|
||||
import { QORT_DECIMALS } from '../constants'
|
||||
|
||||
export default class PaymentTransaction extends TransactionBase {
|
||||
constructor() {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import TransactionBase from './TransactionBase'
|
||||
import {store} from '../../api'
|
||||
import {QORT_DECIMALS} from '../constants'
|
||||
import { store } from '../../api'
|
||||
import { QORT_DECIMALS } from '../constants'
|
||||
|
||||
export default class DeployAtTransaction extends TransactionBase {
|
||||
constructor() {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import TransactionBase from './TransactionBase'
|
||||
import Base58 from '../deps/Base58'
|
||||
import {store} from '../../api'
|
||||
import { store } from '../../api'
|
||||
|
||||
export default class PaymentTransaction extends TransactionBase {
|
||||
constructor() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import ChatBase from './chat/ChatBase'
|
||||
import {QORT_DECIMALS} from '../constants'
|
||||
import { QORT_DECIMALS } from '../constants'
|
||||
|
||||
export default class PublicizeTransaction extends ChatBase {
|
||||
constructor() {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {QORT_DECIMALS, TX_TYPES} from '../constants'
|
||||
import { QORT_DECIMALS, TX_TYPES } from '../constants'
|
||||
import nacl from '../deps/nacl-fast'
|
||||
import Base58 from '../deps/Base58'
|
||||
import utils from '../deps/utils'
|
||||
|
@ -1,6 +1,6 @@
|
||||
import TransactionBase from './TransactionBase'
|
||||
import {store} from '../../api'
|
||||
import {QORT_DECIMALS} from '../constants'
|
||||
import { store } from '../../api'
|
||||
import { QORT_DECIMALS } from '../constants'
|
||||
|
||||
export default class TransferPrivsTransaction extends TransactionBase {
|
||||
constructor() {
|
||||
|
@ -1,6 +1,4 @@
|
||||
'use strict'
|
||||
|
||||
(function () {
|
||||
(function () {
|
||||
function generateSignatureArbitraryTransactionV3(keyPair, lastReference, service, arbitraryData, fee, timestamp) => {
|
||||
const data = generateArbitraryTransactionV3Base(keyPair.publicKey, lastReference, service, arbitraryData, fee, timestamp)
|
||||
return nacl.sign.detached(data, keyPair.privateKey)
|
||||
@ -35,4 +33,4 @@
|
||||
|
||||
return data
|
||||
}
|
||||
}())
|
||||
}())
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {QORT_DECIMALS, TX_TYPES} from '../../constants'
|
||||
import { QORT_DECIMALS, TX_TYPES } from '../../constants'
|
||||
import nacl from '../../deps/nacl-fast'
|
||||
import Base58 from '../../deps/Base58'
|
||||
import utils from '../../deps/utils'
|
||||
|
@ -1,8 +1,8 @@
|
||||
import ChatBase from './ChatBase'
|
||||
import nacl from '../../deps/nacl-fast'
|
||||
import ed2curve from '../../deps/ed2curve'
|
||||
import {Sha256} from 'asmcrypto.js'
|
||||
import {CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP} from '../../constants'
|
||||
import { Sha256 } from 'asmcrypto.js'
|
||||
import { CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP } from '../../constants'
|
||||
|
||||
export default class ChatTransaction extends ChatBase {
|
||||
constructor() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import ChatBase from './ChatBase'
|
||||
import {CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP} from '../../constants'
|
||||
import { CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP } from '../../constants'
|
||||
|
||||
export default class GroupChatTransaction extends ChatBase {
|
||||
constructor() {
|
||||
|
@ -1,7 +1,7 @@
|
||||
import nacl from '../../deps/nacl-fast'
|
||||
import Base58 from '../../deps/Base58'
|
||||
import ed2curve from '../../deps/ed2curve'
|
||||
import {Sha256} from 'asmcrypto.js'
|
||||
import { Sha256 } from 'asmcrypto.js'
|
||||
|
||||
export const decryptChatMessage = (encryptedMessage, privateKey, recipientPublicKey, lastReference) => {
|
||||
let _encryptedMessage = Base58.decode(encryptedMessage)
|
||||
|
@ -1,5 +1,5 @@
|
||||
import TransactionBase from '../TransactionBase'
|
||||
import {QORT_DECIMALS} from '../../constants'
|
||||
import { QORT_DECIMALS } from '../../constants'
|
||||
|
||||
export default class AddGroupAdminTransaction extends TransactionBase {
|
||||
constructor() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import TransactionBase from '../TransactionBase'
|
||||
import {QORT_DECIMALS} from '../../constants'
|
||||
import { QORT_DECIMALS } from '../../constants'
|
||||
|
||||
export default class CancelGroupBanTransaction extends TransactionBase {
|
||||
constructor() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import TransactionBase from '../TransactionBase'
|
||||
import {QORT_DECIMALS} from '../../constants'
|
||||
import { QORT_DECIMALS } from '../../constants'
|
||||
|
||||
export default class CancelGroupInviteTransaction extends TransactionBase {
|
||||
constructor() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import TransactionBase from '../TransactionBase'
|
||||
import {QORT_DECIMALS} from '../../constants'
|
||||
import { QORT_DECIMALS } from '../../constants'
|
||||
|
||||
export default class CreateGroupTransaction extends TransactionBase {
|
||||
constructor() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import TransactionBase from '../TransactionBase'
|
||||
import {QORT_DECIMALS} from '../../constants'
|
||||
import { QORT_DECIMALS } from '../../constants'
|
||||
|
||||
export default class GroupBanTransaction extends TransactionBase {
|
||||
constructor() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import TransactionBase from '../TransactionBase'
|
||||
import {QORT_DECIMALS} from '../../constants'
|
||||
import { QORT_DECIMALS } from '../../constants'
|
||||
|
||||
export default class GroupInviteTransaction extends TransactionBase {
|
||||
constructor() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import TransactionBase from '../TransactionBase'
|
||||
import {QORT_DECIMALS} from '../../constants'
|
||||
import { QORT_DECIMALS } from '../../constants'
|
||||
|
||||
export default class GroupKickTransaction extends TransactionBase {
|
||||
constructor() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import TransactionBase from '../TransactionBase'
|
||||
import {QORT_DECIMALS} from '../../constants'
|
||||
import { QORT_DECIMALS } from '../../constants'
|
||||
|
||||
export default class JoinGroupTransaction extends TransactionBase {
|
||||
constructor() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import TransactionBase from '../TransactionBase'
|
||||
import {QORT_DECIMALS} from '../../constants'
|
||||
import { QORT_DECIMALS } from '../../constants'
|
||||
|
||||
export default class LeaveGroupTransaction extends TransactionBase {
|
||||
constructor() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import TransactionBase from '../TransactionBase'
|
||||
import {QORT_DECIMALS} from '../../constants'
|
||||
import { QORT_DECIMALS } from '../../constants'
|
||||
|
||||
export default class RemoveGroupAdminTransaction extends TransactionBase {
|
||||
constructor() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import TransactionBase from '../TransactionBase'
|
||||
import {QORT_DECIMALS} from '../../constants'
|
||||
import { QORT_DECIMALS } from '../../constants'
|
||||
|
||||
export default class UpdateGroupTransaction extends TransactionBase {
|
||||
constructor() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import TransactionBase from '../TransactionBase'
|
||||
import {QORT_DECIMALS} from '../../constants'
|
||||
import { QORT_DECIMALS } from '../../constants'
|
||||
|
||||
export default class BuyNameTransacion extends TransactionBase {
|
||||
constructor() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import TransactionBase from '../TransactionBase'
|
||||
import {QORT_DECIMALS} from '../../constants'
|
||||
import { QORT_DECIMALS } from '../../constants'
|
||||
|
||||
export default class CancelSellNameTransacion extends TransactionBase {
|
||||
constructor() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import TransactionBase from '../TransactionBase'
|
||||
import {QORT_DECIMALS} from '../../constants'
|
||||
import { QORT_DECIMALS } from '../../constants'
|
||||
|
||||
export default class RegisterNameTransaction extends TransactionBase {
|
||||
constructor() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import TransactionBase from '../TransactionBase'
|
||||
import {QORT_DECIMALS} from '../../constants'
|
||||
import { QORT_DECIMALS } from '../../constants'
|
||||
|
||||
export default class SellNameTransacion extends TransactionBase {
|
||||
constructor() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import TransactionBase from '../TransactionBase'
|
||||
import {QORT_DECIMALS} from '../../constants'
|
||||
import { QORT_DECIMALS } from '../../constants'
|
||||
|
||||
export default class UpdateNameTransaction extends TransactionBase {
|
||||
constructor() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import TransactionBase from '../TransactionBase'
|
||||
import {QORT_DECIMALS} from '../../constants'
|
||||
import { QORT_DECIMALS } from '../../constants'
|
||||
|
||||
export default class CreatePollTransaction extends TransactionBase {
|
||||
constructor() {
|
||||
@ -35,7 +35,7 @@ export default class CreatePollTransaction extends TransactionBase {
|
||||
this._options.push({ length: optionLength, bytes: optionBytes })
|
||||
}
|
||||
|
||||
set feeDialog(feeDialog){
|
||||
set feeDialog(feeDialog) {
|
||||
this._feeDialog = feeDialog
|
||||
}
|
||||
|
||||
@ -106,7 +106,7 @@ export default class CreatePollTransaction extends TransactionBase {
|
||||
params.push(this._options[i].length, this._options[i].bytes)
|
||||
}
|
||||
|
||||
params.push(this._feeBytes);
|
||||
params.push(this._feeBytes)
|
||||
|
||||
return params
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import TransactionBase from '../TransactionBase'
|
||||
import {QORT_DECIMALS} from '../../constants'
|
||||
import { QORT_DECIMALS } from '../../constants'
|
||||
|
||||
export default class VoteOnPollTransaction extends TransactionBase {
|
||||
constructor() {
|
||||
@ -20,7 +20,7 @@ export default class VoteOnPollTransaction extends TransactionBase {
|
||||
`
|
||||
}
|
||||
|
||||
set feeDialog(feeDialog){
|
||||
set feeDialog(feeDialog) {
|
||||
this._feeDialog = feeDialog
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,4 @@
|
||||
'use strict'
|
||||
|
||||
(function () {
|
||||
(function () {
|
||||
function generateSignatureRegisterNameTransaction(keyPair, lastReference, owner, name, value, fee, timestamp) => {
|
||||
const data = generateRegisterNameTransactionBase(keyPair.publicKey, lastReference, owner, name, value, fee, timestamp)
|
||||
return nacl.sign.detached(data, keyPair.privateKey)
|
||||
@ -33,4 +31,4 @@
|
||||
|
||||
return data
|
||||
}
|
||||
}())
|
||||
}())
|
||||
|
@ -1,7 +1,7 @@
|
||||
import TransactionBase from '../TransactionBase'
|
||||
import publicKeyToAddress from '../../wallet/publicKeyToAddress'
|
||||
import {Base58} from '../../deps/deps'
|
||||
import {DYNAMIC_FEE_TIMESTAMP} from '../../constants'
|
||||
import { Base58 } from '../../deps/deps'
|
||||
import { DYNAMIC_FEE_TIMESTAMP } from '../../constants'
|
||||
|
||||
export default class RemoveRewardShareTransaction extends TransactionBase {
|
||||
constructor() {
|
||||
|
@ -2,8 +2,8 @@ import publicKeyToAddress from '../../wallet/publicKeyToAddress'
|
||||
import TransactionBase from '../TransactionBase'
|
||||
import nacl from '../../deps/nacl-fast'
|
||||
import ed2curve from '../../deps/ed2curve'
|
||||
import {Sha256} from 'asmcrypto.js'
|
||||
import {DYNAMIC_FEE_TIMESTAMP} from '../../constants'
|
||||
import { Sha256 } from 'asmcrypto.js'
|
||||
import { DYNAMIC_FEE_TIMESTAMP } from '../../constants'
|
||||
|
||||
export default class RewardShareTransaction extends TransactionBase {
|
||||
constructor() {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {store} from '../../api.js'
|
||||
import { store } from '../../api'
|
||||
|
||||
let subscriptions = []
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import publicKeyToAddress from './publicKeyToAddress'
|
||||
import Base58 from '../deps/Base58.js'
|
||||
import Base58 from '../deps/Base58'
|
||||
|
||||
export const base58PublicKeyToAddress = (base58pubkey, qora = false) => {
|
||||
const decodePubKey = Base58.decode(base58pubkey)
|
||||
|
@ -1,10 +1,10 @@
|
||||
import Base58 from '../deps/Base58.js'
|
||||
import BROKEN_RIPEMD160 from '../deps/broken-ripemd160.js'
|
||||
import RIPEMD160 from '../deps/ripemd160.js'
|
||||
import utils from '../deps/utils.js'
|
||||
import {ADDRESS_VERSION} from '../constants.js'
|
||||
import {Buffer} from 'buffer'
|
||||
import {Sha256} from 'asmcrypto.js'
|
||||
import Base58 from '../deps/Base58'
|
||||
import BROKEN_RIPEMD160 from '../deps/broken-ripemd160'
|
||||
import RIPEMD160 from '../deps/ripemd160'
|
||||
import utils from '../deps/utils'
|
||||
import { ADDRESS_VERSION } from '../constants'
|
||||
import { Buffer } from 'buffer'
|
||||
import { Sha256 } from 'asmcrypto.js'
|
||||
|
||||
const repeatSHA256 = (passphrase, hashes) => {
|
||||
let hash = passphrase
|
||||
|
@ -1,8 +1,8 @@
|
||||
import Base58 from '../deps/Base58.js'
|
||||
import Base58 from '../deps/Base58'
|
||||
|
||||
export const validateAddress = (address) => {
|
||||
const decodePubKey = Base58.decode(address)
|
||||
|
||||
return decodePubKey instanceof Uint8Array && decodePubKey.length == 25;
|
||||
return decodePubKey instanceof Uint8Array && decodePubKey.length == 25
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {store} from './api.js'
|
||||
import { store } from './api'
|
||||
|
||||
let config = false
|
||||
let loaded = false
|
||||
|
Loading…
x
Reference in New Issue
Block a user