Skip to content

Latest commit

 

History

History
103 lines (76 loc) · 7.93 KB

README.md

File metadata and controls

103 lines (76 loc) · 7.93 KB

Cryptography

Learn about cryptography concepts - Both basics and core covered here.

cryptography_.png

Concepts

The below concepts are in brief. For detailed explanation, navigate to the respective sections in this repository.

  • RSA vs ECC

    • Smaller key sizes: RSA requires more key size than ECC for same level of security. For example, a 256-bit ECC key is generally considered to be as secure as a 3072-bit RSA key.
      • Reason: ECC is based on elliptic curves, whereas RSA is based on prime factorization. Elliptic curves allows efficient computation and smaller key sizes than prime factorization which requires larger key sizes for same level of security.
        • ECC is based on the difficulty of finding the discrete logarithm of a random elliptic curve element with respect to a publicly known base point. This is a one-way function, much like calculating the product of two large prime numbers. The difficulty of this function is dependent on the size of the elliptic curve, which is measured by the size of the base point order, which is a large prime number. Basically, the ECC maths is hard to solve than RSA prime factorization. Hence, ECC is more secure (with lesser key size) than RSA.
    • Faster encryption and decryption: ECC is generally faster in terms of encryption and decryption, especially for smaller key sizes.
    • Lower resource consumption: ECC operates efficiently on devices with low CPU and memory resources, making it a suitable choice for mobile devices and embedded systems.
    • Better performance at high security levels: ECC offers better performance at high security levels compared to RSA, making it a suitable choice for applications requiring strong security
    • RSA key generation is slower than ECC, but verification of the former is faster than the latter => 20000 RSA vs 8000 ECC key verification.
    • RSA is simpler to implement than ECC, also the former is less expensive to implement.

      Now, that quantum computer research has advanced, ECC is more secure than RSA, but it still can be broken by quantum computers. So, the researchers are working on quantum resistant cryptography.

  • In case of Ethereum, generating a private key from a mnemonic passphrase is a 2-step process:

    1. Seed generation: There is a mnemonic passphrase (12 to 24 words) -> 512-bit seed using the BIP-39 algorithm.
    2. Private key generation: 512-bit seed seeded with PRNG -> 256-bit private key

    This private key can then be used for a wide variety of purposes such as creating digital signatures, generating public/private key pairs and deriving key pairs for encryption.

  • Hash functions

    All hash functions are covered by RustCrypto org. Source except blake3.

  • ECC (Elliptic Curve Cryptography)

    • Elliptic curve cryptography (ECC) is an approach to public-key cryptography based on the algebraic structure of elliptic curves over finite fields. Not every elliptic curve can promise strong security for practical applications. The curves used in cryptography are carefully chosen to avoid attacks and to make the mathematical computations efficient.

    • It has ECDH (Elliptic Curve Diffie-Hellman) and ECDSA (Elliptic Curve Digital Signature Algorithm) algorithms for key exchange and digital signatures respectively.

      • ECDH is used for key exchange i.e. to share a secret key between two parties i.e. for Alice and Bob to share a secret key. private_key_A * public_key_B = shared_secret_key = private_key_B * public_key_A
    • Using rust, there is a repository by RustCrypto, which maintains multiple elliptic curves. Here is a screenshot attached:

      The most commonly used is secp256k1 i.e. yˆ2 = xˆ3 + a•x + b The image above doesn't include BLS curves which is covered here as crypto primitives by Kogorashi Network.

  • ZKP (Zero Knowledge Proof)

Books

Repositories

Python

Rust

Resources

Blogs

Maths

Use this tool to visualize Desmos your custom maths function.

Finite Elements