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

@anudit/react-native-rapidsnark

v0.0.1-alpha.3

Published

React-native wrapper for rapidsnark

Downloads

9

Readme

react-native-rapidsnark


This library is React Native wrapper for the Rapidsnark. It enables the generation of proofs for specified circuits within a React Native environment.

Platform Support

iOS: Compatible with any iOS device with 64 bit architecture.

Version for emulator built without assembly optimizations, resulting in slower performance.

Android: Compatible with arm64-v8a, x86_64 architectures.

Installation

npm i @iden3/react-native-rapidsnark

Usage

groth16ProveWithZKeyFilePath

Function takes path to .zkey file and witness file (base64 encoded) and returns proof and public signals.

Reads .zkey file directly from filesystem.

import {groth16ProveWithZKeyFilePath} from "react-native-rapidsnark";

// ...

const zkeyPath = "path/to/zkey";
const wtns = await RNFS.readFile("path/to/wtns", "base64");

const {proof, pub_signals} = await groth16ProveWithZKeyFilePath(zkeyPath, wtns);

groth16Verify

Verifies proof and public signals against zkey.

import {groth16Prove, groth16Verify} from "react-native-rapidsnark";

// ...

const zkey = await RNFS.readFile("path/to/zkey", "base64");
const wtns = await RNFS.readFile("path/to/wtns", "base64");
const verificationKey = await RNFS.readFile("path/to/verification_key", "base64");

const {proof, pub_signals} = await groth16Prove(zkey, wtns);

const proofValid = groth16Verify(proof, pub_signals, verificationKey);

groth16Prove

Function that takes zkey and witness files encoded as base64.

proof and pub_signals are JSON encoded strings.

Large circuits might cause OOM. Use with caution.

import {groth16_prover} from "react-native-rapidsnark";

// ...

const zkey = await RNFS.readFile("path/to/zkey", "base64");
const wtns = await RNFS.readFile("path/to/wtns", "base64");

const {proof, pub_signals} = await groth16Prove(zkey, wtns);

groth16PublicSizeForZkeyFile

Calculates public buffer size for specified zkey.

import { groth16PublicSizeForZkeyFile } from "react-native-rapidsnark";

// ...

const public_buffer_size_file = await groth16PublicSizeForZkeyFile("path/to/zkey");

Public buffer size

Both groth16Prove and groth16ProveWithZKeyFilePath has an optional proofBufferSize, publicBufferSize and errorBufferSize parameters. If publicBufferSize is too small it will be recalculated automatically by library.

These parameters are used to set the size of the buffers used to store the proof, public signals and error.

If you have embedded circuit in the app, it is recommended to calculate the size of the public buffer once and reuse it. To calculate the size of public buffer call groth16ProveWithZKeyFilePath.

Troubleshooting

Errors

Invalid witness length.

If you're getting invalid witness length error - check that your witness file is not corrupted and is generated for the same circuit as zkey.

iOS linking troubleshooting

If you get an error like this:

building for 'iOS-simulator', but linking in object file (${SRC_ROOT}/ios/Frameworks/Rapidsnark.xcframework/ios-arm64/librapidsnarkmerged.a[2](fq.o)) built for 'iOS'
  1. Open XCode
  2. Select your project in the left sidebar
  3. Select Build Phases tab
  4. Expand Link Binary With Libraries
  5. Add RapidSnark.xcframework from Workspace/Pods folder.

Example App

Check out the example app and example README for a working example.

Circuits generation

Check out the example/circuits directory and example REAMDE.md inside for more details.

License

react-native-rapidsnark is part of the iden3 project 0KIMS association. Please check the COPYING file for more details.


Made with create-react-native-library