<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by lihan yao on Medium]]></title>
        <description><![CDATA[Stories by lihan yao on Medium]]></description>
        <link>https://medium.com/@lihan-yao?source=rss-ac5e6ec1d7d9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Z6MQA-3y8UJw789q.jpg</url>
            <title>Stories by lihan yao on Medium</title>
            <link>https://medium.com/@lihan-yao?source=rss-ac5e6ec1d7d9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 10:18:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lihan-yao/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Addressing the Blockchain Trilemma with Zero-Knowledge Proof]]></title>
            <link>https://lihan-yao.medium.com/addressing-the-blockchain-trilemma-with-zero-knowledge-proof-657f505b4f3c?source=rss-ac5e6ec1d7d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/657f505b4f3c</guid>
            <category><![CDATA[cryptography]]></category>
            <category><![CDATA[blockchain-trilemma]]></category>
            <category><![CDATA[zero-knowledge-proofs]]></category>
            <category><![CDATA[blockchain-technology]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[lihan yao]]></dc:creator>
            <pubDate>Mon, 28 Jun 2021 16:49:56 GMT</pubDate>
            <atom:updated>2021-07-06T20:28:32.776Z</atom:updated>
            <content:encoded><![CDATA[<p>In a distributed computing system, the Byzantine Fault Problem outlines the difficulty in achieving consensus among unreliable actors. Suppose an unreliable actor broadcasts a false value, say a transaction amount is way larger than the true amount. If this action impedes honest actors from agreeing on the true amount, a system-wide inconsistency occurs. Wouldn’t it be useful if actors can broadcast proofs guaranteeing their values’ validity? This may be done by revealing information within the proof that is only possible if the broadcasted value is true.</p><p>A written signature served as proof that a letter was written by the author. The problem is public knowledge of the signature makes it susceptible to forgery; it seems anything worth arguing for, like author identity, <em>relies on representing private information </em>within the proof. In digital applications, signatures are often public-private key pairs where the private key signs a message by hashing the message with key. The hashed value is attached to the message. The public key verifies the hash signature as only possible if the author was in possession of the private key. The act of solving a hard puzzle (creating the specific hashed value), made easy by secret information of the private key, lets a <strong>verifier</strong> believe the <strong>prover</strong> in this proof.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8UhFg4wExo4FcNydAQYxBw.jpeg" /></figure><p>Generalizing from concealment of signatures, Zero Knowledge Proof (ZKP) lets a prover demonstrate knowledge of X without reveal. This family of techniques operates by obfuscating X by different equations into a set {X’} which can be freely communicated. A verifier receives {X’} from the prover, then poses a series of challenges using elements of {X’} whereby successful responses from the prover are only possible knowing the original X.</p><p>The need to represent knowledge without reveal arises when we consider anonymous blockchain participants collaborating in a trustless environment, e.g. proving someone was randomly selected for block proposal, proving the consistency for a block of transactions, and proving knowledge of transaction amounts for multiple transactions if the amounts are undisclosed.</p><p>A prover commits to a <strong>secret</strong> by hiding it from others while only presenting the obscured output called a cryptographic <strong>commitment</strong>. A <strong>proof</strong> <strong>of knowledge</strong> is created by a prover<strong> </strong>to convince a <strong>verifier </strong>knowledge of a secret. Successful verification of the proof implies the prover is honest and indeed knows the secret; conversely it is very hard for a prover to fabricate a verified proof without knowing the secret. A proof is <strong>zero knowledge</strong> if the verifier gained no additional information aside from the fact that the prover knows the secret, i.e. no information about the secret is leaked. A proof is <strong>interactive</strong> if the verifier challenges the prover over multiple rounds of communication. A <strong>non-interactive </strong>proof is verified by only examining the proof statement itself, and is more complex in construction.</p><p>Pentagon UFO video footage is a zero-knowledge proof of undiscovered flight knowledge. It is a proof insofar to replicate the same movements without UFO creator’s knowledge is <em>nearly</em> impossible, while convincing a verifier is to show it on camera. The footage is zero-knowledge: we learned nothing besides the prover knowing the necessary flight knowledge, we do not have the ability to recover the knowledge itself (though one may argue the maneuvers provide valuable scientific hints. The UFO’s teleportation / disappearance adheres to this property more). Lastly, the proof is non-interactive: we did not challenge the prover, the proof implicitly demonstrates the knowledge.</p><p>Scaling solutions among blockchain projects are also created with non-interactive, zero-knowledge proofs. ZKP solutions create a one-time cost during proof construction, while subsequent verifications are immediate for any verifier. Proofs are also memory compact. Because participants consistently verify the blockchain state, retrieve and store blockchain data, and reach consensus, a ‘prove once, verify always’ framework offers attractive scaling.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/0*-ZAkRYV0uXJCW7sC.png" /><figcaption>Three properties of a blockchain that are difficult to achieve together. Courtesy of Vitalik Buterin. Why sharding is great: demystifying the technical properties [<a href="https://vitalik.ca/general/2021/04/07/sharding.html">https://vitalik.ca/general/2021/04/07/sharding.html</a>]</figcaption></figure><p>In the blockchain trilemma first presented by Vitalik Buterin, projects are hypothesized to cover only two properties out of three: security, scalability, and decentralization, and it is very hard to build a blockchain satisfying all three. ZKPs show a promising direction where security is maintained, while memory and compute costs are significantly lowered, leading to good scaling and better decentralization. For example, personal computers stand a better chance of contributing to consensus if computing costs are lowered.</p><p>Here are some projects that use ZKP implementations (in <strong>bold</strong>) to scale core mechanisms:</p><p>Algorand’s Pure Proof of Stake (PPoS) is an elegant consensus mechanism that is at its core a signature scheme with non-interactive, zero-knowledge properties. The block proposal committee consists of randomly selected Algo holders whose selection probability is weighted by their wallet balances. Random selection to be in the committee is dependent on user secret keys. Proof of selection, without secret key reveal, is enabled by <strong>Random Verifiable Functions.</strong></p><p>In Ethereum 2.0’s <strong>zk-rollup</strong>, a layer 1.5 scaling solution, Zero-Knowledge Succinct Non-Interactive Argument of Knowledge or zk-SNARK, is a form of ZKP proving ETH participants correctly signed all transactions within a side chain block. zk-SNARK implicitly verifies transaction consistency within the block, obsoleting the need to dispute incorrect states while improving compression and computation. The block is published onto main chain in one transaction, reducing traffic.</p><p><strong>Bulletproof</strong> is a newer zk-SNARK variant used to conceal transaction amounts in Monero. Similar to the zk-rollup, bulletproofs validate transaction quantities within a bundle of transactions meant to conceal sender-receiver relations called a ring. Since implementation in late 2018, bulletproof has lowered transaction memory by more than one magnitude and transaction costs from $1 to $0.07.</p><h3>Verifiable Random Functions in Algorand</h3><p><a href="https://medium.com/algorand/algorand-releases-first-open-source-code-of-verifiable-random-function-93c2960abd61#:~:text=A%20Verifiable%20Random%20Function%20">In Algorand, users run VRFs</a> to discover their inclusion or exclusion in the block proposal and agreement committee for the next block. This self-selection process is analogous to drawing from a lottery, where the probability of inclusion is proportional to user stake in the network, i.e. their wallet’s Algo balance. The cost of checking a ticket’s winning status, hence a user’s committee membership, is negligible. To create a Proof of Stake consensus mechanism from first principles, we want to randomly sample users weighted by their stake. In a lottery system analogy, two questions arise:</p><p>1. How do we broadcast random values so participants may begin verifying their committee membership, i.e. what is our TV station to broadcast the lottery balls live?</p><p>2. After the winning numbers are shown, how do we verify but conceal the winners so an adversary cannot manipulate them?</p><p>To broadcast random values, say a random string X, the blockchain is the natural medium to do it. Each block contains a new random string according to which users may be drawn for the committee to propose the next block. If the random string selects by user ID, a function like</p><p>lottery( id, X ) = Y</p><p>Takes the user identity <em>id</em> and broadcasted randomness <em>X</em> as input, while outputting the outcome Y. To conceal the winners until block propagation, a secret Key SK may serve in place to determine the outcome while a public key PK helps observers to verify the outcome.</p><p>lottery( SK, X ) = Y</p><p>verify( PK, X, Y ) = 1 if and only if Y is a winning ticket, else 0</p><p>In fact, lottery systems use such <strong>signature schemes</strong> for anonymity and security.</p><p><a href="https://people.csail.mit.edu/silvio/Selected%20Scientific%20Papers/Pseudo%20Randomness/Verifiable_Random_Functions.pdf">Verifiable Random Function</a> (VRF) is a non-interactive, zero knowledge proof that serves as a signature scheme here. A user P with secret key SK and public key PK may create a signature Y for a message X. Y is a pseudo-random string unique to the tuple ( SK, X ). Y’s <strong>uniqueness</strong> is a key property distinguishing VRF signature scheme from other signature schemes. With a protocol-wide message X, say a random string contained in the last block of a blockchain, one VRF signature per user is guaranteed. Item 2 in the list below explains why this is a necessary property.</p><p>The user uses their secret key and public random string to evaluate the outcome:</p><p>evaluate( SK, X ) = ( Y, ρ )</p><p>ρ serves as the proof-of-knowledge in a zero knowledge manner. The observer may verify with public knowledge PK, X, Y, and ρ:</p><p>verify( PK, X, Y, ρ ) = 1 if and only if ( SK, X ) evaluates to Y else 0</p><p>After user P generates Y with evaluate( SK, X ), an observer may check Y was indeed emitted by P with verify( ). Because the consensus is proof-of-stake, set a value S proportional to P’s stake. If Y in the interval [ 0, S ], then P was selected to be in next round’s committee.</p><p>Some implications are:</p><ol><li>Each block proposal committee samples a different number of Algorand users, independent of how previous committees were selected. An adversary cannot know committee membership (hence control the committee) under the honest majority assumption.</li><li>In evaluate( SK, X ), X is a protocol-wide random string that is generated per block. Due to VRF’s unique signature property, each user has one possible ( SK, X ) input to create their ‘lottery ticket’ Y, so an adversary cannot attempt multiple inputs to receive a winning Y.</li><li>Evaluate and verify are cheap functions to run. They enable a single RaspberryPi to participate in consensus, encouraging decentralization.</li></ol><p>To expand on implication 3, VRF makes the Algorand protocol carbon neutral. In <a href="https://www.algorand.com/resources/blog/sustainable-blockchain-calculating-the-carbon-footprint">Sustainable Blockchain: Estimating the Carbon Footprint of Algorand’s Pure Proof-of-Stake</a>, a number of valuable insights regarding PoW, PoS, and PPoS consensus mechanisms were made. The author puts forth energy and mining assumptions for Bitcoin, Ethereum, and Algorand to calculate their kilowatt-hour per transaction. Algorand expended a near-negligible amount of energy to transact, at 8 × 10e-7 kWh / transaction, due to its VRF powered consensus mechanism.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/0*r6W4PwsNkl_hRT16" /><figcaption>From <a href="https://www.algorand.com/resources/blog/sustainable-blockchain-calculating-the-carbon-footprint">Sustainable Blockchain: Estimating the Carbon Footprint of Algorand’s Pure Proof-of-Stake</a> by Cosimo Bassi, Algorand’s blog</figcaption></figure><h3>zk-SNARK</h3><p>Zk-SNARK was introduced <a href="https://eprint.iacr.org/2011/443">here</a>. Later, a practical, easily verifiable implementation called <a href="https://eprint.iacr.org/2013/279">Pinocchio</a> was introduced. To self-study zk-SNARK, a careful reading of the article serieses in the following sequence is quite productive:</p><p>The first three parts of <a href="https://medium.com/@imolfar/why-and-how-zk-snark-works-1-introduction-the-medium-of-a-proof-d946e931160">Why and How zk-SNARK Works by Maksym</a>, then <a href="https://blog.ethereum.org/2016/12/05/zksnarks-in-a-nutshell/">zkSNARKs in a nutshell by Christian Reitwiessner at the Ethereum Foundatio</a>n, finally the complete tutorial culminating in the Pinocchio implementation with ellptic curves is <a href="https://electriccoin.co/blog/snark-explain/">this series</a> by Ariel Gabizon.</p><p>Like an onion, the core SNARK is built on a verifier challenging a prover regarding knowledge of a specific polynomial’s coefficients. Building on that, homomorphic encryption over their communication imbues SNARK with ZKP notions of completeness, soundedness, and zero-knowledge. Finally, common reference strings between multiple verifiers and provers lead to non-interactivity.</p><p>The appendix section following <a href="https://medium.com/@imolfar/why-and-how-zk-snark-works-1-introduction-the-medium-of-a-proof-d946e931160">the first resource by Maksym</a> look to convince technical and non-technical readers that zk-SNARK machinery is intriguing and worthy of study.</p><h3>zk-SNARK in ETH 2.0</h3><p>In the Ethereum ecosystem, side chains such as the Uniswap decentralized exchange and decentralized applications (dAPPs) operate on plasma contracts; smart contracts that interact with the Ethereum main chain to reflect application activities. A major goal of ETH 2.0 is scaling the Ethereum main chain to handle transaction traffic from side chains. Transactions have frequently clogged the network in recent months, leading to higher fees for new transactions.</p><p>The obstacle in integrating side chain data is how transactions of the side chain may be speedily verified to be consistent with ETH transfers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/939/0*wW68T1Jnjd6QVXIu.png" /><figcaption>As transaction blocks arrive from plasma contracts of side chains, the Ethereum root chain becomes clogged. Photo courtesy of Ivan on Tech from Ivan on Tech Academy.</figcaption></figure><p>Vitalik Buterin mentions the <strong>zk-rollup</strong> proposal in <a href="https://vitalik.ca/general/2019/08/28/hybrid_layer_2.html">The Dawn of Hybrid Layer 2 Protocols</a> as a semi-layer 2 scaling solution. One idea (not zk-rollup) proposed to integrate side chain blocks tentatively, with a <em>verification</em> period during which a block may be <em>challenged</em>. Sounds familiar? <a href="https://academy.ivanontech.com/blog/breaking-down-eth-2-0-zk-snarks-and-zk-rollups">This article on zk-SNARKS and <strong>zk-rollups</strong></a> notes the situation of a malicious validator who conducts a block withhold attack on the side chain, after which a user may detect and dispute. Disputes may delay future block creation and/or undo the disputed block.</p><p>Instead, we can include a ZKP into the block that verifies block consistency without a verification period. A zk-rollup aggregates multiple side chain transactions into a block containing a SNARK, and this appears on the ETH main chain as a single transaction. The key benefit is the existence of such a SNARK proof implicitly verifies the block content, and the SNARK is memory compact.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/0*jswMtVgURw8mfsgY" /><figcaption>Photo courtesy of Vitalik Buterin from <a href="https://vitalik.ca/general/2019/08/28/hybrid_layer_2.html">The Dawn of Hybrid Layer 2 Protocols</a>, Vitalik Buterin’s website</figcaption></figure><blockquote>Vitalik’s 2019 post estimated the zk-rollup to improve ETH to 2000 tx/sec (a 30X improvement at the time of the article) while compressing each transaction to ~10 bytes.</blockquote><p>Now in 2021, metrics from the 2.0 testnet may be drastically different. In another zk-rollup article <a href="https://medium.com/interdax/ethereum-l2-optimistic-and-zk-rollups-dffa58870c93#:~:text=What%20are%20ZK%2DRollups%3F,ensured%20by%20zero%2Dknowledge%20proofs">Scaling Ethereum on L2: Optimistic Rollups and ZK-Rollups</a>, <em>a block of 1,000 transactions is reported to be verified in around 20 minutes</em>. In the same article, an alternative scaling solution called Optimistic Rollup is explained. Lastly, the github repo to implement zk-rollup is <a href="https://github.com/barryWhiteHat/roll_up">here</a>.</p><h3>Bulletproofs in Monero</h3><p>Monero transaction amounts and participants are private. To conceal participants, your output (out-going transaction) is bundled with past outputs in the network to form a <strong>ring</strong>, so any ring address may sign this spending to an observer, while receivers are hidden. Ring signature and stealth address are the respective technologies that enable these features, and is outside the scope of this article.</p><p><a href="https://ieeexplore.ieee.org/document/8418611">Bulletproof</a> is a type of zk-SNARK. It is a non-interactive zero knowledge range proof. Bulletproof obfuscates transaction amounts in Monero. Being a range proof, the transaction amount is the secret, and it is proven to fall within a certain range. The Monero bulletproof ensures a ring of sent and received amounts sum to zero, with received amounts being positive. The true transaction amount is obfuscated by the sender (multiplication with an elliptic curve point) into a cryptographic commitment. Verification of the proof is a compact elliptic curve evaluation. Without cryptographic guarantees behind bulletproofs, an adversary generating such commitments with matching ring signatures may pass observer verification, leading to arbitrary spending in the network.</p><p>By clever algebraic properties, <a href="https://web.getmonero.org/resources/moneropedia/bulletproofs.html">bulletproofs</a> batch together efficiently for verification. One proof ( proving input / output transaction amounts sum to zero ) accounts for a large number of transactions, having proof size scaling logarithmically with the number of transactions. Its <a href="https://www.coindesk.com/monero-to-become-first-billion-dollar-crypto-to-implement-bulletproofs-tech">2018 implementation</a> decreased bytes per transaction, and transaction fee by orders of magnitude.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5HTqHOiNBXEUFXoJ" /><figcaption>Improvements offered by bulletproofs on the Monero network, taken from <a href="https://youtu.be/REC5V7d3pqM?t=705">Behavioral Finance, Cryptocurrency Markets</a> by Sweetwater Digital Asset Consulting. Sources: Monero CLI v0.17.1.9; <a href="https://web.getmonero.org/resources/roadmap">Roadmap</a>; blockchain.com; S. Noether, “CLSAG Audit Results” <a href="https://web.getmonero.org/2020/07/31/clsag-audit.html">CLSAG audit results</a></figcaption></figure><h3>Conclusion</h3><p>Hopefully this article has illustrated ZKP’s progress in the Blockchain Trilemma. In the Byzantine Fault Problem, ZKPs preserve the consistency property of a distributed computing system. By proving once, verify always, the proof framework bring down costs across blockchain protocols:</p><ol><li>Increased scalability, decentralization, and energy efficiency in Algorand consensus mechanism</li><li>Skip dispute periods with zk-rollup, with more compact transaction storage and less side chain traffic in Ethereum 2.0</li><li>verify transaction amounts for large number of transactions, allowing true amounts to be concealed in Monero</li></ol><h3>Appendix</h3><h4>Bulletproof Talkthrough</h4><p>An overview of security implementations for Monero, and other properties: <a href="https://www.youtube.com/watch?v=aC9Uu5BUxII">Monero: Sound Money, Safe Mode</a>.</p><p>A video digging into bulletproof details: <a href="https://www.youtube.com/watch?v=6lEWqIMLzUU">Dr. Sarang Noether Discusses Bulletproofs</a>.</p><h4>Proof of Knowledge of zk-SNARK (that is hopefully not zero-knowledge)</h4><p>From first three articles in <a href="https://medium.com/@imolfar/why-and-how-zk-snark-works-1-introduction-the-medium-of-a-proof-d946e931160">this article series by Maksym</a>.</p><p>If verifier and prover claims to know the same polynomial poly(), the verifier may check prover’s knowledge by evaluating this polynomial at domain element x, send x to prover as a challenge, then check if the prover’s polynomial evaluation at x, poly(x), is correct. Slight differences between polynomial coefficients lead to different evaluations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*H_6vhIK5wF22v9EG.png" /><figcaption>Two polynomials may share solutions at most d (their number of degrees) solutions. Verifier asking the prover for point evaluations at a random point is an effective way to check prover’s knowledge of a polynomial. Figure courtesy of Maksym, from <a href="https://medium.com/@imolfar/why-and-how-zk-snark-works-1-introduction-the-medium-of-a-proof-d946e931160">Why and How zk-SNARK Works 1: Introduction &amp; the Medium of a Proof</a>.</figcaption></figure><p>To build zero knowledge and non-interactivity onto this knowledge-of-polynomial framework, the verifier instead provides an evaluation of a co-factor polynomial t(x) assuming the relationship poly(x) / t(x) = h(x), where h(x) is an arbitrary polynomial containing co-factors in poly(x) not found in t(x). The prover responds with poly(x), h(x), to demonstrate knowledge of poly( ) this way.</p><p>There is a problem. After the verifier sends poly(x), the prover may spoof a response by constructing a polynomial p_fake(x) with the desired factorization p_fake(x) / t(x) = h_fake(x), or pick scalars as spoofed evaluations that satisfy this relation. <a href="https://medium.com/@imolfar/why-and-how-zk-snark-works-2-proving-knowledge-of-a-polynomial-f817760e2805#:~:text=input.-,Homomorphic%20Encryption,-That">Homomorphic encryption</a> prevents this by encrypting values, e.g. the point of evaluation x, while permitting the encrypted values to be added or multiplied. Encryption E(x) have the form</p><p>E(x) = gˣ mod m</p><p>Where x is the secret to be encrypted, g the generator of a cyclic group, and the modulo operation mod is what makes the decryption of E(x) back into x difficult (in cryptography this is the famouse discrete logarithm problem).</p><p>The verifier samples a secret evaluation point x, computes t(x), and transmits encrypted powers of x: { E(x⁰), E(x¹), …, E(xᵈ) } to the prover. <em>Without</em> knowledge of x, i.e. without knowing where polynomial evaluation should occur, but <em>with</em> the means to perform arithmetic on these encrypted powers of x, an honest prover is able to use their knowledge of poly() coefficients to construct an analogous, encrypted evaluation of poly():</p><p>E( poly(x) ) = (E(x⁰)^C₀)(E(x)^C₁)…(E(xᵈ)^Cd)</p><p>In other words, the polynomial, through its coefficients, encodes specific relations preserved by the homomorphic mapping E( ). If the prover knows the polynomial, they must demonstrate knowledge of these relations. Equality holds after encryption if the coefficients { C₀, …, Cd } are correct. Likewise, the remainder polynomial h may be evaluated on the encrypted version of x. E( poly(x) ) and E( h(x) ) are sent back to the verifier where checking</p><p>E( poly(x) ) = E( h(x) ) E( t(x) )</p><p>Is just as good as checking poly(x) = h(x) t(x).</p><p>In this way, the prover’s spoofing method described earlier becomes invalid. Moreover, because polynomial arithmetic has moved to an encrypted space via the homomorphic mapping E(), the prover can obfuscate information of poly( ) by exponentiating his response E( poly(x) ), E( h(x) ) with a random value, while still satisfying the verifier’s equality check. The verifier gained no additional knowledge of poly( ) from this interaction, making it <strong>zero knowledge</strong>. A <a href="https://medium.com/@imolfar/why-and-how-zk-snark-works-2-proving-knowledge-of-a-polynomial-f817760e2805#:~:text=1.-,Zero-Knowledge,-Because">detailed explanation</a>.</p><p><strong>Non-interactivity</strong> is possible with common reference string (CRS) (<a href="https://medium.com/@imolfar/why-and-how-zk-snark-works-3-non-interactivity-distributed-setup-c0310c0e5d1c">detailed explanation here</a>). Its key insight is that verifier secrets, and powers of the secret, after encryption, can be published as a stand-alone problem, this is the CRS and occurs during the protocol setup. Multiple participants may combine their CRS, hence their encrypted secrets and encrypted powers of secrets, into a composite CRS. An observer who trusts at least one verifier during the creation of the composite CRS may trust the proof procedure.</p><p>A prover, instead of interpreting the CRS as a composition of ‘locks’ to be solved in reverse order (computing the encrypted polynomial for the last verifier in the single verifier case, then repeat for the second to last verifier), instead generates one large encrypted polynomial using the encrypted powers of secrets from all participants and the prover’s polynomial coefficients (the knowledge to be demonstrated). This encrypted polynomial, representing the effort of the verifier group, is evaluated all at once ( obfuscation is added to achieve zero knowledge). The resulting polynomial and remainder polynomial, in their encrypted forms, is proof to any interested verifier.</p><h4>A pre-bitcoin ‘cryptocurrency’</h4><p><a href="https://en.wikipedia.org/wiki/Peppercoin">Peppercoin</a> was developed by Algorand founder Dr. Silvio Micali.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=657f505b4f3c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A ConvNet that works on like, 20 samples: Scatter Wavelets]]></title>
            <link>https://medium.com/data-science/a-convnet-that-works-on-like-20-samples-scatter-wavelets-b2e858f8a385?source=rss-ac5e6ec1d7d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/b2e858f8a385</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[convolutional-network]]></category>
            <category><![CDATA[wavelet]]></category>
            <category><![CDATA[representation-learning]]></category>
            <category><![CDATA[signal-processing]]></category>
            <dc:creator><![CDATA[lihan yao]]></dc:creator>
            <pubDate>Thu, 25 Jul 2019 15:23:01 GMT</pubDate>
            <atom:updated>2021-02-19T16:07:30.523Z</atom:updated>
            <content:encoded><![CDATA[<h3>A ConvNet that works well with 20 samples: Wavelet Scattering</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5PvyfQe5lnsz8D6Kz98I3g.png" /><figcaption>Scatter Transform architecture, from J. Bruna and S. Mallat, <a href="https://arxiv.org/abs/1203.1513">Invariant Scattering Convolution Networks</a> (2012)</figcaption></figure><p>Often in data-constrained scenarios, scene comprehension has to occur with few time series observations - whether that’s audio, visual, or even radar. We do this using a surprisingly underrated technique called wavelet scattering.</p><p>Wavelet scattering (or scatter transform) generates a representation that’s <strong>invariant to data rotation/translation and stable to deformations of your data. Uninformative variations in your data are discarded — e.g. an audio sample time-shifted by various amounts. Information for downstream tasks like classification is preserved. </strong>Wavelet scattering requires no training and works great with low data.</p><p>Its main computation is convolution, making it fast and applicable to images and 1D signals. We focus on signals in this article. We will retrace findings by the signal processing community and relate it to modern machine learning concepts. I show that, yes, we can do great <em>without</em> <em>learning, </em>using 20 samples. <a href="https://colab.research.google.com/drive/1uc1BzwnDwXQ5p2jrfY3r_-rVfV869tA6">Recreate experiments and illustrations in this article with the colab notebook in this link.</a></p><h3>Wavelets</h3><p>A wavelet can be convolved with the signal in the same sense that filters can. I think of <strong>convolution</strong> as the continuous analog to inner products, where large activation (commonly said in ML) or wavelet coefficient is caused by similarity between the continuous objects. By convolving elements from a dictionary to the signal under inspection, we capture local, spatial dependencies.</p><p>Convolution is a pivotal computation in the emergence of deep learning — it is extremely fast. The wavelet scattering implementation used by this article calls a deep learning backend solely for the efficient convolution! <a href="https://www.kymat.io/">Kymatio</a> is a great Python package built by passionate researchers that implement wavelet scattering, leveraging the PyTorch framework.</p><figure><img alt="A Morlet Wavelet with real and complex components, plotted in time domain" src="https://cdn-images-1.medium.com/max/850/1*99abNbPjpsn5X3t94FKxEQ.png" /><figcaption>Real and imaginary components of the Morlet Wavelet from M. Adamczyk et al., <a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4652604/">Automatic Sleep Spindle Detection and Genetic Influence Estimation Using Continuous Wavelet Transform</a> (2015)</figcaption></figure><p>The basic building block of wavelet scattering is the <strong>Morlet</strong> <strong>wavelet</strong>. It is a Gaussian windowed sinusoid with deep connections to mammal hearing and vision. By convolving wavelets <em>ψᵥ </em>indexed by different frequency locations <em>v</em>, the wavelet transform of <em>x</em> is the set of scatter coefficients</p><p><em>{ x </em>∗ <em>ψᵥ }ᵥ</em></p><p>When the wavelet’s sine component has room to dilate (sine wave ‘slowing’ its oscillation), it decomposes the signal at decorrelated scales. That’s good for revealing the signal’s frequency structure, but doing so over the course of a longer time range. The consequence is that a wider Gaussian window trades temporal resolution for increased frequency resolution ( itself a consequence of Heisenberg’s Uncertainty Principle). In practice, the width of the Gaussian window that tapers the sine wave is an important parameter <a href="https://www.biorxiv.org/content/biorxiv/early/2018/08/21/397182.full.pdf?source=post_page---------------------------">[M. Cohen 2018]</a>.</p><h3>Wavelet Scattering</h3><p>The historic context of wavelet scattering starts with Fourier transform, the canonical signal processing technique. The shortcoming of Fourier representation includes its instability to signal deformations at high frequency. For a signal <em>x</em> perturbed slightly by a high frequency deformation into <em>x</em>̃, their spectrogram representations look different ( large ‖<em> FFT(x) -FFT(x</em>̃<em>) </em>‖<em> </em>) even if they remain similar signals to the human eye. This instability is due to sine wave’s inability to localize frequency information, since sine itself has non-localized support.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3SihXfYkLHX6IzgSXHJ74g.jpeg" /><figcaption>November, Golden Gardens credit: <a href="https://www.reddit.com/user/purebredcrab/">u/purebredcrab</a> at <a href="https://www.reddit.com/r/analog/comments/a672in/november_golden_gardens_mamiya_rb67_75mm_kodak/">reddit.com/r/analog</a></figcaption></figure><p><strong>Wavelet transform</strong> fixes this by decomposing the signal with a family of wavelets, with various dilation, where every wavelet has localized support (flattening out eventually like the Morlet wavelet). The resulting wavelet representation localizes high frequency components of the signal. <strong>Yet because the wavelet operator commutes with translations, the resulting representation becomes translation covariant — shifting a signal also shifts its wavelet coefficients.</strong> This makes comparison between translated signals difficult, and translation invariance is key to tasks like classification. How do we achieve a signal representation Φ(<em>x</em>) that is translation invariant, stable under deformations, and offers good structural information at all frequencies?</p><p>Wavelet scattering builds a signal <strong>representation</strong> Φ(<em>x</em>) with a redundant dictionary of Morlet wavelets. While the space of signals <em>X</em> can be really high dimensional, the transform forms a kernel metric over the space of signals, inducing a lower dimensional manifold. Watch <a href="https://www.youtube.com/watch?v=4eyUReyIPXg&amp;source=post_page---------------------------">Stéphane Mallat discuss the manifold interpretation</a> with visualization.</p><p>Readers have probably trained a neural convolution network to encode an image into a latent manifold<em> Z</em>, whose code/latent representation is used for classification or structure discovery — and that’s what is happening in analogy. <strong>Wavelet scattering encodes the dataset <em>X</em> where uninformative variability in <em>X</em>: translation, rotation, and scaling — <em>the action of groups</em> — are discarded in the process.</strong></p><p>The key benefits of transforming a signal by Φ <a href="https://www.di.ens.fr/~mallat/papiers/Bruna-Mallat-Pami-Scat.pdf">[J. Bruna and S. Mallat, 2013]</a> is that</p><blockquote><em>Φ</em> is invariant to signal translation.</blockquote><p>Denote by <em>xₜ</em> a signal identical to <em>x</em>, except translated in time, then Φ(<em>x</em>) = Φ(<em>xₜ</em>).</p><blockquote><em>Φ</em> is stable under signal deformations.</blockquote><p>I.e. Φ is Lipschitz continuous to deformations — difference between scatter representations of a signal with its deformed version is <em>linear</em>. A deformation can be some local displacement/distortion (or a <em>ridiculous</em> amount of distortion, as a later example shows). For Lipschitz constant C&gt;0 and a displacement field τ(<em>u</em>) causing deformations to create <em>x</em>̃,</p><p>‖Φ( <em>x </em>) - Φ( <em>x</em>̃ )‖<em> </em>≤<em> C</em>‖<em>x</em>‖<em> </em>supᵤ<em>|</em>∇τ(<em>u</em>)<em>|</em></p><p>Where ‖<em>x</em>‖= ∫ ‖<em>x</em>(<em>u</em>)‖²<em>du</em> and supᵤ<em>|</em>∇τ(<em>u</em>)<em>| </em>is the global deformation amplitude.</p><blockquote><em>Φ </em>does not require learning.</blockquote><p>The priors introduced by wavelet scattering are nice enough that its performance often makes learning redundant; plus it comes with interpretable features and outputs. <strong>In data-constrained scenarios, if comparable data is publicly available, a nice plan is to pipe your small dataset through a pretrained model. But in the difficult situation that your dataset is small and unique, consider wavelet scattering as an initialization for ConvNets and other models.</strong> I suspect the future of ‘data constrained learning’ will be in synergizing predefined filters alongside learned filters.</p><p>Figure below illustrates stability under deformations. <strong>Left</strong> we applied scatter transform to the voice of a speaker saying ‘zero’. The scatter representation consists of the coefficients derived from averaging/low pass filter, order 1 wavelets, and order 2 wavelets. <strong>Right </strong>After applying a displacement field that has mostly masked the structure of the original signal with a sine wave, Φ( <em>x</em>̃ ) is barely affected; the deformation’s effect has been linearized by Φ’s transformation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NQj_nsNq9zdlmjMFPR1B-g.png" /></figure><p><strong>Convolution Network</strong> A scatter representation consists of order 0, 1, and 2 coefficients, which are generated by composing wavelets in different sequences. Multiple wavelets composed together capture high frequency structure, e.g. the 2nd order coefficients display wave interference ( heard as dissonance in music) within the signal. We now give a brief tour of how computation is done (the complex modulus and averaging filter is more closely explained in the appendix).</p><p>At the <em>m</em>-th layer, the set of <em>n</em> pre-defined wavelets { ψᵥ₁ , … , ψᵥₙ} are convolved with coefficients from the (<em>m-1</em>)-th layer, belonging to a previous wavelet ψᵥᵐ⁻¹. So in the figure above, a row of order 2 coefficients results from convolving with ψᵥ¹ in layer 1, then ψᵥ² in layer 2.</p><p>Altogether we denote a sequence of wavelets as a length <em>M</em> path <em>p </em>= (ψᵥ¹<em> , … , </em>ψᵥᴹ). By convolving then taking the complex modulus |⋅|, denote the resulting ordered product of operators U[ v₁, v₂, …, vₘ]. For a path of length 2,</p><p>U[ v₁, v₂ ]<em>x</em> =| |<em>x</em> ∗ ψᵥ₁| ∗ ψᵥ₂|</p><p>To finally extract coefficients like a row in the above figure, apply an averaging filter φ, and call it S[ v₁, v₂, …, vₘ]:</p><p>S[ v₁, v₂ ]<em>x</em> = U[ v₁, v₂ ]<em>x</em> ∗ φ(<em>u</em>)</p><p>Starting at data <em>x</em> as root, the set of rooted paths in this wavelet tree specify Φ(<em>x</em>). In practice, paths up to length 2 is enough to extract all relevant frequency information from naturally occurring data. So the distinguishing aspect of scatter transform over wavelet transform is exactly the order 2 coefficients.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X8Je4T5fIb4uUzsdANjrtA.png" /><figcaption>A 3-layer scatter network. Notice to extract any coefficients, we must apply the averaging filter <em>Φ. Diagram from </em>J. Bruna and S. Mallat, <a href="https://arxiv.org/abs/1203.1513">Invariant Scattering Convolution Networks</a> (2012)</figcaption></figure><p><strong>Example Task</strong> Let’s apply scatter transform to a real dataset. The <a href="https://github.com/Jakobovski/free-spoken-digit-dataset">Free Spoken Digit Dataset (FSDD)</a> has 2000 recordings from 4 speakers, each speaker saying a digit 50 times. After convolving with wavelets, I plotted a 2D t-SNE projection of resulting high dimensional coefficients. Each point is an audio sample’s scatter representation Φ(<em>x</em>), colored by digit class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/543/1*1KczGVgSoSPPjAnCsdYNxg.png" /><figcaption>Blue points belong to class zero? Red is one? Maybe a legend would have been helpful Lihan…</figcaption></figure><p>In time series classification tasks, rivaling techniques include dynamic time warping, Hidden Markov Models, and neural models like LSTMs and RNNs. Let us see how wavelet scattering perform, even under extremely data-constrained situations. As preprocessing, we Z-normalize the audio samples. Then audio samples are 0-padded to uniform length and ~20 audio samples are dropped to ensure scatter representations have the same dimensions. Continuing in the practice of <em>not learning</em>, we use 3-nearest neighbors as the classifier. <em>3NN</em>(Φ(<em>x</em>)) predicts the <em>i</em>-th digit if at least 2 neighbors closest to Φ(<em>x</em>) in the training set belong to digit <em>i</em>, or closest neighbor is <em>i</em> ( a possibility during three-way ties).</p><p>With 1981 samples, we find that <strong>3-fold classification accuracy is 91.5%</strong>, and with a training set of <strong>20 samples</strong>,<strong> </strong>with all other observations in the held-out set<strong>, </strong>we reach<strong> 49%</strong>. Not bad, considering I only tried different values for the Q hyperparameter (number of wavelets per octave), and left other dials alone. Try different values for the scale parameter J in the attached notebook.</p><p>I’m finished with motivating wavelet scattering. At this point, I would love it if you started exploring the technique on your own, <a href="https://colab.research.google.com/drive/1uc1BzwnDwXQ5p2jrfY3r_-rVfV869tA6">maybe starting with my digit audio jupyter notebook</a>. The appendix go into key properties surrounding wavelet scattering like how to leverage Φ(<em>x</em>) when <em>x</em> is an image, and practical considerations.</p><p><strong>Credits </strong>They say it takes a dev team to raise a Medium article. This would not be possible without <a href="https://www.kymat.io/">Kymatio</a> researchers and developers, including Edouard, Vincent, and Michael. I’m grateful for the opportunity to explain and leverage this amazing technology at <a href="https://geomdata.com/">Geometric Data Analytics</a>, under the guidance of Paul Bendich, in collaboration with government agencies.</p><h3>Appendix</h3><p>Actually, given a path <em>p</em> = ( ψᵥ₁ , ψᵥ₂ ), extracting the 2nd order coefficients also requires the <strong>complex modulus </strong>| ᐧ | and <strong>averaging filter</strong> φ:</p><p>S[ v₁, v₂ ]<em>x</em>(<em>u</em>) =||<em>x</em> ∗ ψᵥ₁| ∗ ψᵥ₂|∗ φ(<em>u</em>)</p><p><a href="https://youtu.be/4eyUReyIPXg?t=3060">Stephane Mallat explains</a> the predecessors to wavelet scattering, then the need for complex modulus and averaging filter.</p><p>The complex modulus is the secret sauce of wavelet scattering. | ᐧ | is a non-linearity applied to coefficients that makes them 1) stable to diffeomorphisms and 2) stable in the euclidean metric <em>L</em>². The complex modulus makes Φ(<em>x</em>) Lipschitz continuous with respect to deformations. Visually, the modulus forms an upper envelope over the coefficients.</p><p>Whenever φ is applied to coefficients |<em>x </em>∗ ψᵥ|, we accept the removal of the high frequency component in order to localize the bin covering the lower spectrum ( discarding the phase of |<em>x</em> ∗ ψᵥ |) . To preserve high frequency information, scatter transform propagates high frequency information further down the wavelet path <em>p</em> before localizing its distinct frequency bin via φ.</p><p><strong>Wavelet Scattering for Images</strong> The 2D Morlet wavelets may be convolved two-directionally with image data. In addition to the dilation parameter, the 2D wavelets can be rotated.</p><p>For example, researchers have found wavelet scattering to excel at classification of images of texture, where the major obstacles are finding a representation that is ‘zoom’, translation and rotation invariant — as soon as these <em>group actions</em> are factored out from the sample generation process, texture classification is straightforward. It is precisely these variabilities that wavelet scattering discount.</p><p><strong>Parametrizing Wavelet Dictionary</strong> When the wavelet’s sine component has room to dilate (sine wave ‘slowing’ its oscillation), it decomposes the signal at decorrelated scales. That’s good for revealing the signal’s frequency structure, but doing so over the course of a longer time range. The consequence is that a wider Gaussian window trades temporal resolution for increased frequency resolution (itself a consequence of Heisenberg’s Uncertainty Principle). In practice, the width of the Gaussian window that tapers the sine wave is an important parameter<a href="https://www.biorxiv.org/content/biorxiv/early/2018/08/21/397182.full.pdf?source=post_page---------------------------"> [M. Cohen 2018]</a>.</p><p>A wavelet dictionary in this article is parametrized by J, the maximum log scale and Q, the number of wavelets per octave. Increasing J trades temporal resolution for frequency resolution by increasing wavelet width by a factor of 2^J. A large J means a ‘long’ wavelet that emits fewer wavelet coefficients, leading to shorter wavlet representations.</p><p>“For audio signals, it is often beneficial to have a large value for Q (between 4 and 16), since these signals are often highly oscillatory and are better localized in frequency than they are in time.” — <a href="https://www.kymat.io/gallery_1d/plot_filters.html#sphx-glr-gallery-1d-plot-filters-py">kymatio tutorial</a></p><p>For signal processing practitioners, scatter transform’s wavelets form a non-orthogonal, redundant dictionary.</p><p><strong>Signal energy is conserved </strong>Composition of wavelet convolutions preserves the signal norm, or essentially the signal energy. This follows from the fact that wavelet transform is a contracting and invertible operator. Energy within the original signal is converted to ‘coefficient energy’ by the averaging filter after every convolution along a path. For the Caltech-101 image database, <a href="https://www.di.ens.fr/~mallat/papiers/Bruna-Mallat-Pami-Scat.pdf">[J. Bruna and S. Mallat, 2013]</a> shows ~99% of the signal energy has been conserved by networks of depth 3, for any value of J.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b2e858f8a385" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/a-convnet-that-works-on-like-20-samples-scatter-wavelets-b2e858f8a385">A ConvNet that works on like, 20 samples: Scatter Wavelets</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>