Ali Yousefian
  • Home
  • Blog
  • About
  • Contact
  • Click to open the search input field Click to open the search input field Search
  • Menu Menu

ECDSA public key compression in Erlang

2024-01-14/0 Comments/in Uncategorized

In this blog post, I will share an Erlang code snippet that can be used to compress the Elliptic Curve Digital Signature Algorithm (ECDSA) public keys. This technique can significantly reduce data size without compromising security.

Before diving into compression, it’s essential to grasp the structure of ECDSA public keys. These keys consist of two coordinates, commonly denoted as (x, y), representing points on an elliptic curve. Compression focuses on minimizing the size of these coordinates.

The process of compressing ECDSA public keys

1. Understand ECDSA Public Keys:

ECDSA public keys are represented by two coordinates, denoted as (x, y), which correspond to points on an elliptic curve.

2. Determine the Parity of y:

Calculate the parity (even or odd) of the y-coordinate.

  • If y is even, a specific prefix byte 02 is set.
  • If y is odd, a different prefix byte 03 is set.

3. Concatenate Prefix and x-coordinate:

Concatenate the chosen prefix byte with the x-coordinate. This creates a binary representation that combines the information about the parity of y and the x-coordinate.

4. Final Compressed Key:

The result of the concatenation is the compressed form of the ECDSA public key.

Erlang code snippet

Now, to implement this compression technique in Erlang, you can refer to the code snippet:

GitHub Gist

This code provides a practical implementation of the compression process discussed above.

To run the provided code, you’ll need to follow these steps:

1. Save the code in a file with the name “compress_ecdsa_publickey.erl”. Make sure the file extension is “.erl”.

2. Open a terminal and navigate to the directory where you saved the file.

3. Start an Erlang shell by typing “erl” and pressing Enter.

4. Compile the module by running the following command inside the Erlang shell:

c(compress_ecdsa_publickey).

This will compile the Erlang module and generate a BEAM file (.beam).

5. After successful compilation, you can run the “test/0” function:

compress_ecdsa_publickey:test().

This will execute the “test/0” function, which in turn calls the “compress_ecdsa_publickey/1” function with a sample uncompressed public key. The result will be printed on the console.

Conclusion

In summary, the compression process involves choosing a prefix based on the parity of the y-coordinate and concatenating these components to form a compressed binary representation of the ECDSA public key. This technique reduces the size of the public key while maintaining its integrity for cryptographic purposes.

Tags: compress public key, ecdsa, erlang
Share this entry
  • Share on Facebook
  • Share on X
  • Share on WhatsApp
  • Share on Pinterest
  • Share on LinkedIn
  • Share on Tumblr
  • Share on Vk
  • Share on Reddit
  • Share by Mail
https://www.aliyousefian.com/wp-content/uploads/2024/01/ecdsa.png 359 638 Ali Yousefian https://www.aliyousefian.com/wp-content/uploads/2023/06/AliYousefian-logo-300x300.png Ali Yousefian2024-01-14 15:14:562024-01-20 11:04:15ECDSA public key compression in Erlang
You might also like
ErlyTalk | Build a highly scalable distributed messaging application with Erlang and Kubernetes on AWS
0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Categories

  • Uncategorized
  • Link to LinkedIn
  • Blog
  • About
  • Contact
  • GitHub
Scroll to top Scroll to top Scroll to top