Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Enumerations

Interfaces

Type aliases

Variables

Functions

Object literals

Type aliases

Curve

Curve: "Secp256k1" | "Secp256r1"

Secp256k1 for BTC, ETH Secp256r1 for NEO

FillPoolFn

FillPoolFn: (arg: { blockchain: Blockchain; client_dh_publics: string[] }) => Promise<string[]>

Type declaration

    • (arg: { blockchain: Blockchain; client_dh_publics: string[] }): Promise<string[]>
    • Parameters

      • arg: { blockchain: Blockchain; client_dh_publics: string[] }
        • blockchain: Blockchain
        • client_dh_publics: string[]

      Returns Promise<string[]>

GenerateProofFn

GenerateProofFn: (arg: {}) => Promise<Proof>

Type declaration

    • (arg: {}): Promise<Proof>
    • Parameters

      • arg: {}

      Returns Promise<Proof>

Variables

Const ADDR_VERSION

ADDR_VERSION: "17" = "17"

Const BLOCKCHAIN_PRECISION

BLOCKCHAIN_PRECISION: 8 = 8

Const BLOCK_RPOOL_SIZE

BLOCK_RPOOL_SIZE: 4 = 4

Const BN

BN: BigNumber = BigNumber.clone({ DECIMAL_PLACES: 16 })

Const BuyOrSellBuy

BuyOrSellBuy: "BUY" = "BUY"

Const BuyOrSellSell

BuyOrSellSell: "SELL" = "SELL"

Const EPOCH_START

EPOCH_START: 163400000000 = 163400000000

Const HASH_DOUBLESHA256

HASH_DOUBLESHA256: "DOUBLESHA256" = "DOUBLESHA256"

Const HASH_DOUBLE_SHA256

HASH_DOUBLE_SHA256: "DOUBLE_SHA256" = "DOUBLE_SHA256"

Const HASH_NONE

HASH_NONE: "NOHASH" = "NOHASH"

Const HASH_SHA256

HASH_SHA256: "SHA256" = "SHA256"

Const MAX_FEE_RATE

MAX_FEE_RATE: 0.0025 = 0.0025

Const MAX_ORDER_AMOUNT

MAX_ORDER_AMOUNT: "ffffffffffffffff" = MAX_ORDER_RATE

Const MAX_ORDER_RATE

MAX_ORDER_RATE: "ffffffffffffffff" = "ffffffffffffffff"

Const MIN_ORDER_RATE

MIN_ORDER_RATE: 0 = 0

Let MIN_RPOOL_SIZE

MIN_RPOOL_SIZE: number = 10

Let MPCWallet

MPCWallet: any

Const MovementTypeDeposit

MovementTypeDeposit: "DEPOSIT" = "DEPOSIT"

Const MovementTypeTransfer

MovementTypeTransfer: "TRANSFER" = "TRANSFER"

Const MovementTypeWithdrawal

MovementTypeWithdrawal: "WITHDRAWAL" = "WITHDRAWAL"

Const N

N: number = 2 ** 16

Const NEO3_ADDR_VERSION

NEO3_ADDR_VERSION: "35" = "35"

Const NONCE_SIZE

NONCE_SIZE: 12 = 12

Const NON_SEGWIT

NON_SEGWIT: CoinType[] = [CoinType.BCH, CoinType.DOGE]

Const ORDER_NONCE_IGNORE

ORDER_NONCE_IGNORE: 4294967295 = 4294967295

Let RPOOL_SIZE

RPOOL_SIZE: number = 100

Const SECRET_KEY_SIZE_BYTES

SECRET_KEY_SIZE_BYTES: 16 = 16

Const bip44Purpose

bip44Purpose: 44 = 44

Const canonicalString

canonicalString: (a1: A1) => R4 = compose(toLower,JSON.stringify,o =>Object.keys(o).sort().reduce((acc, el) => ({ ...acc, [el]: o[el] }), {}),deep(mapKeys(snakeCase)))

Generates the canonical string for a given payload.

The canonical string is a human-readable JSON representation of the payload parameters. The keys are alphabetized, and are represented in snake case.

Type declaration

    • (a1: A1): R4
    • Parameters

      • a1: A1

      Returns R4

Const curve

curve: ec = new EC('secp256k1')

Const dkLen

dkLen: 32 = 32

Const ellipticContext

ellipticContext: ec = new EC.ec('secp256k1')

Const hexRegex

hexRegex: RegExp = /^([0-9A-Fa-f]{2})*$/

Const length

length: 32 = 32

Const nashPurpose

nashPurpose: 1337 = 1337

Const p

p: 1 = 1

Const paillierPKs

paillierPKs: Map<string, Promise<string>> = new Map<string, Promise<string>>()

Const r

r: 8 = 8

Functions

Keccak256

  • Keccak256(data: string): Buffer

_fill

ab2hexstring

  • ab2hexstring(arr: ArrayBuffer | ArrayLike<number>): string

addRawBlockchainOrderData

addRawPresignBlockchainOrderData

alterOrderPayloadForGraphql

  • alterOrderPayloadForGraphql(payload: any): any

Const bitcoinAddressFromPublicKey

  • bitcoinAddressFromPublicKey(publicKey: Buffer, type: CoinType, net: string): string

Const bitcoinNetworkFromString

  • bitcoinNetworkFromString(type: CoinType, net: string | undefined): Network

bufferize

  • bufferize(str: string): Buffer
  • Converts a hex string to a buffer. Used for consistency to ensure the proper canonical string representation for buffers.

    See bufferize.ts.

    Parameters

    • str: string

    Returns Buffer

buildETHMovementSignatureData

  • buildETHMovementSignatureData(address: string, payloadAndKind: PayloadAndKind): string

buildETHOrderSignatureData

buildMovementSignatureData

buildNEOMovementSignatureData

  • buildNEOMovementSignatureData(address: string, publicKey: string, assetData: Config["assetData"], payloadAndKind: PayloadAndKind): string

buildNEOOrderSignatureData

buildOrderSignatureData

Const canonicalizePayload

  • Different payload types have different preprocessing strategies. This is a convenience function to properly process various payloads.

    Parameters

    Returns string

Const coinTypeFromString

  • coinTypeFromString(s: string): CoinType

computePresig

Const configurePoolSettings

  • configurePoolSettings(poolSize: number, minPoolSize?: undefined | number): void
  • Parameters

    • poolSize: number
    • Optional minPoolSize: undefined | number

    Returns void

constructLength

  • constructLength(arr: number[], len: number): void

convertEthNonce

  • convertEthNonce(nonce: number): string

createAPIKey

  • createAPIKey(__namedParameters: { curve: "Secp256k1" | "Secp256r1"; generateProofFn: (arg: {}) => Promise<Proof>; secret: string }): Promise<SignKey>
  • Parameters

    • __namedParameters: { curve: "Secp256k1" | "Secp256r1"; generateProofFn: (arg: {}) => Promise<Proof>; secret: string }
      • curve: "Secp256k1" | "Secp256r1"
      • generateProofFn: (arg: {}) => Promise<Proof>
          • (arg: {}): Promise<Proof>
          • Parameters

            • arg: {}

            Returns Promise<Proof>

      • secret: string

    Returns Promise<SignKey>

createAccountPortfolioParams

  • createAccountPortfolioParams(fiatSymbol?: undefined | string, period?: undefined | string): PayloadAndKind

createAddMovementParams

  • createAddMovementParams(address: string, backendGeneratedPayload: boolean, quantity: object, type: string, nonce: number, timestamp?: undefined | number, recycledOrders?: ClientSignedState[], digests?: TransactionDigest[]): PayloadAndKind

createCancelOrderParams

  • createCancelOrderParams(id: string, marketName: string): PayloadAndKind

createGetAccountAddressParams

createGetAccountBalanceParams

createGetAccountOrderParams

createGetAccountVolumesParams

createGetAssetsNoncesParams

createGetDepositAddressParams

createGetMovementParams

createGetOrdersForMovementParams

createGetStatesParams

Const createHashedMessage

  • createHashedMessage(data: string): Buffer

createListAccountBalanceParams

  • createListAccountBalanceParams(ignoreLowBalance?: boolean): PayloadAndKind

createListAccountOrdersParams

  • createListAccountOrdersParams(before?: undefined | string, buyOrSell?: undefined | string, limit?: undefined | number, marketName?: undefined | string, rangeStart?: undefined | string, rangeStop?: undefined | string, status?: [string], type?: [string]): PayloadAndKind
  • Parameters

    • Optional before: undefined | string
    • Optional buyOrSell: undefined | string
    • Optional limit: undefined | number
    • Optional marketName: undefined | string
    • Optional rangeStart: undefined | string
    • Optional rangeStop: undefined | string
    • Optional status: [string]
    • Optional type: [string]

    Returns PayloadAndKind

createListAccountTradesParams

  • createListAccountTradesParams(before?: undefined | string, limit?: undefined | number, marketName?: undefined | string): PayloadAndKind

createListAccountTransactionsParams

  • createListAccountTransactionsParams(cursor?: undefined | string, fiatSymbol?: undefined | string, limit?: undefined | number): PayloadAndKind

createListMovementsParams

  • createListMovementsParams(currency?: undefined | string, status?: undefined | string, type?: undefined | string): PayloadAndKind

createPlaceLimitOrderParams

  • createPlaceLimitOrderParams(allowTaker: boolean, amount: object, buyOrSell: string, cancellationPolicy: string, limitPrice: object, marketName: string, noncesFrom: number[], noncesTo: number[], nonceOrder?: undefined | number, cancelAt?: undefined | string): PayloadAndKind
  • Parameters

    • allowTaker: boolean
    • amount: object
    • buyOrSell: string
    • cancellationPolicy: string
    • limitPrice: object
    • marketName: string
    • noncesFrom: number[]
    • noncesTo: number[]
    • Optional nonceOrder: undefined | number
    • Optional cancelAt: undefined | string

    Returns PayloadAndKind

createPlaceMarketOrderParams

  • createPlaceMarketOrderParams(amount: object, buyOrSell: string, marketName: string, noncesFrom: number[], noncesTo: number[], nonceOrder?: undefined | number): PayloadAndKind
  • Parameters

    • amount: object
    • buyOrSell: string
    • marketName: string
    • noncesFrom: number[]
    • noncesTo: number[]
    • Optional nonceOrder: undefined | number

    Returns PayloadAndKind

createPlaceStopLimitOrderParams

  • createPlaceStopLimitOrderParams(allowTaker: boolean, amount: object, buyOrSell: string, cancellationPolicy: string, limitPrice: object, marketName: string, stopPrice: object, noncesFrom: number[], noncesTo: number[], nonceOrder?: undefined | number, cancelAt?: undefined | string): PayloadAndKind
  • Parameters

    • allowTaker: boolean
    • amount: object
    • buyOrSell: string
    • cancellationPolicy: string
    • limitPrice: object
    • marketName: string
    • stopPrice: object
    • noncesFrom: number[]
    • noncesTo: number[]
    • Optional nonceOrder: undefined | number
    • Optional cancelAt: undefined | string

    Returns PayloadAndKind

createPlaceStopMarketOrderParams

  • createPlaceStopMarketOrderParams(amount: object, buyOrSell: string, marketName: string, stopPrice: object, noncesFrom: number[], noncesTo: number[], nonceOrder?: undefined | number): PayloadAndKind
  • Parameters

    • amount: object
    • buyOrSell: string
    • marketName: string
    • stopPrice: object
    • noncesFrom: number[]
    • noncesTo: number[]
    • Optional nonceOrder: undefined | number

    Returns PayloadAndKind

createPrepareMovementParams

  • createPrepareMovementParams(address: string, backendGeneratedPayload: boolean, quantity: object, type: string, timestamp?: undefined | number, targetAddress?: undefined | string, capQuantityToMaximum?: undefined | false | true, gasPrice?: undefined | number): PayloadAndKind
  • Parameters

    • address: string
    • backendGeneratedPayload: boolean
    • quantity: object
    • type: string
    • Optional timestamp: undefined | number
    • Optional targetAddress: undefined | string
    • Optional capQuantityToMaximum: undefined | false | true
    • Optional gasPrice: undefined | number

    Returns PayloadAndKind

createSendBlockchainRawTransactionParams

  • createSendBlockchainRawTransactionParams(blockchain: string, transactionPayload: string): PayloadAndKind

createSignStatesParams

createSyncStatesParams

Const createTimestamp

  • createTimestamp(): number

Const createTimestamp32

  • createTimestamp32(): number

decodeAPIKeys

  • decodeAPIKeys(encoded: string): APIKey

decryptSecretKey

  • decryptSecretKey(encryptionKey: Buffer, aead: AEAD): Promise<Buffer>

Const deep

  • deep(fn: (x: any) => any): (Anonymous function)
  • Parameters

    • fn: (x: any) => any
        • (x: any): any
        • Parameters

          • x: any

          Returns any

    Returns (Anonymous function)

deriveIndex

  • deriveIndex(extendedKey: BIP32Interface, index: number): BIP32Interface

derivePath

  • derivePath(masterSeed: Buffer, purpose: number, coinType: CoinType, account: number, change: number): BIP32Interface

determineSignatureNonceTuplesNeeded

encodeApiKeys

  • encodeApiKeys(key: APIKey): string

encryptSecretKey

  • encryptSecretKey(encryptionKey: Buffer, secretKey: Buffer): AEAD
  • Encrypts a secret key via AEAD. Returns an AEAD object. This object is stored server-side, while the encryption key is never stored. When authenticating, the server returns the AEAD object while the client must generate the encryption key on the fly from the user's password using getHKDFKeyFromPassword.ts.

    Uses aes-256-gcm.

    See decryptSecretKey.ts.

    Parameters

    • encryptionKey: Buffer
    • secretKey: Buffer

    Returns AEAD

ensureHex

  • ensureHex(str: string): void

exchangeAmount

  • exchangeAmount(price: BigNumber, amount: string): string

fillRPool

fillRPoolIfNeeded

generateAPIKeys

generateBIP44Key

  • generateBIP44Key(masterSeed: Buffer, coinType: CoinType, index: number): BIP32Interface
  • Generates a deterministic key according to the BIP-44 spec.

    M' / purpose' / coin' / account' / change / index M' / 44' / coin' / 0' / 0

    Parameters

    • masterSeed: Buffer
    • coinType: CoinType
    • index: number

    Returns BIP32Interface

generateNashPayloadSigningKey

  • generateNashPayloadSigningKey(masterSeed: Buffer, index: number): Wallet

generateWallet

  • generateWallet(masterSeed: Buffer, coinType: CoinType, index: number, net?: undefined | string, blockchain?: Blockchain): Wallet

generateWalletForCoinType

  • generateWalletForCoinType(key: BIP32Interface, coinType: CoinType, index: number, net?: undefined | string, blockchain?: Blockchain): Wallet

Const getAddressFromScriptHash

  • getAddressFromScriptHash(scriptHash: string, addressVersion: string): string

getBlockchainMovement

  • getBlockchainMovement(wallets: { btc: { address: string; publicKey: string }; eth: { address: string; publicKey: string }; neo: { address: string; publicKey: string } }, assets: Config["assetData"], payloadAndKind: PayloadAndKind): BlockchainMovement
  • Parameters

    • wallets: { btc: { address: string; publicKey: string }; eth: { address: string; publicKey: string }; neo: { address: string; publicKey: string } }
      • btc: { address: string; publicKey: string }
        • address: string
        • publicKey: string
      • eth: { address: string; publicKey: string }
        • address: string
        • publicKey: string
      • neo: { address: string; publicKey: string }
        • address: string
        • publicKey: string
    • assets: Config["assetData"]
    • payloadAndKind: PayloadAndKind

    Returns BlockchainMovement

getDhPoolSize

getETHAssetID

  • getETHAssetID(asset: string): string

getHKDFKeysFromPassword

  • getHKDFKeysFromPassword(password: string, salt: string): Promise<HKDFKeys>
  • Derives two keys from a given input key via HKDF.

    Specifically, we use this to derive keys from a user's hashed password and never use the hashed password directly. Thus, if one derived key is compromised, other keys are not affected.

    See the HKDFKeys interface for information on how Nash uses these keys.

    Parameters

    • password: string
    • salt: string

    Returns Promise<HKDFKeys>

getLimitPrice

  • getLimitPrice(marketName: string, buyOrSell: string, limitPrice: any): BigNumber

Const getMPCWallet

  • getMPCWallet(): Promise<any>

getNEOAssetHash

  • getNEOAssetHash(asset: Asset): string

getNEOScriptHash

  • getNEOScriptHash(address: string): string

Const getScriptHashFromAddress

  • getScriptHashFromAddress(address: string): string

getSecretKey

  • getSecretKey(): Buffer
  • Generates a secret key of Nash's desired length from a random entropy.

    This secret key is ultimately the foundation of a user's wallets, so should be treated with extreme care.

    Returns Buffer

getUnitPairs

  • getUnitPairs(market: string): any

Const getVerificationScriptFromPublicKey

  • getVerificationScriptFromPublicKey(publicKey: string, blockchain?: Blockchain): string

Const hash

  • hash(hex: string, hashingFunction: (i: any) => WordArray): string

hash160

  • hash160(hex: string): string

hash256

  • hash256(hex: string): string

hashPassword

  • hashPassword(password: string, salt: string): Promise<Buffer>

inferBlockchainData

initialize

invertPrice

  • invertPrice(amount: BigNumber): BigNumber

isHex

  • isHex(str: string): boolean

isLimitOrderPayload

isOrderPayload

isStateSigning

kindToName

kindToOrderPrefix

mnemonicToMasterSeed

  • mnemonicToMasterSeed(mnemonic: ReadonlyArray<string>): Buffer

mnemonicToSecretKey

  • mnemonicToSecretKey(mnemonic: ReadonlyArray<string>): Buffer

needBlockchainMovement

needBlockchainSignature

neoGetPublicKeyFromPrivateKey

  • neoGetPublicKeyFromPrivateKey(privateKey: string, encode?: boolean): string

normalizeAmount

  • normalizeAmount(amount: string, precision: number): number

normalizeString

  • normalizeString(str: string): Buffer

preSignBTC

preSignPayload

preSignStateListAndRecycledOrders

precisionDiff

  • precisionDiff(amount: string, precision: number): number

presignBlockchainData

  • Presign blockchain data. Returns an array of signatures. Needed for operations such as order placement.

    If the operation occurs within the same blockchain origin, 1 signature is returned. For example, 1 signature is returned when trading NEO for GAS.

    If the operation is cross-chain, 2 signatures are returned. For example, two signatures are returned for a BTC-ETH trade.

    Parameters

    Returns Promise<ReadonlyArray<BlockchainSignature>>

presignETHBlockchainData

presignNEOBlockchainData

presignRecycledOrdersForAddMovement

presignStateList

presignTransactionDigestsForAddMovement

presignTransactionDigestsForIterateTransaction

publicKeyFromSecretKey

  • publicKeyFromSecretKey(__namedParameters: { curve: "Secp256k1" | "Secp256r1"; secret: string }): Promise<string>
  • Parameters

    • __namedParameters: { curve: "Secp256k1" | "Secp256r1"; secret: string }
      • curve: "Secp256k1" | "Secp256r1"
      • secret: string

    Returns Promise<string>

randomBytes

  • randomBytes(bytes: number): Buffer
  • Returns an entropy with the given number of bytes. Works in both Node and the browser.

    Parameters

    • bytes: number

    Returns Buffer

rateWithFees

  • rateWithFees(rate: BigNumber): BigNumber

regenerateMnemonic

  • regenerateMnemonic(aead: AEAD, password: string, salt: string): Promise<ReadonlyArray<string>>
  • Convenience function for retrieving a mnemonic from a user's password and AEAD. Simply derives the encryption key from the password, and uses that to decrypt the encrypted secret key, then derives the mnemonic from the key.

    Parameters

    • aead: AEAD
    • password: string
    • salt: string

    Returns Promise<ReadonlyArray<string>>

reverseHex

  • reverseHex(hex: string): string

reverseHexString

  • reverseHexString(hex: string): string

ripemd160

  • ripemd160(hex: string): string

rmPadding

  • rmPadding(buf: number[]): number[]

secretKeyToMnemonic

  • secretKeyToMnemonic(secretKey: Buffer): ReadonlyArray<string>
  • Converts a given secret key to its BIP-39 mnemonic representation.

    Returns the mnemonic as an array of words.

    See mnemonicToSecretKey.ts.

    Parameters

    • secretKey: Buffer

    Returns ReadonlyArray<string>

Const sha256

  • sha256(hex: string): string
  • sha256(msg: string): string

sign

  • sign(sk: string, msg: string): Promise<{ r: string; s: string }>
  • We can use this signing function instead of the one from elliptic. It is about 3/4 times faster in node environments

    Parameters

    • sk: string
    • msg: string

    Returns Promise<{ r: string; s: string }>

signBTC

signBlockchainData

  • Signs blockchain data. Returns an array of signatures. Needed for operations such as order placement.

    If the operation occurs within the same blockchain origin, 1 signature is returned. For example, 1 signature is returned when trading NEO for GAS.

    If the operation is cross-chain, 2 signatures are returned. For example, two signatures are returned for a BTC-ETH trade.

    Parameters

    Returns ReadonlyArray<BlockchainSignature>

signETHBlockchainData

signNEOBlockchainData

  • signNEOBlockchainData(privateKey: string, data: string, performHash?: boolean): BlockchainSignature

signPayload

  • Signs a payload using a private key. The private key should be the key created by initialization of the Nash Protocol. Payloads are signed via ECDSA using secp256k1.

    If the payload to be signed is for a blockchain operation, the Config object must be passed as well to create the blockchain signatures.

    Refer to the documentation for the Config interface and to initialize.ts.

    Parameters

    Returns PayloadSignature

signRecycledOrdersForAddMovement

signStateList

signStateListAndRecycledOrders

signTransactionDigestsForAddMovement

snakeCase

  • snakeCase(obj: Record<string, any>): object

snakeCaseString

  • snakeCaseString(str: string): string

stringify

  • stringify(buffer: Buffer): string
  • Converts a buffer to a hex string. Used for consistency to ensure the proper canonical string representation for buffers.

    See bufferize.ts.

    Parameters

    • buffer: Buffer

    Returns string

toBigEndian

  • toBigEndian(n: number): Buffer

toBigEndianHex

  • toBigEndianHex(n: number): string

toDER

  • toDER(sig: { r: string; s: string }, enc: string): number[]
  • Parameters

    • sig: { r: string; s: string }
      • r: string
      • s: string
    • enc: string

    Returns number[]

toLittleEndian

  • toLittleEndian(n: number): Buffer

toLittleEndianHex

  • toLittleEndianHex(n: number): string

validateMnemonic

  • validateMnemonic(mnemonic: ReadonlyArray<string>): boolean
  • Checks if an array of BIP39 words forms a valid BIP39 mnemonic. Note that Nash uses 12-word mnemonics, but this function will return true for a spec compliant mnemonic of any length.

    Parameters

    • mnemonic: ReadonlyArray<string>

      An array of words to validate.

    Returns boolean

Object literals

Const BlockchainCurve

BlockchainCurve: object

__computed

__computed: "Secp256r1" = "Secp256r1"

Const PayloadIDToName

PayloadIDToName: object

__computed

__computed: string = "iterate_transaction"

Const _FILL_JOB

_FILL_JOB: object

Secp256k1

Secp256k1: null = null

Secp256r1

Secp256r1: null = null

Const bigNumberFormat

bigNumberFormat: object

decimalSeparator

decimalSeparator: string = "."

groupSeparator

groupSeparator: string = ""

groupSize

groupSize: number = 50

prefix

prefix: string = ""

Legend

  • Property

Generated using TypeDoc