<?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 Thusitha Dayaratne on Medium]]></title>
        <description><![CDATA[Stories by Thusitha Dayaratne on Medium]]></description>
        <link>https://medium.com/@thusithathilina?source=rss-f32eb2305e04------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*9gtR_v6ku6LuIg4c.jpeg</url>
            <title>Stories by Thusitha Dayaratne on Medium</title>
            <link>https://medium.com/@thusithathilina?source=rss-f32eb2305e04------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 00:25:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@thusithathilina/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[Building ExpenseReminder with AI pair programming: from failed debits to a working extension]]></title>
            <link>https://thusithathilina.medium.com/building-expensereminder-with-ai-pair-programming-from-failed-debits-to-a-working-extension-4a69dee5109f?source=rss-f32eb2305e04------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a69dee5109f</guid>
            <category><![CDATA[vibe-coding]]></category>
            <category><![CDATA[chrome-extension]]></category>
            <dc:creator><![CDATA[Thusitha Dayaratne]]></dc:creator>
            <pubDate>Thu, 18 Sep 2025 16:13:29 GMT</pubDate>
            <atom:updated>2025-09-18T16:19:23.119Z</atom:updated>
            <content:encoded><![CDATA[<p>When your direct debits rely on a “transaction” account you keep intentionally lean, timing matters. I’d often forget to top it up from my savings, and a debit would fail due to insufficient funds. I needed a simple system where I can enter the debit amount and date, then get a reminder the day before to transfer enough money. No spreadsheets. No calendar clutter. Just a timely notification.I built that as a Brave/Chromium extension without writing a single line of code myself by “vibe coding” with Cursor.</p><h3>The vision</h3><ul><li>Enter the debit amount and the debit date.</li><li>The extension schedules a reminder for the previous day at a chosen time.</li><li>A browser notification pops up the day before: “Top up your transaction account.”</li><li>Minimal UI: one form, one list of upcoming reminders.</li></ul><h3>Letting AI write it: the experience</h3><p>I explained the problem and outcome I wanted. The AI:</p><ul><li>Proposed an MV3 extension layout: manifest, popup UI, background service worker.</li><li>Implemented storage with chrome.storage, scheduling via chrome.alarms, and notifications with chrome.notifications.</li><li>Built a clean popup with a form and an “Upcoming reminders” list.</li><li>Wired create/delete flows so reminders persist and alarms restore on browser startup.</li></ul><p>I just reviewed, reloaded the extension, and tested. No manual coding.</p><h3>Tech</h3><ul><li>Manifest V3 service worker (background.js) to schedule alarms and fire notifications.</li><li>chrome.alarms for precise “when” scheduling using ISO dates.</li><li>chrome.notifications for user-visible reminders.</li><li>chrome.storage.local to persist reminders and restore alarms on install/startup.</li></ul><h3>Debugging</h3><ul><li>Brave/macOS notifications: My notifications were “created” but not displayed. This is because I have disabled Brave notifications at the OS level. Enabling notifications (System Settings → Notifications → Brave) fixed it immediately.</li><li>Resilience: We added diagnostics (permission checks, message flows, listing active notifications) to verify everything. Once notifications worked, we removed the debug UI to keep things clean.</li><li>Service worker reliability: Ensured asynchronous message responses returned true, and guarded optional listeners to avoid errors.</li></ul><h3>What the extension does now</h3><ul><li>Lets you add reminders with amount, debit date, and an optional time (default 09:00) for the previous day.</li><li>Shows a native notification the day before so you can move money into your transaction account.</li><li>Restores alarms when the browser starts, so reminders survive restarts.</li><li>Allows deleting reminders from the list and cancels the alarm.</li></ul><h3>How I “coded” with vibes only</h3><ul><li>I described intent and constraints in plain English.</li><li>The AI generated files, wiring, and edge-case handling.</li><li>We tested iteratively: added a test notification, verified permissions, handled Brave quirks, and streamlined UX.</li><li>I never typed the implementation just guided outcomes and accepted edits.</li></ul><h3>Install and try it</h3><p>You can get the extension from <a href="https://github.com/thusithathilina/expenser-reminder">https://github.com/thusithathilina/expenser-reminder</a></p><ul><li>Open brave://extensions</li><li>Enable Developer mode</li><li>Load unpacked and select the extension folder</li><li>Pin it and add your first reminder</li></ul><p>Tip: Make sure Brave is allowed to show notifications in macOS System Settings and that Focus/Do Not Disturb is off during your reminder window.</p><h3>What I’d add next</h3><ul><li>Snooze buttons (1 hour, later today, tomorrow)</li><li>Recurring debits (monthly, fortnightly)</li></ul><h3>Takeaway</h3><p>A small, personal pain debits failing because I forgot to top up was solved with an ultra-focused tool. But the main point is that I didn’t write the code. AI pair programming turned intent into a working, polished extension faster than I could have done manually. The most “code-like” work I did was testing and deciding when to keep or remove diagnostics.The result is simple, reliable, and exactly what I needed: a reminder at the right time so my direct debits never bounce for lack of funds.</p><p><strong>AI-assisted writing:</strong> Parts of this post were drafted with AI tools. I reviewed, edited, and take responsibility for the content.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a69dee5109f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI Agentic-DNS with Self-Sovereign Identity]]></title>
            <link>https://thusithathilina.medium.com/ai-agentic-dns-with-self-sovereign-identity-7e5c9f62084e?source=rss-f32eb2305e04------2</link>
            <guid isPermaLink="false">https://medium.com/p/7e5c9f62084e</guid>
            <category><![CDATA[decentralized-identity]]></category>
            <category><![CDATA[self-sovereign-identity]]></category>
            <category><![CDATA[verifiable-credentials]]></category>
            <category><![CDATA[ai-agent-discovery]]></category>
            <category><![CDATA[ai-agent]]></category>
            <dc:creator><![CDATA[Thusitha Dayaratne]]></dc:creator>
            <pubDate>Tue, 13 May 2025 15:03:54 GMT</pubDate>
            <atom:updated>2025-05-13T23:52:36.773Z</atom:updated>
            <content:encoded><![CDATA[<h3>AI Agentic-DNS with Self-Sovereign Identity for Agent Discovery</h3><p>The concept of autonomous AI agents is being actively explored across various industries, including healthcare, finance, marketing, and e-commerce, to automate tasks, improve decision-making, and enhance efficiency. Existing agent communication standards, such as the Model Context Protocol (MCP), which enables secure, standardised connections between data sources and AI-powered tools, and the Agent2Agent (A2A) protocol, which facilitates interoperable and secure interactions among AI agents, address secure and interoperable communication after agents have been identified.</p><p>However, neither MCP nor A2A directly address the essential initial step of discovering relevant, trusted AI agents within AI ecosystems. Given the increasing use and potential large-scale adoption of AI agents, it is essential to establish secure, reliable, and decentralised agent discovery mechanisms. There are existing solutions such as Google Agentspace, which attempt to address this issue in enterprise-specific contexts. However, centralised registries pose several risks, including single points of failure and privacy and trust concerns.</p><p>The realisation of Self-Sovereign Identity (SSI) through Decentralised Identifiers (DIDs) and Verifiable Credentials (VCs) can be leveraged to address these challenges. This work proposes integrating SSI with a DNS-like decentralised discovery mechanism to securely and efficiently enable agent-to-agent interactions.</p><p><strong>Challenges in Current Agent Discovery</strong><br>Current agent discovery systems depend on centralised directories or platform-specific registries, where they are vulnerable to</p><ol><li>Centralised Control: Single points of failure and control risks.</li><li>Security and Authenticity Issues: Impersonation attacks, lack of reliable authenticity verification.</li><li>Interoperability Concerns: Incompatibility between different ecosystems.</li></ol><p>These challenges force a decentralised, interoperable, secure mechanism for agent discovery.</p><h3>A Potential Solution: SSI-based DNS for Agent Discovery</h3><figure><img alt="Generated using Chat GPT" src="https://cdn-images-1.medium.com/max/1024/0*5RmKGQNgp4_MNsaV" /></figure><p>A decentralised, DNS-like discovery mechanism built on using DIDs and VCs can be used as a potential solution. High-level steps includes</p><ol><li>DID Generation and Credential Issuance:<br>Each AI agent (or the corresponding developer/company) generates a DID and corresponding DID Document including the service endpoints. Trusted issuers (developer companies can be a trusted issuer) then provide agents with VCs, which detail verified capabilities, ownership, and trustworthiness.</li><li>Decentralised DNS-like Registry:<br>Agents/developers register these DIDs/DID Documents, and relevant VCs onto a decentralised registry such as blockchain (e.g. Hyperledger Indy, Ethereum ENS).</li><li>Discovery and Verification:<br>Agents query the decentralised registry, similar to DNS, discovering other agents by capability, identity, or trust metrics. Queries can return cryptographically verifiable VCs and associated DIDs. This allow secure verification of agent identities and attributes.</li><li>Secure, Decentralised Communication:<br>After the discover phase, agents can utilise any secure communication protocols (these can be standardised ones such as A2A or custom ones specified on VCs) for interactions. Existing information such as cryptographic keys on DID Documents can be leveraged for authentication and authorisation purposes.</li></ol><p><strong>Advantages of this Approach</strong><br>1<strong>. <em>Enhanced Security and Trust</em></strong>. VCs and cryptographic proofs ensure authenticity. Thus, prevent AI agent impersonation attempts.<br>2. <strong><em>Reliability</em></strong>: Removes single points of failure, ensuring robust discovery processes.<br>3. <strong><em>Interoperability and Scalability</em></strong>: Open standards (DIDs, VCs) allow compatibility across diverse platforms and ecosystems.<br>4. <strong><em>Privacy</em></strong>: Selective disclosure processes can be used to disclose only necessary data of Agents</p><p>The integration of SSI principles with a decentralised DNS-like registry can be leveraged t improve the security, interoperability, and scalability of AI agent discovery.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7e5c9f62084e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Basic Implementation of W3C Verifiable Credential specification]]></title>
            <link>https://thusithathilina.medium.com/basic-implementation-of-w3c-verifiable-credential-specification-fdebc58d0603?source=rss-f32eb2305e04------2</link>
            <guid isPermaLink="false">https://medium.com/p/fdebc58d0603</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[self-sovereign-identity]]></category>
            <category><![CDATA[verifiable-credentials]]></category>
            <dc:creator><![CDATA[Thusitha Dayaratne]]></dc:creator>
            <pubDate>Tue, 30 May 2023 12:49:32 GMT</pubDate>
            <atom:updated>2023-05-30T12:50:22.489Z</atom:updated>
            <content:encoded><![CDATA[<p>I’ve recently implemented the basics of the <a href="https://www.w3.org/TR/vc-data-model/">W3C verifiable credential specification</a></p><p>A verifiable credential (VC) consists of 3 components</p><ol><li>Metadata</li><li>Claim(s)</li><li>Proof(s)</li></ol><p>In my implementation CredentialMetaData, CredentialSubject and Proof classes/interface represent the above component as follows</p><ul><li>Metadata - CredentialMetaData.java</li><li>Claims — Credential.java</li><li>Proofs — Proof.java</li></ul><p>To create a VC, first we need to create one or more CredentialSubject objects and add required claims to that as follows</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c756568291c5bd3a118d7ccb85d1d2f0/href">https://medium.com/media/c756568291c5bd3a118d7ccb85d1d2f0/href</a></iframe><p>Then use that object to construct a Credential object</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7b2e25e08702a960f19a7d4117280c4d/href">https://medium.com/media/7b2e25e08702a960f19a7d4117280c4d/href</a></iframe><p>Next we can generate the metadata that describes the issuer, issued date, VC id, VC type, expiry and other information as below</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5d902a4a19f9058378a53e85716806ce/href">https://medium.com/media/5d902a4a19f9058378a53e85716806ce/href</a></iframe><p>Once we have the Credential and metadata, we can generate a proof for them. The VC specification doesn’t mandate any particular proof mechanism. It listed a couple of proof mechanisms. I’ve implemented the Ed25519Signature2020 based proof.</p><p>To generate the proof, first we need to create/possess a Ed25519 key pair. Here I’ve used the Mnemonic class from Algorand SDK to generate a deterministic key.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/03c2854d29796f1962f92e98cf79fbb8/href">https://medium.com/media/03c2854d29796f1962f92e98cf79fbb8/href</a></iframe><p>We can use the generated key along with the credential and metadata to generate the Ed25519Signature2020 proof as follows</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/064ed960e2d254c8613c374e0e06eee4/href">https://medium.com/media/064ed960e2d254c8613c374e0e06eee4/href</a></iframe><p>We combined the constructed 3 components to form a VC as follows</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/00d9975762dc165c09345ef9e22f222e/href">https://medium.com/media/00d9975762dc165c09345ef9e22f222e/href</a></iframe><p>The JSON representation of the constructed VC can be observed using the VCUtil class</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6f8af31fa8665dc065c12991174748dd/href">https://medium.com/media/6f8af31fa8665dc065c12991174748dd/href</a></iframe><p>The following snippet shows a JSON representation of a sample VC</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/08542dca2ae2d69169dd9628d7f11e18/href">https://medium.com/media/08542dca2ae2d69169dd9628d7f11e18/href</a></iframe><p>The complete code can be found on <a href="https://github.com/thusithathilina/VerifiableCredentials/blob/master/src/main/java/org/ttd/vc/Main.java">https://github.com/thusithathilina/VerifiableCredentials/blob/master/src/main/java/org/ttd/vc/Main.java</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fdebc58d0603" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My own Decentralised Identifier (DID) implementation]]></title>
            <link>https://thusithathilina.medium.com/my-own-decentralised-identifier-did-implementation-b70d448cf27f?source=rss-f32eb2305e04------2</link>
            <guid isPermaLink="false">https://medium.com/p/b70d448cf27f</guid>
            <category><![CDATA[algorand]]></category>
            <category><![CDATA[did]]></category>
            <category><![CDATA[identity]]></category>
            <category><![CDATA[decentralized-identity]]></category>
            <category><![CDATA[decentralized-identifier]]></category>
            <dc:creator><![CDATA[Thusitha Dayaratne]]></dc:creator>
            <pubDate>Tue, 11 Oct 2022 12:43:15 GMT</pubDate>
            <atom:updated>2022-10-11T12:52:18.013Z</atom:updated>
            <content:encoded><![CDATA[<p>W3C has approved the decentralised identifiers (DID) <a href="https://www.w3.org/TR/did-core/">specification</a> on late June this year. DID is considered as one of the pillars in enabling the concept of self-sovereign identity, which is expect to be the identity model in Web 3.0.</p><p>There are 149 DID methods listed on the <a href="https://w3c.github.io/did-spec-registries/#did-methods">did spec registry</a> as of 11th October 2022. Hyperledger Indy is the most popular among the existing implementations so far. However, most of the the existing implementations that I tried out were not able to cater the set of requirement that I had (maybe I didn’t get them fully). Therefore, I have decided that it would be worth spending some time to come up with my own implementation. As a result, I have started implementing <a href="https://github.com/thusithathilina/MyDID">MyDID</a></p><h3>MyDID</h3><p>According to the DID specification a DID should follow the following convention</p><blockquote>&lt;scheme&gt;:&lt;method&gt;:&lt;method specific identifier&gt;</blockquote><p>where scheme is <strong>did</strong>. Method name and the method specific identifier are decided by the implementers.</p><p>My <strong><em>MyDID</em></strong> implementation uses the following format when generating DIDs, where method name is <strong>ttd</strong></p><pre>&quot;did:ttd:&quot;(namespace&quot;:&quot;)identifier<br>namespace: idchar*<br>identifier: base58char+<br>idchar: ALPHA / DIGIT <br>base58char: 123456789ABCDEFGH JKLMN PQRSTUVWXYZabcdefghijk mnopqrstuvwxyz</pre><h4>MyDID Identifier Generation</h4><p>I used the same approach that Indy uses when generating DIDs, which is <em>base58 encoding of the first 16 bytes of the SHA256 of the Verification Method public key<br>e.g. did &lt;- Base58(Truncate_msb(16(SHA256(publicKey))))</em></p><h3>How to use MyDID</h3><p>MyDID implementation is far away from the 100% spec complete status. However, it can be use to generate DIDs and corresponding DID documents. Also, DID documents can be stored on Algorand blockchain and query existing documents that are on the chain.</p><p>Sample usage of the MyDID can be found on the <a href="https://github.com/thusithathilina/MyDID/blob/master/src/main/java/org/ttd/Main.java">Main.java</a> file that is available in the repository.</p><p>First you need to generate a key pair. General EC curves and edward curves are supported at the moment. I’ve tested the code with following KeyPairGeneration methods</p><pre>KeyPairGenerator generator = KeyPairGenerator.getInstance(&quot;EC&quot;);<br>KeyPairGenerator generator = KeyPairGenerator.getInstance(&quot;EC&quot;, &quot;BC&quot;);<br>KeyPairGenerator generator = KeyPairGenerator.getInstance(&quot;Ed25519&quot;);</pre><p>For the example I’m using the bouncy castle as the provider. Therefore, you need to add the <em>BouncyCastleProvider </em>as a security provider.</p><pre>Security.<em>addProvider</em>(new BouncyCastleProvider());</pre><p>Once the provider is added, we can use the provider to generate a elliptic curve based KeyPair</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/47bf96a73e1d55c77bcd974129729ab4/href">https://medium.com/media/47bf96a73e1d55c77bcd974129729ab4/href</a></iframe><p>Here I have used a fixed secure random based on a Mneomic code to ensure the deterministic nature of the generated key pair.</p><p>The generated key pair is then used to generate a DID as follow</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d5f4d3b37c87fb5c1e47f521e4f0514a/href">https://medium.com/media/d5f4d3b37c87fb5c1e47f521e4f0514a/href</a></iframe><p><em>createDid </em>method generates a DID and returns the DIDDocument corresponding to the generated DID. By default the controller is assumed to be the same as the id and the key pair that is used to generate the DID is set as the default verification method. <br>Generated DID and the DIDDocument looks as follows</p><p>DID<br><em>did:ttd:zJZQR1SNtHwmLfQN477yabW</em></p><p>DIDDocument</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/541a6c06f3a42d11729d1b5692276528/href">https://medium.com/media/541a6c06f3a42d11729d1b5692276528/href</a></iframe><p>Similarly, another DID can be generated to represent the receiver.</p><p>Then these generated DID documents need to be stored somewhere. Distributed file systems such as IPFS is the default choice for this. However, in this example, I’m going to store them directly on a blockchain. More specifically, I’m using Algorand (a public blockchain) to store the document. So, anyone can get the document if they knows the DID.</p><p>For local testing purposes, I have used Algorand sandbox, which is available on <a href="https://github.com/algorand/sandbox">https://github.com/algorand/sandbox</a>. You can clone the Algorand sandbox repo and start the sandbox using the command<br>./sandbox up <br>This will start the Algorand private node on the local machine. Sandbox also provide option to connect to different nodes including the public chain. You can refer to Algorand documentation on that.</p><p>Then we need to create a client to connect to the Algorand node. I have defined a sort of a wrapper class named <em>AlgorandUtil.java </em>to group all Algorand related functionalities. This class can be used to generate a client as follows (or you can refer to Agorand java-sdk sample).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/520afaa0df10b8f57cdacd0791658ebf/href">https://medium.com/media/520afaa0df10b8f57cdacd0791658ebf/href</a></iframe><p>We need an Algorand user to initiate the transaction of storing DID document on the chain. By default, the sandbox comes with 3 accounts. <br>I’m using the first account in this example. In order to use that account, we need to access its private key. We can get the private key of that default user using the Algorand KMD. Then that private key is used to construct a Account object as follows</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d363894a17dcab32dc5933629015be0e/href">https://medium.com/media/d363894a17dcab32dc5933629015be0e/href</a></iframe><p>Once we have an Algorand account we can store the document using <em>storeDID</em> method in <em>AlgorandUtil</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7b63b1b3502cd827fd91783bfbdfd77c/href">https://medium.com/media/7b63b1b3502cd827fd91783bfbdfd77c/href</a></iframe><p>We can access existing DID documents that are stored on the chain using the <em>getDIDDocument</em> method. It will return DID document of a given DID as a JSON object. We can use either a DID object or a string representation of (full qualified) DID to query documents. <br><strong>Note that, updates on a document will result multiple documents on the chain for the same DID. Thus we need to get the latest one from the chain. </strong><br>We can then parse the JSON object to a DIDDocument using the jsonToDIDDocument method</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b5556d8ade6e2d01f7c4433eeb222402/href">https://medium.com/media/b5556d8ade6e2d01f7c4433eeb222402/href</a></iframe><p>Given that both sender’s and receiver’s DID documents are on the chain, they can use the their private key and other party’s public key (which is on the DID document) to start the key exchange process. Here, I’’m using elliptic curve Diffie–Hellman (ECDH) and generate a AES key</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a61d89e50ef7bc192fa45fdeffec1030/href">https://medium.com/media/a61d89e50ef7bc192fa45fdeffec1030/href</a></iframe><p>Sender can sign any message using their private key and the receiver can verify the message authenticity using the sender’s public key that is on the DID document</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cc300a1f2ab149de6d2d270775d7890d/href">https://medium.com/media/cc300a1f2ab149de6d2d270775d7890d/href</a></iframe><p>We can use the mutually generated AES key for encryption and decryption</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b6c23c244b3843e70ffd68026808f545/href">https://medium.com/media/b6c23c244b3843e70ffd68026808f545/href</a></iframe><p>The complete example is on <a href="https://github.com/thusithathilina/MyDID/blob/master/src/main/java/org/ttd/Main.java">https://github.com/thusithathilina/MyDID/blob/master/src/main/java/org/ttd/Main.java</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b70d448cf27f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to register a custom serializer for chaincode in Hyperledger Fabric]]></title>
            <link>https://thusithathilina.medium.com/how-to-register-a-custom-serializer-for-chaincode-in-hyperledger-fabric-9e865f6d68d0?source=rss-f32eb2305e04------2</link>
            <guid isPermaLink="false">https://medium.com/p/9e865f6d68d0</guid>
            <category><![CDATA[hyperledger-fabric]]></category>
            <category><![CDATA[hyperledger]]></category>
            <category><![CDATA[chaincode]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Thusitha Dayaratne]]></dc:creator>
            <pubDate>Tue, 16 Nov 2021 03:55:06 GMT</pubDate>
            <atom:updated>2021-11-16T05:06:04.683Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently, I come across an issue where Fabric chaincode throws a <em>NullPointerException </em>as follows when try to return an <em>ArrayList&lt;String&gt;</em></p><pre>org.hyperledger.fabric.Logger error nulljava.lang.NullPointerException<br>at org.hyperledger.fabric.contract.execution.JSONTransactionSerializer.toBuffer(JSONTransactionSerializer.java:84)<br>at org.hyperledger.fabric.contract.execution.impl.ContractExecutionService.convertReturn(ContractExecutionService.java:89)<br>at org.hyperledger.fabric.contract.execution.impl.ContractExecutionService.executeRequest(ContractExecutionService.java:67)<br>at org.hyperledger.fabric.contract.ContractRouter.processRequest(ContractRouter.java:119)<br>at org.hyperledger.fabric.contract.ContractRouter.invoke(ContractRouter.java:130)<br>at org.hyperledger.fabric.shim.impl.ChaincodeInvocationTask.call(ChaincodeInvocationTask.java:100)<br>at org.hyperledger.fabric.shim.impl.InvocationTaskManager.lambda$newTask$17(InvocationTaskManager.java:265)<br>at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1736)<br>at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)<br>at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)<br>at java.base/java.lang.Thread.run(Thread.java:834)</pre><p>As I understand this happens due to the default <em>JSONTransactionSerializer </em>cannot handle my return type. Thus, I had to find a way to implement my own Serializer to cater my requirement.</p><p>After some googling, it seems there is a SerializerInterface (<strong>org.hyperledger.fabric.contract.execution.SerializerInterface</strong>) that need to be implemented according to the according to <a href="https://jira.hyperledger.org/browse/FAB-15634">[FAB-15634] Implement Interface/annotation for the serializer — Hyperledger JIRA</a>. However, I couldn’t find any documentation on how to register the custom serializer so that chaincode can use the custom serializer instead of the default one. Checking on the Serializer PR <a href="https://github.com/hyperledger/fabric-chaincode-java/pull/41">[FAB-15634] Annotations for Serializer by mbwhite · Pull Request #41 · hyperledger/fabric-chaincode-java · GitHub</a> I realised how to register the custom implementation.</p><p>What you have to do is use the <strong>transactionSerializer </strong>attribute with the Contract annotation</p><p>Sample code</p><p>Implement the SerializerInterface and create the Serializer</p><pre>import org.hyperledger.fabric.contract.annotation.Serializer;<br>import org.hyperledger.fabric.contract.execution.SerializerInterface;<br>import org.hyperledger.fabric.contract.metadata.TypeSchema;<br><br>@Serializer()<br>public class CustomSerializer implements SerializerInterface {<br>    @Override<br>    public byte[] toBuffer(Object value, TypeSchema ts) {<br>        ...<br>    }<br><br>    @Override<br>    public Object fromBuffer(byte[] buffer, TypeSchema ts) {<br>        ...<br>    }<br>}</pre><p>Register the Serializer with the contract</p><pre>@Contract(<br>        name = &quot;HelloHyper&quot;,<br>        transactionSerializer = &quot;org.contract.CustomSerializer&quot;<br>)<br>@Default<br>public class InverterContract implements ContractInterface {</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9e865f6d68d0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reused key vulnerability in One-time pad for CTF]]></title>
            <link>https://thusithathilina.medium.com/reused-key-vulnerability-in-one-time-pad-for-ctf-9e1fc04015c?source=rss-f32eb2305e04------2</link>
            <guid isPermaLink="false">https://medium.com/p/9e1fc04015c</guid>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[vulnerability]]></category>
            <category><![CDATA[one-time-pad]]></category>
            <dc:creator><![CDATA[Thusitha Dayaratne]]></dc:creator>
            <pubDate>Sun, 29 Mar 2020 07:30:35 GMT</pubDate>
            <atom:updated>2020-03-29T08:33:53.497Z</atom:updated>
            <content:encoded><![CDATA[<p>Yesterday, I participated in a beginners CTF competition organized by the <a href="https://monsec.io/">MonSec</a>. One challenge was to find the flag given two ciphertexts which are said to be encrypted using OTP. However, texts are said to be encrypted using the same key. I couldn’t solve it during the given time. So decided to spend Sunday on this.</p><p>I had to read on how OTP get vulnerable if the key is reused. Found an excellent description of that under 1st answer in <a href="https://crypto.stackexchange.com/questions/59/taking-advantage-of-one-time-pad-key-reuse">https://crypto.stackexchange.com/questions/59/taking-advantage-of-one-time-pad-key-reuse</a> It really explains things very clearly. (I used the same images used by the original author.)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/1*tJIwnuj8k6MVB6X7FmVDiQ.png" /></figure><p>Then, I had to figure out how to use that idea to solve the issue. 3rd answer in the same link was so handy in that. So I started with a simple python script. The initial guess was that the key should contain either ‘MONSEC‘ or ‘FLAG‘</p><pre>c1 = <strong>&quot;</strong>02036109340314070d131510141c06077a0b646d7f671a0b0d151403120463050b761b3241282f41312d20282f35243935412e2f412c38412524322a352e2d<strong>&quot;<br></strong>c2 = <strong>&quot;</strong>0b0d0a025b0775001b08166211017f1e711c1d0409711c1d7f1875011777641d64630a24323241233435412420323841352e4133242c242c2324334040405c<strong>&quot;<br><br></strong>known_word = &quot;FLAG{&quot;.encode(<strong>&quot;utf-8&quot;</strong>).hex()<br><br>test = hex(int(known_word, 16) ^ int(c1[0:len(known_word)], 16))<br>print(bytes.fromhex(test[2:]).decode(<strong>&quot;utf-8&quot;</strong>))<br>test = hex(int(known_word, 16) ^ int(c2[0:len(known_word)], 16))<br>print(bytes.fromhex(test[2:]).decode(<strong>&quot;utf-8&quot;</strong>))</pre><p>Decoded plain texts seem to make sense. But it was very hard for me to guess the remaining parts. So did another digging and find a gem “<a href="https://github.com/SpiderLabs/cribdrag"><strong>cribdrag</strong></a>”.<strong> </strong>A<strong> </strong>cool tool that can be used to tackle this sort of problems. So many guesses for several hours and finally able to obtain the key. However, compared steps that are mentioned in some blog posts, what I did was partially cribdrag one of the ciphertexts (instead of c1 ⊕ c2) and use the partially obtained flag on other ciphertexts. I had to do this interchangeably for several iterations.</p><p>I believe the attacker needs to know at least some part of the flag or ciphertexts to solve this. Otherwise, I’m not quite sure how can tackle this. Maybe there is a more efficient way of doing this rather than just some guess. Anyway I really enjoyed doing this though it cost me about 8 hours 😁</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9e1fc04015c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Face Detection — OpenCV 3.4.0 with Python 3.x]]></title>
            <link>https://thusithathilina.medium.com/face-detection-opencv-3-4-0-with-python-3-x-a1a1e6987fdd?source=rss-f32eb2305e04------2</link>
            <guid isPermaLink="false">https://medium.com/p/a1a1e6987fdd</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[facedetection]]></category>
            <category><![CDATA[opencv]]></category>
            <dc:creator><![CDATA[Thusitha Dayaratne]]></dc:creator>
            <pubDate>Sun, 18 Feb 2018 11:11:38 GMT</pubDate>
            <atom:updated>2018-05-18T02:16:30.631Z</atom:updated>
            <content:encoded><![CDATA[<p>I started to watch Person of Interest again so the surveillance and face detection again :P But this time with python instead of Java.</p><p><strong>Setup</strong></p><ol><li>Download and install latest python 3.x version from <a href="https://www.python.org/downloads/">https://www.python.org/downloads/</a></li><li>Download install OpenCV 3.4.0 from <a href="https://opencv.org/releases.html">https://opencv.org/releases.html</a></li><li>Then install opencv-python module. You can use the below command<br> <strong><em>pip install opencv-python</em></strong></li></ol><p>If you are ready with the setup, code is not hard.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d5b647ebd6f0655a9f88cb55a2c2fa20/href">https://medium.com/media/d5b647ebd6f0655a9f88cb55a2c2fa20/href</a></iframe><p>When you run the code you will see that it can identify the face and eyes. Since OpenCV doesn’t have a much UI support you can’t close the window by clicking ‘X’. Use ESC to exit.</p><p>One of the common error you might face is <br><strong><em>OpenCV Error: Assertion failed (!empty()) in cv::CascadeClassifier::detectMultiScale..<br></em></strong>If you face that check the file path to your harcascade file.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a1a1e6987fdd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[msf4j-maven-plugin]]></title>
            <link>https://thusithathilina.medium.com/msf4j-maven-plugin-cf87bb729574?source=rss-f32eb2305e04------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf87bb729574</guid>
            <category><![CDATA[wso2]]></category>
            <category><![CDATA[maven]]></category>
            <category><![CDATA[msf4j]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[microservices]]></category>
            <dc:creator><![CDATA[Thusitha Dayaratne]]></dc:creator>
            <pubDate>Sat, 16 Sep 2017 02:42:28 GMT</pubDate>
            <atom:updated>2017-09-16T02:42:28.109Z</atom:updated>
            <content:encoded><![CDATA[<p>I’ve created an simple maven plugin which can be used to run a MSF4J service with a single command.</p><p>You can use the MSF4J archtype to generate a sample MSF4J service. Add the following plugin to build section of your project</p><pre>&lt;plugin&gt;<br>        &lt;groupId&gt;org.wso2.msf4j&lt;/groupId&gt;<br>        &lt;artifactId&gt;msf4j-maven-plugin&lt;/artifactId&gt;<br>        &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;<br>&lt;/plugin&gt;</pre><p>Then once you develop the services. You can execute following command. It will build your service and run the service.</p><pre>mvn msf4j:run</pre><h3>Note</h3><p>Please note that since this is not available in maven central first you need to get this and locally build the plugin. To do that just clone or download the repo and do a <strong><em>mvn clean install</em></strong></p><p><strong>Github link</strong> <a href="https://github.com/thusithathilina/msf4j-maven-plugin">https://github.com/thusithathilina/msf4j-maven-plugin</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf87bb729574" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hello Ballerina]]></title>
            <link>https://thusithathilina.medium.com/hello-ballerina-fb624b8aee8c?source=rss-f32eb2305e04------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb624b8aee8c</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[ballerina]]></category>
            <category><![CDATA[wso2]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[hello-world]]></category>
            <dc:creator><![CDATA[Thusitha Dayaratne]]></dc:creator>
            <pubDate>Tue, 21 Feb 2017 07:25:13 GMT</pubDate>
            <atom:updated>2017-02-21T07:29:49.283Z</atom:updated>
            <content:encoded><![CDATA[<p>Ballerina an interpreted, general purpose, concurrent, and strongly typed programming language with both textual and graphical syntaxes. It is designed to make it easier to write programs that integrate with data sources, services, and network-connected APIs of all kinds. It is optimized primarily for such programs — while it can be use to program anything, it is not recommended to use Ballerina if a significant portion of the program is not related to integrating with data sources, services, or network-connected APIs.</p><p>Ballerina has been inspired by Java, Go, and other languages, but it has a concurrency model built around a sequence diagram metaphor. — source <a href="https://github.com/ballerinalang/ballerina">https://github.com/ballerinalang/ballerina</a></p><p>You can download the Ballerina distribution, try samples, and read the documentation at <a href="http://ballerinalang.org/">http://ballerinalang.org</a></p><h4>Hello World With Ballerina</h4><p>In Ballerina you can write a program which will print a Hello World in the console and exit also you can write a Ballerina service which will keep running and print same thing when some one send a request.</p><h4>Hello World</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d5dc0990f6de3eb1b2600a7d4345c2a3/href">https://medium.com/media/d5dc0990f6de3eb1b2600a7d4345c2a3/href</a></iframe><ol><li>Copy the above content to a file and name it as helloworld.bal</li><li>Go to ballerina distribution bin directory</li><li>Run the<strong> ./ballerina run main &lt;path to helloword.bal&gt;</strong></li><li>This will print Hello, World! in the screen and exit.</li><li>You can also package this as an archive</li><li>Change the file as follows</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0c6b9ab758f770d8307164753dc2460f/href">https://medium.com/media/0c6b9ab758f770d8307164753dc2460f/href</a></iframe><p>7. Create directory stricture as follows and copy the file to hello directory</p><p>8. Go to the parent directory of org from the console</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/352/1*Li8bsjgEEcQvAlMbI2ItAw.png" /></figure><p>9. Execute <strong>./ballerina build main org/wso2/ballerina/hello</strong></p><p>10. This will create a hello.bmz in the current directory. You can use -o flag to set the output file name</p><p>11. Now you can run this archive using <strong>./ballerina run main &lt;path to bmz&gt;</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb624b8aee8c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Encrypt password-persist file in WSO2]]></title>
            <link>https://thusithathilina.medium.com/encrypted-password-persist-file-in-wso2-c9d6ea6428fd?source=rss-f32eb2305e04------2</link>
            <guid isPermaLink="false">https://medium.com/p/c9d6ea6428fd</guid>
            <category><![CDATA[wso2]]></category>
            <dc:creator><![CDATA[Thusitha Dayaratne]]></dc:creator>
            <pubDate>Tue, 06 Dec 2016 08:36:32 GMT</pubDate>
            <atom:updated>2016-12-06T08:55:02.609Z</atom:updated>
            <content:encoded><![CDATA[<p>When you enable cipher-tool in WSO2 products you need to provide the keystore password when starting the server. For that you have 3 options</p><ol><li>Input the password each time through the console</li><li>Create a password-tmp file in the &lt;WSO2_Home&gt; with the password. This file will get deleted each time. So you have to create the file each time server starts</li><li>Create a password-persist file in the &lt;WSO2_Home&gt; with the password.</li></ol><p>In 2nd and 3rd options, we have to provide the plain text password in the file. Therefore some may want to encrypt that password as well.</p><p>password-tmp/persist files are read by the DefaultSecretCallbackHandler. By default it expects the file contains the plain text password. But you can customize this easily.</p><p>What you need to do is create a custom callback handler use that to resolve the password. You can refer to the <a href="https://github.com/thusithathilina/wso2-custom-callback-ciphertool">sample handler.</a></p><ol><li>Open the sample project.</li><li>Go to the <a href="https://github.com/thusithathilina/wso2-custom-callback-ciphertool/blob/master/src/main/java/org/wso2/custom/callback/CustomSecretCallback.java"><strong>org.wso2.custom.callback.CustomSecretCallback</strong></a> class</li><li>Put your custom logic inside the <strong>org.wso2.custom.callback.CustomSecretCallback#handleSingleSecretCallback</strong> method. (You can either read the password-persist file and decrypt the password based on your request or you can implement any other way to resolve the password)</li><li>Set the password to callback <br>e.g.<br><strong>org.wso2.securevault.secret.SingleSecretCallback#setSecret</strong><br>(In the custom project I’ve hard coded the password)</li><li>Build up the project</li><li>Copy the jar to <strong>&lt;Product-Home&gt;/repository/components/lib</strong> directory</li><li>Open the <strong>&lt;Product-Home&gt;/repository/conf/security/secret-conf.properties</strong></li><li>Change the following values and put your full qualified class name<br><strong>keystore.identity.store.secretProvider</strong>=org.wso2.carbon.securevault.DefaultSecretCallbackHandler <br><strong>keystore.identity.key.secretProvider</strong>=org.wso2.carbon.securevault.DefaultSecretCallbackHandler<br>e.g.<br>keystore.identity.store.secretProvider=org.wso2.custom.callback.CustomSecretCallback<br>keystore.identity.key.secretProvider=org.wso2.custom.callback.CustomSecretCallback</li><li>Start the server. Then it will use the custom callback handler to resolve the password</li></ol><p><strong>Note</strong><br>Please note that you need to change the <strong>secret-conf.properties</strong> file after you run the cipher-tool. If you change the file first and then run the cipher-tool it will reset the values in secret-conf.properties to default.<br>You can refer [1] for more details.<br>[1] — <a href="https://docs.wso2.com/display/ADMIN44x/Carbon+Secure+Vault+Implementation">https://docs.wso2.com/display/ADMIN44x/Carbon+Secure+Vault+Implementation</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c9d6ea6428fd" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>