@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
Markdown
[](https://telegram.coti.io)
[](https://discord.coti.io)
[](https://twitter.coti.io)
[](https://youtube.coti.io)
[](https://coti.io)
# COTI SDK TypeScript
[](https://www.npmjs.com/package/@coti-io/coti-sdk-typescript)
[](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.