You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This library is Flutter wrapper for the Rapidsnark. It enables the
generation of proofs for specified circuits within a Flutter 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
flutter pub add flutter_rapidsnark
Usage
groth16Prove
Function takes path to .zkey file and witness file as [Uint8List] and returns proof and public signals as record.
Reads .zkey file directly from filesystem.
import'package:flutter_rapidsnark/flutter_rapidsnark.dart';
// ...final zkeyPath ="path/to/zkey";
final witness =awaitFile("path/to/wtns").readAsBytes();
final proof =awaitgroth16Prove(zkeyPath, witness);
groth16Verify
Verifies proof and public signals against zkey.
import'package:flutter_rapidsnark/flutter_rapidsnark.dart';
// ...final zkey =awaitFile("path/to/zkey").readAsBytes();
final witness =awaitFile("path/to/wtns").readAsBytes();
final verificationKey =awaitFile("path/to/verification_key").readAsBytes();
final proof =awaitgroth16Prove(zkey, witness);
final proofValid =awaitgroth16Verify(proof.proof, proof.publicSignals, verificationKey);
groth16Prove 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 groth16Prove.
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.