utils¶
oasis.utils provides a collection of client utilities.
utils.encrypt¶
utils.encrypt(
nonce,
plaintext,
peerPublicKey,
privateKey,
aad
);
Parameters¶
nonce-Uint8Array: The nonce used to encrypt the ciphertext.plaintext-Uint8Array: The text to be encryptedpeerPublicKey-Uint8Array: The public key to which the ciphertext will be encrypted.publicKey-Uint8Array: The public key of the entity encrypting the data.privateKey-Uint7Array: The private key of the entity encrypting the data.aad-Uint8Arraythe additional authenticated data for the AEAD.
Returns¶
Uint8Array: The encoded wire format of the ciphertext PUBLIC_KEY || CIPHER_LENGTH || AAD_LENGTH || CIPHER ||AAD || NONCE, where CIPHER_LENGTH AND AAD_LENGTH are encoded as big endian uint64.
utils.decrypt¶
Decrypts the given ciphertext using Deoxysii.js and the wire format specified above.
utils.decrypt(encryption, secretKey);
Parameters¶
encryption-Uint8Array: The encrypted data in the wire formated specified above.secretKey-Uint8Array: The secret key to which the data was encrypted.
Returns¶
Object: The decryption of the object with a key for each component of the decryption.nonce-Uint8Array: The nonce used to encrypt the ciphertext.plaintext-Uint8Array: The decrypted ciphertext.peerPublicKey-Uint8Array: The public key from which the ciphertext encrypted.aad-Uint8Arraythe additional authenticated data for the AEAD.
utils.header.parseFromCode¶
oasis.utils.header.parseHex(deploycode);
Parameters¶
deploycode-Uint8Array | String: The deployed bytecode of a service, prefixed with the header wire format:
b'\0sis' || version (2 bytes big endian) || length (2 bytes big endian) || json-header
Returns¶
Object: The deploy header with all fields.version-number: The version number of the header.expirty-number: Service expiry timestampconfidential-boolean: True if the service is confidential.
utils.bytes.parseHex¶
oasis.utils.bytes.parseHex(hexStr);
Parameters¶
hexStr-String: Hex string to parse.
Returns¶
Uint8Array: Transformed representation the given hex string.
utils.bytes.toHex¶
oasis.utils.bytes.toHex(byteArray);
Parameters¶
byteArray-Uint8Array: Byte array to convert into a hex string
Returns¶
String: Transformed representation of the given byte array.
utils.bytes.encodeUtf8¶
oasis.utils.header.encodeUtf8(input);
Parameters¶
input-string: String to encode into a utf8 encoded byte array
Returns¶
Uint8Array: Utf8 encoded byte earray
utils.bytes.decodeUtf8¶
oasis.utils.header.decodeUtf8(input);
Parameters¶
input-Uint8Array: Byte array previously encoded withutils.bytes.encodeUtf8
Returns¶
String: Utf8 encoded string
utils.cbor.encode¶
oasis.utils.cbor.encode(input);
Parameters¶
input-Object: JSON object to cbor encode
Returns¶
Uint8Array: Cbor encoded byte array
utils.cbor.decode¶
oasis.utils.cbor.decode(input);
Parameters¶
input-Uint8Array: Cbor encoded byte array
Returns¶
Object: Decoded JSON object
utils.idl.fromWasm¶
oasis.utils.idl.fromWasm(bytecode);
Returns¶
Promise<Object>: Promise resolving to the Idl extracted from the oasis-interface section of the given bytecode.
utils.idl.fromWasmSync¶
oasis.utils.idl.fromWasmSync(input);
A synchronous version of utils.idl.fromWasm.