Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-provenance-hash

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-provenance-hash

A cli tool to use when you need to create a provenance HASH for an HFT project.Can also be used to prove that folder contents have not been changed since creation of the hash

  • 0.0.5
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

node-provenance-hash

Create a provenance hash for folder contents.

This package is made (but not limited) for NFT projects that have a need to prove that a folder did not have its contents changed. To do this, we do the following:

  1. Load the files in specific order
  2. Concatenate the hashes (sha256) of their content
  3. Hash the hashes

This gives us a string. In case the order of files has changed or contents of any file has changed, the string we get would change also indicating that the contents of the folder has changed, hence the PROVE in provenance hash. We are proving the contents and ordering is same.

##Usage

hash.ts

import { makeHash } from "node-provenance-hash";

//The following function will sort the files in ascending order using number derived from filename i.e 1.jpg (if it doesn't contain Infinity and NaN)
const numericalCompare = (a: string, b: string): number => {
    const fileNameToNumber = (file: string): number => Number(file.split(".")[0]);

    return fileNameToNumber(a) - fileNameToNumber(b);
};

makeHash(
    __dirname + "/sources/images",
    __dirname + "/sources/json",
    numericalCompare
).then((data) => console.log(data));

then ts-node hash.ts

FAQs

Package last updated on 15 Dec 2021

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