Bhargav Bhatt
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Applying Fiat-Shamir to BEEFY Light-Client Protocol Authors: Bhargav Bhatt and Alistair Stewart, @bhargavbhatt:matrix.org This spec has been implemented by Snowfork as part of [PR-1462](https://github.com/Snowfork/snowbridge/pull/1462) ## Introduction The Fiat-Shamir Transform is a method to make an interactive proof of knowledge non-interactive. It achieves this by replacing the verifier's random challenge with a hash of the prover's initial message. We spec the steps and requirements for implementing the Fiat-Shamir Transform on the current Random Sampling BEEFY Light Client protocol (referred to as $\Pi_{int}$). This doc elaborates on ideas discussed in the [BEEFY paper](https://eprint.iacr.org/2025/057.pdf). In the current implementation, the light client in $\Pi_{int}$ samples 27 signatures (assuming the [dynamic sampling](https://eprint.iacr.org/2025/057.pdf#page=8.42) is not triggered). However, the interactive protocol has a latency of ~20 minutes for the consensus updates. It is necessary to wait two ethereum epochs before sampling, else the RANDAO randomness is predictable, resulting in violation of protocol's security. This latency is unavoidable in the interactive protocol. Applying the Fiat-Shamir transform reduces the latency to the time required to get a heavy transaction (>2M gas) included on ethereum at the cost of 100 signature checks (instead of 27 currently). We do not have exact numbers but estimate the latency to be <20s. Snowfork will run an experiment to benchmark the gas costs and absolute cost in ETH to verify 100 signatures in the smart contract. If necessary, this can be split across multiple blocks, slightly increasing the latency. For instance, splitting the 100 checks across $m$ blocks would add $m\times 12$s latency. We suggest a weaker security parameter (signature checks) for fiat-shamir derived by levaraging crypto-economic arguments. In this model, our security is relative to bitcoin mining and the analysis can be found in [Chapter 6](https://eprint.iacr.org/2025/057.pdf#page=16.42) of the BEEFY paper. For any rational adversary, using its hash power to mine bitcoin is in expectation more profitable than attacking the bridge. ## Transformation Spec We refer to [Protocol-1](https://eprint.iacr.org/2025/057.pdf#page=6) for description of the current Commit-Challenge-Response-Verify protocol. In the context of applying Fiat-Shamir, it is sufficient to consider the non dynamic sampling version. Dynamic sampling was only introduced to counter the concurrnecy issues of interactiveness. Applying Fiat-Shamir to protocol-1 reduces the 4-step Commit-Challenge-Response-Verify to just the two steps: 1. Prover collects the BEEFY signature and creates a proof using the hash function. 2. Verifier non-interactively verifies the proof and is convinced at least 1 honest valiadtor signed the block. We introduce a new transaction: ```solidity= submitFiatShamir( Commitment calldata commitment, uint256[] calldata bitfield, ValidatorProof[] calldata proofs, MMRLeaf calldata leaf, bytes32[] calldata leafProof, uint256 leafProofOrder ) ``` which is in spirit very similar to `submitFinal` in the current implementation. ### Notations: 1. $\mathcal{P}_B$: The payload of the block $B$ to be relayed. 2. $\mathcal{C}$: Merkle root of a tree whose leaves are all the validators public keys for the epoch in which $B$ is finalised. 3. $Claims$: A bit-vector representing the validators signatures that prover claims to know. 4. $pk_i$ is the public key of validator with index $i$. 5. $\pi_i$ is opening of $pk_i$ w.r.t $\mathcal{C}$. 7. $R_\sigma$: Merkle root of a tree whose leaves are claimed signatures. 8. $n$: the number of signatures to be included in the non-interactive proof. Relying on "relative to bitcoin mining" security argument, this can be set to ~101. ### Prover's Algorithm (Run by Relayer) 1. Prover listens to the BEEFY channel and collects signatures for the block (with payload $\mathcal{P}_B$) to be relayed. 2. **Generate FSCommitment ($a$)**: The prover computes the fiat-shamir commitment $a := \mathcal{P}_B ++ \mathcal{C} ++ Claims$. Here $++$ denotes concatenation. 3. **Compute Challenge ($e$)**: The prover computes the challenge $e = H(a)$, where $H$ is a cryptographic hash function. 4. **Generate Response (z)**: The prover computes the response $z$ based on $a$ and $e$. - The prover uses $e$ as the seed for a PRNG $r$ (currently Keccak256) to generate a list of $n$ **distinct** indices $[j_1,\ldots j_n]$ of the $Claims$ bitvector which are set to 1. This logic already exists in the current [subsample](https://github.com/Snowfork/snowbridge/blob/5aabf721a613e23dfe2ba414068e12de7dbe127b/contracts/src/utils/Bitfield.sol#L41) function. - Generate the list $z = [(\sigma_{j_i},j_i,pk_{j_i},\pi_{j_i}) | j_i \leftarrow[j_1,\ldots,j_n]]$ where $\sigma_{j_i}$ is the signature of validator $j_i$, $pk_{j_i}$ is public key of $j_i$, and $\pi_{j_i}$ is the opening of $pk_{j_i}$ w.r.t $\mathcal{C}$. ### Verifier's Algorithm (On-chain Lightclient) The number of signatures to be included in the non-interactive proof $n$ is a constant that is set to 101 (derived from relative security to bitcoin argument). 1. **Receive Proof (a, z)**: Relayer (prover) submits the proof $z$ to the light-client smart contract as call data of the transaction $SubmitFiatShamir(\mathcal{P}_B,Claims,z,$leaf,leafProof,leafProofOrder)$. The parameters leaf, leafProof, and leafProofOrder are only used at the boundaries of sessions when a new validatorSet is to be set. The logic for updating new validator set is exactly the same as current implementation. 2. **Computes Challenge ($e'$)**: The verifier computes the challenge $e' = H(\mathcal{P}_B++\mathcal{C}++Claims)$, using the same hash function $H$. It already knows $\mathcal{C}$ and receives the other two from the prover. 3. **Verify Response**: The verifier checks if $z$ is a valid response for $a$ and $e'$ as follows. Perform following checks (these already exist in [verifyCommitment](https://github.com/Snowfork/snowbridge/blob/5aabf721a613e23dfe2ba414068e12de7dbe127b/contracts/src/BeefyClient.sol#L374)): a. check if $|z|= n$. If not, verifier outputs $False$. b. Compute indices $[j'_1,\ldots, j'_n]$ with $e'$ as the seed and the same mechanism as the prover in `Generate Response`. c. for each element $(\sigma, pk, i, \pi)$ in the list $z$: - check if $i\in [j'_1,\ldots, j'_n]$, and $i$ did not appear before in $z$. - we [verify](https://github.com/Snowfork/snowbridge/blob/5aabf721a613e23dfe2ba414068e12de7dbe127b/contracts/src/BeefyClient.sol#L533) the signature $\sigma_i$ against $pk_i$ and that $\pi_i$ [opens](https://github.com/Snowfork/snowbridge/blob/5aabf721a613e23dfe2ba414068e12de7dbe127b/contracts/src/BeefyClient.sol#L528) against $\mathcal{C}$ as the $i^{th}$ element. If any of the check fails, verifier outputs $False$. d. if all previous checks pass, verifier outputs $True$. 4. **Update State**: If verifier outputs $True$, update the `latestMMRroot` and `latestBeefyBlock` with values from the payload. ### Cryptographic Hash Function A cryptographically secure hash function $H$ is required. The hash function should have the following properties: - Preimage Resistance: Given a hash $h$, it is computationally infeasible to find a message m such that $H(m) = h$. - Second Preimage Resistance: Given a message $m1$, it is computationally infeasible to find a different message $m2$ such that $H(m1) = H(m2)$. - Collision Resistance: It is computationally infeasible to find two different messages $m1$ and $m2$ such that $H(m1) = H(m2)$. Suitable hash functions include: - SHA-256 - Keccak-256 To rely on the security argument relative to bitcoin mining, we must use the same hash function as bitcoin mining. ## Additional Considerations - It would be beneficial if Polkadot validators BEEFY-sign blocks even after the $2n/3 +1$ threshold is reached. This would further improve efficiency. The number of signature checks would be $m/log2(3x)$ where x is the fraction of validator's BEEFY-signatures that can be gathered by the relayer. Here $m$ is the number of signature checks required assuming 2/3 n +1 validators sign BEEFY. If all validators sign, then signature checks required is $100/1.54 = 64$. - there are two points of latency in the current consensus update of the bridge (Polkadot -> Ethereum): 1. cadence of consensus updates. IIRC, this is set as 4hrs in current relayer implementation 2. ~20min from the time `initialSubmit` is called to timepoint where the MMR root is updated on the light client. The fiat shamir approach only helps wrt (2), reducing that latency to hopefully < 1 min but does not help with (1). In fact, with fiat-shamir, reducing latency (1) costs even more as each update is costlier. For example, if we increase cadence to once per hour, then total costs is 16x (4x for fiat shamir and 4x for higher cadence). - We can run both the fiat-shamir version and interactive random-sampling in parallel. Fiat-shamir could be used for on-demand consensus updates where the user is willing to pay the costs for lower latency. However, there are subtleties that need to be taken care of when combining the above stand-alone Fiat-shamir spec with the interactive random sampling. For example, there needs to be some logic which ensures the the $latestMMRroot$ value on the smart contract is not updated simultaneously by two fiat-shamir transaction and $SubmitFinal$ (of the interactive protocol) or does not go backwards. This seems to be already taken care by [validateTicket](https://github.com/Snowfork/snowbridge/blob/5aabf721a613e23dfe2ba414068e12de7dbe127b/contracts/src/BeefyClient.sol#L623), but this would now have to be directly part of `submitFiatShamir` as there is no notion of tickets in FiatShamir. ## Resources - https://sigma.zkproof.org/ - https://eprint.iacr.org/2024/1565.pdf (Describes common pitfalls in implementing Fiat-Shamir) - https://blog.openzeppelin.com/the-last-challenge-attack

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully