Reclaim Protocol: Verifying any Data with Zero-Knowledge Proofs with NEAR Protocol

(32 nL)
5 min read
To Share and +4 nLEARNs

Introduction

Want to use verified Uber ride data or Amazon purchase history to enhance your app while keeping user privacy intact? Discover Reclaim Protocol’s powerful, seamless solution!


Overview

Reclaim Protocol’s zkTLS infrastructure enables Web2 and Web3 users to generate verified credentials with zero-knowledge proofs, securely proving online data without revealing sensitive information. Unlike other solutions, no app or browser extension is needed, allowing users to seamlessly share selected data with third-party applications.

Reclaim SDKs simplify the integration of user activity, reputation, and identity from external websites into your platform.

Reclaim Protocol provides SDKs for web, mobile, and on-chain platforms. These SDKs enable you to build applications with access to user activity, reputation, and identity data from websites across the internet.

Example Use Cases

  • Ride Sharing Platforms: Import the number of rides a user has taken on Uber to build a competing ride-sharing platform.
  • E-Commerce Personalization: Import users’ purchasing preferences from Amazon to provide targeted discounts.
  • Blockchain Economics: Enable economic features on a blockchain using users’ off-chain activity data.
  • KYC: Use national IDs to perform Know Your Customer (KYC) verification.
  • And many more…

We have data providers from most popular websites. If the website you want to import data from isn’t on the list, you can create your own data provider using our developer tools.

How It Works

Reclaim Protocol generates cryptographic proofs on HTTPS traffic. The type of cryptographic proof it generates is called a zero-knowledge proof. This allows the user to generate proof without revealing any information other than what they choose to share. The protocol is built upon open standards such as HTTPS and TLS.

Safety and Security

The user data is secured by the TLS protocol. This ensures that no third party, including Reclaim Protocol or the participating stakeholders (aka attestors), can see the data being transferred between the user and the website.

Publishing Reclaim Protocol Proofs on-chain on NEAR Blockchain

Prerequisite:

Contract Deployment

If you don’t need to add more checks and logic to on-chain contract, You can skip those steps and use our already deployed contract on the testnet.

1. Clone the near contract sdk repo

This Near contract (opens in a new tab) serves as a client to our Reclaim protocol. It instantiates Reclaim’s contract, handles proofs, and verifies them.

git clone https://gitlab.reclaimprotocol.org/integrations/onchain/near-sdk

cd near-sdk

cargo near build

2. Create a new account or import an existing account

Use near-cli to create a new account or import an existing account.

near account import-account using-web-wallet network-config testnet

3. Deploy
Deploy the contract with your account and the wasm file.

near contract deploy <ACCOUNT_ID\> use-file <PATH_TO_WASM_BUILD> with-init-call init text-args '' prepaid-gas '100.0 Tgas' attached-deposit '0 NEAR' network-config testnet sign-with-keychain send

4. Add Epoch
Send transaction to add epoch from the owner account.

near contract call-function as-transaction <ACCOUNT_ID\> add_epoch \

json-args '{"minimum_witness_for_claim_creation": 1, "epoch_start": 1717429000, "epoch_end": 1817429000, "witnesses": [{"address": "244897572368eadf65bfbc5aec98d8e5443a9072", "host": "reclaim.testnet"}]}' \

prepaid-gas '100.0 Tgas' attached-deposit '0 NEAR' sign-as <ACCOUNT_ID\> \

network-config testnet sign-with-keychain

Frontend Development

1. Cloning the frontend repo

git clone https://gitlab.reclaimprotocol.org/starterpacks/reclaim-near-example cd reclaim-near-frontend-example npm install

2. Code discovery (src/components/create-new-proof.js).

We will submit the proof on-chain once we get the onSuccessCallback. Fill in your Reclaim credentials marked with //TODOs.

import { Reclaim } from '@reclaimprotocol/js-sdk'

import { useState } from 'react'

import { useQRCode } from 'next-qrcode'




export const CreateNewProof = ({ setNewProof, setReadyToVerify }) => {

const [url, setUrl] = useState('')

const { Canvas } = useQRCode()




const reclaimClient = new Reclaim.ProofRequest('') //TODO: replace with your applicationId




async function generateVerificationRequest() {

const providerId = '' //TODO: replace with your provider ids you had selected while creating the application




reclaimClient.addContext(

`user's address`,

'for acmecorp.com on 1st january'

)




await reclaimClient.buildProofRequest(providerId)




reclaimClient.setSignature(

await reclaimClient.generateSignature(

'' //TODO : replace with your APP_SECRET

)

)




const { requestUrl, statusUrl } =

await reclaimClient.createVerificationRequest()




setUrl(requestUrl)




await reclaimClient.startSession({

onSuccessCallback: proofs => {

console.log('Verification success', proofs)

setNewProof(proofs[0])

setReadyToVerify(true)

// Your business logic here

},

onFailureCallback: error => {

console.error('Verification failed', error)

// Your business logic here to handle the error

}

})

}

return (

<div

style={{

display: 'flex',

alignItems: 'center',

justifyContent: 'center',

height: '50vh'

}}

>

{!url && (

<button

className='btn btn-secondary'

onClick={generateVerificationRequest}

>

Create New Proof

</button>

)}

{url && (

<Canvas

text={url}

options={{

errorCorrectionLevel: 'M',

margin: 3,

scale: 4,

width: 200,

color: {

dark: '#010599FF',

light: '#FFBF60FF'

}

}}

/>

)}

</div>

)

}

3. Code discovery (src/config.js)

If you deployed your own version of the contract, you will need to update the contractPerNetwork list with your contract’s account address.

const contractPerNetwork = {

mainnet: 'todo()',

testnet: 'reclaim-protocol-testnet-hadi-sa.testnet' // Replace it with your contract's account address

}




export const NetworkId = 'testnet'

export const ReclaimNearContract = contractPerNetwork[NetworkId]




export const SMOKE_PROOF = {

identifier:

'0x9ec8f9f52623234433ce5ea0cc0f5aac0dfbeef553e68d2d403633bd9192e365',

claimData: {

provider: 'http',

parameters:

'{"body":"","geoLocation":"in","method":"GET","paramValues":{"CLAIM_DATA":"76561199614512180"},"responseMatches":[{"type":"contains","value":"_steamid\\">Steam ID: {{CLAIM_DATA}}</div>"}],"responseRedactions":[{"jsonPath":"","regex":"_steamid\\">Steam ID: (.*)</div>","xPath":"id(\\"responsive_page_template_content\\")/div[@class=\\"page_header_ctn\\"]/div[@class=\\"page_content\\"]/div[@class=\\"youraccount_steamid\\"]"}],"url":"https://store.steampowered.com/account/"}',

owner: '0xa1b6e6ffb85df5bdf78e6558d3224ab87f7cc4c7',

timestampS: 1717053708,

context:

'{"contextAddress":"user\'s address","contextMessage":"for acmecorp.com on 1st january","extractedParameters":{"CLAIM_DATA":"76561199614512180"},"providerHash":"0x5f5312e27124dc7605f70a7d884e169049679b93f91c137b4d18a8569d825900"}',

identifier:

'0x9ec8f9f52623234433ce5ea0cc0f5aac0dfbeef553e68d2d403633bd9192e365',

epoch: 1

},

signatures: [

'0xcbad077154cc5c8e494576d4336f57972f7412058c1a637e05832c6bdabd018f4da18ad973f29553921d7d030370032addac1159146b77ec6cc5dab4133ffec01c'

],

witnesses: [

{

id: '0x244897572368eadf65bfbc5aec98d8e5443a9072',

url: 'https://reclaim-node.questbook.app'

}

]}

 

Reclaim Protocol can be integrated with both front-end and backend?

Correct! Wrong!

4. Submitting the proof

npm run dev

  • First, You will need to connect your near account.
  • Then, After requesting a proof from Reclaim and performing the verification on your end, a verify proof button will appear on the screen.
  • Finally, Clicking on the Verify Proof button will send a transaction.

Now your proof will get approved on-chain, here is the sample transaction

(opens in a new tab) from the screenshot above.

What is the primary function of Reclaim Protocol's zkTLS infrastructure?

Correct! Wrong!

Demo on Publishing zero-knowledge proofs on NEAR Blockchain

1. Visit our website https://publish-credentials.reclaimprotocol.org/ and Connect your Near wallet.

2. Select a chain: for this demo, please select Near Testnet.


3. Proceed next and choose from the list for which you would like to generate proof. In our example, we are going to generate a proof of our amazon order count.

4. Clicking on Generate Proof generates a QR code that can be scanned by any mobile camera.

5. Now using your mobile device, scan the QR code to login into your amazon account and this will generate a proof.

6. On successful login, reclaim protocol will generate a zk-proof within ~45 seconds.

7. After zk-proof generation, the user gets redirected back to the original website sharing the generated proof.

What standards does Reclaim Protocol use to ensure the security of user data?

Correct! Wrong!

Generate comment with AI 2 nL
13

4 thoughts on “Reclaim Protocol: Verifying any Data with Zero-Knowledge Proofs with NEAR Protocol”

  1. Top comment

    Handling personal DATA is very serious in terms of privacy and the publicity of information for non authorized party.

    Show replies
  2. 1q2w.near (0 nL)
    (in collaboration with : near.ai)

    It sounds like Reclaim Protocol's zkTLS infrastructure and SDKs are promising solutions for users looking to securely share their data with third-party applications without revealing sensitive information. The fact that no app or browser extension is needed and that users can seamlessly integrate their activity, reputation, and identity from external websites into their platform is particularly appealing. It seems like these solutions could greatly enhance the privacy and security of online data sharing. Good luck, team!

    Show replies

Leave a Comment

Hire AI to help with Comment

To leave a comment you should to:


Scroll to Top
October Redeem to NEAR
This is default text for notification bar