Online Proof

To cut the gas fee incurred when nodes send online proof transactions, BTFS v2.3 and above adopt a new online proof flow to replace the previous one that involves sending transactions to smart contracts.

Here is how it works:

Architecture of Online Proof Service

1200

Online Proof Process

  1. The signature data of each host is reported to online-server every day;
  2. Online-server generates merkle-tree every day based on the data from all hosts;
  3. Store merkle-proof on s3 so that hosts can check their proof info; also store merkle-proof in the database for users to view data in BTFS SCAN;
  4. Store merkle-root in the online-proof-v2 contract;
  5. Users validate the daily data reported through BTFS SCAN (or BTTCScan).

Verify Online Proof

From the node details page of BTFS scan users are able to verify via Merkle proofs that a node's online proof data is kept in the collection published by the official BTFS team in the online proof contract.

2000

We provide 2 Merkle verification methods: Local Verify and Verify on BTTC Scan

Local Verify

Local verification will call the front-end code for Merkle verification, the source code is as follows:

// npm packages
// "keccak256": "^1.0.6",
// "merkletreejs": "^0.3.9",
import MerkleTree from 'merkletreejs'
import keccak256 from 'keccak256'

const localVerify = (merkleRoot, proof, leaf) => {
  const leafHash = keccak256(Buffer.from(leaf)).toString('hex')
  const options = { sortPairs: true }
  const verified = MerkleTree.verify(
    proof,
    leafHash,
    merkleRoot,
    keccak256,
    options
  )
  return verified
}

// console.log(localVerify(merkleRoot, proof, leaf))

Successful verification shows: “Merkle Verify Passed”, otherwise: "Merkle Verify Failed"

Verify on BTTC Scan

You can also perform Merkle verification on the BTTC smart contract.

Click the Verify on BTTC Scan button to jump to the Online Proof contract on BTTC Scan. Call the Verify() method, copy and input the three parameters of timestamp, Proof and data in turn, and it will return True if the verification is passed.

1600