{"_id":"@anudit/react-native-rapidsnark","name":"@anudit/react-native-rapidsnark","dist-tags":{"latest":"0.0.1-alpha.3"},"versions":{"0.0.1-alpha.3":{"name":"@anudit/react-native-rapidsnark","version":"0.0.1-alpha.3","description":"React-native wrapper for rapidsnark","main":"lib/commonjs/index","module":"lib/module/index","types":"lib/typescript/index.d.ts","react-native":"src/index","source":"src/index","scripts":{"test":"jest","typecheck":"tsc --noEmit","lint":"eslint \"**/*.{js,ts,tsx}\"","prepack":"bob build","example":"yarn --cwd example","build:android":"cd example/android && ./gradlew assembleDebug --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a","build:ios":"cd example/ios && xcodebuild -workspace RapidsnarkExample.xcworkspace -scheme RapidsnarkExample -configuration Debug -sdk iphonesimulator CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ GCC_OPTIMIZATION_LEVEL=0 GCC_PRECOMPILE_PREFIX_HEADER=YES ASSETCATALOG_COMPILER_OPTIMIZATION=time DEBUG_INFORMATION_FORMAT=dwarf COMPILER_INDEX_STORE_ENABLE=NO","bootstrap":"yarn example && yarn install && yarn example pods","clean":"del-cli android/build example/android/build example/android/app/build example/ios/build"},"keywords":["react-native","ios","android","rapidsnark","groth16","circom"],"repository":{"type":"git","url":"git+https://github.com/iden3/react-native-rapidsnark.git"},"homepage":"https://github.com/iden3/react-native-rapidsnark","author":{"name":"demonsh","email":"dmytro.sukhiy@gmail.com"},"license":"GPL-3.0","bugs":{"url":"https://github.com/iden3/react-native-rapidsnark/issues"},"publishConfig":{"registry":"https://registry.npmjs.org/"},"dependencies":{"@babel/runtime":"^7.24.0"},"devDependencies":{"@commitlint/config-conventional":"^17.0.2","@react-native-community/eslint-config":"^3.0.2","@types/jest":"^28.1.2","@types/react":"~17.0.21","@types/react-native":"0.70.0","commitlint":"^17.0.2","del-cli":"^5.0.0","eslint":"^8.4.1","eslint-config-prettier":"^8.5.0","eslint-plugin-prettier":"^4.0.0","jest":"^28.1.1","pod-install":"^0.1.0","prettier":"^2.0.5","react":"18.2.0","react-native":"0.72.4","react-native-builder-bob":"^0.21.3","turbo":"^1.10.7","typescript":"^5.0.2"},"resolutions":{"@types/react":"17.0.21"},"peerDependencies":{"react":"*","react-native":"*"},"engines":{"node":">= 16.0.0"},"packageManager":"^yarn@1.22.15","jest":{"preset":"react-native","modulePathIgnorePatterns":["<rootDir>/example/node_modules","<rootDir>/lib/"]},"commitlint":{"extends":["@commitlint/config-conventional"]},"eslintConfig":{"root":true,"extends":["@react-native-community","prettier"],"rules":{"prettier/prettier":["error",{"quoteProps":"consistent","singleQuote":true,"tabWidth":2,"trailingComma":"es5","useTabs":false}]}},"eslintIgnore":["node_modules/","lib/"],"prettier":{"quoteProps":"consistent","singleQuote":true,"tabWidth":2,"trailingComma":"es5","useTabs":false},"react-native-builder-bob":{"source":"src","output":"lib","targets":["commonjs","module",["typescript",{"project":"tsconfig.build.json"}]]},"codegenConfig":{"name":"RNRapidsnarkSpec","type":"all","jsSrcsDir":"src","android":{"javaPackageName":"com.rapidsnark"}},"gitHead":"d7e58c5acc5a67acc62550b75517ae0242ff9acd","_id":"@anudit/react-native-rapidsnark@0.0.1-alpha.3","_nodeVersion":"18.17.0","_npmVersion":"9.6.7","dist":{"integrity":"sha512-rcs0vEmxFtNB+te3K64deFF4lBpVUrUNajCJB66HjZAl/KsD+d7optkHAt9JEf+cM5Ykj3oTH1+0Ju8ohYES2Q==","shasum":"5dcc1da29b7384a4fa03d42f84477f6a0db2eef3","tarball":"https://registry.npmjs.org/@anudit/react-native-rapidsnark/-/react-native-rapidsnark-0.0.1-alpha.3.tgz","fileCount":41,"unpackedSize":28912825,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEMCIFk7Hs7PahwwBKJyisPbm54mdSOvgpmdWzN8hex+XkBSAh9nWs3CGiLD9/OfQLabixeYazZfeFNYDMFqO/5ubgDy"}]},"_npmUser":{"name":"anudit","email":"nagaranudit@gmail.com"},"directories":{},"maintainers":[{"name":"anudit","email":"nagaranudit@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/react-native-rapidsnark_0.0.1-alpha.3_1713370961308_0.4794544193465766"},"_hasShrinkwrap":false}},"time":{"created":"2024-04-17T16:22:41.207Z","0.0.1-alpha.3":"2024-04-17T16:22:41.650Z","modified":"2024-04-17T16:22:41.910Z"},"maintainers":[{"name":"anudit","email":"nagaranudit@gmail.com"}],"description":"React-native wrapper for rapidsnark","homepage":"https://github.com/iden3/react-native-rapidsnark","keywords":["react-native","ios","android","rapidsnark","groth16","circom"],"repository":{"type":"git","url":"git+https://github.com/iden3/react-native-rapidsnark.git"},"author":{"name":"demonsh","email":"dmytro.sukhiy@gmail.com"},"bugs":{"url":"https://github.com/iden3/react-native-rapidsnark/issues"},"license":"GPL-3.0","readme":"# react-native-rapidsnark\n\n---\n\nThis library is React Native wrapper for the [Rapidsnark](https://github.com/iden3/rapidsnark). It enables the\ngeneration of proofs for specified circuits within a React Native environment.\n\n## Platform Support\n\n**iOS**: Compatible with any iOS device with 64 bit architecture.\n> Version for emulator built without assembly optimizations, resulting in slower performance.\n\n**Android**: Compatible with arm64-v8a, x86_64 architectures.\n\n## Installation\n\n```sh\nnpm i @iden3/react-native-rapidsnark\n```\n\n## Usage\n\n#### groth16ProveWithZKeyFilePath\n\nFunction takes path to .zkey file and witness file (base64 encoded) and returns proof and public signals.\n\nReads .zkey file directly from filesystem.\n\n\n```js\nimport {groth16ProveWithZKeyFilePath} from \"react-native-rapidsnark\";\n\n// ...\n\nconst zkeyPath = \"path/to/zkey\";\nconst wtns = await RNFS.readFile(\"path/to/wtns\", \"base64\");\n\nconst {proof, pub_signals} = await groth16ProveWithZKeyFilePath(zkeyPath, wtns);\n```\n\n#### groth16Verify\n\nVerifies proof and public signals against zkey.\n\n```js\nimport {groth16Prove, groth16Verify} from \"react-native-rapidsnark\";\n\n// ...\n\nconst zkey = await RNFS.readFile(\"path/to/zkey\", \"base64\");\nconst wtns = await RNFS.readFile(\"path/to/wtns\", \"base64\");\nconst verificationKey = await RNFS.readFile(\"path/to/verification_key\", \"base64\");\n\nconst {proof, pub_signals} = await groth16Prove(zkey, wtns);\n\nconst proofValid = groth16Verify(proof, pub_signals, verificationKey);\n```\n\n#### groth16Prove\n\nFunction that takes zkey and witness files encoded as base64.\n\n`proof` and `pub_signals` are JSON encoded strings.\n\n>Large circuits might cause OOM. Use with caution.\n\n```js\nimport {groth16_prover} from \"react-native-rapidsnark\";\n\n// ...\n\nconst zkey = await RNFS.readFile(\"path/to/zkey\", \"base64\");\nconst wtns = await RNFS.readFile(\"path/to/wtns\", \"base64\");\n\nconst {proof, pub_signals} = await groth16Prove(zkey, wtns);\n```\n#### groth16PublicSizeForZkeyFile\n\nCalculates public buffer size for specified zkey.\n\n```js\nimport { groth16PublicSizeForZkeyFile } from \"react-native-rapidsnark\";\n\n// ...\n\nconst public_buffer_size_file = await groth16PublicSizeForZkeyFile(\"path/to/zkey\");\n```\n\n### Public buffer size\n\nBoth `groth16Prove` and `groth16ProveWithZKeyFilePath` has an optional `proofBufferSize`, `publicBufferSize` and `errorBufferSize`  parameters. If publicBufferSize is too small it will be recalculated automatically by library.\n\nThese parameters are used to set the size of the buffers used to store the proof, public signals and error.\n\nIf you have embedded circuit in the app, it is recommended to calculate the size of the public buffer once and reuse it.\nTo calculate the size of public buffer call `groth16ProveWithZKeyFilePath`.\n\n## Troubleshooting\n\n### Errors\n\n#### Invalid witness length.\n\nIf you're getting invalid witness length error - check that your witness file is not corrupted and is generated for the same circuit as zkey.\n\n#### iOS linking troubleshooting\n\nIf you get an error like this:\n\n```\nbuilding for 'iOS-simulator', but linking in object file (${SRC_ROOT}/ios/Frameworks/Rapidsnark.xcframework/ios-arm64/librapidsnarkmerged.a[2](fq.o)) built for 'iOS'\n```\n\n1. Open XCode\n2. Select your project in the left sidebar\n3. Select `Build Phases` tab\n4. Expand `Link Binary With Libraries`\n5. Add `RapidSnark.xcframework` from `Workspace/Pods` folder.\n\n## Example App\n\nCheck out the [example app](./example) and [example README](./example/README.md) for a working example.\n\n### Circuits generation\n\nCheck out the [example/circuits](./example/circuits) directory and [example REAMDE.md](./example/README.md) inside for more details.\n\n## License\n\nreact-native-rapidsnark is part of the iden3 project 0KIMS association. Please check the [COPYING](./COPYING) file for\nmore details.\n\n---\n\nMade with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)\n","readmeFilename":"README.md"}