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

@nearfoundation/near-js-encryption-box

v0.1.2

Published

> An experimental library to encrypt and decrypt data using the NEAR account's ed25519 keypairs; you can use it to store encrypted data on-chain, off-chain, or in any decentralized storage (IPFS, Arweave).

Downloads

3

Readme

near-js-encryption-box NEAR License

An experimental library to encrypt and decrypt data using the NEAR account's ed25519 keypairs; you can use it to store encrypted data on-chain, off-chain, or in any decentralized storage (IPFS, Arweave).

⚠️ This is an experimental library. We do not recommend to use it to store confidential information publically.

Installation

npm install @nearfoundation/near-js-encryption-box

Usage

You can find below an example where Alice encrypt data with her private key and Bob's public key. Then Bob can decrypt the message with his private key, Alice's public key and a nonce.

import { create, open } from 'near-js-encryption-box';
import { utils } from 'near-api-js';

// Randomly generating key pairs for the example
const keyPairAlice = utils.key_pair.KeyPairEd25519.fromRandom();
const keyPairBob = utils.key_pair.KeyPairEd25519.fromRandom();

// Encrypting a message
const message = 'Hello Bob';
const publicKeyBob = keyPairBob.getPublicKey().toString();
const privateKeyAlice = keyPairAlice.secretKey;
const { secret, nonce } = create(message, publicKeyBob, privateKeyAlice); // you can also pass your own custom nonce as a 4th parameter

// Decrypting the message
const publicKeyAlice = keyPairAlice.getPublicKey().toString();
const privateKeyBob = keyPairBob.secretKey;
const messageReceived = open(secret, publicKeyAlice, privateKeyBob, nonce);
console.log(messageReceived); // will return 'Hello Bob'

Find more examples in the near-js-encryption-box-test.ts

Encryption

  • Convert NEAR Ed25519 signing key pair into Curve25519 key pair suitable for Diffie-Hellman key; using ed2curve.js
    • "Note that there's currently no proof that this is safe to do. It is safer to share both Ed25519 and Curve25519 public keys (their concatenation is 64 bytes long)."
  • Then uses Curve25519-XSalsa20-Poly1305 implemented by TweetNaCl.js

Authors

License

MIT License