UNPKG

@coti-io/coti-sdk-typescript

Version:

A library for encryption, decryption and cryptographic utilities for the COTI blockchain.

59 lines (41 loc) 2.93 kB
[![image](https://img.shields.io/badge/Telegram-2CA5E0?style=for-the-badge&logo=telegram&logoColor=white)](https://telegram.coti.io) [![image](https://img.shields.io/badge/Discord-5865F2?style=for-the-badge&logo=discord&logoColor=white)](https://discord.coti.io) [![image](https://img.shields.io/badge/X-000000?style=for-the-badge&logo=x&logoColor=white)](https://twitter.coti.io) [![image](https://img.shields.io/badge/YouTube-FF0000?style=for-the-badge&logo=youtube&logoColor=white)](https://youtube.coti.io) [![COTI Website](https://img.shields.io/badge/COTI%20WEBSITE-4CAF50?style=for-the-badge)](https://coti.io) # COTI SDK TypeScript [![image](https://img.shields.io/badge/npm-CB3837?style=for-the-badge&logo=npm&logoColor=white)](https://www.npmjs.com/package/@coti-io/coti-sdk-typescript) [![image](https://img.shields.io/badge/Node%20js-339933?style=for-the-badge&logo=nodedotjs&logoColor=white)](https://nodejs.org/download/release/v18.20.5/) 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. ## Documentation Full API documentation is available in the [COTI docs](https://docs.coti.io/coti-v2-documentation/build-on-coti/tools/coti-sdk) ## Build and Install ```bash npm install ``` ## Testing ```bash npm test ``` ## Deprecations The following legacy helpers remain available for compatibility, but will be removed in a future major version: - `buildInputText`: use `prepareIT` for unsigned integer input-text values. `buildInputText` is an older 64-bit-only wrapper; `prepareIT` supports the canonical 128-bit `itUint` path. - `buildItSignature`: use `signInputText` with an ethers `Wallet` for private-key signing. For browser wallets and 256-bit values, use `buildItUint256WithSigner`. - `encodeString`: use `binaryStringToBytes`. The old name suggests UTF-8 encoding, but the function converts a node-forge binary string to bytes. - `generateRandomAesKeySizeNumber`: use `generateRandomAesKeyBinaryString`. The old name suggests a numeric value; it returns a 16-byte binary string. ### ctUint naming `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](https://github.com/coti-io/coti-sdk-typescript/issues/new) tab.