Othent
  • 👋Welcome to Othent
  • 🥪JS SDK
    • Getting Started
    • Events
    • Error Handling
    • Binary Data Types Utils
    • TypeScript Types
    • Config Constants
  • 🥪JS SDK API
    • constructor()
    • startTabSynching()
    • completeConnectionAfterRedirect()
    • connect()
    • disconnect()
    • requireAuth()
    • isAuthenticated
    • getActiveAddress()
    • getActivePublicKey()
    • getAllAddresses()
    • getWalletNames()
    • getUserDetails()
    • getSyncActiveAddress()
    • getSyncActivePublicKey()
    • getSyncAllAddresses()
    • getSyncWalletNames()
    • getSyncUserDetails()
    • sign() (transaction)
    • dispatch() (transaction)
    • encrypt()
    • decrypt()
    • signature()
    • signDataItem()
    • signMessage()
    • verifyMessage()
    • privateHash()
    • walletName
    • walletVersion
    • config
    • getArweaveConfig()
    • getPermissions()
  • Demos
    • 🍏SDK playground / demo
    • 🍏SDK playground / demo GitHub
    • 🍎File upload app example
    • 🍎File upload app example GitHub
  • 📚External libraries
    • arweave-js
    • Arweave Wallet Kit
  • Additional Links
    • 🌐Othent.io
    • 🌐Discord
    • 🌐GitHub
    • 🌐X
Powered by GitBook
On this page
  • API
  • ciphertext: BinaryDataType
  • return Promise<Uint8Array>
  • Example usage
  1. JS SDK API

decrypt()

Othent JS SDK decrypt() function

Previousencrypt()Nextsignature()

Last updated 8 months ago

The decrypt() function allows applications to decrypt data that has been encrypted using the active user's private key, similarly to the .

Limitation: There's currently an 8KB limit in data size when using Othent, but this is currently being worked on. Track the progress on this .

Limitation: Also, the only currently available encryption/decryption algorithm is AES (AES256-GCM).

This function assumes (and requires) a user is authenticated. See .

API

decrypt(ciphertext: BinaryDataType): Promise<Uint8Array>;

ciphertext: BinaryDataType

The data to be decrypted with the user's private key, which can be of type , or .

return Promise<Uint8Array>

A Promise containing the decrypted data as .

Example usage

import { Othent } from "@othent/kms";

const othent = new Othent({ appInfo, throwErrors: false, ... });

// Make sure the user is authenticated, or prompt them to authenticate:
await othent.requireAuth();

// Encrypt data using RSA:
const encrypted = await othent.encrypt("This message will be encrypted");

console.log("Encrypted bytes:", encrypted);

// Decrypt the same data using RSA:
const decrypted = await othent.decrypt(encrypted);
const decryptedString = new TextDecoder().decode(decrypted);

console.log(`The original secret message is "${ decryptedString }".`);
🥪
Web Crypto API's decrypt()
GitHub issue
requireAuth()
ArrayBuffer
TypedArray
DataView
Uint8Array