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

crypto-puzzle

v5.0.2

Published

A time-lock puzzle generator

Downloads

3,519

Readme

Crypto Puzzle

A time-lock puzzle generator.

Description

Time-lock puzzles are kind of a way to craft a message that can only be read after some point in the future, which you can pick.

A time-lock puzzle is a computational puzzle that requires a deterministic number of operations to solve. By calculating how many operations per second an attacker, or the receiver of your message, could perform you can configure the amount of operations needed to decrypt the message such that at least the amount of time that you require must have passed for the message to have been decrypted.

This works because the operations that need to be performed to solve a puzzle are not parallelizable, you can't solve time-lock puzzles meaningfully faster with a GPU or a million computers, and generating the puzzle is always cheap, because you know which prime numbers it's secured by, basically.

Time-lock puzzles are basically little proof-of-works, they have lots of interesting applications, for example a solution like this can be used to fight spam, by requiring that each request that your server receives comes with its own solution to a unique time-lock puzzle, which would be cheap for you to generate, cheap for you to check, cheap for legitimate users to solve, but prohibitively expensive for abusers/spammers to solve many of. It can be used as a sort of transparent captcha that can't be bypassed.

Install

npm install --save crypto-puzzle

Usage

import Puzzle from 'crypto-puzzle';

// Generate a puzzle that can only be read in about 10 seconds from now

const puzzle = await Puzzle.generate ({
  /* OPTIONAL OPTIONS */
  primeBits: 100, // Number of bits of entropy that the two internally generated primes will have
  primeRounds: 6, // Number of Miller-Rabin primality checks that the prime numbers will have to pass
  opsPerSecond: 3_300_000, // Rough number of operations per second that the attacker/receiver can perform, 3.3M is around what a MBP M1 Max can do
  /* REQUIRED OPTIONS */
  duration: 10_000, // Rough minimum number of milliseconds that this puzzle will be unsolvable for
  message: 'Hey there!' // Message to encrypt inside the puzzle
});

// Now let's solve the puzzle

const solution = await Puzzle.solve ( puzzle );

// About 10 seconds later...

console.log ( solution ); // => 'Hey there!'

License

MIT © Fabio Spampinato