<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Arun S M on Medium]]></title>
        <description><![CDATA[Stories by Arun S M on Medium]]></description>
        <link>https://medium.com/@arsulegai?source=rss-b16a2100ab91------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*DjFVvULB3i5W8ffb</url>
            <title>Stories by Arun S M on Medium</title>
            <link>https://medium.com/@arsulegai?source=rss-b16a2100ab91------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 17:17:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@arsulegai/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Cryptography: Primer]]></title>
            <link>https://arsulegai.medium.com/cryptography-primer-837f7abbbdee?source=rss-b16a2100ab91------2</link>
            <guid isPermaLink="false">https://medium.com/p/837f7abbbdee</guid>
            <dc:creator><![CDATA[Arun S M]]></dc:creator>
            <pubDate>Fri, 07 Jun 2024 04:59:06 GMT</pubDate>
            <atom:updated>2024-06-07T04:59:06.170Z</atom:updated>
            <content:encoded><![CDATA[<p>Cryptography, a sophisticated field, stretches beyond just securing communication. It ensures data integrity, authentication, and non-repudiation. This intricate science beautifully merges mathematics, computer science, and engineering.</p><p>At the heart of cryptography is the design of algorithms and protocols. These tools encrypt and decrypt messages, thereby safeguarding data during transmission and storage. However, the scope of cryptography transcends this, delving into diverse methods used to decode these complex systems and authenticate identities.</p><p>In my comprehensive series of blog articles, I will explore numerous subfields of cryptography. These include symmetric and asymmetric encryption, hash functions, digital signatures, and public key infrastructure — all essential components in ensuring data integrity and secure communication.</p><p>The significance of cryptography is unparalleled in various domains, including secure web browsing, online banking, digital currencies, and computer password protection. Furthermore, it plays a pivotal role in data authentication, ensuring that the data’s origin and delivery are verifiable and undeniable. Delving into the study of cryptography broadens one’s understanding of online security and privacy, unveiling the extensive applications of this intricate field.</p><blockquote>The foundation of digital security is based on the <strong>CIA</strong> triad, which stands for Confidentiality, Integrity, and Availability. These are the three key principles that should be guaranteed in every kind of secure system.</blockquote><ol><li><strong>Confidentiality:</strong> This principle ensures that the information is accessible only to those who are authorized to view it. It involves the encryption of data to restrict access to the contents of the data or message. In this context, cryptography ensures confidentiality by using various encryption algorithms that make the data unreadable to unauthorized users.</li><li><strong>Integrity:</strong> This principle ensures that the information is protected from unauthorized modification or deletion. It confirms that the data received is exactly the same as it was sent, without any alteration. Cryptography can provide data integrity by using hashing algorithms that allow the receiver to verify that the data has not been tampered with during transmission.</li><li><strong>Availability: </strong>This principle ensures that information and resources are available to authorized users whenever they need them. This includes ensuring the systems, hardware, and software are working correctly and are accessible when needed. Cryptography doesn’t directly ensure availability, but it indirectly contributes to it by ensuring the confidentiality and integrity of data, hence protecting the system from attacks that may lead to unavailability.</li></ol><blockquote>Understanding these principles is essential for anyone working with systems that require the secure storage or transmission of data.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=837f7abbbdee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enabling New Age Digital Era Security: OpenSSF Sigstore]]></title>
            <link>https://arsulegai.medium.com/enabling-new-age-digital-era-security-openssf-sigstore-195f30a8adb2?source=rss-b16a2100ab91------2</link>
            <guid isPermaLink="false">https://medium.com/p/195f30a8adb2</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[signature]]></category>
            <category><![CDATA[sigstore]]></category>
            <category><![CDATA[binary]]></category>
            <category><![CDATA[openssf]]></category>
            <dc:creator><![CDATA[Arun S M]]></dc:creator>
            <pubDate>Fri, 10 Nov 2023 04:33:28 GMT</pubDate>
            <atom:updated>2023-11-10T04:33:28.009Z</atom:updated>
            <content:encoded><![CDATA[<p>In the ever-evolving realm of software development, dependency libraries stand out as pivotal elements. These dependencies are designed with a focus on efficiency, reusability, and seamless ecosystem integration. However, they don’t come without their challenges. Concerns about maintainability and the potential risks associated with inadequate governance, particularly regarding security vulnerabilities, underscore their importance.</p><p>For software developers seeking to deliver their creations as binaries to end consumers, a vulnerable aspect emerges: binary distribution. The looming question arises — what if an unauthorized entity injects malicious code, jeopardizing the integrity of the application? Addressing these apprehensions, Sigstore, a project housed under the Open Source Security Foundation (OpenSSF), steps in. This blog article delves into the intricacies of how various components within the Sigstore project collaboratively address and overcome these challenges, ensuring a robust and secure software development environment.</p><blockquote>Secure your development environment and the ground before asking the user of your software to secure their environment.</blockquote><p>Fulcio: The first component that we discuss from Sigstore is Fulcio. The simple definition of Fulcio is that it is a service that verifies the identity, generates a short lived certificate associated with the signing key, the signing key would then be valid for a shorter duration. The developer’s identity is verified using one of the known IAM solutions. There is also OpenID Connect interface to verify the identity.</p><blockquote>Goal is to avoid the need to store and secure the signing key.</blockquote><figure><img alt="Fulcio" src="https://cdn-images-1.medium.com/max/722/1*HleV_Qnc0DzmoKLzRgB4Cg.png" /></figure><p>Cosign: The tool that facilitates the signing process. Be it a build artifact, a binary or just a blob, the cosign tool has support for all. Use this to generate a signature, also comes integrated so that it can connect to Fulcio instance of your choice. The signature and the publicly verifiable information is uploaded to an immutable record keeper, called rekor. More information on that will be discussed in the next section.</p><blockquote>Generate the necessary signature on the generated artifact, distribute the signature and the verification information, along with the binary.</blockquote><figure><img alt="Cosign" src="https://cdn-images-1.medium.com/max/722/1*eRHGcxsAGTlgxbw2e4Eq0g.png" /></figure><p>Rekor: The place where signatures along with their verification information is stored. It is an immutable record, so that once written the records can be used to verify any number of times. The public information such as the certificate associated with the signing key, identity which generated the signature are some of the critical parameters one can fetch from this store.</p><blockquote>Leaves no chance for an attacker to fake a binary, developer or the release engineer has full access to what is produced as a build.</blockquote><figure><img alt="Rekor" src="https://cdn-images-1.medium.com/max/722/1*YaLrLsd5c78ytgPXMEl32g.png" /></figure><p>Policy Controller: The signing process is only as strong as the verification process. The generated signature shall be verified for its authenticity. The users of the build artifacts are expected to verify if they are pulling in the right build. Policy Controller is one of the components available for an end user to verify if their binary is valid, the validity check is embed within the Kubernetes’ container image pull mechanism. It just makes the whole process of verification much easier to adopt.</p><blockquote>Don’t just believe the documentation, implement verification mechanism to be very sure.</blockquote><figure><img alt="Policy Controller" src="https://cdn-images-1.medium.com/max/722/1*WOyRK5cjmE4clHMZOvzY6A.png" /></figure><p>Overall, these tools should suffice for the complete lifecycle of build artifact management. I will add more details and the commands in next blog post, with a sample project using the Sigstore model.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=195f30a8adb2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Blockchain Platform]]></title>
            <link>https://arsulegai.medium.com/blockchain-platform-55d5c0408b44?source=rss-b16a2100ab91------2</link>
            <guid isPermaLink="false">https://medium.com/p/55d5c0408b44</guid>
            <category><![CDATA[blockchain-as-a-service]]></category>
            <category><![CDATA[hyperledger]]></category>
            <category><![CDATA[blockchain-technology]]></category>
            <category><![CDATA[design]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Arun S M]]></dc:creator>
            <pubDate>Sat, 20 Nov 2021 11:51:12 GMT</pubDate>
            <atom:updated>2021-11-20T11:51:12.382Z</atom:updated>
            <content:encoded><![CDATA[<h3>Blockchain Platform: Building a managed Blockchain-as-a-Service (BaaS)</h3><p>The article discusses challenges associated with building a blockchain as a service offering. Sophisticated orchestration/tooling mechanisms are in place for distributed micro-service architecture deployment, management and monitoring. Cloud native development has became a common saga across industries in the recent years. The blockchain technology itself is evolving alongside the blockchain technology adoption, this is a never seen before trend in the enterprise world. While it is true that (distributed) database as a service offerings are available on almost all of the cloud service providers, the same level of matured offering is still a distant future for the blockchain technology. The complexity lies in the details of “<strong><em>decentralized</em></strong>” network architecture. The blog is an answer to how can one sustain the ever-advancing landscape of this technology, face through the skill-gap, yet produce an offering that hides away complexities for rapid adoption demands.</p><h3>Design Thinking</h3><p>Let’s start by defining the desired features for a good “<strong>as a Service</strong>” offering</p><ul><li><strong>Infrastructure independent, cloud native and cloud service provider agnostic deployment options:</strong> One must be able to choose between their private cloud and public/dedicated cloud infrastructure, resource types varying all the way from VMs to containers. In cloud terminology one must be able to support both IaaS and PaaS.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/1*3r97lXSGV3nawWb_mmIUMw.png" /><figcaption>Infrastructure Independent, Cloud Native &amp; Cloud Service Provider Agnostic</figcaption></figure><ul><li><strong>Highly available system including failover and recovery strategies:</strong> Guaranteeing a 100% uptime of services on cloud is next to impossible, yet these challenges can be mitigated practically via design choices. There shall be an option to recover from a failing point, if required one must also have an option to switch-over a live deployment to a new infrastructure altogether.</li><li><strong>Identity and access management:</strong> Define, segregate interactive and non-interactive personas. Create, manage and assign roles/permissions. Assign roles to these generated identities for the scope of a specific instance of the application. It is important to know what happened, who did it, when did that happen. These would also help in accounting for the cost.</li><li><strong>Monitoring, logging and alerting:</strong> While it is important to be prepared for a mayhem, it is important for one to capture (though it is tiniest) indication of approaching a mayday. It is good practice to capture metrics in order to continuously work on possible optimizations.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/1*aNm7VQEKz_NAQnn8-pcOQg.png" /><figcaption>Highly Available, Backup &amp; Recovery Integrated, IAM, Logging &amp; Monitoring Enabled Deployment</figcaption></figure><ul><li><strong>Ability for multi-tenancy:</strong> While it is hard to build and manage a resource on cloud with SLAs, the benefit can be reaped only when it can be reused, shared across to others, with isolation. However, multi-tenancy shall be an optional configuration for the platform user.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/1*SyJQGfhveUkhp0C3YjTxkQ.png" /><figcaption>Cloud Multi-Tenancy</figcaption></figure><p>A user interface can be provided for any deployment, administration needs. The roles defined and identity management shall be taken into consideration while designing the user experience.</p><p>Personally, I consider security to be an all rounder. It is not just horizontal but it is also vertical domain. The very reason why it is not listed as a requirement here is because, it is not only about securing the network traffic, identifying entities, securing the secrets. One must practice security in every step, starting from requirements gathering, procuring resources, architecting the solution, components design, coding and all the way upto the user experience.</p><blockquote>Remember the <strong>KISS (Keep it Simple, Stupid)</strong> model, follow the principle of least privileges, be accountable for every resource and action.</blockquote><blockquote>Indeed, with great power comes great responsibility!</blockquote><p>While all of these are true for any application, a good “<strong>Blockchain as a Service</strong>” offering would also encompass</p><ul><li>An option to choose the blockchain protocol of choice (be it <em>Hyperledger Fabric</em>, <em>Hyperledger Besu</em>, <em>ConsenSys Quorum</em> etc) with an ability to swap the protocol later. Includes support for a blockchain protocol agnostic smart contract engine and language interpreter.</li><li>An option to use &amp; switch between supported state databases by the underlying blockchain protocol, reuse an existing managed database offering where applicable.</li><li>Application data ingestion and eventing: Abstract away any complexities involved in developing a blockchain application. Provide asynchronous means of transacting, record keeping for the incoming requests. It is good to have a synchronous write requests but that is not possible given that commit operation on blockchain is indeterminate. However, read requests can always be synchronized and an optional off-chain caching can be provided. Capture also all the events either emitted through the blockchain or smart contracts, streamline them to the applications.</li><li>An option to interact &amp; exchange data, make smart decisions spanning across multiple networks (could be of same blockchain protocol type or a different one). Blockchain interoperability plays a critical role given the current landscape.</li><li>Tools for blockchain network/block visualization, consortium management, smart contract deployment, blockchain domain role mapping with the platform identities would come in handy. A good product would allow an administrator to debug the running instance of their platform.</li><li>An easy to execute, end to end testing &amp; performance benchmarking capabilities within the platform will complete the loop.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GFCYCFYg8Y5cF1nKO4MI4A.png" /><figcaption>Blockchain as a Service Feature List Visual Representation</figcaption></figure><p>Add self-sustainability/self-management to all of these requirements defined so far, so that the human intervention is minimized. Well, you can be proud of building a software robot.</p><h3>Design Choices</h3><p>If you were to build a platform from scratch, it’s a no easy task. You will require skills from infrastructure provisioning all the way upto writing a sophisticated application abstraction layer. Consider breaking them into following broad areas to work on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/761/1*DRyA2RIlK4PVfTEi81hggQ.png" /><figcaption>Control Plane and Data Plane</figcaption></figure><h4>Control Plane</h4><p>The part of system that will manage the underlying blockchain protocol. It may involve a (rather complex) mechanism to do all the heavy lifting.</p><p><strong>Management:</strong> Consists of components that will procure &amp; provision required resources, deployment automation, assign appropriate roles and secure them, generate necessary configurations, keep the health of the (entirety) system up &amp; valid at any point, attach right monitoring tools, enable automated recovery procedures. These include deprecating and renewing necessary identities, accesses, optimizing the resource utilization when possible &amp; scaling them up when required.</p><p><strong>Administration:</strong> One would require different access levels for multiple kinds of resources. It is important to consider each persona in sight, especially it is crucial for an application developer to utilize blockchain offering at ease without having to learn underlying complexities. At the same time, an administrator should be able to play around with configurations. To give an example, a typical application developer would not worry about “<em>how</em>” does the distributed database perform synchronization and rather they would only consider how to store/retrieve the data. Whereas an administrator would not worry what data is added into the database, but rather consider the better configuration choices to guarantee SLAs.</p><blockquote>Remember to secure provisioned resources! Take appropriate measures to restrict access and allow for data encryption by the right entity (both at rest and in transit).</blockquote><p>A good platform would be modular, that is, you should be able to replace a particular component with another and the system should continue working as expected. Look for options to make control plane components highly reliable, these come by choices such as choosing the right inter-process messaging layers, make use of the storage spaces, designing each component for horizontal scalability, avoiding any bottleneck architecture, circuit breaking capability to withstand a particular component failure etc.</p><h4>Data Plane</h4><p>Define boundaries for user/service interaction with the platform. Remember that the control plane will manage all identities, however it is data plane components that will enable authentication &amp; authorization to the right entity. Add components that will make application developers, business operators, consortium and network administrators to interact with the blockchain network managed by the control plane. Provide conventional means for interfacing including, for instance one can support RESTful APIs, web sockets, queues and pub-sub topics for data ingestions/event reading.</p><blockquote>If you were to construct the platform as a House then control plane will be your cornerstone, blockchain protocol itself will be your structure on top of that. It is the data plane that makes it a Home! Sweet Home!</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tc_vD4jTbEdjfcvT05dQzw.png" /><figcaption>A well built cloud native Home!</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=55d5c0408b44" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WebAssembly (Wasm) Smart Contracts]]></title>
            <link>https://arsulegai.medium.com/webassembly-wasm-smart-contracts-b40e77080c7e?source=rss-b16a2100ab91------2</link>
            <guid isPermaLink="false">https://medium.com/p/b40e77080c7e</guid>
            <category><![CDATA[hyperledger]]></category>
            <category><![CDATA[hyperledger-sawtooth]]></category>
            <category><![CDATA[smart-contract-blockchain]]></category>
            <category><![CDATA[webassembly]]></category>
            <dc:creator><![CDATA[Arun S M]]></dc:creator>
            <pubDate>Sun, 17 Oct 2021 11:15:52 GMT</pubDate>
            <atom:updated>2021-10-17T11:15:52.366Z</atom:updated>
            <content:encoded><![CDATA[<h3>WebAssembly (Wasm) Smart-Contracts</h3><p>The blog will introduce you to the concept of WebAssembly, why &amp; how is it used in blockchain smart-contract development, specifically going into how is <a href="https://paritytech.github.io/wasmi/wasmi/index.html">wasmi</a> (a Wasm interpreter) used in Hyperledger Sawtooth.</p><h3>What is &amp; Why WebAssembly?</h3><p>WebAssembly (Wasm) is a binary instruction format for a stack based virtual machine, it is a standard defined by the <a href="https://webassembly.org/">W3C Working Group</a>. The motivation is to navigate through size and load overhead. Wasm provides a memory-safe, sandboxed environment whose security policies can be enforced as that of its host, allows to utilize hardware capabilities in a safe manner.</p><blockquote>In simple terms, a programming language <strong>Compiler</strong> translates instructions into an assembly language, then you would use <strong>Assembler</strong> to generate machine instructions. Imagine, what if we could generate a <strong>WebAssembly</strong> instead and there are <strong>Wasm Engines</strong> which understand these instructions.</blockquote><p>Wasm binaries are light weight, major web browsers support Wasm runtime environment, making it an ideal candidate for web applications. These binaries can easily be transmitted through network.</p><h3>Quick intro to Hyperledger Sawtooth</h3><p><a href="https://sawtooth.hyperledger.org/docs/">Hyperledger Sawtooth</a> is the second blockchain protocol project to incubate and graduate under Hyperledger. It follows a modular micro-service architecture where an administrator can add components on ad-hoc basis. The <strong>Validator</strong> is primary component with the required intelligence of scheduling/execution of smart-contracts, handling state databases, network communication and et al.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/391/1*5Rr36qBPuiQV-T8Rv99kGA.png" /><figcaption>Hyperledger Sawtooth Components</figcaption></figure><p><strong>Transaction Processor</strong> knows how to connect to a validator node and runs user-written transaction handlers (smart-contracts). <strong>Consensus Engine</strong> enables the Sawtooth network to follow a specific ruleset to create a block. Optionally, <strong>REST API</strong> can be attached to the validator node, making it easy for interacting with the network.</p><h3>Peek into Transaction Processor and the SDK</h3><blockquote>The modular architecture and protobuf messages allow application developers to use language of their choice to write smart-contract logic &amp; the client application in Hyperledger Sawtooth.</blockquote><p>Out of the box, Hyperledger Sawtooth has SDKs available in Rust, Python, Go, JavaScript, Java, C++. It can be easily extended to other languages. A <strong>Transaction Processor</strong> (TP) consists of a ZMQ connector, protobuf message handlers, expose interface for application developers to implement their smart-contract logic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/973/1*3MWPHY9suQbvuCwlxzIzow.png" /><figcaption>Transaction Processor SDK</figcaption></figure><p>A <strong>Transaction Handler</strong> is the application logic, one TP can have multiple such handlers in it. The validator node would send the message to a particular TP using its identity that it broadcasts as part of initial connection. The SDK message handler would translate the incoming messages and route them to appropriate handler. It is also possible to load balance requests across handlers if same handler is attached multiple times to a TP.</p><h3>What is Sabre TP &amp; How is Wasm supported in Hyperledger Sawtooth?</h3><p><a href="https://github.com/hyperledger/sawtooth-sabre"><strong>Sabre TP &amp; CLI</strong></a><strong> </strong>is a Transaction Processor &amp; CLI written using Rust SDK, that comes out of the box in Hyperledger Sawtooth. A smart-contract developer would compile their transaction handler into Wasm, upload it to the Hyperledger Sawtooth network via the CLI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rLHHwLzQE6N-ZhaM2sHSQA.png" /><figcaption>Hyperledger Sawtooth Sabre (Wasm Smart-Contract) Design</figcaption></figure><p>The Sabre TP provides Hyperledger Sawtooth administrators an option to maintain the Wasm smart-contract as <em>a </em><strong><em>stored procedure on-chain</em></strong>, thus avoiding an overhead to maintain older versions of the transaction handlers.</p><p>Hyperledger Sawtooth makes use of <a href="https://paritytech.github.io/wasmi/wasmi/index.html"><strong>wasmi</strong></a> (a Wasm interpreter) initially written for parity ethereum. The Sabre TP would pull in the smart-contract on need basis into wasmi’s <strong><em>Module</em></strong> abstraction. A new <strong>Module</strong> is spawned as needed when an execute transaction is issued. The <strong>Wasm Executor</strong> abstraction also has Sawtooth (external) to Wasm parameter/type conversion utility.</p><blockquote><strong>Note:</strong> Sabre TP is acting as a proxy layer for your smart-contract to reach the Hyperledger Sawtooth network/state database. Security</blockquote><p>As an application developer, you would ideally follow these steps:</p><ol><li>Create a contract registry for the smart-contract.</li><li>Upload the contract definition.</li><li>Create namespace registry for the smart-contract.</li><li>Grant necessary permissions to the namespace registries.</li></ol><blockquote>Sabre further provides SDKs for smart-contract developers that follows the similar semantics as that of a TP itself. Currently a AssemblyScript (JavaScript based) and Rust Sabre SDKs are available. One can simply extend the SDK to the language of their choice, then convert their existing TP into Wasm smart-contract.</blockquote><p>After deployment the network topology would look something as follows. Note that even if the application developer wants to run <em>’n’</em> number of smart-contracts in the network, they only need to run one Sabre TP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/701/1*4NL9M1CcPVHCbjWiB60M3w.png" /><figcaption>Hyperledger Sawtooth Network With Sabre TP</figcaption></figure><blockquote>I have a sample project (<a href="https://github.com/arsulegai/produce-consume">Product Consume</a>) implemented, with detailed instructions on how to write and execute the Sabre smart-contracts. This example stores an integer value against a string key, it allows you to increment or decrement the value. All of this happens on a Hyperledger Sawtooth blockchain network.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b40e77080c7e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hyperledger Fabric: Buildpacks & External Chaincode Server Builder]]></title>
            <link>https://arsulegai.medium.com/hyperledger-fabric-buildpacks-external-chaincode-server-builder-e5614855c6f?source=rss-b16a2100ab91------2</link>
            <guid isPermaLink="false">https://medium.com/p/e5614855c6f</guid>
            <category><![CDATA[chaincode]]></category>
            <category><![CDATA[chaincode-operation]]></category>
            <category><![CDATA[lifecycle-chaincode]]></category>
            <category><![CDATA[hyperledger]]></category>
            <category><![CDATA[hyperledger-fabric]]></category>
            <dc:creator><![CDATA[Arun S M]]></dc:creator>
            <pubDate>Mon, 23 Aug 2021 07:44:35 GMT</pubDate>
            <atom:updated>2021-08-24T07:09:53.605Z</atom:updated>
            <content:encoded><![CDATA[<p>Detect, Build, Release, Run and Repeat!</p><p>Reference an external chaincode server builder written in Go at <a href="https://github.com/arsulegai/fabric-cc-external-builder">https://github.com/arsulegai/fabric-cc-external-builder</a>. Feel free to raise a PR, extend the source code to include additional scenarios or use it in your development cycle.</p><h3>How does a Hyperledger Fabric `Peer` node build the chaincode?</h3><p>Have you wondered what happens in the background when you run peer chaincode install command? Well, look no further. Consider that the peer node is doing more than magic for you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/914/1*VIkzlnUHdxU4WK9X6rzjOQ.png" /><figcaption>Hyperledger Fabric Peer node chaincode build process</figcaption></figure><ul><li>The peer CLI packages the chaincode source, adds a metadata file to it.</li><li>The package is then sent over to the peer node by the peer CLI.</li><li>The peer node stores the submitted package, but before that it computes the SHA256of the submitted package.</li><li>The peer node stores the submitted chaincode package as is using name , version , SHA256 . This together constitutes a chaincode package ID.</li><li>The peer node runs the package through a list of buildpacks .</li><li>The first builder that detects the metadata successfully picks up the code and runs through the build process.</li><li>The build generates artefacts using appropriate language compilers.</li><li>The release process copies the generated artefacts along with related metadata files for execution. This is when the peer node generates a chaincode’s connection.json file.</li><li>Finally run will package the generated artefacts on top of a chaincode base image for execution.</li></ul><blockquote>Note: In case of failure to detect any of the custom builders. The chaincode package is sent to the in-built builders. These in-built builders are language specific and they try to package the chaincode as a container image and bring up the peer’s host.</blockquote><h3>What are buildpacks and why external chaincode builder?</h3><p>Consider buildpacks to be a collection of executable binaries. These binaries work together to achieve the task of build. The detect and build mechanism of buildpacks allows one to write code once, leave the build and deployment to the buildpacks agent.</p><p>In case of Hyperledger Fabric peer node, a detect process can read and identify which language is the chaincode written in. If an administrator supplies additional builders, those will be prioritized for detect phase over the in-built builders.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/294/1*YfCtRHrBnPmKWOYDzLUtzQ.png" /><figcaption>Buildpacks in Hyperledger Fabric Peer node</figcaption></figure><p>There can be multiple reasons to run chaincode as a server. In a Kubernetes based deployment, administrators would like to have chaincode spun up and in control of the controller manager. If a peer node brings up the chaincode then it is tied to the host where peer node runs. Kubernetes is deprecating docker daemon support from 1.20 version onwards.</p><p>All these leads to one adding buildpacks for external chaincode server build. Though the chaincode itself is not packaged, there is no code to build, one still have to package and place the metadata information in appropriate places.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/261/1*jpu3KC6V5_PCTBc-MX4c-g.png" /><figcaption>Chaincode Server</figcaption></figure><blockquote>Tip<strong>: </strong>If you are writing a new builder make sure to dump all the output to STDERR. Hyperledger Fabric peer node does not consider STDOUT logs. Refer to the example implementation to know how to control log levels.</blockquote><p>A chaincode builder becomes mandatory in case of chaincode run as a server. With all the information related to how to connect to a chaincode server. A peer node can establish connection to the chaincode server when either invoke or equivalent actions are called on the chaincode.</p><blockquote>Note: Chaincode’s connection.json is different from peer’s connection.json . Unlike chaincode run by the peer node, in the case of chaincode server these parameters can be passed in any form, this is controlled by the administrator and not by the peer node.</blockquote><blockquote>Hyperledger Fabric follows CNCF buildpacks principles. Read more about CNCF’s buildpacks at <a href="https://buildpacks.io/">https://buildpacks.io/</a>. The explanation in this article is overly simplified for the purpose of understanding.</blockquote><h3>How to support multiple buildpacks?</h3><p>The peer node does run through the list of detect processes that are listed in the core.yaml configuration file. The first detect process that returns an error status 0 would be considered an ideal match. Make sure to read enough metadata information before considering the builder a match.</p><p>Good practice is to match type information in metadata.json file. In addition to this, one can pass in extra data to be consumed in the custom builders. The extra metadata can optionally also include dependencies if any.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*m0d8tBE8pIkYiYcYAp40jQ.png" /><figcaption>Using the Buildpack to <strong>detect</strong>, <strong>build</strong> and <strong>release</strong> an External Chaincode servers’ artefacts</figcaption></figure><blockquote>R<em>ead in detail about chaincode installation in my other blog article </em><a href="https://arsulegai.medium.com/hyperledger-fabric-chaincode-install-upgrade-and-revert-af52015c4007"><em>https://arsulegai.medium.com/hyperledger-fabric-chaincode-install-upgrade-and-revert-af52015c4007</em></a><em>.</em></blockquote><h3>How to keep the Chaincode ID consistent across all the peer nodes in an organization?</h3><p>If your chaincode server package contents vary across multiple peers belonging to same organization. The SHA256 checksum of the chaincode package varies. Thus you cannot have the same package ID to approve on.</p><p>Key challenges for adoption of chaincode server and external builders</p><ol><li>Unique key-pair for TLS client authentication by the chaincode server i.e., a chaincode server shall be aware of which peer it is talking to.</li><li>If an organization has multiple peers and each peer would like to have its own chaincode server instance, participate in the channel.</li><li>If an organization has multiple peers and each peer wishes to use different timeout option.</li></ol><p>In each of these scenarios, the chaincode package contents vary. How to get a unique chaincode ID? Let’s look at the following diagram</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/871/1*XzTOeMLpV3b2hocd2ITJ2w.png" /><figcaption>Building the External Chaincode server the <strong>Right</strong> way!</figcaption></figure><p>In this case, all of the variadic parameters are passed as an environment variable. The actual connection.json file expected by the peer node is built as part of the buildpacks’ build process. The challenge however is still in passing these environment variables to the external builder. First you have to inject them to the peer process environment, from there you shall be passing them to the external builders via the peer’s environment variable passing the core.yaml file.</p><p>Hope this article was helpful, happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e5614855c6f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hyperledger Fabric: Chaincode Install, Upgrade and Revert]]></title>
            <link>https://arsulegai.medium.com/hyperledger-fabric-chaincode-install-upgrade-and-revert-af52015c4007?source=rss-b16a2100ab91------2</link>
            <guid isPermaLink="false">https://medium.com/p/af52015c4007</guid>
            <category><![CDATA[chaincode]]></category>
            <category><![CDATA[hyperledger-fabric]]></category>
            <category><![CDATA[hyperledger]]></category>
            <category><![CDATA[lifecycle-chaincode]]></category>
            <category><![CDATA[chaincode-operation]]></category>
            <dc:creator><![CDATA[Arun S M]]></dc:creator>
            <pubDate>Sun, 22 Aug 2021 08:55:42 GMT</pubDate>
            <atom:updated>2021-08-22T08:56:54.119Z</atom:updated>
            <content:encoded><![CDATA[<p>Operating the Hyperledger Fabric smart contracts the right way!</p><p>The document is for Hyperledger Fabric developers and administrators. You would need to know how to install, upgrade and revert your chaincode on a Hyperledger Fabric network. This article is an attempt to simplify the understanding, it is not a replacement for the wonderful documentation created by the Hyperledger community. Refer to the <a href="https://hyperledger-fabric.readthedocs.io/en/release-2.2/chaincode_lifecycle.html">official documentation</a> for the detailed insights.</p><blockquote><strong>Tip: </strong>Understanding the chaincode package in detail requires another article. In simple terms, a package is file archive that has everything related to your chaincode. Hyperledger Fabric peer wouldn’t require anything extra outside of this package.</blockquote><h3>Chaincode installation “Old” vs “New” lifecycle</h3><p>In the earlier versions of Hyperledger Fabric, you would install a chaincode package on all the peers in a channel, initialize the chaincode on the peer (Hyperledger Fabric peer brings up a chaincode container), then invoke the chaincode.</p><p>The process lacks a way of customizing chaincode per organization. If an organization has additional smart contract validations, they want to customize the chaincode for themselves, there needs to be a way for it. The new chaincode lifecycle allows for each organization to choose the package they want. Hyperledger Fabric has a lifecycle system chaincode to manage the requirement.</p><blockquote>A system chaincode is pre-installed in your Hyperledger Fabric peer node. It has specific functionality defined. It is used handle administration of your Hyperledger Fabric network using blockchain principles.</blockquote><h3>How to install “Chaincode” on Hyperledger Fabric using lifecycle?</h3><p>The points below can be considered a golden summary for installing the chaincode. Installing a chaincode involves following steps</p><ol><li>Install chaincode on each peer node at a specific version.</li><li>Approve chaincode package ID for an organization at a sequence.</li><li>Commit chaincode approved at a specific sequence.</li></ol><p><strong>Install: </strong>The peer node generates the chaincode package ID when a package is installed. The chaincode package is copied and stored on a peer node at the installation step. The peer node also does a match of chaincode builders when a chaincode package is installed. The release artefacts that a peer can later use to connect to the chaincode or the artefacts that a chaincode can use to connect to the peer node are generated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/511/1*O7uDRvUzemuDG5wDz3YWig.png" /><figcaption>Install Chaincode</figcaption></figure><p><strong>Approve: </strong>An organization participating in a channel will approve for a particular package ID. The approval shall happen against a specific sequence. Each organization could have their own package ID approved for the same sequence.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/506/1*Guum2kBCQsAyhw3-hJ_qYg.png" /><figcaption>Approve Chaincode</figcaption></figure><p><strong>Commit: </strong>Once the channel participants have approved for their sequence, one of them can proceed with committing to the sequence. What this allows is for every participant to have their own version of chaincode running alongside their peer nodes, but globally agreed upon in a channel setup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/981/1*DbgUvIXT6-oLTEdkffCPBA.png" /><figcaption>Commit Operation</figcaption></figure><h3>What is relationship between chaincode “Version”, “Package ID”, “Sequence”, “Name” and the “Channel”?</h3><p>When you are working with Hyperledger Fabric, there are so many terms related to chaincode. It could easily distract you if you do not understand their meaning accurately.</p><blockquote>Always remember that the chaincode installation happens on a peer node. The chaincode can then be used on all the channels to which that particular peer is part of. Every channel requires a chaincode commit operation. You can have a setup where on a channel 1 it has chaincode A at version 2, at the same time channel 2 has chaincode A at version 3. There exists complete independence for an administrator.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/1*VqOc1Ohd_jxgRqJamWUMUQ.png" /><figcaption>Channel and Chaincode Relationship</figcaption></figure><p><strong>Name:</strong> Unique name to identify the chaincode on a peer node.</p><p><strong>Channel: </strong>A chaincode definition can be approved and committed on multiple channels. The peer nodes participating in a channel would pick up the chaincode package by using the chaincode package ID.</p><p><strong>Version:</strong> It is important to note that the version number of a chaincode is local to the peer node where it is installed. Use this parameter as a SVN that a system administrator requires.</p><p><strong>Chaincode ID (Package ID): </strong>An organization has to approve for one package ID for a chaincode (identified by its “name”). If you have multiple peers belonging to an organization, then install same version of chaincode on all of them. They all “<strong>shall”</strong> generate the same package ID.</p><p><strong>Sequence: </strong>Once there are sufficient number of approvals as per the policy, a chaincode definition can be committed. Sequence number is a unique number across consortium members to commit to a change in the definition.</p><blockquote>A peer node when you install the chaincode package, stores it using name, version and the package ID.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*NE7vKA29faDy5_UWjpQc6Q.png" /><figcaption>Chaincode: Version, ID and the Sequence</figcaption></figure><blockquote><strong>Tip: </strong>It is tricky to generate the same package ID in case of using chaincode as a server. Especially if you are trying to attach different chaincode servers to each of the peer node.</blockquote><h3>How to “Upgrade” and “Revert” a chaincode in Hyperledger Fabric?</h3><p>Upgrading a chaincode involves one to run through series of same steps as they followed for initial installation of the chaincode. You would update the version number for easier identification of the package on a peer node.</p><blockquote>At given point in time for a given chaincode <strong>name</strong>, there can only be one version active.</blockquote><p>Every time, you require to upgrade the chaincode, the new sequence associated with the new package ID shall be committed by the channel participants (as per the policy).</p><p>There is no <strong>true</strong> “<strong>Revert</strong>” of chaincode, you would instead assign a newer version to your earlier chaincode, repeat all the steps you did for the chaincode upgrade.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/522/1*2AQiYLADfluBFd7t-7RsTQ.png" /><figcaption>Chaincode: Upgrade and Revert</figcaption></figure><blockquote><strong>Note:</strong> Remember that the blockchain technology provides a means of keeping immutable entry of records. Blockchain data is trustable as long as you have put in appropriate measures to not write unexpected data. “<strong>What you Write is What you Get</strong>” from the blockchain. If you had an erroneous smart contract installed on your network, and it has done an unexpected state change then the only way to recover back your old data is to run a correction method in your smart contract. You cannot erase that you did an error earlier, but at the same time you get to know that you took a recovery action.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=af52015c4007" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hyperledger Fabric: TLS Enabled External Chaincode]]></title>
            <link>https://arsulegai.medium.com/hyperledger-fabric-tls-enabled-external-chaincode-bcbab5618740?source=rss-b16a2100ab91------2</link>
            <guid isPermaLink="false">https://medium.com/p/bcbab5618740</guid>
            <category><![CDATA[hyperledger]]></category>
            <category><![CDATA[chaincode]]></category>
            <category><![CDATA[hyperledger-fabric]]></category>
            <category><![CDATA[hyperledger-fabric-ca]]></category>
            <category><![CDATA[lifecycle-chaincode]]></category>
            <dc:creator><![CDATA[Arun S M]]></dc:creator>
            <pubDate>Sun, 18 Apr 2021 11:09:03 GMT</pubDate>
            <atom:updated>2021-04-18T11:09:03.771Z</atom:updated>
            <content:encoded><![CDATA[<p>The document describes how to run the chaincode as a service and enable TLS connections for the messages exchanged. Enabling TLS will ensure that as long as chaincode server is accessible, any connection to it is secured. However, it is not sufficient to protect unwanted parties from reaching out the chaincode service. Towards the end of the document, I will walk you through how a chaincode service can authenticate if the right peer is sending the request. Thus completing a secure communication between an externally running chaincode instance and the peer node.</p><p>Externally run chaincode could enable deployment environments (such as orchestration engines e.g. Kubernetes) manage the node for you.</p><h3>Steps involved in running an external chaincode server:</h3><ol><li>Configure the peer service to handle external chaincode builders. i.e. Tell the peer node to not package and run the chaincode by itself.</li><li>Inform the peer node about external chaincode’s availability. i.e. Tell the peer node where can it find the external chaincode service. This is given through the connection.json file. The file itself is packaged into external builder package as expected.</li><li>Install the chaincode package that carries connection.json file. Installation step is to be done once per <strong>peer</strong> node where it is needed.</li><li>Instantiate or approve/commit the chaincode for a particular channel. Note that the <strong>peer</strong> node which belongs to the channel should have chaincode installed in it.</li><li>Run the chaincode server externally. Note that if you’re following “peer lifecycle” process for chaincode management then you would see a warning at the time of commit if chaincode server is not already started.</li></ol><blockquote>Couple of points to note:</blockquote><blockquote>1. Chaincode server can be started/stopped any number of times. If the peer node does not find a connection to the running instance of chaincode server it will establish one when either commit, invoke or query.</blockquote><blockquote>2. Multiple peers can connect to a single instance of a chaincoder server. This is because the peer node passes the context required in every request.</blockquote><p><strong>Note: </strong>At the time of writing this article, the PR is still in process. You may refer to the PR <a href="https://github.com/hyperledger/fabric-samples/pull/438">https://github.com/hyperledger/fabric-samples/pull/438</a> for end to end hands-on with <a href="https://github.com/hyperledger/fabric-samples/tree/main/asset-transfer-basic">asset-transfer-basic</a> example.</p><h3><strong>How is trust achieved in real world?</strong></h3><p>Let’s understand the fundamental concepts, it will help you in understanding what parameters to pass and visualize the connection between a peer node and a chaincode service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/1*XkhuVzdfqclYUU8BLpd4jA.png" /><figcaption>Person Verifying Documents</figcaption></figure><p>Above diagram depicts a flow of achieving trust in real world. A verifying person would request for a document that is signed by a signatory authority (such as Govt. entity, educational institute etc.). The trust is established by the fact that the verifying person knows who signatory authority is and forging the signature is highly difficult.</p><h3>How is trust achieved in digital world?</h3><blockquote>For the sake of this article, I would skip explaining digital signature, digital certificate, ciphersuite, client-server TLS handshake protocol. You may read on them from the available resources on the internet or feel free request in the comment section. I am happy to explain those concepts in later articles.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/551/1*s56XFvYTcTJl7v_76ZNQpw.png" /><figcaption>Client Verifying a Server</figcaption></figure><p>Above diagram shows that client has a list of signatories. While establishing the connection with the server, a client machine would request server to send the server’s certificate. This is first step of TLS handshake protocol. Server will respond back to the client’s request with a certificate that it owns. If the certificate served by the server is issued by any of the signatory that the client already trusts then the client will proceed. As follow up steps, the connection establishment happens using the ciphersuite that is agreed upon by both server and the client.</p><h3>How does peer trust the chaincode server?</h3><p>You would first configure your chaincode to run and serve a certificate. chaincode shim/library would make use of this certificate respond back to p<strong>eer</strong> node’s connection establishment request.</p><p>The<strong> Peer</strong> node should have been configured to trust the certificate issued by the chaincode server. This is made possible by adding root_cert parameter in the connection.json file. In this example, I will explain with a self signed certificate so the certificate and the root certificate will both remain same.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1011/1*FRSs08xnLyIl6zz4ZlDCEA.png" /><figcaption>Peer Establishing Trust With Chaincode Server</figcaption></figure><p>You may run the below command to generate a self signed certificate and a key pair. Note that the chaincode’s hostname parameter shall be specified in the certificate. It is part of TLS certificate verification, the verification will fail otherwise.</p><pre>openssl req -nodes -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -subj &quot;/C=IN/ST=KA/L=Bangalore/O=example Inc/OU=Developer/CN=chaincode.domain/emailAddress=dev@chaincode.domain&quot;</pre><p>Use these values in your chaincode’s TLS properties. Also, copy the root certificate (in this case cert.pem itself) and put it in the root_cert parameter of the connection.json file for the chaincode. Make sure you have enabled tls_required to true.</p><p>Enabling TLS ends here. If you are successful till this step, then all the communication between peer nodes and the chaincode server will be encrypted. Continue if you would like chaincode service to authenticate that the expected peer node is sending the request.</p><h3>What does client_auth_required mean and how does chaincode verify if it is expected peer node?</h3><p>So far, the chaincode server is only serving request at a given port. It is equivalent you writing your web service and serving the certificate for TLS connection. However, in this case you would like to protect your chaincode from unwanted requests. You would like to block requests from the peer nodes which are not expected to be sending requests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1011/1*j82yGFDb0r5mN1qCxVBhQQ.png" /><figcaption>TLS Enabled andChaincode Authenticating The Peer Node</figcaption></figure><p>From the diagram you might have seen that this time the client_auth_required parameter is set to true. This is an indicator for your peer node to expect other two files client_key and client_cert. In every connection request to the chaincode service, the peer node will use the certificate you have specified in the connection.json file.</p><p>Chaincode shall also be configured to trust the peer node’s certificate. This is achieved through the ClientCACerts parameter. Supply the certificate using which the peer’s certificate can be trusted. You could have self-signed certificate per connection.json or per chaincode. But in order to make it easier to manage and take full benefit of certificate authority structure you could use the certificate issued by a certifying authority.</p><blockquote><strong>Note: </strong>Consider using a certificate generated by Fabric CA of the organization to host chaincode as a service and also for the peer node to authenticate itself against the chaincode server.</blockquote><p>Hope this article was helpful, Happy Coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bcbab5618740" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>