<?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[Spider R&amp;D - Medium]]></title>
        <description><![CDATA[Spider, the Research and Development Club of National Institute of Technology, Tiruchirappalli is a group of people enthusiastic about technology and innovation. - Medium]]></description>
        <link>https://medium.com/spidernitt?source=rss----7fa9174f5b5c---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Spider R&amp;amp;D - Medium</title>
            <link>https://medium.com/spidernitt?source=rss----7fa9174f5b5c---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 27 May 2026 23:55:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/spidernitt" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[Understanding Zero-Knowledge Proofs for Enabling Privacy Preserving Identity Verification]]></title>
            <link>https://medium.com/spidernitt/understanding-zero-knowledge-proofs-for-enabling-privacy-preserving-identity-verification-e20cd25efb01?source=rss----7fa9174f5b5c---4</link>
            <guid isPermaLink="false">https://medium.com/p/e20cd25efb01</guid>
            <category><![CDATA[privacy]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[zero-knowledge]]></category>
            <category><![CDATA[zkp]]></category>
            <category><![CDATA[zero-knowledge-proofs]]></category>
            <dc:creator><![CDATA[KaranSinghBisht]]></dc:creator>
            <pubDate>Sun, 02 Mar 2025 17:48:37 GMT</pubDate>
            <atom:updated>2025-03-02T17:48:37.075Z</atom:updated>
            <content:encoded><![CDATA[<p>What if I told you that you could prove who you are without revealing any personal information — and I could still verify your identity with complete confidence? Sounds magical, doesn’t it? But it’s not magic — it’s mathematics. Let me explain.</p><p>The problem with traditional identity verification, commonly known as <strong>KYC (Know Your Customer),</strong> is that even when a website only needs to confirm if you’re over 18, it often requires you to upload an official identity document. That document contains far more personal details than necessary — details you might not want to share.</p><p>This creates two major concerns:</p><ol><li>The website might <strong>sell your data</strong> without your knowledge.</li><li>Even if they don’t, they might <strong>store it insecurely</strong>, leaving it vulnerable to breaches. If a data leak occurs, your sensitive information is exposed.</li></ol><p>Even in an ideal scenario where a company promises not to save or misuse your data, there’s no way for you to <strong>verify their claim</strong>. A common workaround is <strong>PII redaction</strong> — blurring or censoring unnecessary information before submitting documents.</p><p>But what if I told you that you could prove your identity <strong>without revealing any details at all</strong>?</p><p>Well, that’s exactly what <strong>Zero-Knowledge Proofs (ZKPs)</strong> enable — and they are already revolutionizing privacy in identity verification.</p><h3>What are Zero Knowledge Proofs?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aP3wq4U5SC0nqo0ZgQhPZQ.png" /></figure><blockquote>A zero-knowledge protocol is a method by which one party (the prover) <strong>can prove</strong> to another party (the verifier) <strong>that something is true, without revealing any information</strong> apart from the fact that this specific statement is true. (<a href="https://ethereum.org/en/zero-knowledge-proofs/">Source</a>)</blockquote><p>To illustrate this with a real life example, I’ll share the example I understood the most and was the first introduction to ZKP given to me by my <a href="https://x.com/bisht__13">Brother</a>. Which is explained both in this <a href="https://medium.com/swlh/a-zero-knowledge-proof-for-wheres-wally-930c21e55399">blog</a> as well as this <a href="https://www.youtube.com/watch?v=fOGdb1CTu5c">youtube video</a>.</p><p>Imagine you’re playing <strong>Where’s Waldo</strong> with a friend. To win, you need to find Waldo on the map and prove to your friend that you found him. Normally, the only way to convince them is by pointing directly at Waldo — but then they, too, will know his location.</p><p>A <strong>zero-knowledge protocol</strong>, however, would allow you to <strong>prove you know where Waldo is — without revealing his exact position</strong>.</p><p>Here’s how we can do that:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pAqf27mYNKLnJmuaB68fBQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dc8J9-7WU4m3OWu-gjwJ-Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_Yb4eYFZhDHAnyItRe3RDw.png" /></figure><p>Or you can also read the <a href="https://en.wikipedia.org/wiki/Zero-knowledge_proof#The_Ali_Baba_cave">Ali Baba Cave Story</a> to understand them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*GEIT87l3MkN74HmpvbAHxA.png" /><figcaption>One of my <a href="https://www.linkedin.com/in/ashwanth-k-38b092305/">mentors</a> explaining me the <a href="https://en.wikipedia.org/wiki/Zero-knowledge_proof#The_Ali_Baba_cave">Ali Baba Cave Story</a> [I was supposed to be the one explaining :)]</figcaption></figure><p>Now that we have an understanding of how Zero-Knowledge proofs work let us look into coding a zero knowledge proof.</p><h3>Writing your first ZK Circuit</h3><p>I am going to use <a href="https://noir-lang.org/"><strong>noir-lang</strong></a><strong> </strong>developed by <a href="https://aztec.network/"><strong>Aztec</strong></a>. <strong>Noir</strong> is an <strong>open-source</strong> <strong>Domain-Specific Language</strong> for safe and seamless construction of privacy-preserving Zero-Knowledge programs, requiring no previous knowledge on the underlying mathematics or cryptography.</p><p>The installation steps for <strong>Noir</strong> are taken from the official documentation. You can either <strong>follow along</strong> with this guide or refer directly to the <a href="https://noir-lang.org/docs/getting_started/quick_start"><strong>docs</strong></a>.</p><p>Step 1 — Installation of Nargo — the CLI tool</p><p><strong>Nargo</strong> is the CLI tool used to manage Noir projects. To install it, run</p><pre>curl -L https://raw.githubusercontent.com/noir-lang/noirup/refs/heads/main/install | bash<br>noirup</pre><p>Step 2 — Installation of Proving Backend</p><p>Proving backends provide functionalities such as <strong>generating proofs, verifying proofs, and generating smart contracts</strong> for your Noir programs. To install the proving backend, run</p><pre>curl -L https://raw.githubusercontent.com/AztecProtocol/aztec-packages/refs/heads/master/barretenberg/bbup/install | bash<br>bbup</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cyvGhcDOpwpnD35H2GjeRA.png" /></figure><p>Step — 3 Setting up hello_world project</p><p>Once noir is setup, we can initiate one of the already available examples the traditional hello_worldproject</p><pre>nargo new hello_world</pre><p>This will generate 2 files</p><ul><li>src/main.nr contains a simple boilerplate circuit</li><li>Nargo.toml contains environmental options, such as name, author, dependencies, and others.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/1*vvYvWIeefCjxHulQWsu-sA.png" /></figure><p>Generating the Prover.toml File</p><p>We can now use nargo to generate a <em>Prover.toml</em> file, where our input values will be specified</p><pre>nargo check</pre><p>This will create a <em>Prover.toml </em>file, give the following inputs there</p><pre>x = &quot;11&quot;<br>y = &quot;2017&quot;</pre><p>We’re now ready to compile and execute our Noir program. By default the nargo execute command will do both, and generate the witness that we need to feed to our proving backend:</p><pre>nargo execute</pre><p>The witness corresponding to this execution will then be written to the file <em>./target/witness-name.gz</em>.</p><p>The command also automatically compiles your Noir program if it was not already / was edited, which you may notice the compiled artifacts being written to the file <em>./target/hello_world.json</em>.</p><p>With circuit compiled and witness generated, we’re ready to prove.</p><p>Step 4 — Proving Backend</p><pre>bb prove -b ./target/hello_world.json -w ./target/hello_world.gz -o ./target/proof</pre><p>The proof is now generated in the target folder. To verify it we first need to compute the verification key from the compiled circuit, and use it to verify</p><pre>bb write_vk -b ./target/hello_world.json -o ./target/vk<br>bb verify -k ./target/vk -p ./target/proof</pre><p>Congratulations, you have now created and verified a proof for your very first Noir program!</p><p>If you try to execute the circuit with having the variable values as same, it’ll throw an error.</p><p>Say your input was</p><pre>x = &quot;1&quot;<br>y = &quot;1&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*MemgNVWU28U5v3Js1jsqmg.png" /><figcaption>As it should due to the assert (x != y) being False</figcaption></figure><h3>Exploring Existing Initiatives for Privacy-Preserving Identity Verification in the Web3 Space</h3><h4>Privado ID — Identity Ownership in Web3</h4><p>One of the most well-structured identity solutions in Web3, <strong>Privado ID</strong>, provides <strong>middleware infrastructure</strong> for <strong>privacy-preserving digital identity</strong>. Unlike traditional ID systems that require revealing personal details, <strong>Privado ID enables users to own their data and share only the necessary parts with their consent.</strong></p><p>How does this work?</p><ul><li>Users are issued <strong>Verifiable Credentials (VCs)</strong>, signed cryptographically and <strong>secured by blockchain</strong> to ensure they are <strong>tamper-proof</strong>.</li><li>These credentials are stored in an <strong>identity wallet</strong>, much like how a crypto wallet holds private keys.</li><li>Whenever verification is needed, instead of sharing full credentials, the <strong>wallet generates a zero-knowledge proof</strong>, proving <strong>only what’s required</strong> — like “I am over 18” without exposing <strong>date of birth</strong>.</li></ul><p>You can read more about them <a href="https://www.privado.id/">here</a>.</p><h4><strong>OpenPassport — Proving Humanity Without Exposing Identity</strong></h4><p>Sybil attacks (where bad actors create multiple fake accounts) are a huge problem in Web3. <strong>OpenPassport</strong> helps prevent this by allowing users to <strong>prove they are human</strong> without compromising privacy.</p><p>Instead of revealing personal details, <strong>users generate a cryptographic proof</strong> linked to their identity — without disclosing any private information.</p><p>You can learn more about them <a href="https://www.youtube.com/watch?v=hHmt8Q9yodI">here</a>, This workshop was part of DevCon Bangkok, held from 12–15 November, 2024.</p><h4>zkPassport — Zero-Knowledge Passport Verification</h4><p><strong>zkPassport</strong> brings identity verification into <strong>Web3</strong> while maintaining <strong>anonymity</strong>. It allows users to <strong>scan the NFC chip of their passport or ID card</strong> and generate a <strong>zero-knowledge proof</strong>.</p><p>You can learn more about them <a href="https://www.youtube.com/watch?v=hHmt8Q9yodI">here</a>, This workshop was part of DevCon Bangkok, held from 12–15 November, 2024.</p><h3>Key Discussions from ETHDenver 2025 on Decentralized Identity</h3><p>Decentralized identity is evolving rapidly, and <strong>ETHDenver 2025</strong> had some major discussions on <strong>privacy, KYC alternatives, and the role of AI in identity verification</strong>.</p><h4><strong>Bye Bye Biometrics: AI Demands Stronger Security Standards</strong></h4><p>Traditional <strong>biometric authentication</strong> (fingerprints, face scans) is increasingly being bypassed using <strong>AI-powered attacks</strong>. This talk featured experts from:</p><ul><li><a href="https://medium.com/u/b49bf53580df">0xbilly</a> (<a href="https://x.com/0xbilly">twitter</a>) from <a href="https://x.com/0xintuition">0xintuition</a></li><li><a href="https://x.com/Francis_Berwa">Francis_Berwa</a> from <a href="https://x.com/zkPass">zkPass</a></li><li><a href="https://x.com/provenauthority">Evin McMullen</a> from <a href="https://x.com/PrivadoID">PrivadoID</a></li></ul><p>The discussion emphasized how <strong>zero-knowledge identity proofs</strong> will play a crucial role in <strong>securing user identity without centralized storage of biometrics</strong>. You can watch the <a href="https://www.youtube.com/watch?v=gHmMrhCoTfY">session here</a>.</p><h4>Decentralized Identity: Unlocking Interoperability &amp; User Control</h4><p>A session by <a href="https://x.com/patkyoung">Patrick Young</a> from <a href="https://www.galxe.com/"><strong>Galxe</strong></a>, one of the biggest <strong>Web3 identity &amp; reputation</strong> platforms, discussing:</p><ul><li><strong>Self-sovereign identity</strong> — Users control their credentials, rather than relying on Google/Facebook logins.</li><li><strong>Zero-knowledge credential verification</strong> — Users can prove their <strong>reputation, participation, or age</strong> without revealing personal info.</li><li><strong>Interoperability</strong> — Users can <strong>reuse</strong> credentials across different ecosystems.</li></ul><p>You can watch the <a href="https://www.youtube.com/watch?v=vwPWpPcjPOY">session here</a>.</p><h4>Privacy Without KYC — The Labyrinth Protocol Approach</h4><p>A session by <a href="https://x.com/amitchax">Amit Chaudhary</a> from <a href="https://x.com/Labyrinth_HQ">Labyrinth</a>. Labyrinth Protocol explores the idea of <strong>privacy-friendly KYC alternatives</strong>, focusing on <strong>on-chain selective disclosure</strong>.</p><ul><li>Users remain <strong>completely private</strong> unless flagged for <strong>suspicious activity</strong>.</li><li>If a <strong>compliance check is triggered</strong>, data <strong>remains encrypted</strong> and is <strong>only shared when necessary</strong>.</li><li>Unlike centralized KYC databases, <strong>Labyrinth ensures privacy by default while allowing regulated access when needed</strong>.</li></ul><p>You can watch the <a href="https://www.youtube.com/watch?v=I6k5-MGmFKg">session here</a>.</p><h3>Exploring Existing Initiatives for Privacy-Preserving Identity Verification in the Web2 Space</h3><p>I’ve placed this section at the end since it primarily explores <strong>India-specific</strong> identity verification challenges, which may not be relevant to all readers.</p><h4>Understanding Aadhaar and the Privacy Concerns</h4><p>The <strong>Aadhaar card</strong> is a unique identity document for Indian citizens, issued by the government. It contains a <strong>12-digit Aadhaar number</strong>, along with personal details such as <strong>name, date of birth, and address</strong>.</p><p>With Aadhaar being widely shared online — especially with <strong>centralized institutions</strong> for identity verification — privacy concerns arose. Cases of <strong>fraud, identity theft, and unauthorized use</strong> of Aadhaar details became a major discussion point, prompting the government to take corrective measures.</p><h4>Government Measures to Improve Aadhaar Privacy</h4><p>To mitigate these risks, the government introduced <strong>privacy-enhancing features</strong>:</p><ol><li><strong>Masked Aadhaar</strong> → Hides the Aadhaar number while keeping most other details visible. (Not so private)</li><li><strong>Virtual ID (VID)</strong> → A temporary, revocable <strong>16-digit identifier</strong> that can be used <strong>instead of the Aadhaar number</strong> for verification.</li></ol><h4>Does VID Truly Solve the Privacy Issue?</h4><p>At first glance, VID seems like a great privacy improvement. Since banks (<a href="https://retail.onlinesbi.sbi/vkyc/vkyclanding.htm">including <strong>SBI’s Video KYC</strong></a>) now accept either Aadhaar or VID, it ensures that your <strong>Aadhaar number remains hidden</strong>. Additionally, since VID is a <strong>one-way function</strong>, it is <strong>not reversible</strong> — meaning institutions cannot derive your Aadhaar number from it.</p><p>However, this raises a critical concern:</p><p>If <strong>every institution</strong> starts accepting VID instead of Aadhaar, <strong>doesn’t VID effectively become the new Aadhaar?</strong><br>Yes, VID can be changed, but if someone uses your VID before you reset it, doesn’t that defeat the privacy purpose?</p><h3>What is Anon Aadhaar?</h3><p><strong>Anon Aadhaar</strong> is a <strong>zero-knowledge protocol</strong> that enables Aadhaar ID holders to <strong>prove their identity in a privacy-preserving way</strong>. I haven’t explored it in depth, but you can check out their <a href="https://documentation.anon-aadhaar.pse.dev/docs/intro"><strong>documentation here</strong></a>. Since it’s <strong>open-source</strong>, you can also explore the <a href="https://github.com/anon-aadhaar/anon-aadhaar"><strong>GitHub repository</strong></a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/544/1*_PTYW24cNGuKMQ7-_S9J8A.png" /></figure><h4>Anon Aadhaar in Action</h4><p>One notable use case of <strong>Anon Aadhaar</strong> was its <strong>integration at ETHIndia 2024</strong> for <strong>Sybil-resistant voting</strong> in the judging process. This implementation showcased how zero-knowledge proofs can enhance <strong>fairness and security</strong> in decentralized voting.</p><p>If you’re interested in learning more, you can read about its application in <strong>quadratic voting at </strong><a href="https://x.com/ETHIndiaco/status/1869715278533452134"><strong>ETHIndia 2024</strong> here</a>.</p><h3>Final Thoughts</h3><p>Zero-Knowledge Proofs (ZKPs) are redefining privacy in identity verification, eliminating unnecessary data exposure while ensuring security.</p><p>If you have any questions, please feel free to ask them in the comments, or reach out directly to me on <strong>LinkedIn or X</strong>.</p><p>Cheers! 🙌</p><p>Karan Singh Bisht</p><p><a href="https://www.linkedin.com/in/karanbisht09/">LinkedIn</a><br> <a href="https://x.com/Karan_Bisht09">X (Twitter)</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*esssbCIQ7IlQ5vtcktYpiQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e20cd25efb01" width="1" height="1" alt=""><hr><p><a href="https://medium.com/spidernitt/understanding-zero-knowledge-proofs-for-enabling-privacy-preserving-identity-verification-e20cd25efb01">Understanding Zero-Knowledge Proofs for Enabling Privacy Preserving Identity Verification</a> was originally published in <a href="https://medium.com/spidernitt">Spider R&amp;D</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CASCA: Coflow Aware Selective Compression Accelerator]]></title>
            <link>https://medium.com/spidernitt/casca-coflow-aware-selective-compression-accelerator-c32020e4d6fd?source=rss----7fa9174f5b5c---4</link>
            <guid isPermaLink="false">https://medium.com/p/c32020e4d6fd</guid>
            <category><![CDATA[dta]]></category>
            <category><![CDATA[computer-networking]]></category>
            <category><![CDATA[internet]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[network-protocols]]></category>
            <dc:creator><![CDATA[Ashutosh Anand]]></dc:creator>
            <pubDate>Tue, 16 Apr 2024 14:58:19 GMT</pubDate>
            <atom:updated>2024-04-16T15:20:55.537Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U7WNvcjawQHrqSfntcDU_w.gif" /></figure><p>In <strong>Smart India Hackathon’23</strong>, a very special problem statement revolved around prominent challenges faced by backbone networks, opening an increasing demand for efficient data transmission and network optimization. As participants, we were supposed to develop a solution that compresses data effectively, minimizes bandwidth usage, and enhances overall network performance, all simultaneously.</p><p>For this problem statement, we built CASCA — a selective compression system for backbone networks. Before paving a final pathway for making CASCA, we looked into a lot of current research papers to find out the best way to tackle the issues.</p><p>With the help of this article, we will share the same thought process of approaching the problem statement, the work past the hackathon, and how we are proceeding in the near future with this project.</p><h3><strong>Understanding the Backbone Networks:</strong></h3><h4><strong>What is a backbone network?</strong></h4><p>Think of backbone networks as the superhighways of the internet, connecting cities of data across the digital landscape. They’re like the vital veins of our online world, making sure information gets where it needs to go, fast. But there’s also a problem lurking in these digital highways: too much traffic. As more and more people use the internet for everything from streaming videos to sending emails, these networks are getting clogged up with data. It’s like rush hour traffic on the internet!</p><p>That’s where the need for data compression comes in. It’s like packing your suitcase efficiently before a trip and squeezing out extra air to fit more stuff. Similarly, with data compression, we can make the files and messages traveling through these networks smaller to take up less space and move faster.</p><figure><img alt="Backbone Network for a LAN" src="https://cdn-images-1.medium.com/max/600/1*UvphOXp9aeucw5CwtVbujw.png" /><figcaption>Backbone Network For a LAN</figcaption></figure><p>This was the way for us to develop a better data compression system. What we are doing is making files smaller and smarter to make networks run smoother and keep the internet flowing :)</p><h3>Delving Deep into the data transmission:</h3><p>To make backbone networks faster and more efficient, we need to understand what’s happening with the data flowing through them. But here’s the thing: we don’t control where the data comes from or where it goes. So, we use a clever trick called NetfilterQueue to intercept the data as it moves through the network.</p><figure><img alt="OSI Reference Model" src="https://cdn-images-1.medium.com/max/942/1*91kyZFAMbuhJlyCGFrCf8Q.png" /></figure><blockquote>You can imagine it as watching traffic on a highway from a bridge above.<br>Now, this interception happens at a specific level of the network called the data link layer. It’s like catching cars as they drive by, but in our case, we’re grabbing packets of data instead. By peeking at these packets, we can gather important information about where they’re coming from, where they’re going, and what they contain. This helps us understand how the network is used and find ways to improve it.</blockquote><h4><strong>How does it happen?</strong></h4><p>In backbone networks, prioritizing efficiency necessitates a selective approach to data compression. Rather than compressing entire packets, our focus is solely on compressing the payload — the actual transmitted data — while leaving packet headers intact. This ensures critical information like source and destination addresses, error control details, and routing information remains unchanged.</p><p>While compression in the system would be the most efficient approach, both sender and receiver will need to be aware of the algorithm used. What CASCA does is move the compression from the application layers in the sender and receiver to the data link layer by intercepting packets. Thus, by implementing compression through CASCA, compression can occur within the routers themselves. This ensures a transparent process where neither the sender nor the receiver need to be aware of compression taking place. This approach is particularly advantageous for handling streams of data commonly encountered in backbone networks.</p><p>While compressing the payload reduces the amount of data that needs to be transmitted, it also introduces overhead in processing time and computational resources. To address this tradeoff, we employ a selective compression method. This approach allows us to adjust our compression strategy dynamically based on the data&#39;s characteristics and current network conditions.</p><h4><strong>Surfing the waves of information with precision and speed :</strong></h4><p>The journey of a packet from point A to point B is influenced by various factors, each contributing to the overall transit time. These factors include:</p><figure><img alt="Delays while packet transmission" src="https://cdn-images-1.medium.com/max/424/1*LlIZbfibGNkL0bhlRHXB3g.png" /></figure><ul><li><strong>Routing Delay Time:</strong> The time taken for routers to process and forward the packet along the optimal path to its destination.</li><li><strong>Processing Time:</strong> The time required for processing tasks such as packet inspection, routing table lookup, and Quality of Service (QoS) enforcement.</li><li><strong>Propagation Time: </strong>The time it takes for the packet to travel across the physical distance between nodes.</li><li><strong>Transmission Time: </strong>The time taken to transmit the packet over the network link, influenced by the link’s bandwidth and the packet’s size.</li></ul><p>We employ a predictive approach to data compression to optimize network performance and reduce bandwidth utilization. This involves including a neural network model trained on system metrics, such as the number of CPU cores, CPU utilization, CPU frequency, total memory, and memory availability, to predict the compression rate.</p><p>Furthermore, the transit time of packets is estimated using round trip time (RTT) and bandwidth considerations. By factoring in delay, queue, propagation, and transmission times, we accurately calculate the total transit time.</p><figure><img alt="Compression strategy" src="https://cdn-images-1.medium.com/max/942/1*7mXQ4z5qSiOKRoohmg-NNg.png" /><figcaption>Compression Conditions</figcaption></figure><p>However, compression itself introduces latency, as it takes time to compress and decompress data. Thus, we carefully evaluate whether performing compression on intercepted packets is advantageous. This decision hinges on whether the total time required for compression, transit with compression and decompression is less than the transit time for uncompressed packets.</p><blockquote>Compression time + Transit time (compression)+ decompression time &lt; Transit time(original)</blockquote><p>Suppose there’s a lot of data from various streams that come to the router. In this case, the compression time to compress any packet would be quite high since there is a lot of system load. In this case, sending data uncompressed might be more efficient.</p><p>In the case of a very heavily congested network, we would need to aggressively compress data so that network transit time is less.</p><h3>Tech behind CASCA:</h3><figure><img alt="Tech Stack" src="https://cdn-images-1.medium.com/max/648/1*_zp-TbKui0pNaCLKaUxWvg.png" /></figure><h4><strong>Network simulation</strong></h4><p>We simulate a sample network using gns3. We limit the bandwidth and the specs of the machines to simulate how our proposed model works under load. In network simulation using GNS3, we create a virtual representation of our target network setup. This involves designing a network topology similar to our actual backbone network and configuring virtual machines within GNS3 to mimic the hardware specifications of real-world machines. We then impose bandwidth limitations on network links to replicate congestion scenarios and simulate traffic generation to observe network behavior under different loads.</p><figure><img alt="GNS3 setup for emulating CASCA" src="https://cdn-images-1.medium.com/max/591/1*kR4SFZNqNrqwszYqYbTWZQ.png" /><figcaption>GNS3 Setup</figcaption></figure><p>Once the network environment is set up, we integrate our proposed compression model into the simulation. This includes configuring compression and decompression processes within network nodes to mirror real-world implementation. We then conduct performance evaluations, measuring metrics like transit time, throughput, and compression ratio under varying network conditions.</p><h4>Compression Technology</h4><p>Indeed, since we’re compressing data at the link layer, we’re dealing with packets regardless of their initial content or form. Our compression process remains the same whether it’s encrypted data or any other format.</p><figure><img alt="Filtering out packets" src="https://cdn-images-1.medium.com/max/482/1*xX0AMdRlqwF6VbQkbmHHVQ.png" /></figure><p><strong>Here’s how it works: </strong><br>We take the entire payload of each packet, compress it using our chosen compression algorithm, and then extract and retain only the relevant information from the packet headers. This information forms a new header for the compressed data.</p><blockquote>It’s like taking each packet, separating out the header information, compressing the payload, and then appending the compressed payload with the relevant header information.</blockquote><p>By compressing only the payload and retaining essential header information, we ensure that the critical details, such as source and destination addresses, error control, and routing information, remain intact. This allows for efficient data transmission while preserving essential network functionality.</p><h4>Packet manipulation using Scapy:</h4><p>Scapy is used to create a Scapy packet object from the raw packet data received from the Netfilter Queue. This object allows us to easily access and manipulate the various layers and fields of the packet. Scapy’s built-in layer detection capabilities are then used to determine if the intercepted packet contains a Raw layer, which typically carries payload data. We extract different headers from the packet, allowing the script to access information such as source and destination IP addresses, source and destination ports, and protocol type.</p><p>The payload data is extracted from the Raw layer of the packet and compressed or decompressed using Zstandard compression, depending on whether the packet is outgoing or incoming. After compression or decompression, we reconstruct the packet with the modified payload data. This involves updating the packet’s Raw layer with the compressed or decompressed payload.</p><h4>Netfilterqueue and iptable rules:</h4><p>Netfilter Queue is a mechanism provided by the Linux kernel’s Netfilter framework that allows userspace programs to intercept and modify network packets. It operates by providing a queueing mechanism where packet matching rules can be directed for processing by userspace applications.</p><p>In the context of CASCA, Netfilter Queue is being utilized to intercept network packets at the firewall level and to capture outgoing and incoming IP packets. When a packet is intercepted, it is passed to the user space program for further processing.</p><p>Within the defined function, the code inspects each intercepted packet using Scapy. It then examines the IP and UDP headers to determine the source, destination, and type of traffic.</p><p>For outgoing packets, it compresses the payload data using Zstandard compression and updates the packet accordingly before allowing it to continue its journey.</p><h4>Zstandard for compressing</h4><figure><img alt="Compression speed and decompression speed comparison" src="https://cdn-images-1.medium.com/max/1024/1*A4_Qpas-i46XPQY8G0wZag.png" /></figure><p>Using Zstandard for data compression in the context of backbone networks offers several advantages, particularly due to its high compression and decompression rates while maintaining excellent compression ratios. This makes it an attractive choice for optimizing network performance without sacrificing data integrity.</p><p>One of the key considerations in selecting a compression algorithm is the tradeoff between compression speed and compression ratio. Compression speed refers to how quickly data can be compressed, while compression ratio refers to the level of compression achieved, typically measured as the ratio of compressed data size to original data size.</p><p>Below is a comparison between different compression algorithms:-</p><figure><img alt="Comparison between different compression algorithms" src="https://cdn-images-1.medium.com/max/420/1*1wbU5nNg6GlcexlvnkC9Rg.png" /></figure><p>In the case of Zstandard, a balance between speed and compression ratio is struck. It achieves high compression rates, meaning it can significantly reduce the size of data packets while also maintaining relatively fast compression and decompression speeds. This is crucial in backbone networks, where efficient data transmission is essential, and latency must be minimized.</p><h3>Working of CASCA</h3><figure><img alt="Working of CASCA for client and server" src="https://cdn-images-1.medium.com/max/1024/1*A-gHb6ajPfxJVgj8wXa3GQ.gif" /><figcaption>Compressing Image and transferring it using CASCA</figcaption></figure><p>We can visualize the work by using the demonstration above; here, we’re transferring an image from our local machine (X) to another host (Y). Underneath, NetfilterQueue is being used to intercept all the packets transmitted towards Y from source X.</p><p>Scapy plays a critical role in this process. It dissects each packet, meticulously identifying the headers and extracting the payload (the actual image data). Subsequently, we use Zstandard, a powerful compression algorithm, to selectively compress these packets on the fly.</p><p>Finally, on the receiving end (Y), the decompressed packets are reassembled, resulting in the original file.</p><h3>Novelty and scalability:</h3><p>Our solution, using Zstandard for data compression, can be deployed directly within routers and can offer a seamless experience for users. Unlike existing solutions that may require additional software or configurations, our approach integrates compression directly into the network infrastructure. This means developers can implement our solution effortlessly, using a simple command without a complex setup.</p><p>In the upcoming time, we plan to integrate Coflow Awareness into CASCA to enhance its network management capabilities. By incorporating Coflow Awareness, CASCA will be able to intelligently prioritize and manage data flows based on their Coflow relationships. This means that CASCA will be able to optimize the transmission of Coflows, grouping related flows together and ensuring they are transmitted efficiently through the network. This enhancement will lead to improved network resource utilization, reduced latency, and enhanced application performance, particularly for data-intensive distributed computing tasks.</p><p>This article is published as a part of the ‘Decoding the Architecture Series’ under Spider Research and Development Club, NIT Trichy.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c32020e4d6fd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/spidernitt/casca-coflow-aware-selective-compression-accelerator-c32020e4d6fd">CASCA: Coflow Aware Selective Compression Accelerator</a> was originally published in <a href="https://medium.com/spidernitt">Spider R&amp;D</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Statik: Revolutionizing Version Control with Decentralization]]></title>
            <link>https://medium.com/spidernitt/statik-revolutionizing-version-control-with-decentralization-49ea5e0b979b?source=rss----7fa9174f5b5c---4</link>
            <guid isPermaLink="false">https://medium.com/p/49ea5e0b979b</guid>
            <category><![CDATA[ipfs]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[version-control]]></category>
            <category><![CDATA[dta]]></category>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[Bharanichandraprabhu]]></dc:creator>
            <pubDate>Tue, 09 Apr 2024 15:33:19 GMT</pubDate>
            <atom:updated>2024-04-09T15:43:20.471Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aZrRTnhqkjI4tG4-" /></figure><p>In the ever-evolving software development landscape, Version control is like a super organized file cabinet for software developers. It helps us work together smoothly, keeps track of changes we make to our code, and ensures everything stays in order. It’s like a map that helps us navigate different versions of our code and merge our work. Overall, it’s a big help in keeping our projects neat.</p><p>As more people lean towards decentralization, old-fashioned centralized systems for managing different code versions are starting to feel outdated. That’s where Statik comes in. It’s a new way to handle and work together on code, spreading it across many places to keep it safer and more reliable.</p><p>Enter Statik, our project leading the charge in decentralized version control. By harnessing the capabilities of IPFS (InterPlanetary File System), Statik revolutionizes how we handle and collaborate.For those eager to delve deeper into the underlying technology, check out our in-depth article on IPFS: <a href="https://medium.com/spidernitt/welcome-to-the-world-of-decentralised-file-storage-systems-c0a70beda5e4"><strong>Welcome to the world of decentralised file storage systems!</strong></a></p><p>But before we embark on our journey through the intricacies of Statik, let’s take a step back and ponder: what exactly is version control, and why does it hold such paramount importance in software engineering?</p><h3>Version Control</h3><p>Version control is a system that records changes to files over time. It allows you to revisit specific versions of a file or project by tracking modifications and who made them. This is crucial for collaboration, tracking progress, and reverting to previous states if needed.</p><h3>Git</h3><p>Git is a distributed version control system that efficiently handles projects of any size. It tracks changes to files, allows branching for parallel development, and facilitates collaboration among developers. Git’s decentralized nature means every developer has a complete repository copy, enabling offline work and faster operations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/968/0*zL4qqBmZnaShwqOq" /></figure><h3>Key Git Features:</h3><ul><li><strong>Branching and Merging</strong>: Git allows developers to create branches for parallel development, making it easy to work on new features or bug fixes without affecting the main codebase. Merging branches back into the main branch is seamless, preserving the project’s history and integrity.</li><li><strong>Fast Performance:</strong> Git is known for its speed and efficiency, making it ideal for large projects with many files and contributors. Operations like committing changes, branching, and merging are typically fast, even in complex projects.</li><li><strong>Distributed Development</strong>: Git’s distributed nature means that every developer has a complete copy of the repository. This allows offline work and enables teams to collaborate more effectively, especially in remote or distributed environments.</li><li><strong>Data Integrity:</strong> Git uses cryptographic hashing to ensure the integrity of your data. Every change is checksummed, and the history of changes is stored in a Merkle tree, making it virtually impossible to change or corrupt historical data without detection.</li></ul><h3>GitHub</h3><p>GitHub is a web-based platform built around Git that provides hosting for Git repositories. It adds a social and collaborative aspect to version control, allowing developers to share code, contribute to open-source projects, and manage workflows. GitHub offers features like pull requests, issues tracking, and project management tools, making it a central hub for many developers and teams.</p><p>In conclusion, version control systems like Git and platforms like GitHub have revolutionized the way developers work, enabling efficient collaboration, tracking changes, and ensuring project integrity. Statik builds on these principles, offering a decentralized approach to version control, empowering users with more control over their data and projects.</p><pre>  ____  _        _   _ _    <br> / ___|| |_ __ _| |_(_) | __<br> \___ \| __/ _` | __| | |/ /<br>  ___) | || (_| | |_| |   &lt; <br> |____/ \__\__,_|\__|_|_|\_\</pre><p><strong>Statik</strong> is a decentralized version control tool built on top of IPFS, the Inter Planetary File System. Unlike traditional version control systems such as Git, which rely on a single, centralized file storage system, Statik leverages the decentralized nature of IPFS. In IPFS, data is divided into chunks and distributed across a network of peers, creating a decentralized and immutable data structure.</p><p>Statik is currently under active development, developed as an open-source project, focusing on providing a robust alternative to centralized repository hosting services like GitHub. By enabling users to manage versions of their files without relying on a central server, Statik ensures data integrity, availability, and security. Join us as we delve into the world of Statik and explore its innovative approach to version control.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*okkdumTh-i8_YYr5" /></figure><h3><strong>Architecture:</strong></h3><p><em>The basic workflow of statik can be considered a Function call made via CLI that, in turn, creates and manipulates the folders and files in the directory in which we wish to initialize a statik repository, basically the “.statik/” folder. Within this folder, we have /SNAPSHOTS,/HEAD,/head/branch folders, whose significance will be discussed as we go through this article along with the different commands that this CLI tool offers. When we run the start script in the src folder (i.e. the index.ts ), we utilize the commander package to create a command-line interface (CLI) for a version control system (VCS) called “Statik,” and then based the command line arguments we call the respective functions.</em></p><p><strong>Init (CWD, ipfs_node_url) </strong>— It takes input as the Current working directory and the ipf_node_url (the one which defines our IPFS node’s identity), and when it is called, the following directories are created and manipulated.</p><ul><li><strong>/. </strong>statik/heads contain the list of branches</li><li>/.statik/heads/main includes the latest committed contents in the main branch (when we make new branches /heads/(branch name), which consist of the previously committed contents in that corresponding branch as cids.</li><li>/.statik/HEAD/ consists of the current branch, which is the main when the statik repo is initialized.</li><li>The CONFIG file has the IPFS node URL.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/0*nI6Fx6QMNs56BkxO" /></figure><p><strong>Add(CWD, path of the directory to be staged)</strong>- It first checks if the current directory is a Statik repository and if any file paths are specified for adding. If not, it provides a helpful hint.</p><p>- It then initializes an IPFS client based on the configuration fetched from the local Statik setup. Depending on whether there are previous commits, it either creates a new snapshot of the specified files or updates an existing one.</p><p>- The function iterates over the provided paths, checks if they are directories, and adds the files recursively to the snapshot. If no changes are compared to the previous snapshot, it notifies the user accordingly.</p><ul><li>Finally, it writes the updated snapshot path to the repository and exits the process gracefully, handling any errors encountered during the process.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/735/1*auqVCBKWftkfDehqrQaPzQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/0*V6tQA06YlkFjmfg1" /></figure><p>- It then initializes an IPFS client based on the local Statik configuration, retrieves the current branch, and reads the previous commit from the repository. It constructs a commit object containing the previous commit hash, the snapshot hash, the commit message, and a timestamp.</p><ul><li>This commit object is added to IPFS, and its resulting hash is written to the repository’s branch file. The function clears the snapshot file and logs the successful commit with the hash to IPFS before gracefully exiting the process. Any encountered errors are logged, and the process exits with an error status.</li></ul><p><strong>The chaining of CID’s of commit data:</strong></p><p>After the statik commit command in the heads/&lt;branch_name&gt; folder, the CID of the commit content (which is in the form of JSON data) is written, the of which looks like</p><p><em>commit = {</em></p><p><em>prevCommit: prevCommit,</em></p><p><em>snapshot: snapshot,</em></p><p><em>message: message,</em></p><p><em>timestamp: Date. now()</em></p><p><em>};</em></p><p>it can be seen that the prevcommit field has the value prev commit which is the CID that’s been already there before the current commit,</p><p>hence, the commit data has a link in the form of CID to the previous commit and the current snapshot; this way of structuring helps as we compare the previous commit data and current staging data, figuring out the mismatches and deciding whether any changes have been made.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/695/1*Kd1IWW9gtPMer_GuCtgl1g.jpeg" /></figure><p><strong>Log(cwd)</strong>-It is similar to the git log. We get the array of commit data from the /heads/branch file, and we iterate through it by decrypting the CID using client.cat() and serially print the commit messages and the time of commit through asynchronous iteration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/0*yn4hXWMEESsY8rSE" /></figure><p>As mentioned before, the commit history is like linked lists where each commit data has a CID pointing to the previous commit, using which we can extract the Entire commit history. With just the single Head commits CID.</p><p><strong>List(cwd)</strong> -lists all the branches in the repository. First, it ensures that the current directory is a Statik repository. It then reads the current branch from the repository’s HEAD file and retrieves a list of all branch files from the head’s directory.</p><p>- It iterates through each branch file, printing its name to the console. The current branch is highlighted with arrow symbols to differentiate it from others. They are caught and logged to the console if errors occur during the process. Overall, this function provides a simple way for users to view all branches within the Statik repository from the command line.</p><p><strong>Jump(cwd,branch_name)</strong>-It first verifies that the current directory is a Statik repository. Then, it reads the current branch and checks if the requested branch matches the current one. If so, it logs a message indicating that the branch has already been checked out.</p><ul><li>It further checks for staged changes, if any, and prevents switching branches without committing them. If the requested branch doesn’t exist, it creates a new branch by copying the current head commit.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/716/0*7aH5EA_etCALJNp0" /></figure><p>- If the requested branch exists, it fetches the head commit of that branch from IPFS and compares it with the current working directory’s files to determine any unstaged changes. If unstaged changes are found, it lists them and terminates the process. Next, it checks for overriding changes and handles them similarly.</p><p>- Finally, it switches to the requested branch, updates the working directory with the branch’s files, and updates the HEAD pointer accordingly. Any encountered errors are caught and logged.</p><h3><strong>Why contribute to the project?</strong></h3><p><strong>Learning Opportunities</strong>: Contribute to a project that combines IPFS and version control, gaining knowledge in both domains.</p><p><strong>Open Source Spirit:</strong> Delve deep into the open-source spirit, fostering transparency and allowing contributors to showcase their skills to a broader audience.</p><p><strong>Impact:</strong> Make meaningful contributions that have the potential to revolutionize how version control is approached in a decentralized world.</p><p><strong>New Technology</strong>: Work with the latest decentralized technologies and version control systems advancements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cYhaJxg_jKdA6SWJ" /></figure><p>Statik is an open-source project hosted on GitHub. You can contribute to the development of Statik by visiting our <a href="https://github.com/SpiderNitt/statik"><strong>GitHub repo</strong></a><strong>.</strong></p><p>Statik represents a significant leap in version control, leveraging IPFS’s decentralized architecture for secure, efficient, and transparent versioning. By embracing Statik, developers can explore a new paradigm in collaboration and data management, shaping the future of decentralized version control.</p><p>This article is published as a part of the ‘Decoding the Architecture Series’ under Spider Research and Development Club, NIT Trichy.</p><p>This article was co-written by <a href="https://medium.com/@lokvisnu"><strong>Lok Visnu</strong> </a>and <a href="https://medium.com/@gabriel_338"><strong>Gabriel</strong></a>, who are also contributors to the Spider Research and Development Club’s ‘Decoding the Architecture Series’ at NIT Trichy.</p><p>Check out our previous article that discusses the architecture of the Gym Pool Registration Portal: <a href="https://medium.com/spidernitt/decoding-the-architecture-c63b006488a3"><strong>Gym and Pool Registration Portal Architectur</strong></a><strong>e</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=49ea5e0b979b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/spidernitt/statik-revolutionizing-version-control-with-decentralization-49ea5e0b979b">Statik: Revolutionizing Version Control with Decentralization</a> was originally published in <a href="https://medium.com/spidernitt">Spider R&amp;D</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Welcome to the world of decentralised file storage systems!]]></title>
            <link>https://medium.com/spidernitt/welcome-to-the-world-of-decentralised-file-storage-systems-c0a70beda5e4?source=rss----7fa9174f5b5c---4</link>
            <guid isPermaLink="false">https://medium.com/p/c0a70beda5e4</guid>
            <category><![CDATA[ipfs]]></category>
            <category><![CDATA[filesystem]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[p2p]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Bharanichandraprabhu]]></dc:creator>
            <pubDate>Tue, 09 Apr 2024 15:32:31 GMT</pubDate>
            <atom:updated>2024-04-09T15:32:31.355Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/828/0*O81_8FRRcFAt3jlo" /><figcaption>Image source: <a href="https://github.com/topics/ipfs"><strong>Github</strong></a></figcaption></figure><p>Imagine a world where files are stored and shared without the limitations of traditional client-server models. This world exists in the InterPlanetary File System (IPFS), a decentralized network where files are distributed across nodes, ensuring quick access and reliability.</p><p>In traditional client-server models, when files are stored on centralized servers, there’s a vulnerability known as single-point failure. If the server crashes or experiences issues, access to those files is completely cut off until the server is restored. It’s like putting all your eggs in one basket — if something happens to that basket, you’re out of luck.</p><p>However, with IPFS (InterPlanetary File System), things work differently. Instead of relying on one central server, files are distributed across multiple nodes on various systems. Each node stores a copy of the file, so if one node goes down or experiences issues, plenty of other nodes still have a copy. It’s like having backups of your files scattered across different locations — even if one area fails, you can still access your files from another location.</p><p>This decentralized approach makes the system more resilient to failure and enhances security. Since files are distributed across multiple nodes, it becomes much more challenging for malicious actors to tamper with or manipulate them. Additionally, because no central authority controls access to the files, IPFS resists censorship. This means that even in environments where access to certain information may be restricted, IPFS ensures that files remain accessible to those who need them.</p><p>The shift towards IPFS represents a significant advancement in storing and accessing files. It offers increased resilience, enhanced security, and greater freedom of access, addressing critical concerns in today’s digital landscape.</p><p>The internet&#39;s rise and increasing reliance on technology has highlighted the need for more open, transparent, and resilient systems. Decentralization, exemplified by protocols like IPFS, offers a solution to these challenges, paving the way for a more equitable distribution of wealth and opportunities in the digital realm.</p><p>Join us on a journey to explore the world of IPFS, where files are not just stored but are part of a distributed, interconnected web that transcends borders and central authorities.</p><p>Watch the recording of our workshop about IPFS here to learn more about the topic.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FdzuEhCb2MEo%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DdzuEhCb2MEo&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FdzuEhCb2MEo%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/b59aaa3d08f774eeafb3cfbaaf546bcb/href">https://medium.com/media/b59aaa3d08f774eeafb3cfbaaf546bcb/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*gOROdakflx0GFKAPo5c4Gg.gif" /></figure><p>This is a demo of adding files to IPFS and viewing them through the local gateway. Here, we upload a video, inspect its Content Identification Index(CID), and get the corresponding DAG (Directed Acyclic Graph) of the CID (data chunks) split up. You can view the video through the local gateway. If you try to click any of the leaves of the DAG, its corresponding CID’s DAG will be shown, and if you view that in a local gateway, you can probably see a small part of the complete video. This demonstrates how the data is split into chunks.</p><h3><strong>How Content Delivery Works in Centralised Networks</strong></h3><p>Let’s imagine you’re sitting at home browsing the internet and deciding to watch a popular YouTube video. When you click on the video link, your web browser sends a request to YouTube’s servers asking for the video data. In a location-based addressing system, this request is directed to a specific server based on your geographic location or network proximity.</p><p>For instance, if you’re in India, the request might be routed to a YouTube server located in a data centre in India. The internet infrastructure makes This routing decision, considering network latency and server availability. The YouTube server retrieves the video data and streams it back to your web browser. The video content travels through various network links and infrastructure through this process before reaching your device.</p><p>While location-based addressing optimizes content delivery by directing requests to nearby servers, it does have limitations. For instance, if the designated YouTube server in India experiences high traffic or technical issues, it could lead to delays or interruptions in video streaming. Additionally, as internet usage grows in India and more users access YouTube simultaneously, scalability becomes a concern as individual servers may struggle to handle the increasing load.</p><h3><strong>How It Works in IPFS</strong></h3><p>When you click on a YouTube video link, your web browser sends a request to retrieve the video data. In IPFS, instead of routing the request to a specific server based on your geographic location, the request is broadcast across the IPFS network. The video content isn’t stored on a centralized server. Instead, it’s broken down into smaller chunks called blocks, each assigned a unique cryptographic hash called a Content Identifier (CID). These blocks are distributed across multiple nodes in the IPFS network.</p><p>When your request reaches the IPFS network, nodes with the requested blocks respond by delivering them directly to your web browser. These blocks may come from multiple nodes across the network. Your browser then assembles the blocks to reconstruct the original video content.</p><p>Having seen how content delivery happens in centralized networks and IPFS, we will dive deep into how IPFS works, its features, etc…</p><h3><strong>Key features of IPFS</strong></h3><h4><strong>Content addressing with CID:</strong></h4><p>IPFS uses Content Identifiers (CIDs) to identify content uniquely. To explain the underlying concept of CID, let us look at this analogy. Think of the CID as a unique fingerprint for each book in the library. Just as each person has a unique fingerprint, each book has a unique CID that distinguishes it from others. This allows users to identify and retrieve specific files in the IPFS network quickly.</p><h4><strong>Visualisation of how CIDs are chained:</strong></h4><p>Below is the visualization made with the DAG visualizer available on the internet, which presents how the bytes of data are split into chunks and form a Directed Acyclic Graph. Each chunk has its own CID and the points the bytes of data allotted to that node.</p><p>In this example, we added a PPT file, showing that the DAG is big. It depends on the files’ complexity and the data input structure for a folder, Video, or Picture. The sizes and a very spread graph can be even more significant.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*J7AyK3x2OqOmLTosIlGWvQ.gif" /></figure><h4><strong>Peer to Peer network:</strong></h4><p>Imagine a network of post offices where each can send and receive mail directly to and from other post offices without needing a central sorting facility. This decentralized approach allows for efficient communication and sharing of information, similar to how IPFS nodes communicate directly with each other to share files.</p><h4><strong>Decentralized Storage</strong></h4><p>In IPFS, files are divided into smaller chunks, and each chunk is stored on multiple nodes in the network. This decentralized storage approach ensures that files remain accessible even if some nodes go offline, making the system more resilient to failures and censorship.</p><p>Here is an easy analogy to help you understand the concept better. Picture a community pantry storing food items in multiple households instead of a single central pantry. If one household runs out of a particular item, they can borrow it from another. Similarly, in IPFS, files are stored across multiple nodes, ensuring that even if some nodes go offline, the files remain accessible.</p><h4><strong>Versioning and History</strong></h4><p>IPFS supports versioning and maintains a history of changes to content. Users can access previous versions of files by referencing their CIDs, allowing for efficient tracking of changes over time.</p><h4><strong>Offline Access</strong></h4><p>IPFS allows users to access content offline by caching content locally. When a user requests a piece of content, IPFS checks its local cache before retrieving it from the network, reducing latency and improving accessibility.</p><h4><strong>Secure and Encrypted</strong></h4><p>IPFS provides security and privacy features by allowing users to encrypt their data before storing it on the network. This ensures that only authorized users can access the content and protects against unauthorized access and tampering.</p><p>Having explored the key features of IPFS, let’s now delve into its practical applications. From decentralized file sharing to innovative storage solutions, IPFS offers diverse use cases that showcase its transformative potential in various domains.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*f2dnfbmhpTdk1gGu" /></figure><h3><strong>IPFS Use Cases</strong></h3><p><strong>Decentralization in IPFS: </strong>IPFS revolutionizes file management through decentralized file sharing, storage, and content distribution. It enables direct file exchange, eliminating intermediaries and central servers for peer-to-peer connectivity. Data dispersal across interconnected nodes ensures redundancy, resilience, and security, empowering users with greater control over their data. IPFS optimizes content distribution, enhancing download speeds and minimizing latency, benefiting content creators and overcoming centralized platform limitations.</p><p><strong>Decentralized applications (dApps)</strong>: IPFS can be used to build decentralized applications (dApps) that run on a distributed network of nodes. This allows for greater security and privacy and increased reliability and scalability compared to traditional centralized applications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/0*WfPrC9XvZPRmYAzJ" /></figure><p><strong>Permanent web hosting</strong>: IPFS provides a permanent web hosting solution that allows users to host content indefinitely without the risk of the content being taken down or removed. This can be particularly useful for hosting content that is politically sensitive, controversial, or subject to censorship.</p><p><strong>Filecoin:</strong> Filecoin integrates with IPFS by utilizing IPFS as its underlying storage layer. IPFS provides the decentralized and content-addressable storage infrastructure for Filecoin. When users store data on Filecoin, it is chunked, encrypted, and distributed across IPFS nodes in the network. Filecoin introduces a layer of economic incentives and market mechanisms on top of IPFS to incentivize storage providers and ensure the reliability and availability of stored data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*U2RAgByxzdST7E6D" /></figure><p>Having examined the applications of IPFS, it’s clear that its decentralized model offers unique solutions to various challenges. Now, let’s shift our focus to the advantages IPFS provides.</p><h3><strong>Advantages of IPFS:</strong></h3><p><strong>Quick Access to Content:</strong> IPFS enables fast content retrieval by storing files on a distributed network, reducing latency compared to centralized systems.</p><p><strong>Increased Data Availability</strong>: By distributing files across multiple nodes, IPFS ensures data availability even if some nodes are offline, enhancing system resilience.</p><p><strong>Improved Security</strong>: IPFS enhances security using cryptographic hashes to identify and verify content, preventing tampering and ensuring secure file storage and sharing.</p><p>While the advantages of IPFS are compelling, understanding its comparative strengths and weaknesses against centralized storage systems is crucial for informed decision-making. Let’s delve into scenarios where IPFS shines and where it might fall short compared to traditional centralized storage solutions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dWBXmXb7SiPNWaHA" /><figcaption>Image source: <a href="https://blog.ipfs.tech/2022-06-09-practical-explainer-ipfs-gateways-1/">IPFS Docs</a></figcaption></figure><h3><strong>When is IPFS Better/Worse than Centralized Storage:</strong></h3><ul><li>Better: IPFS is better than centralized storage for scenarios where data availability and resilience are critical. For example, in disaster-prone areas with unreliable internet connectivity, IPFS can ensure that files remain accessible even during outages.</li><li>Worse: IPFS may be worse than centralized storage in scenarios requiring strict access control and centralized management. For example, a traditional centralized storage solution may be more suitable in a corporate environment where files must be accessed and managed centrally.</li></ul><p>In conclusion, IPFS represents a significant shift in internet content storage and access. It offers resilience to failures by distributing files across multiple nodes, akin to a library storing books in different branches. IPFS is also resistant to censorship and can scale efficiently by adding new nodes. IPFS presents a decentralized and resilient alternative to traditional centralized systems, promising a transformative impact on the Internet’s future.</p><p>We are building a decentralised version of the Control Tool called Statik on top of IPFS. To learn more about it, check out our article: <a href="https://medium.com/spidernitt/statik-revolutionizing-version-control-with-decentralization-49ea5e0b979b"><strong>Statik: Revolutionizing Version Control with Decentralization</strong></a>.</p><p>This article was co-written by <a href="https://medium.com/@lokvisnu"><strong>Lok Visnu</strong></a> and<strong> </strong><a href="https://medium.com/@gabriel_338"><strong>Gabriel</strong></a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c0a70beda5e4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/spidernitt/welcome-to-the-world-of-decentralised-file-storage-systems-c0a70beda5e4">Welcome to the world of decentralised file storage systems!</a> was originally published in <a href="https://medium.com/spidernitt">Spider R&amp;D</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Subset Sum DP -further optimizations]]></title>
            <link>https://medium.com/spidernitt/subset-sum-dp-further-optimizations-4f6777b71b4e?source=rss----7fa9174f5b5c---4</link>
            <guid isPermaLink="false">https://medium.com/p/4f6777b71b4e</guid>
            <category><![CDATA[math]]></category>
            <category><![CDATA[pd]]></category>
            <dc:creator><![CDATA[Ashwanth K]]></dc:creator>
            <pubDate>Mon, 18 Sep 2023 10:46:40 GMT</pubDate>
            <atom:updated>2023-09-18T10:47:22.883Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Prerequisites:</strong> DP, Standard subset sum dp, maths<br><strong>Topic difficulty:</strong> Hard</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/747/1*GRz3I5wmx98s8JT8LCwRgA.jpeg" /></figure><p>It is recommended to have a good understanding of the subset sum dp problem before reading this blog.</p><p><a href="https://www.geeksforgeeks.org/subset-sum-problem-dp-25/">Dynamic Programming - Subset Sum Problem</a></p><blockquote><strong>General Problem:<br> </strong>Given an <strong>array </strong>of size <strong>N</strong>, and a <strong>target_sum</strong>. You need to determine whether any <strong>subset </strong>of this array has its <strong>sum = target_sum</strong>.</blockquote><blockquote><strong>Constraints: <br> </strong>1≤ N ≤ 2000<strong><br> </strong>1 ≤ target_sum ≤ N<br> 0 ≤ Array[i] ≤ N</blockquote><p>The above problem is called the standard subset sum problem which is usually solved using an <strong>O(N²)</strong> dp approach like <em>dp[index][target_sum].</em></p><p>However, a variation of this problem can be further optimized to <strong>O(N*sqrt(N)*logN)</strong> using some observations. This variant problem and its interesting solution is what we will see in our blog.</p><blockquote>Consider a variant of this subset sum problem where you were asked to find whether the <strong>target_sum </strong>is achievable or not using some <strong>subset </strong>of elements.</blockquote><blockquote><strong>But additional constraints:<br> </strong>1 ≤ N ≤ 2*10⁴<strong><br></strong> sum of all array elements ≤ 2*10⁴</blockquote><p>In our variant problem, we are provided with additional information that my input array sum ≤ N. Can we use this to optimize our algorithm …..</p><p>Yes, we can use this additional piece of information to improve our complexity. Let’s see how can this be done.</p><p><strong>Observation 1:</strong><br>If a positive integer <strong>N</strong> is represented as a sum of positive integers, such a sum always contains at most <strong>O(sqrt(n))</strong> distinct numbers.</p><ul><li>The reason for this is that to construct a sum that contains a maximum number of distinct numbers, we should choose small numbers.</li><li>If we choose the numbers 1,2,…,k, the resulting sum is <br> k(k +1)/2 = N (total_sum).</li><li>Thus, the maximum amount of distinct numbers is k = <strong>O(sqrt(n))</strong></li></ul><p><strong>Conclusion:<br></strong>My input array always contains<strong> O(sqrt(N)) distinct numbers. </strong>This observation gives us some hope that we can somehow compress our array into smaller sizes and perform our standard dp algorithm to achieve a good complexity.</p><p><strong>Observation 2:<br></strong>If a positive integer is repeated <strong>K</strong> times in the input array, we can compress it into just <strong>log(K) </strong>elements while retaining all possible subset sum information.</p><p><strong>Example:</strong></p><ul><li>Lets say I have number x repeated 10 times : {x,x,x,x,x,x,x,x,x,x}<br> <strong>10 = (1 + 2 + 4) + 3</strong></li><li>Try to express 10 as the sum of continuous powers of 2.</li><li>Since 1+2+4+8 = 15 &gt;10, we just express it as 1+2+4+(remaining) 3</li></ul><p>{x,x,x,x,x,x,x,x,x,x} this array can generate subset sums: {x , 2x , … , 10x}<br>Even our compressed array: <strong>{x, 2x, 4x, 3x}</strong> can also express the same set of sums as above.</p><ul><li>Similarly<strong> {x,x,x,… 15 times }</strong> can be compressed as <strong>{x,2x,4x,8x} </strong>where all my subset sums are retained.</li></ul><p><strong>Conclusion:<br></strong>My input array has <strong>O(sqrt(N))</strong> distinct elements. Each distinct element with frequency<strong> K</strong> can be compressed into <strong>log(K) </strong>elements. So the compressed version of my array contains only <strong>O(sqrt(N)log(N)) elements</strong>.</p><p>Running our standard dp on<strong> O(sqrt(N)log(N)) </strong>elements with<strong> target sum ≤ N</strong> takes <strong>O(Nsqrt(N)log(N))</strong> time complexity.</p><p><strong>Code snippet for compressing array:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/06902e346545c22e3a3e96e959f348ad/href">https://medium.com/media/06902e346545c22e3a3e96e959f348ad/href</a></iframe><p><strong>Problem for practice (Hard):</strong></p><p><a href="https://codeforces.com/contest/1856/problem/E1">Problem - E1 - Codeforces</a></p><p><strong>Summary:</strong></p><p>In Competitive coding, It is always good to use up all information provided to you in the problem statements, From the above content we can see that a small additional information has improved the time complexity of our program.</p><p><em>This article is published as a part of the ‘</em><strong><em>Algo Reads</em></strong><em>’ under Spider Research and Development Club, NIT Trich</em>y.</p><p><strong>Resource:</strong></p><ul><li>CSES Book chapter 27</li></ul><p><a href="https://codeforces.com/blog/entry/97396">[Tutorial] Subset Sum Square Root Optimisation - Codeforces</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f6777b71b4e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/spidernitt/subset-sum-dp-further-optimizations-4f6777b71b4e">Subset Sum DP -further optimizations</a> was originally published in <a href="https://medium.com/spidernitt">Spider R&amp;D</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Contribution technique-I]]></title>
            <link>https://medium.com/spidernitt/contribution-technique-i-c1730f195b41?source=rss----7fa9174f5b5c---4</link>
            <guid isPermaLink="false">https://medium.com/p/c1730f195b41</guid>
            <category><![CDATA[dfs]]></category>
            <category><![CDATA[math]]></category>
            <category><![CDATA[trees]]></category>
            <category><![CDATA[contribution]]></category>
            <dc:creator><![CDATA[Ashwanth K]]></dc:creator>
            <pubDate>Sun, 10 Sep 2023 05:54:34 GMT</pubDate>
            <atom:updated>2023-09-10T05:54:33.821Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><strong>Pre Requisites:</strong> trees basic dfs, calculating subtree sizes, basic math<br><strong>Difficulty:</strong> Medium</blockquote><p>Today, we will see a good technique in CP known as contribution sums. This technique can be used in many counting problems to make our computations faster.</p><p>The basic idea behind this technique is to <strong>identify the entities</strong> (basic elements) that constitute the final answer. We need an answer to this question: “What is my final answer made up of?” Then, we would iterate on each entity and find its own <strong>contribution </strong>to the final answer.</p><p>Solving a counting problem with the contribution technique might be faster than a normal brute force.</p><p>This post will specifically deal with the contribution technique on trees.</p><p>Let&#39;s start with a simple problem to understand this technique.</p><p><strong>Q) Given a tree (with any number of children) of N vertices and N-1 edges rooted at (1). I have to find the sum of the edge lengths between all possible pairs of nodes in the given tree.</strong></p><p>Sample example and explanation:</p><p><strong><em>Brute-force:</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1007/1*JPIeqCpSh__4DTCSE4lAOA.png" /></figure><p>Consider the above tree with 6 Nodes. There are 15 pairs of nodes that I can choose. I have to find the path length for each pair and add it to my final answer. Let&#39;s do a walkthrough on this brute-force approach.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*f-nYPvFDCaSbEJ_hhg1BZg.png" /></figure><p>The above image is self-explanatory. Basically, we have tried all possible combinations of choosing two nodes and iterating through its path. In the worst case, each path length can be O(N), and there are O(N²) such pairs of nodes.</p><p>So, our brute force solution will have an <strong>O(N³)</strong> complexity. The above solution may be optimized to <strong>O(N²)</strong> with some observations but still gives TLE for large N ≤ 10⁵.</p><p><strong>Efficient solution: O(N) using contribution technique</strong></p><p>Let&#39;s see how we can use the idea of contribution here. If we notice carefully that our final answer constitutes only the edges of our tree. (i.e.,) Our final answer is just a collection of edges taken many times. So, our basic entity of the final answer is my<strong> edge of the tree</strong>.</p><p>Let&#39;s <strong>iterate on each edge</strong> and find its contribution. Basically, I am fixing my edge say (u,v), and trying to find how many of the paths contain this (u,v) edge.</p><p>See the image below for a better understanding:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*wAZD5sRMK7KKQhRy_fiDhg.png" /></figure><p><strong>Example: </strong><br><strong>3–4 edge</strong> is contained in <strong>5</strong> paths: 4 →3, 4 →1, 4 →2, 4 → 5, 4 → 6. <br>So, the (3–4) edge <strong>contributes a value of 5 </strong>to my final answer. Similarly, this can be calculated for other edges too.</p><p>Now, a question arises: “How do we efficiently compute occurrences of each edge? ”</p><p>Let&#39;s do some maths and observations here:</p><p>Let&#39;s try to find the contribution of <strong>(1–3) edge</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/983/1*XB12pp2cAbq3Jp9Ikk_opw.png" /></figure><p>Any node in the green region paired with any node in the orange region will have (1–3) edge passing by. So, the green region contains three nodes, and my orange region (outside green) also contains three nodes. So 3 x 3 = 9 pairs (u,v) contains this edge passing by.</p><p>The green region contains basically <strong>subtree_size[u]</strong> nodes. My orange region contains <strong>(N - subtree_size[u])</strong> nodes.</p><p>So the contribution of edge <strong>(u, parent[u]) </strong>is basically :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*DPfDElq-bzxBHf4lpZV57A.png" /></figure><p>So, just summing up the above equation for all “u” gives my answer.</p><p><em>subtreeSize[u]</em> for all nodes can be calculated with a simple dfs on the tree and summing values taking an overall <strong>O(N)</strong> complexity.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7f96f330834361b563f0449dae4f0666/href">https://medium.com/media/7f96f330834361b563f0449dae4f0666/href</a></iframe><p><strong>Summary:</strong></p><p>Thinking in terms of contributions can lead to a better solution with good time complexity. This technique is more common in competitive coding. We just need to figure out my <strong>basic elements</strong> and how they <strong>affect </strong>my final answer. I hope you all have some basic ideas on contributions; for more interesting problems, you can refer to the resource below.</p><p><em>This article is published as a part of the ‘</em><strong><em>Algo Reads</em></strong><em>’ under Spider Research and Development Club, NIT Trich</em>y.</p><p><strong>Resource:</strong></p><p><a href="https://codeforces.com/blog/entry/62690">Sums and Expected Value - part 1 - Codeforces</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c1730f195b41" width="1" height="1" alt=""><hr><p><a href="https://medium.com/spidernitt/contribution-technique-i-c1730f195b41">Contribution technique-I</a> was originally published in <a href="https://medium.com/spidernitt">Spider R&amp;D</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Matrix Exponentiation]]></title>
            <link>https://medium.com/spidernitt/matrix-exponentiation-acd80b217d16?source=rss----7fa9174f5b5c---4</link>
            <guid isPermaLink="false">https://medium.com/p/acd80b217d16</guid>
            <category><![CDATA[math]]></category>
            <category><![CDATA[matrix-exponentiation]]></category>
            <dc:creator><![CDATA[Ashwanth K]]></dc:creator>
            <pubDate>Fri, 25 Aug 2023 14:24:17 GMT</pubDate>
            <atom:updated>2023-08-25T14:24:17.187Z</atom:updated>
            <content:encoded><![CDATA[<p>“A nice technique you will appreciate once known.”</p><blockquote>Pre Requisites: <strong>Binary Exponentiation</strong>, <strong>Linear Recurrence</strong> relations, <strong>Matrices, </strong>Fibonacci Numbers<br>Topic Difficulty: <strong>Medium</strong></blockquote><p>In the previous <a href="https://medium.com/spidernitt/binary-exponentiation-fed536ea6c38">post</a>, we have seen that we can calculate the powers of integers in <em>logarithm </em>complexity. Are we only restricting this idea of binary exponentiation only to integers …… Can we go beyond this and extend this same idea to matrices?</p><p>It&#39;s a Yes. As the topic suggests, we can also calculate the powers of a matrix in logarithm complexity. But to note: If the matrix is of size <strong>K x K</strong>, then the multiplication of matrices costs <strong>O(k³)</strong> complexity.</p><p>Then raising the power of the matrix costs an overall complexity of <br><strong>O(k³ logN)</strong>, where <strong>K x K</strong> is the size of the matrix, and <strong>N</strong> is the power to be raised. (Refer to prev blog if you are not clear about this complexity)</p><p>But why are we so concerned about matrices? What problems does this technique actually solve? We shall see the answers to these questions soon below…</p><p><strong>Note: </strong>We are dealing with only square matrices here of size <strong>K x K</strong></p><h4>Code snippet on matrix exponentiation:</h4><p>For simplicity, all matrices are 2x2 in the below code, but they can be easily generalized to any K x K matrix.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fdd142f66269dc029876ab72f8b15647/href">https://medium.com/media/fdd142f66269dc029876ab72f8b15647/href</a></iframe><p>I hope that the above snippet is clear. If not, compare this snippet&#39;s pow function with the pow function of the previous blog.</p><p>Let&#39;s deal with a problem now….</p><h3>Find the Nth Fibonacci number in log(N) time complexity.</h3><p>Yes, you heard it right. Till now, we would have only seen O(N) as an easy solution for finding the Nth Fibonacci number.</p><p>But the truth is that there exists an O(logN) solution that solves the same problem of just finding the Nth Fibonacci number.</p><p>Try to think intuitively about what happens at O(N) algorithm. We are computing all 1st, 2nd to …. N th Fibonacci numbers. But my problem <strong>requires only the Nth Fibonacci Number</strong>. We are doing unnecessary computation here. We can intuitively think there can be a better solution to directly finding the required Fibonacci number without computing all previous values.</p><p>And Yes, matrix exponentiation comes to the rescue.</p><p>Now let&#39;s see how my Fibonacci number problem can be converted to matrices and solved using this technique.</p><p>Consider <strong>f(n) = Nth fibonacci number</strong>. Look at below matrix equation carefully.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*RtSvYtyBrZvNB4-HvkGOrA.png" /></figure><p>This matrix equation can be easily verified. <br>Consider <strong>RHS</strong>: <br> 1 * f(n-1) + 1 * f(n-2) = f(n-1) + f(n-2) = f(n) by definition {1st value}<br> Similarly f(n-1) = f(n-1) {2nd value}</p><p>On going further, we can see that …</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/544/1*dlXrXfjlmAkLQ9uBDG2gKQ.png" /></figure><p>You would have got an idea of what we are doing here. Going on further, we can see that….</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/485/1*AZn8W8FsxhmVAEI55oiBUQ.png" /></figure><p>Here my base cases are <strong>f(1) = 1</strong> and <strong>f(0) = 0</strong></p><p>It&#39;s done…. We have somehow converted our problem into a problem of matrix exponentiation. We need to raise the <strong>{{11}{10}} base matrix</strong> to power <strong>N-1, </strong>which<strong> </strong>can be solved with matrix expo in complexity <strong>O(k³ logN)</strong>. <br>{in this example k = 2}. O(8logN) will run faster.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ee6a1c9dd65aa21162481d215b983c14/href">https://medium.com/media/ee6a1c9dd65aa21162481d215b983c14/href</a></iframe><p><strong>NOTE:</strong></p><ul><li>Fibonacci numbers are even larger for large N, which does not fit in integer datatype. So generally, problems are asked in this technique based on printing answers in modulo P. Also, use LONG LONG.</li></ul><p><strong>SUMMARY:<br> </strong>It is to be shown that any linear recurrence of form <br> f(n) = c1*f(n-1) + c2*f(n-2) + …..+ ck*f(n-k) where c1,..,ck are integers. <br>It can be solved with matrix expo taking k x k base matrix size.</p><p>Even popular linear-dp problems like dice rolling and Staircase Dp have a matrix expo solution running in <strong>O(logN)</strong> complexity.</p><p>Coming up with a correct base matrix is sometimes harder, but it can be easily framed by considering the recurrence relation.</p><p><em>This article is published as a part of the ‘</em><strong><em>Algo Reads</em></strong><em>’ under Spider Research and Development Club, NIT Trich</em>y.</p><p><strong>Resource</strong>: <a href="https://usaco.guide/plat/matrix-expo?lang=cpp">Usaco Guide</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=acd80b217d16" width="1" height="1" alt=""><hr><p><a href="https://medium.com/spidernitt/matrix-exponentiation-acd80b217d16">Matrix Exponentiation</a> was originally published in <a href="https://medium.com/spidernitt">Spider R&amp;D</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Binary Exponentiation]]></title>
            <link>https://medium.com/spidernitt/binary-exponentiation-fed536ea6c38?source=rss----7fa9174f5b5c---4</link>
            <guid isPermaLink="false">https://medium.com/p/fed536ea6c38</guid>
            <category><![CDATA[placement]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[binary-exponentiation]]></category>
            <category><![CDATA[competitive-programming]]></category>
            <dc:creator><![CDATA[Ashwanth K]]></dc:creator>
            <pubDate>Fri, 18 Aug 2023 03:19:57 GMT</pubDate>
            <atom:updated>2023-08-18T03:23:41.897Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Topic Difficulty: <strong>EASY<br></strong>Pre Requisites: <strong>Basic Math</strong>, general idea on <strong>time complexity.</strong></blockquote><p>Can we compute powers faster in <strong>O(logN)</strong> complexity? This topic uses divide and conquer; let&#39;s see how we can achieve this complexity …</p><p>Let&#39;s take this problem —<a href="https://leetcode.com/problems/count-good-numbers/description/"> <strong>Count good number</strong></a>. Try to spend some time on this problem before proceeding with this article.</p><p>This problem somehow boils down to finding expressions like <strong>pow(A, B)</strong> where <strong>A</strong> and <strong>B</strong> are integers.</p><p>Here, I am given two numbers, <strong>A</strong> and <strong>B</strong>.</p><p><strong>My Aim:</strong> Compute <strong>pow(A, B)</strong> efficiently.</p><ol><li><strong>Naive Approach: </strong>Just brute force, initialize ans = 1, and perform multiplication with <strong>A</strong> for <strong>B</strong> times.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/1*mpxp8bkcfB_ktEiiiFpTLw.png" /></figure><p>2. <strong>Divide and Conquer Style:</strong> The main idea is to split the work in half and try to find the results. It can be observed that ….</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/1*p5fYWQ4-LtDtk7qVifTm1g.png" /></figure><p>Analyzing the above relation shows that my power factor gets reduced by half every time. Assuming that each multiplication operation takes <strong>O(1)</strong> time, our overall complexity becomes <strong>O(log(N))</strong>, where <strong>N </strong>is the power to be raised.</p><p>Code: (<strong>Recursive approach</strong>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*u-ahtsP7BZawf9GQsBqEVw.png" /></figure><p>We shall see a small example to show how the above code works. Let&#39;s say I want to compute pow(3,14)</p><p>pow(3,14) = pow(3,7) * pow(3,7)<br>pow(3,7) = pow(3,3) * pow(3,3) * 3<br>pow(3,3) = pow(3,1) * pow(3,1) * 3<br>pow(3,1) = pow(3,0) * pow(3,0) * 3</p><p>pow(3,0) = 1<br>pow(3,1) = 1 * 1 * 3 = 3<br>pow(3,3) = 3 * 3 * 3 = 27<br>pow(3,7) = 27 * 27 * 3 = 2187<br>pow(3,14) = 2187 * 2187 = 4782969</p><p>Even an <strong>iterative approach</strong> exists, which exploits the bitwise representation of my exponent number. Let&#39;s take a look at this too.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*jpxZuQX_q5vRhRdM4EreuA.png" /></figure><p><strong>Main Logic:</strong> break down my exponent number into powers of 2 and combine the results.</p><ul><li>Since 14 = <strong>1110 </strong><em>in base 2</em>, 14 = 8 + 4 + 2.</li><li>We can see that: 3¹⁴ = (3⁸)*(3⁴)*(3²)</li><li>Here we are computing values 3¹, 3², 3⁴,3⁸, and exclude 3¹.</li></ul><p>Since the number <strong>N</strong> can have only <strong>log(N)+1</strong> bits at most, we can see that we do <strong>O(logN)</strong> multiplications if we know the powers a¹,a²,a⁴,a⁸,a¹⁶,… so on.</p><p>Luckily these numbers {a¹,a²,a⁴,a⁸,a¹⁶,…} can be easily computed by just squaring the previous number.</p><p><strong>Summary:</strong></p><ul><li>We can compute <strong>power(A, N)</strong> in <strong>log(N).</strong></li></ul><p>Though this may look too easy, this technique has many applications.<br>In the next blog, we will see about a more powerful technique in CP called <strong>Matrix Exponentiation</strong>, which has binary exponentiation as its prerequisite.</p><p><em>This article is published as a part of the ‘</em><strong><em>Algo Reads</em></strong><em>’ under Spider Research and Development Club, NIT Trich</em>y.</p><p>Resource: <a href="https://cp-algorithms.com/algebra/binary-exp.html">cp-algorithms</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fed536ea6c38" width="1" height="1" alt=""><hr><p><a href="https://medium.com/spidernitt/binary-exponentiation-fed536ea6c38">Binary Exponentiation</a> was originally published in <a href="https://medium.com/spidernitt">Spider R&amp;D</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Gym and Pool Registration Portal Architecture]]></title>
            <link>https://medium.com/spidernitt/decoding-the-architecture-c63b006488a3?source=rss----7fa9174f5b5c---4</link>
            <guid isPermaLink="false">https://medium.com/p/c63b006488a3</guid>
            <category><![CDATA[design-systems]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[dta]]></category>
            <category><![CDATA[load-management]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Naveen Nair]]></dc:creator>
            <pubDate>Fri, 11 Aug 2023 07:47:42 GMT</pubDate>
            <atom:updated>2023-08-12T17:34:37.508Z</atom:updated>
            <content:encoded><![CDATA[<p>NIT Trichy has taken a significant leap towards enhancing user experience with its state-of-the-art online gym and swimming pool registration portal, meticulously crafted by the Spider R&amp;D club. The days of enduring long queues have been replaced by the convenience of a few simple clicks. Remarkably, every available slot now gets snatched up within a mere minute of opening. This article will delve into the underlying architecture and share the insights gained from our experimental journey to handle burstable loads with thousands of concurrent requests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*S7dNghqrCPMXp4MypZKrKw.png" /><figcaption>The Registration Portal’s Homepage</figcaption></figure><p><strong>UNDERSTANDING THE REQUIREMENTS AND THE PROBLEM</strong></p><p>A website that allows students to log in and register for the gym and swimming pool facilities of NIT Trichy. At first glance, this application is a simple registration portal where the users can log in and click on register, and it’s done. Still, we need to consider the fact that there are 300 different slots and at least a thousand students applying for the slots at a particular instant. It would be easier if we had scaled the server vertically. But we took the challenge to build an efficient system with average specs and tried to optimize the design. Additionally, we wanted the application to be real-time.</p><p><strong>Breaking down the underlying architecture</strong></p><p>After identifying two issues in our system — the possibility of overbooking slots for students and a lack of clarity regarding the number of available free slots during registration — we set out to find a solution. Our research led us to discover gRPC, a technology that enables us to display real-time free slots to users while they are registering. This way, students can clearly understand the available slots and avoid any potential overbooking problems.</p><p>Think of gRPC as a way for different computer programs to talk to each other. It’s like a common language they can use to communicate and exchange information. There are four types of streaming in gRPC.</p><p>1. Unary — send a single message and get a single message back</p><p>2. Server streaming — continuous flow of messages from the server</p><p>3. Client streaming — continuous flow of messages from the client</p><p>4. Bi-directional streaming — continuous back-and-forth communication</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*sTtoWcxePzXzZCnpH8I_hA.png" /><figcaption>Four types of streaming in gRPC</figcaption></figure><p>For our registration purpose, we need the client to send one message requesting details about the availability of slots, and the server needs to send multiple responses in a particular time interval. So we used server streaming.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*Pt76s3fCfxxeO5n-0e7PLA.png" /></figure><p>Also, this process leads to many reads from the database, which might result in overloading or similar situations. To overcome this, we used Redis, an in-memory data store. It provides better throughput and less latency. Redis improves performance, reduces the load on backend systems, and provides a better user experience by serving data quickly and efficiently. Additionally, we have used the publisher-subscriber concept of Redis to listen to the slot allocation and the registration status internally and trigger the streaming, which provides a real-time experience for the end users.</p><p>We also used a MySQL instance to store other information, such as information about different slots, allocation, etc. We chose MySQL because it is well known for its high performance and ease of use.</p><p>Although we use gRPC for server-side streaming, an issue was that gRPC works on a different version of the internet protocol (http/2) than our NextJS frontend, which operates on http/1. To overcome this problem, we implemented a gRPC wrapper. This wrapper acts as a bridge, converting the requests and responses between http/1 and http/2, ensuring smooth communication between the server and the front end.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*QJoJEYdezLzASzu2I5vb0A.png" /><figcaption>HTTP/2 vs HTTP/1</figcaption></figure><p>One crucial aspect of gRPC that we leverage in our project is its efficient server-to-server connection. This feature is especially beneficial during the authentication process. When our clients authenticate through LCA (Lynx Central Auth), we must make server-to-server requests to verify their identity. To protect against spam request attacks, we use reCaptcha. We have also used DDoS-deflate, an open-source tool, to temporarily block IP addresses suspected of performing a Denial of Service attack.</p><p>Moreover, gRPC truly shines in handling heavy server loads efficiently. It allows us to manage the authentication process smoothly, even under high demand. Additionally, gRPC’s streaming feature comes in handy for our project. It allows us to set up real-time communication between different parts of our system. For example, we can update the front end with the latest information about available slots during registration. This ensures that clients have accurate and up-to-date details while making their selections. By utilizing gRPC effectively, we address various challenges in our project, such as ensuring secure authentication, managing server loads, and providing real-time updates to our users.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*8S_AI0EcI4tvR3j4G3eYlw.png" /><figcaption>Gym Registration Frontend</figcaption></figure><p>For the front end, we use NextJS, a framework built on top of ReactJS, known for its high-speed and server-side rendering capabilities. This means the web pages load quickly, and some processing happens on the server side, providing a smoother user experience.</p><p>On the other hand, we have opted for Golang (Go) as our programming language for the backend owing to its speed and concurrency capabilities. gRPC uses the Protocol buffer data format. This data interchange format makes the system more efficient, making the whole process faster.</p><p>The backend has two services: the main service and the streaming service. The main service deals with the allocation and user profiles, whereas the streaming service is responsible for the real-time nature of the application. We have containerized every application for better portability and scaling.</p><p>By combining NextJS on the front end and Golang on the back end, we ensure that our application performs exceptionally well, delivering information to users swiftly and handling requests optimally. The result is a seamless and responsive system that caters to our users’ needs effectively.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*CuE6V_JIRpRq9XoZDLoIbQ.png" /><figcaption>The Overall Architecture</figcaption></figure><p>By now, we have gone through the different tech stacks used, the various challenges faced while building the project, and how they have been handled, but one crucial edge case still pertains, what if there are less number of seats remaining but more clients registering for a slot at the same time? How do we allocate seats up until a particular user?</p><p>This is famously known as the race condition. If only one seat remains, but two people are registering for that seat simultaneously, we use the unique key property of the Mysql DB to handle this by rejecting the clients after the number of seats is zero.</p><p>We’ve created an easy-to-use admin panel to ensure a smooth and well-organized experience for our clients. This panel gives our administrators the tools to create slots and manage the registration process independently and effortlessly.</p><p><strong>RESULTS AND STATS</strong></p><p>We tested the server simulating 2000 users sending requests concurrently, and we were happy to find that the server performed exceptionally well, considering it was a relatively low-specification machine. Despite its modest hardware configuration, the server demonstrated impressive response times and handled the burstable load without any noticeable performance degradation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*yQyrqWaRV447yeWnUicUrw.png" /><figcaption>A graph representing the time taken to get the responses</figcaption></figure><p>At the end of the registration process, we received positive feedback from both users and administrators, indicating the success of this project. Indeed, this project has scope for improvement. So stay tuned for more engineering!</p><p>This article is published as a part of the ‘Decoding the Architecture Series’ under Spider Research and Development Club, NIT Trichy.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c63b006488a3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/spidernitt/decoding-the-architecture-c63b006488a3">Gym and Pool Registration Portal Architecture</a> was originally published in <a href="https://medium.com/spidernitt">Spider R&amp;D</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Surviving the Unthinkable ft. Blockchain]]></title>
            <link>https://medium.com/spidernitt/surviving-the-unthinkable-ft-blockchain-63152c306863?source=rss----7fa9174f5b5c---4</link>
            <guid isPermaLink="false">https://medium.com/p/63152c306863</guid>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[decentralization]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[bitcoin]]></category>
            <dc:creator><![CDATA[Rutujeet Suryawanshi]]></dc:creator>
            <pubDate>Wed, 12 Apr 2023 12:35:09 GMT</pubDate>
            <atom:updated>2023-05-22T15:33:33.247Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Human nature doesn’t change. That struggle existed a hundred thousand years ago. That struggle exists today. What does change is technology. A hundred thousand years ago, an enraged human being could maybe kill 10 other people. And today, an enraged human being can kill a hundred million people. So as technology advances, our thoughts about ethics and morality and technology and civility have to evolve.</blockquote><blockquote>Micheal Saylor</blockquote><p>Experts in every field have spent a lot of time thinking about the potential implications of global catastrophes like nuclear war. It’s not a pleasant topic, but it’s a necessary one. The fact is, the risk of nuclear war is always present, and we need to consider how we can best prepare ourselves and our communities for the aftermath.</p><p>In recent years, we’ve seen the power of blockchain to provide secure and decentralized storage of information. But what if we could take this one step further? What if we could use blockchain as a tool for survival in the face of a nuclear war? This blog will explore the potential applications of blockchain technology in a post-apocalyptic world and how it could help us rebuild and thrive. It’s time to start thinking about the unthinkable and considering the role of blockchain in our future survival.</p><p>In a blockchain network, data is stored on a decentralized network of nodes rather than on a centralized server. Each node in the network stores a copy of the blockchain, which is a ledger of all transactions that have taken place on the network. This means that if one node goes down, the data on the network is still accessible from other nodes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*85wzlkF0IBGuYbiyPtZ_tg.png" /><figcaption>Example: Map shows the concentration of reachable Bitcoin nodes found in countries around the world</figcaption></figure><p>For example, storing identity information, financial records, and medical records on the blockchain network would be like having a plant that has spread its seeds globally. As long as a single seed (a node) is still around, the information and assets can be completely regrown. Smart contracts can be used to enforce strict access controls and permissions, ensuring that only authorized parties can view or modify the information stored on the blockchain.</p><p>In addition to providing secure storage of information, blockchain technology could also serve as a tool for trade and commerce in a post-apocalyptic world. After the nuclear blast (if you survive), are you going to wait for the government to reboot the banking system? Will you trust them to honour your previous account balances (lol)? After a global calamity, anyone with blockchain-based cryptocurrency will be transacting with each other far before legacy financial systems are rebooted.</p><p>Humanity will do everything that it can to rebuild the internet after a global calamity. When the electricity comes back on and some form of global communication resumes — Blockchain network will return.</p><p>But what if a global nuclear war completely wipes out humanity? Well then,</p><blockquote>That&#39;s a galactic shame.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=63152c306863" width="1" height="1" alt=""><hr><p><a href="https://medium.com/spidernitt/surviving-the-unthinkable-ft-blockchain-63152c306863">Surviving the Unthinkable ft. Blockchain</a> was originally published in <a href="https://medium.com/spidernitt">Spider R&amp;D</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>