Socket
Socket
Sign inDemoInstall

@privy-io/crypto

Package Overview
Dependencies
Maintainers
4
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@privy-io/crypto

Privy encryption and decryption library


Version published
Weekly downloads
8
increased by300%
Maintainers
4
Weekly downloads
 
Created
Source

@privy-io/crypto

JavaScript library for encrypting and decrypting data with Privy.

Usage

import {CryptoEngine, CryptoVersion} from 'privy-crypto-js';

// Grab the engine (implementation) corresponding to the version
const x0 = CryptoEngine(CryptoVersion.x0);

const plaintext = Buffer.from('{"ssn": "123-45-6789"}');

// Encryption
const privyEncryption = new x0.Encryption(plaintext, {
  wrapperKey: wrapperKey, // RSA public key from privy server
  wrapperKeyId: wrapperKeyId, // Metadata id of RSA public key from Privy's KMS
});
const encryptionResult = await privyEncryption.encrypt();
const ciphertext = encryptionResult.ciphertext();

// Decryption
const privyDecryption = new x0.Decryption(ciphertext);

// This is where Privy would decrypt the encrypted data
// key against the Privy server, ultimately doing so in an HSM.
const decryptedDataKey = decryptDataKey(
  privyDecryption.wrapperKeyId('utf8'),
  privyDecryption.encryptedDataKey('base64')
);

const decryptionResult = await privyDecryption.decrypt(decryptedDataKey);

// {"ssn": "123-45-6789"}
console.log(decryptionResult.plaintext('utf8'));

Running tests

npm test

Keywords

FAQs

Package last updated on 04 Feb 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc