<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Muhammad Auzair</title>
    <description>The latest articles on Forem by Muhammad Auzair (@muhammad_auzair).</description>
    <link>https://forem.com/muhammad_auzair</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1093087%2Fae585a50-a42f-4535-a883-af480499a5b9.jpeg</url>
      <title>Forem: Muhammad Auzair</title>
      <link>https://forem.com/muhammad_auzair</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/muhammad_auzair"/>
    <language>en</language>
    <item>
      <title>Embarking on a Backend Development Journey with Node.js, Express, and MongoDB!</title>
      <dc:creator>Muhammad Auzair</dc:creator>
      <pubDate>Sun, 10 Sep 2023 14:49:45 +0000</pubDate>
      <link>https://forem.com/muhammad_auzair/embarking-on-a-backend-development-journey-with-nodejs-express-and-mongodb-47m</link>
      <guid>https://forem.com/muhammad_auzair/embarking-on-a-backend-development-journey-with-nodejs-express-and-mongodb-47m</guid>
      <description>&lt;h2&gt;
  
  
  Hey fellow devs,
&lt;/h2&gt;

&lt;p&gt;I hope this post finds you all in great coding spirits! I wanted to share my exciting journey into the world of backend development using Node.js, Express, and MongoDB. 🌐💻&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Background:&lt;/strong&gt;&lt;br&gt;
I've been tinkering with frontend technologies for a while, but I've decided to dive deeper into the backend to expand my skill set and create more dynamic and interactive web applications. So, I've set my sights on Node.js for server-side JavaScript, Express for building web APIs, and MongoDB for database management. 📦&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Learning Progress So Far:&lt;/strong&gt;&lt;br&gt;
I've completed a few online courses and tutorials, and I feel comfortable with the basics of Node.js, Express, and MongoDB. I've learned about routing, middleware, database interactions, and I've even built a few simple REST APIs. 📚&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Call for Help:&lt;/strong&gt;&lt;br&gt;
Now, I'm looking to take my skills to the next level! I believe that one of the most effective ways to learn is by doing, so I'm on the hunt for some practice tasks or small pet projects to work on. That's where you, the wonderful developer community, come in!&lt;/p&gt;

&lt;p&gt;I would greatly appreciate any suggestions, tips, or guidance you can provide. Whether it's pointing me towards useful resources, recommending practice exercises, or proposing interesting project ideas, your input would be invaluable. 🙏&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What I'm Interested In:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Authentication and authorization using JWT or OAuth&lt;/li&gt;
&lt;li&gt;Building a RESTful API for a specific domain (e.g., a task manager or a to-do list)&lt;/li&gt;
&lt;li&gt;Real-time features using WebSockets or a similar technology&lt;/li&gt;
&lt;li&gt;Working with third-party APIs&lt;/li&gt;
&lt;li&gt;Anything that helps me dive deeper into Node.js, Express, and MongoDB!&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Please share your knowledge and experiences with me. Feel free to drop your ideas, tips, or even your own learning experiences in the comments below. Let's learn and grow together as a community of developers! 🌱&lt;/p&gt;

&lt;p&gt;Thank you for taking the time to read my post, and I look forward to hearing from you all. Happy coding! 🚀👩‍💻👨‍💻&lt;/p&gt;

</description>
      <category>node</category>
      <category>express</category>
      <category>backenddevelopment</category>
      <category>mongodb</category>
    </item>
    <item>
      <title>Signature Verification in solidity</title>
      <dc:creator>Muhammad Auzair</dc:creator>
      <pubDate>Fri, 07 Jul 2023 17:54:35 +0000</pubDate>
      <link>https://forem.com/muhammad_auzair/signature-verification-in-solidity-11h6</link>
      <guid>https://forem.com/muhammad_auzair/signature-verification-in-solidity-11h6</guid>
      <description>&lt;h2&gt;
  
  
  Introduction:
&lt;/h2&gt;

&lt;p&gt;Signature verification plays a crucial role in ensuring the integrity and authenticity of data in various applications, especially in the blockchain domain. In this article, we will explore how to perform signature verification using the ECDSA (Elliptic Curve Digital Signature Algorithm) algorithm in the OpenZeppelin framework. OpenZeppelin provides a comprehensive set of smart contracts and libraries for building secure and auditable decentralized applications (dApps) on the Ethereum blockchain.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites:
&lt;/h2&gt;

&lt;p&gt;To follow along with this tutorial, you should have a basic understanding of Ethereum, smart contracts, and the Solidity programming language. Additionally, you will need to open up the &lt;a href="https://remix.ethereum.org/"&gt;remix tool&lt;/a&gt; on your browser .&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Step 1:&lt;/strong&gt; Setting Up the Project on remix
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Open your web browser and navigate to the Remix IDE website:&lt;a href="https://remix.ethereum.org"&gt;https://remix.ethereum.org&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Create a new file by clicking on the "+" button in the File Explorer panel.&lt;/li&gt;
&lt;li&gt;Save the file with the extension .sol, e.g., SignatureVerification.sol.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Step 2:&lt;/strong&gt; Implementing Signature Verification
&lt;/h2&gt;

&lt;p&gt;In the newly created file, define the Solidity contract and import the required OpenZeppelin contracts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight solidity"&gt;&lt;code&gt;   &lt;span class="k"&gt;pragma&lt;/span&gt; &lt;span class="n"&gt;solidity&lt;/span&gt; &lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="mf"&gt;0.8&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

   &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s"&gt;"@openzeppelin/contracts/utils/cryptography/ECDSA.sol"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s"&gt;"@openzeppelin/contracts/utils/Address.sol"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

   &lt;span class="k"&gt;contract&lt;/span&gt; &lt;span class="n"&gt;SignatureVerification&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="n"&gt;ECDSA&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="kt"&gt;bytes32&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
       &lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="n"&gt;Address&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="kt"&gt;address&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

       &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;verifySignature&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
           &lt;span class="kt"&gt;bytes32&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
           &lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="n"&gt;signer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
           &lt;span class="kt"&gt;bytes&lt;/span&gt; &lt;span class="k"&gt;memory&lt;/span&gt; &lt;span class="n"&gt;signature&lt;/span&gt;
       &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;pure&lt;/span&gt; &lt;span class="k"&gt;returns&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;bool&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
           &lt;span class="kt"&gt;bytes32&lt;/span&gt; &lt;span class="n"&gt;hash&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;toEthSignedMessageHash&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
           &lt;span class="kt"&gt;address&lt;/span&gt; &lt;span class="n"&gt;recoveredSigner&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;hash&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;recover&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;signature&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
           &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;signer&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;recoveredSigner&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
       &lt;span class="p"&gt;}&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Explanation
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;using&lt;/code&gt; statements enable the use of ECDSA and Address utility functions from OpenZeppelin within the contract. The &lt;code&gt;verifySignature&lt;/code&gt; function takes in the message, expected signer address, and signature, and verifies the signature's validity.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;verifySignature&lt;/code&gt; function takes the keccak256 hash value of the message.It also takes the signer address which is the person who signed the message and at last it takes the signature. It returns a bool value stating that has the signer signed the message or not.&lt;/p&gt;

&lt;p&gt;First of all, we add the prefix &lt;code&gt;'\x19Ethereum Signed Message:\n'&lt;/code&gt; using the &lt;code&gt;toEthSignedMessageHash&lt;/code&gt; function on the keccak256 message.While signing the message this is automatically added to the signature Hence we also have to do the same.&lt;/p&gt;

&lt;p&gt;After that, we recover the address from the signature and the hashed values and we check to see if the address matches that of the signer or not.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Step 3:&lt;/strong&gt; Generating  Signature on Backend
&lt;/h2&gt;

&lt;p&gt;Now to generate the signature we will use python and web3 module. You can use node.js as well&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Make sure you installed &lt;code&gt;web3&lt;/code&gt; module onin your enviroment.&lt;/li&gt;
&lt;li&gt;Create a Signature.py file and add the following contents to it.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from web3 import Web3, Account

# Initialize Web3 provider
web3 = Web3(Web3.HTTPProvider('https://mainnet.infura.io/v3/YOUR_INFURA_PROJECT_ID'))

# Private key of the account signing the data
private_key = 'YOUR_PRIVATE_KEY'

# Data to be signed
data_to_sign = b'Test Data'

# Generate the signature
account = Account.privateKeyToAccount(private_key)
signature = web3.eth.account.sign(data_to_sign, private_key=account.privateKey)

# Get the signature components
r = signature.r
s = signature.s
v = signature.v

# Print the signature components
print(f'r: {r}')
print(f's: {s}')
print(f'v: {v}')

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion:
&lt;/h2&gt;

&lt;p&gt;In this article, we've explored how to implement signature verification using the ECDSA algorithm in OpenZeppelin. By leveraging OpenZepplin library.&lt;/p&gt;

</description>
      <category>blockchain</category>
      <category>web3</category>
      <category>solidity</category>
      <category>smartcontract</category>
    </item>
  </channel>
</rss>
