New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

umbral

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

umbral

```npm install umbral```

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Umbral

Installation

npm install umbral

Initialization

The module must be initialized with a sodium instance.

let _sodium = null;
await _sodium.ready;
umbral.init(_sodium);

Encryption

/**
  * Encrypts a user's record
  * @param {Uint8Array} randId - random ID
  * @param {IRecord} record - user record
  * @param {Uint8Array[]} publicKeys - options counselor public keys
  * @param {Uint8Array} skUser - user's secret key
  * @returns {IEncryptedData[]} an array of records encrypted under each public key
  */
function encryptData(randId: Uint8Array, record: IRecord, publicKeys: Uint8Array[], skUser: Uint8Array)

Decryption

The function should be provided with matched encrypted records

/**
 * Decrypts an array of encrypted data
 * @param {IEncryptedData[]} encryptedData - an array of encrypted data of matched users
 * @param {Uint8Array} skOC - secret key of an options counselor
 * @param pkUser - user's private key
 * @returns {IRecord[]} array of decrypted records from matched users
 */
function decryptData(encryptedData: IEncryptedData[], skOC: Uint8Array, pkUser: Uint8Array)

Basic End-to-End Example


await _sodium.ready;
umbral.init(_sodium);

const ocKeyPair = _sodium.crypto_box_keypair();
const userKeyPair = _sodium.crypto_box_keypair();

const perpId = createName();
let userId = createName();
const randId: Uint8Array = hashId(perpId);

const encryptedDataA = umbral.encryptData(randId, { perpId, userId }, [ocKeyPair.publicKey], userKeyPair.privateKey);
userId = userId + userId;
const encryptedDataB = umbral.encryptData(randId, { perpId, userId }, [ocKeyPair.publicKey], userKeyPair.privateKey);
const decryptedRecords = umbral.decryptData([encryptedDataA[0], encryptedDataB[0]], ocKeyPair.privateKey, userKeyPair.publicKey);

Additional examples can be found under test/tests.ts

Relevant Interfaces

A record is currently only a perpetrator ID and a user ID. This can be amended to include additional information.

export interface IRecord {
  perpId: string;
  userId: string;
}

FAQs

Package last updated on 29 Jun 2018

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