npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@lorena-ssi/lorena-crypto

v0.0.2

Published

A javascript library to interact with @polkadotjs/util-crypto

Downloads

3

Readme

A Javascript Library for Zenroom

zenroom-lib is a javascript library to interact with the Zenroom Virtual Machine

npm version Build Status Coverage Status

Zenroom is a tiny and portable virtual machine that integrates in any application to authenticate and restrict access to data and execute human-readable smart contracts.

Installation

npm install @lorena-ssi/zenroom-lib

For React

This library uses Zenroom 1.0.0 which has a problem with create-react-app. To fix this issue we've added a script which patches the installed package:

./node_modules/@lorena-ssi/zenroom-lib/bin/zenroom_modules.sh

Usage

Initialize

const Zen = require('@lorena-ssi/zenroom-lib')
let z = new Zen()

Keypairs

Create keypairs

// Create a new keypair for Alice & Bob
let alice_keypair = await z.newKeyPair('Alice')
let bob_keypair = await z.newKeyPair('Bob')

Being the result:

{
  zenroom: {
    curve: 'goldilocks',
    encoding: 'url64',
    version: '1.0.0+a7fab75',
    scenario: 'simple'
  },
  Alice: {
    keypair: {
      public_key: 'u64:BH4GCburF7yL1KhITA676nxKIgEB2SQZ9BmeehuoWgPObMpb9ZTTigBgfhbrwLTxf0tWtRK6kM6D0DVItqdMWGRDsII75qXcLOunQTTiGcpAH3_iTlqjzXUDeDzcudyFhZByFohsi1wCqeAXPsKsjeQ',
      private_key: 'u64:IKwYf6BRXMQBveMizlkx0k1ru3qg3wApZBAfZ2sUL6nUGKG9tvU6hB9s4cmN-Gi2rXDjeIm-quk'
    }
  }
}

Retrieve only the public Key

// Create a new keypair for Alice & Bob
let alice_public = await z.publicKey('Alice', alice_keypair)
let bob_public = await z.publicKey('Bob', bob_keypair)

Being the result:

{
  zenroom: {
    curve: 'goldilocks',
    encoding: 'url64',
    version: '1.0.0+a7fab75',
    scenario: 'simple'
  },
  Alice: {
    public_key: 'u64:BJeFhvqKzJERiHrZaMHlPR6ms59086qcwtafngq2nJvyDUatcdH7NSkVGvf5iKnWpsC546lTjhLIxWDf1-wfUdRy3dXa6Y6OzQvmMtqrRh33t5pXvuCDylRGiA4DqWKV6ocymggIvhdtMaXLOvNDoy4'
  }
}

Signatures

Sign a message

// Create a new keypair for Alice & Bob
const signature = await z.signMessage('Alice', alice_keypair, message)

Being the result:

{
  zenroom: {
    curve: 'goldilocks',
    encoding: 'url64',
    version: '1.0.0+a7fab75',
    scenario: 'simple'
  },
  Alice: {
    draft: 'u64:SGVsbG9fV29ybGQ',
    signature: {
      s: 'u64:H71LonTCQOhhvuYCx9dMXNLDe0g-qngR28njL0tAgn8mdX2YYu2tAn9jyeaUJmBpk9iJijr7cvE',
      r: 'u64:Pv4lnBlJgPaFxEGXHntwIaUem__tjFpWQMOG9yelvb2VB5xvj2PXMTg-SsHExfL6BSPaHwFSbdo'
    }
  }
}

Check the signature

// Create a new keypair for Alice & Bob
const check = await z.checkSignature('Alice', alice_public, signature, 'Bob')

Being the result:

{
  zenroom: {
    curve: 'goldilocks',
    encoding: 'url64',
    version: '1.0.0+a7fab75',
    scenario: 'simple'
  },
  signature: 'correct'
}

Encryption

encrypts a message

// Create a new keypair for Alice & Bob
const msg_encrypted = await z.encryptMessage('Alice', alice_keypair, 'Bob', bob_public, 'HelloWorld')

Being the result:

{
  secret_message: {
    iv: 'u64:Da57UyzCWz0gbxCeLpPPLA',
    header: 'u64:VGhpc19pc190aGVfaGVhZGVy',
    text: 'u64:4vazxwae5d4Pi9E',
    checksum: 'u64:pRGDjsiYg_9dQS1rWk-gVg'
  },
  zenroom: {
    curve: 'goldilocks',
    encoding: 'url64',
    version: '1.0.0+a7fab75',
    scenario: 'simple'
  }
}

Decrypts a message

// Create a new keypair for Alice & Bob
let msg = await z.decryptMessage('Alice', alice_public, 'Bob', bob_keypair, msg_encrypted)

Being the result:

{
  message: 'Hello_World',
  zenroom: {
    curve: 'goldilocks',
    encoding: 'url64',
    version: '1.0.0+a7fab75',
    scenario: 'simple'
  },
  header: 'This_is_the_header'
}