<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Vladislav Semkin]]></title><description><![CDATA[Vladislav Semkin]]></description><link>https://semkin.dev</link><generator>RSS for Node</generator><lastBuildDate>Thu, 19 Nov 2026 03:04:19 GMT</lastBuildDate><atom:link href="https://semkin.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[BLS Signature Scheme Cheatsheet]]></title><description><![CDATA[The BLS Signature Scheme uses elliptic curve pairings for short, aggregatable signatures, suitable for Ethereum Beacon Chain and VRFs]]></description><link>https://semkin.dev/bls-signature-scheme-cheatsheet</link><guid isPermaLink="true">https://semkin.dev/bls-signature-scheme-cheatsheet</guid><category><![CDATA[elliptic curve cryptography]]></category><category><![CDATA[Cryptography]]></category><category><![CDATA[bilinear pairings]]></category><category><![CDATA[BLS]]></category><dc:creator><![CDATA[Vladislav Semkin]]></dc:creator><pubDate>Sun, 21 Dec 2025 18:23:44 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1766340363785/27714b1b-9337-4d81-85c8-3e4d749cbe4b.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-introduction">Introduction</h1>
<p>The <strong>Boneh–Lynn–Shacham (BLS)</strong> signature scheme is an exciting piece of cryptography. It uses pairings on elliptic curves to create <strong>short, aggregatable signatures</strong> with strong security guarantees. This scheme got popular with usage in Ethereum Beacon Chain, but it has some other exciting use cases, such as VRF.</p>
<p>This post demonstrates the BLS formulas and constructs (non-scientific) proofs to show why they work.</p>
<p>Readers should be familiar with:</p>
<ul>
<li><p>Elliptic curve groups and scalar multiplication</p>
</li>
<li><p>Finite fields and modular arithmetic</p>
</li>
<li><p>Basic cryptographic notation</p>
</li>
</ul>
<h2 id="heading-a-primer">A primer</h2>
<h3 id="heading-pairings">Pairings</h3>
<p>Some elliptic curves have a surprising structure:</p>
<p>$$e: \ \ E(F_p) \times E(F_p) \rightarrow F_{P^a}$$</p><p>Two points on the curve can be mapped onto a finite field extension.</p>
<p>A <strong>bilinear pairing</strong> is an operation on two group elements that satisfies:</p>
<p>$$\begin{align} e(g^r, H(m)^x) &amp;= e(g, H(m))^{rx} &amp;&amp; \text{(bilinearity)} \\                &amp;= e(g, H(m))^{xr} &amp;&amp; \text{(commutativity)} \\                &amp;= e(g^x, H(m)^r) &amp;&amp; \text{(bilinearity)} \end{align}$$</p><p>Notes:</p>
<ul>
<li><p>We could have used any other group element instead of \(H(m)\), but in the BLS scheme the tuple \((g, H(m))\) naturally appears.</p>
</li>
<li><p>\(g^x\) denotes <strong>scalar multiplication</strong>, not exponentiation, since elliptic curve groups use additive or scalar multiplication notation.</p>
</li>
<li><p>Bilinearity also extends to products:</p>
</li>
</ul>
<p>$$e(a, \prod_{i=1}^{n} b_i) = \prod_{i=1}^{n} e(a, b_i)$$</p><h2 id="heading-bls-signature-scheme">BLS Signature Scheme</h2>
<h3 id="heading-ec-groups">EC Groups</h3>
<p>The algorithm may use two elliptic curve groups (often denoted \(G_1\) and \(G_2\), though it can also operate on one:</p>
<ul>
<li><p>\(G\): base group</p>
</li>
<li><p>\(g\): generator (base point)</p>
</li>
<li><p>\(q\): order of the group</p>
</li>
</ul>
<h3 id="heading-key-generation">Key Generation</h3>
<p>Pick a random secret key \(x \in \mathbb{Z}_r\).</p>
<p>Derive the public key:</p>
<p>$$Y = g^x \in G$$</p><h3 id="heading-sign">Sign</h3>
<p>Let the hash function \(H\) map messages into the group \(G_1\):</p>
<p>$$sig = H(m)^x$$</p><h3 id="heading-verify">Verify</h3>
<p>To verify the correctness of a BLS signature, check that:</p>
<p>$$e(g, sig) \equiv e(Y, H(m))$$</p><p>If both sides are equal, the signature is valid.</p>
<h3 id="heading-proof">Proof</h3>
<p>Expand \(sig\) and \(Y\):</p>
<p>$$e(g, H(m)^x) \equiv e(g^x, H(m))$$</p><p>Apply bilinearity to transform the right term:</p>
<p>$$e(g, H(m))^x \equiv e(g, H(m))^x$$</p><p>Since both terms coincide exactly, the equation holds.</p>
<h2 id="heading-aggregation">Aggregation</h2>
<p>One of the exciting properties of BLS signatures is their aggregation support. A single check can verify the validity of numerous signatures. This exact property is used in the Beacon Chain.</p>
<h3 id="heading-sign-1">Sign</h3>
<p>Let each signer \(i \in \{1, \ldots, n\}\) generate their own keypair \((x_i, Y_i)\):</p>
<p>$$sig_i = H(m_i)^{x_i}$$</p><p>Aggregate all partial signatures:</p>
<p>$$Sig = \prod_{i=1}^{n} sig_i$$</p><h3 id="heading-verify-1">Verify</h3>
<p>To verify an aggregated signature, check:</p>
<p>$$e(g, Sig) \equiv \prod_{i=1}^{n} e(Y_i, H(m_i))$$</p><h3 id="heading-proof-1">Proof</h3>
<p>Expand \(Sig\) using its definition:</p>
<p>$$e(g, Sig) = e\left(g, \prod_{i=1}^{n} H(m_i)^{x_i}\right)$$</p><p>Apply bilinearity step by step to separate the product inside the pairing:</p>
<p>$$e(g, \prod_{i=1}^{n} H(m_i)^{x_i}) = \prod_{i=1}^{n} e(g, H(m_i)^{x_i})$$</p><p>Next, expand each term by bilinearity again:</p>
<p>$$\prod_{i=1}^{n} e(g, H(m_i)^{x_i}) = \prod_{i=1}^{n} e(g^{x_i}, H(m_i))$$</p><p>Substitute the public keys \(Y_i = g^{x_i}\):</p>
<p>$$\prod_{i=1}^{n} e(g^{x_i}, H(m_i)) = \prod_{i=1}^{n} e(Y_i, H(m_i))$$</p><p>Thus:</p>
<p>$$e(g, Sig) = \prod_{i=1}^{n} e(Y_i, H(m_i))$$</p><p>We have reached equality from both directions, confirming the validity of the aggregation proof.</p>
]]></content:encoded></item><item><title><![CDATA[Cryptography in Fluence Developer Rewards]]></title><description><![CDATA[And how to claim the Fluence Airdrop]]></description><link>https://semkin.dev/cryptography-in-fluence-developer-rewards</link><guid isPermaLink="true">https://semkin.dev/cryptography-in-fluence-developer-rewards</guid><category><![CDATA[Cryptography]]></category><category><![CDATA[depin]]></category><category><![CDATA[Ethereum]]></category><dc:creator><![CDATA[Vladislav Semkin]]></dc:creator><pubDate>Mon, 29 Apr 2024 20:29:33 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1721913522337/a957971c-94fb-47b7-becd-d62f736a0438.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Over 110,000 web3 developers have been allocated 5,000 <code>FLT</code> tokens each, with allocations halving every three months. The Fluence team has released a comprehensive guide on how to claim your allocation of the ERC20 token FLT-DROP. For more details, visit:</p>
<p><a target="_blank" href="https://blog.fluence.network/flt-developer-reward/">Fluence Network - Developer Rewards</a></p>
<p>I happened to be one of the lucky devs who received an allocation, so I was curious how the distribution process works.</p>
<p>This article delves deeper into the cryptography underlying the distribution of rewards and outlines the conversion process from <code>FLT-DROP</code> to <code>FLT</code>.</p>
<h1 id="heading-tldr">TL;DR</h1>
<p>Once your lockup period concludes, you can transfer 5,000 FLT (or your specific allocation) to any address. The FLT-DROP contract will then transfer an equivalent amount of FLT to your address. This process is outlined in the <code>transfer(address to, uint256 value)</code> function within the <code>DevRewardDistributor</code> contract, which can be viewed here:</p>
<p><a target="_blank" href="https://etherscan.io/token/0x6081d7f04a8c31e929f25152d4ad37c83638c62b#code">Etherscan - DevRewardDistributor Contract</a></p>
<pre><code class="lang-solidity"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">transfer</span>(<span class="hljs-params"><span class="hljs-keyword">address</span> to, <span class="hljs-keyword">uint256</span> value</span>) <span class="hljs-title"><span class="hljs-keyword">external</span></span> <span class="hljs-title"><span class="hljs-keyword">returns</span></span> (<span class="hljs-params"><span class="hljs-keyword">bool</span></span>) </span>{
        <span class="hljs-built_in">require</span>(value <span class="hljs-operator">&gt;</span> <span class="hljs-number">0</span>, <span class="hljs-string">"Value is 0"</span>);
        <span class="hljs-built_in">require</span>(lockedBalances[<span class="hljs-built_in">msg</span>.<span class="hljs-built_in">sender</span>].amount <span class="hljs-operator">=</span><span class="hljs-operator">=</span> value, <span class="hljs-string">"Invalid amount"</span>);
        <span class="hljs-built_in">require</span>(<span class="hljs-built_in">block</span>.<span class="hljs-built_in">timestamp</span> <span class="hljs-operator">&gt;</span> lockedBalances[<span class="hljs-built_in">msg</span>.<span class="hljs-built_in">sender</span>].unlockTime, <span class="hljs-string">"Tokens are locked"</span>);

        <span class="hljs-comment">// your FLT-DROP is set to 0</span>
        lockedBalances[<span class="hljs-built_in">msg</span>.<span class="hljs-built_in">sender</span>].amount <span class="hljs-operator">=</span> <span class="hljs-number">0</span>;
        _totalSupply <span class="hljs-operator">-</span><span class="hljs-operator">=</span> value;
        <span class="hljs-comment">// FLT is transferred to you from the **DevRewardDistributor contract**</span>
        IERC20(token).safeTransfer(<span class="hljs-built_in">msg</span>.<span class="hljs-built_in">sender</span>, value);
        <span class="hljs-keyword">emit</span> Transfer(<span class="hljs-built_in">msg</span>.<span class="hljs-built_in">sender</span>, <span class="hljs-keyword">address</span>(<span class="hljs-number">0x00</span>), value);

        <span class="hljs-keyword">return</span> <span class="hljs-literal">true</span>;
}
</code></pre>
<p>At the time of writing, the <code>DevRewardDistributor</code> (FLT-DROP) holds 48,740,000 FLT.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1714422262961/aeae09a8-e037-472b-8c0b-3cb23f4a0372.png" alt="DevRewardDistributor's FLT balance" class="image--center mx-auto" /></p>
<p>You can verify this yourself in the "Read as Proxy" section:</p>
<p><a target="_blank" href="https://etherscan.io/token/0x236501327e701692a281934230af0b6be8df3353#readProxyContract">Etherscan - FLT</a></p>
<p>Note that the balance is displayed in wei, which is 1/(10^18) of an Ether.</p>
<h1 id="heading-what-is-fluence">What is Fluence?</h1>
<p>Fluence is a distributed computing project which aims to liberate computation from centralized infrastructures, providing low-cost, decentralized, and verifiable computing solutions.</p>
<p>Learn more about their initiatives at <a target="_blank" href="https://fluence.network/">Fluence Network</a>.</p>
<h1 id="heading-rewards-architecture">Rewards Architecture</h1>
<p>The rewards program consists of two main phases:</p>
<ul>
<li><p><strong>Generation Phase:</strong> Conducted prior to the contract deployment by the Fluence team.</p>
</li>
<li><p><strong>Claim Phase:</strong> Executed by developers once the contracts are live.</p>
</li>
</ul>
<h2 id="heading-generation-phaze">Generation Phaze</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1714422350582/e222d01a-44d1-4af5-953f-81be3425f4a7.png" alt class="image--center mx-auto" /></p>
<p>During the generation phase, the Fluence team:</p>
<ul>
<li><p>Compiled a list of developer public keys.</p>
</li>
<li><p>Generated random Ethereum accounts, each linked to a developer's public key<br />  The source of randomness for the private keys comes from a python package called <code>secrets</code>: <a target="_blank" href="https://github.com/fluencelabs/dev-rewards/blob/c82cfa5acc4fd0384e0724baaa8b499abc4c6cea/python/generate.py#L99">https://github.com/fluencelabs/dev-rewards/blob/c82cfa5acc4fd0384e0724baaa8b499abc4c6cea/python/generate.py#L99</a></p>
</li>
<li><p>Encrypted the private keys of those Ethereum accounts with the developers’ GitHub pubkeys An asymmetric encryption tool called <code>age</code> has been used: <a target="_blank" href="https://github.com/fluencelabs/dev-rewards/blob/c82cfa5acc4fd0384e0724baaa8b499abc4c6cea/python/generate.py#L106">https://github.com/fluencelabs/dev-rewards/blob/c82cfa5acc4fd0384e0724baaa8b499abc4c6cea/python/generate.py#L106</a> <a target="_blank" href="https://github.com/FiloSottile/age">https://github.com/FiloSottile/age</a></p>
</li>
<li><p>Constructed a Merkle tree of the Ethereum account addresses to embed within the rewards contract. <a target="_blank" href="https://github.com/fluencelabs/dev-rewards/blob/c82cfa5acc4fd0384e0724baaa8b499abc4c6cea/python/generate.py#L249">https://github.com/fluencelabs/dev-rewards/blob/c82cfa5acc4fd0384e0724baaa8b499abc4c6cea/python/generate.py#L249</a></p>
</li>
</ul>
<p>The source code for the generation script is accessible here:</p>
<p><a target="_blank" href="https://github.com/fluencelabs/dev-rewards/blob/c82cfa5acc4fd0384e0724baaa8b499abc4c6cea/python/generate.py#L145">Fluence Labs - Developer Rewards Script</a></p>
<h2 id="heading-claim-phaze">Claim Phaze</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1714422386294/542f26c5-4f04-4c5e-a316-317eba2cf9ef.png" alt class="image--center mx-auto" /></p>
<p>To claim their allocated tokens, a developer must:</p>
<ul>
<li><p>Decrypt the Ethereum account's private key using their GitHub private key.</p>
</li>
<li><p>Generate a Merkle proof of inclusion for their Ethereum account in the tree.</p>
</li>
<li><p>Sign an Ethereum message with the temporary account as proof of possession.</p>
</li>
</ul>
<p>It is as easy as that!</p>
<p>We can check out the <code>DevRewardDistributor</code> contract to see the two cryptographic mechanisms in action:</p>
<pre><code class="lang-solidity"><span class="hljs-comment">/**
 * @notice Claim reward token
 * @param userId - user id in merkle tree
 * @param merkleProof - merkle proof for leaf
 * @param temporaryAddress - temporary Ethereum address that's used only for signing
 * @param signature - signature of temporary Ethereum address
 *
 */</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">claimTokens</span>(<span class="hljs-params">
    <span class="hljs-keyword">uint32</span> userId,
    <span class="hljs-keyword">bytes32</span>[] <span class="hljs-keyword">calldata</span> merkleProof,
    <span class="hljs-keyword">address</span> temporaryAddress,
    <span class="hljs-keyword">bytes</span> <span class="hljs-keyword">calldata</span> signature
</span>) <span class="hljs-title"><span class="hljs-keyword">external</span></span> <span class="hljs-title">whenClaimingIs</span>(<span class="hljs-params"><span class="hljs-literal">true</span></span>) </span>{
    ...
    <span class="hljs-comment">// the value, which existance in the merkle tree you prove</span>
    <span class="hljs-keyword">bytes32</span> leaf <span class="hljs-operator">=</span> <span class="hljs-built_in">keccak256</span>(<span class="hljs-built_in">abi</span>.<span class="hljs-built_in">encodePacked</span>(userId, temporaryAddress));
        <span class="hljs-comment">// MerkleProof.verify reverts if the merkle proof is invalid,</span>
        <span class="hljs-comment">// e.g. you are trying to prove a non-existant temporary account</span>
        <span class="hljs-comment">// or an invalid tree root</span>
    <span class="hljs-built_in">require</span>(MerkleProof.verify(merkleProof, merkleRoot, leaf), <span class="hljs-string">"Valid proof required"</span>);

        <span class="hljs-comment">// the message signed by your temporary address</span>
    <span class="hljs-keyword">bytes32</span> msgHash <span class="hljs-operator">=</span> <span class="hljs-built_in">keccak256</span>(<span class="hljs-built_in">abi</span>.<span class="hljs-built_in">encodePacked</span>(<span class="hljs-string">"\\x19Ethereum Signed Message:\\n20"</span>, <span class="hljs-built_in">msg</span>.<span class="hljs-built_in">sender</span>));
    <span class="hljs-comment">// the recovered signer of the provided message</span>
    <span class="hljs-keyword">address</span> signer <span class="hljs-operator">=</span> ECDSA.recover(msgHash, signature);
    <span class="hljs-comment">// if the recovered signer is valid, you indeed posess this temporary account</span>
    <span class="hljs-built_in">require</span>(signer <span class="hljs-operator">=</span><span class="hljs-operator">=</span> temporaryAddress, <span class="hljs-string">"Invalid signature"</span>);

      ...
}
</code></pre>
<h1 id="heading-conclusion">Conclusion</h1>
<p>The setup here is pretty straightforward and well designed.</p>
<p>At first I was a bit surprised by the fact that the team decided to create random accounts and encrypt the private keys.</p>
<p>This implementation involves some trust — we have to trust that the team didn’t keep copies of the keys before they got encrypted.</p>
<p>I believe this has been done for the sake of simplicity of the cryptographic scheme.</p>
<p>A simple cryptosystem:</p>
<ul>
<li><p>Is cheaper to develop (in developer hours).</p>
</li>
<li><p>Is faster to compute.</p>
</li>
<li><p>Is more straightforward to explain and understand.</p>
</li>
</ul>
<p>Could it be done trustlessly though? Sure, that’s totally possible. But diving into how that might work is for another day and another article.</p>
]]></content:encoded></item></channel></rss>