Skip to main content

ZKP: ZK Proofs for bitcoin transactions

Workflow:

  • A bitcoin transaction is published. Either a regular transfer, or a more complex script.
  • An EVM contract, or directly a dApp, requests the ZKP contract to generate the proof for the transaction. For this, it submits a set of mandatory values about the bitcoin transaction, so that BeL2 can verify it.
  • The BeL2 ZKP service produces the cairo proof and makes it availabiel from EVM smart contracts to verify.

Submitting a proof from a client app or web service

See samples folder for full code

Ether v5 Quickstart

import { ZKP } from "@bel2labs/sdk";
import { Web3Provider } from "@ethersproject/providers";

const verification = await ZKP.EthersV5.TransactionVerification.create(
txId,
20
);
if (!verification.isSubmitted()) {
const provider = new Web3Provider(window.ethereum);
const signer = await provider.getSigner();

verification.status$.subscribe((status) => {
console.log("New status:", status);
});

const response = await verification.submitVerificationRequest(signer);
}

Ether v6 Quickstart

import { ZKP } from "@bel2labs/sdk";
import { ethers } from "ethers";

const verification = await ZKP.EthersV6.TransactionVerification.create(
txId,
20
);
if (!verification.isSubmitted()) {
const provider = new ethers.BrowserProvider(window.ethereum);
const signer = await provider.getSigner();

verification.status$.subscribe((status) => {
console.log("New status:", status);
});

const response = await verification.submitVerificationRequest(signer);
}