Quickstart
The Reclaim Protocol Proofs are compatible with blockchain applications.
Prerequisites
- Node.js 18.0.0 or later
- An application ID and secret from Reclaim Protocol. Obtain these from the Reclaim Developer Protocol.
you can find more examples/starter packs here
Quickstart
The following tutorial is based on a Node.js
Create an application on Dev Tool
Head to https://dev.reclaimprotocol.org and create a new zkFetch application. Once you create the application, you'll be given an application ID
and an application secret
. Please take note of these. These will be used in the next steps.
Install zkFetch SDK
For using response redactions additionally, please download zk files using this command:
Import Reclaim Client
Initialize Reclaim Client
Boiler plate stuff.
Add Public/Private headers, optional but recommended
For public endpoints
If the endpoint you want to fetch and generate a proof of the response. This endpoint is public, and doesn't need any private data like auth headers/api keys.
This is useful when
- Verifier needs to verify without re-doing the api call
- The API doesn't need any private headers or auth
- The proof or response needs to be generated for a particular endpoint now, and verified later
Note : all the data in the publicOptions will be visible to them who you share the proof with (aka, verifier).
For private endpoint
If you want to fetch and generate a proof of the response, but the fetch involves some private data like auth headers or api keys
This is useful when
- Using API keys
- Using Auth headers
All the data in the privateOptions will stay hidden to the verifier.
Fetch using zkFetch
Additonal Features
Retries and Retry Interval
Add retries and set a retry interval for fetch requests:
Add Geolocation
Specify a geolocation (optional) using a two-letter ISO country code:
Using Response Match and Redactions
ou can also use responseMatches and responseRedactions to match and redact the response. This is useful when you want to verify the response against a particular value or redact some part of the response.
Note: The responseMatches and responseRedactions are optional and can be used as per the requirement.
Verify the proofs and transform proof for onchain
Verify the proofs
Install @reclaimprotocol/js-sdk
Import the Reclaim class from the js-sdk
Use Reclaim.verifySignedProof(proof)
You must send the proofObject and not the verifiedResponse to the verifier for them to be able to verify.
it verifies the authenticity and completeness of a given proof. It checks if the proof contains signatures, recalculates the proof identifier, and verifies it against the provided signatures. If the verification fails, it will log the error and return false.
More information about the verifySignedProof method can be found here
Transform proof for onchain
Transforms proof data into a format suitable for on-chain transactions, you need to use it before sending the proof to the blockchain.
Use Reclaim.transformForOnchain(proof) from the js-sdk to transform the proof for onchain.