Socket
Socket
Sign inDemoInstall

@dataparty/crypto

Package Overview
Dependencies
51
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @dataparty/crypto

dataparty crypto routines


Version published
Weekly downloads
1
Maintainers
2
Created
Weekly downloads
 

Readme

Source

@dataparty/crypto

stablelicense

dataparty cryptography

It slices, it dices, and it enciphers

Features

Identity

Creating a random key pair

const dataparty_crypto = require('@dataparty/crypto')

const alice = new dataparty_crypto.Identity({id:'alice'})
const bob = new dataparty_crypto.Identity({id:'bob'})

Messages

let encryptedMessage = new dataparty_crypto.Message({
    msg: {
        data: 'hello world'
    }
})
Encryption
//! Bob encrypts the message
await encryptedMessage.encrypt(bob, alice.toMini())

sendToAlice( encryptedMessage.toJSON() )
Decryption
//! Later alice decrypt a message
const decryptedMessage = new dataparty_crypto.Message(msgFromBob)

await decryptedMessage.decrypt(alice)

console.log(`alice read: ${JSON.stringify(decryptedMessage.msg,null,2)}`)

//! Another way to verify that bob sent the message
await decryptedMessage.assertVerified(bob)
Signing
//! Alice signs a message
const signedMsg = await alice.sign({a:'hello world'})

sendToAlice( signedMsg.toJSON() )
Verifying
const signedMsg = new dataparty_crypto.Message(msfFromAlice)

//! Verify that Alice sent the message
const verified = await alice.verify(signedMsg)
console.log('verified?', verified)

//! Another way to verify that alice sent the message
await signedMsg.assertVerified(alice)
Password key derivation
const password = 'super-strong-password'
const salt = await dataparty_crypto.Routines.generateSalt() //! Salt would be read from disk after 1st run

const key = await dataparty_crypto.Routines.createKeyFromPasswordArgon2(
    argon2,
    "supersecretpassword123",
    salt
)
Mnemonic derived keys seed phrases
const phrase = await dataparty_crypto.Routines.generateMnemonic()

let key = await dataparty_crypto.Routines.createKeyFromMnemonic(phrase)

Developing

  • npm build
  • npm watch
  • npm test

Support

Buy us a coffee!

FAQs

Last updated on 23 Apr 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc