Enigma-JS ========== The Enigma client library, Enigma-JS, is a JavaScript library that interfaces with the Enigma protocol. Enigma-JS contains tools to: 1. Safely encrypt sensitive data in-memory for immediate use or storage. 2. Obtain an authoritative proof that the target worker is securely running trusted hardware prior to sending data and paying fees. (Trusted hardware for this release means Intel SGX; for more information on SGX, see the :ref:`On SGX ` and :ref:`Registration ` sections.) This client library is still in active development. This documentation will be added to as development proceeds. **validateKeyHex** ~~~~~~~~~~~~~~~~~~~ validateKeyHex(key) - description: Checks whether the supplied key is valid. - arguments: key: the supplied key in hex. - returns: A valid key derived from the argument. **getDerivedKey** ~~~~~~~~~~~~~~~~~~ getDerivedKey(enclavePublicKey, clientPrivateKey) - description: Gets a shared key derived from the client and the enclave. - arguments: enclavePublicKey: the public key of the enclave. clientPrivateKey: the private key of the client. - returns: A shared key derived from Elliptic Curve Diffie-Hellman. **encryptMessage** ~~~~~~~~~~~~~~~~~~~ encryptMessage(derivedKey, msg) - description: Encrypts a user message. - arguments: derivedKey: the shared key resulting from the getDerivedKey function call. msg: the data to be encrypted. - returns: An encrypted message using derivedKey and msg. **getPublicKey** ~~~~~~~~~~~~~~~~~ getPublicKey(clientPrivateKey) - description: Gets the public key of the enclave. - arguments: clientPrivateKey: the client's private key. - returns: The public key of the enclave. **removeTrailing0x** ~~~~~~~~~~~~~~~~~~~~~ removeTrailing0x(str) - description: Removes "0x" from the input. - arguments: str: the string to be trimmed. - returns: The shortened string if the string contained "0x", the original string if not. **recoverPubKey** ~~~~~~~~~~~~~~~~~~ recoverPubKey(msgHash, signature) - arguments: - returns: **verifySignature** ~~~~~~~~~~~~~~~~~~~~ verifySignature(msg, signature, pubAddr) - arguments: - returns: **selectWorker** ~~~~~~~~~~~~~~~~~ selectWorker(taskId) - arguments: - returns: