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

geoduck-js-sdk

v1.0.0

Published

Library for interacting with the zk merkle tree.

Downloads

5

Readme

Zk Merkle Airdrop Library

Self-contained repo for interacting with the zkp-merkle-airdrop-contracts. A browser usage example of this library can be found in zkp-merkle-airdrop-fe-ex.

Usage

Create MerkleTree from file (ex file)

import { MerkleTree } from 'zkp-merkle-airdrop-lib';

let merkleTreeStorageString = ...; // Load the file from network or local into a string
let mt = MerkleTree.createFromStorageString(merkleTreeStorageString);

Create MerkleTree from leaves

import { MerkleTree } from 'zkp-merkle-airdrop-lib';

let treeHeight = 2**13;
// Create an array of BigNumbers to enter as leaves
let leaves: BigNumber[] = new Array(treeHeight).fill(0).map(_ => randomBigNumber());
let mt = MerkleTree.createFromLeaves(leaves)

Export MerkleTree storage string

import { MerkleTree } from 'zkp-merkle-airdrop-lib';

let mt: MerkleTree = ...;
let storageString = mt.getStorageString();
fs.WriteFileSync("./file/path/text.txt', storageString);

Generate proof

import { MerkleTree, pedersenhashConcat, generateProofCallData } from 'zk-merkle-airdrop-lib';

let KEY = "0x00d8d681994b73f635532cc3f0a7e3f02e10d55a6e107e1bd374b1c23bead940";
let SEC = "0x00b87f2a60e72cc5c6f334833c56aaed80aef550b76bd94837a86070c10dd061";
let airdropToAddress = "0x0"; // Reciever address -- caller of PrivateAirdrop.collectAirdrop()

// Optional: Compute commitment
let commitment: BigInt = pedersenhashConcat(BigInt(KEY), BigInt(SEC));

// Load tree into string
let merkleTreeStorageString: string = ...;
// Load dep files into buffers
let wasmBuffer: Buffer = ...;
let zkeyBuffer: Buffer = ...;

// Create MerkleTree
let mt = MerkleTree.createFromStorageString(merkleTreeStorageString);

// Optional: Check leaf exists
if (!mt.leafExists(commitment)) {
    alert("Commitment does not exist as leaf in tree!);
}

// Compute proof -- long running operation
let proof = await generateProofCallData(mt, BigInt(key), BigInt(secret), airdropToAddress, wasmBuffer, zkeyBuffer);

Notes

  • Recommended installation is as a submodule, then npm install --save file:zkp-merkle-airdrop-lib
  • witness_calculator is copied from those generated by the circom library with a BigInt adjustment to work in the browser.
  • The circom/snarkjs dependencies rely on server only libraries (fs, stream, path, crypto, os), which will not exist in a browser environment. If webpacking, these must be ignored.

Cmds

  • Install: npm i
  • Build: npm run build

Disclaimer

These smart contracts are being provided as is. No guarantee, representation or warranty is being made, express or implied, as to the safety or correctness of the user interface or the smart contracts. They have not been audited and as such there can be no assurance they will work as intended, and users may experience delays, failures, errors, omissions or loss of transmitted information. In addition, any airdrop using these smart contracts should be conducted in accordance with applicable law. Nothing in this repo should be construed as investment advice or legal advice for any particular facts or circumstances and is not meant to replace competent counsel. It is strongly advised for you to contact a reputable attorney in your jurisdiction for any questions or concerns with respect thereto. a16z is not liable for any use of the foregoing and users should proceed with caution and use at their own risk. See a16z.com/disclosure for more info.