Welcome to COTI SDK TypeScript, a comprehensive set of encryption, decryption, and cryptographic utilities, including RSA and AES encryption, message signing, and key handling functions. The utilities are primarily designed to work with cryptographic operations for secure communication and message signing, particularly within Ethereum smart contracts or similar environments.
Full API documentation is available in the COTI docs
npm installnpm testThe following legacy helpers remain available for compatibility, but will be removed in a future major version:
buildInputText: useprepareITfor unsigned integer input-text values.buildInputTextis an older 64-bit-only wrapper;prepareITsupports the canonical 128-bititUintpath.buildItSignature: usesignInputTextwith an ethersWalletfor private-key signing. For browser wallets and 256-bit values, usebuildItUint256WithSigner.encodeString: usebinaryStringToBytes. The old name suggests UTF-8 encoding, but the function converts a node-forge binary string to bytes.generateRandomAesKeySizeNumber: usegenerateRandomAesKeyBinaryString. The old name suggests a numeric value; it returns a 16-byte binary string.
ctUint (COTI ctUint64) is a bigint that packs 32 bytes of ciphertext
material on-chain, not a 64-bit plaintext value. Plaintext limits depend on the
API: encryptUint/decryptUint accept up to 64-bit plaintext; prepareIT
accepts up to 128-bit plaintext using the same wire format.
Do not treat prepareIT256 and buildItUint256WithSigner as interchangeable:
they intentionally sign different payload formats for different callers.
To report an issue, please see the issues tab.