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

pyt-pos

v0.0.3

Published

A library to generate and verify pan-y-tomate Proof of Solvency

Downloads

8

Readme

pyt-pos

pyt-pos is a library to generate and verify pan-y-tomate Proof of Solvency.

The library contains the apis to generate a proof of solvency for each user and let them verify it.

npm install pyt-pos

import { Prover, UserVerifier } from 'pyt-pos';
import { MerkleSumTree } from 'pyt-merkle-sum-tree';

Prover is a class that contains the core APIs to let CEXs generate Proof Of Solvency for each of its users. The proof doesn't reveal any information such as the total balances of each user, the number of users and the total amount of liabilities of the exchange.

UserVerifier is a class that contains the core APIs to let a user verify the proof that has been provided to them by the exchange.

MerkleSumTree is a class that contains the core methods to create a Merkle Sum Tree from a csv file containing the username and balances of its users. More information about Merkle Sum Tree can be found at pyt-merkle-sum-tree.

APIs - Prover

# new Prover(tree: MerkleSumTree, assetsSum bigint, proverArtifacts SnarkProverArtifacts): Prover

import { Prover } from "pyt-pos"
import { MerkleSumTree } from "pyt-merkle-sum-tree"

const tree = new MerkleSumTree("test/entries/entry-65536-valid.csv")

const assetsSum = BigInt(4000000000)
const pathToWasm = './test/artifacts/valid/pyt-pos-16.wasm'
const pathToZkey = './test/artifacts/valid/pyt-pos-16_final.zkey'

const proverArtifacts = {
    wasmFilePath: pathToWasm,
    zkeyFilePath: pathToZkey
}

const prover = new Prover(tree, assetsSum, proverArtifacts)

Initializes a prover object. Takes as input an instance of the Merkle Sum Tree, the total assets owned by the exchange and the zkSNARK prover artifacts.

The available prover artifacts generated after a trusted-setup can be found in the pyt-circuits repository. For now, the trusted setup is only available for a merkle sum tree with 16 levels.

# generateProof(userIndex number): FullProof

Generates a proof of solvency for a specific user using a zkSNARK taking as input the index of the user in the Merkle Sum Tree.


const userIndex = 0
const proof = await prover.generateProofForUser(userIndex)

APIs - UserVerifier

# new UserVerifier(username: string, balance bigint, verificationKey JSON): UserVerifier

import { UserVerifier } from "pyt-pos"

const username = "OiMkdfHE"
const balance = BigInt(22404)
const verificationKey = require('./artifacts/valid/vkey.json');


const userVerifier = new UserVerifier(username, balance, verificationKey)

Initializes a user verifier object. Takes as input the username of the user, the balance of the user and the verification key.

The available verification key generated after a trusted-setup can be found in the pyt-circuits repository. For now, the verification key is only available for a merkle sum tree with 16 levels.

# verifyProof(proof: FullProof): boolean

Verifies the zk proof of solvency generated by the exchange for a specific user. Takes as input the proof


const bool = await userVerifier.verifyProof(proof)

The implementer should make sure that the public signals of the proof of solvency generated for a specific user match the expected values. These can be accessed from the proof object.


const rootHash = proof.rootHash // must match the root hash of the merkle sum tree published by the exchange
const assetsSum = proof.assetsSum // must match the total assets owned by the exchange as published by the exchange

Code Quality and Formatting

Run ESLint to analyze the code and catch bugs:

npm run lint

Run Prettier to check formatting rules and to fix them:

npm run format

Testing

npm run test