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.
Converts a hex string to a buffer. Used for consistency to ensure the proper canonical string representation for buffers.
See bufferize.ts
.
Different payload types have different preprocessing strategies. This is a convenience function to properly process various payloads.
Returns the number of milliseconds since the Unix Epoch.
Decrypts an encrypted secret key via AEAD. Takes an AEAD
object.
See encryptSecretKey.ts
.
Derives a new key from the extended key for the given index.
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
.
Throws an error if input is not hexstring.
Generates a deterministic key according to the BIP-44 spec.
M' / purpose' / coin' / account' / change / index
M' / 44' / coin' / 0' / 0
Creates the keypair used for signing payloads. Used during Nash Protocol initialization.
Creates a wallet for a given token via the BIP-44 protocol.
Requires the user's master seed.
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.
Converts an address to scripthash.
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.
Hashes a plaintext password via the scrypt key derivation function.
Checks if input is a hexstring. Empty string is considered a hexstring.
Converts a BIP-39 mnemonic to its master seed representation. This representation is used to generate blockchain wallets.
Converts a BIP-39 mnemonic to its secret key representation.
See secretKeyToMnemonic.ts
.
Presigns a payload using a apikey.
[description]
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.
Returns an entropy with the given number of bytes. Works in both Node and the browser.
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.
Reverses a HEX string, treating 2 chars as a byte.
Converts a given secret key to its BIP-39 mnemonic representation.
Returns the mnemonic as an array of words.
See mnemonicToSecretKey.ts
.
We can use this signing function instead of the one from elliptic. It is about 3/4 times faster in node environments
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.
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
.
Converts a buffer to a hex string. Used for consistency to ensure the proper canonical string representation for buffers.
See bufferize.ts
.
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.
An array of words to validate.
Generated using TypeDoc
Secp256k1 for BTC, ETH Secp256r1 for NEO