- What are the differences between message confidentiality and message integrity
- Reasons why some Internet entities might want secure communication
- Attributes of an 8-block cipher
- Symmetric Encryption vs Public Key Encryption
- Why does a Hash provide better message integrity then an Internet checksum?
- Monoalphabetic Cipher and Inverse Written in Python
- Block cipher lab

**How many keys are involved for symmetric key encryption? How about public key encryption?**

Suppose you have N people who want to communicate with each other using symmetric keys. All communication between any two people, i and j, is visible to group N. Only person i and person j can decrypt each others messages.

**How many keys would Symmetric Encryption require to protect group N?**

I solved this with the following python function:

def count_symmetric_keys( N=2 ): """Provide the number of entities in group N. return the number of symmetric keys needed for this group""" keys = 0 for i in range( 0, N ): keys += i return keysA reader suggested the following optimized formula:

def calc_symmetric_keys( N=2 ): """Provide the number of entities in group N. return the number of symmetric keys needed for this group""" return N*(N-1)/2

If group N had 10 members, it would need to generate and maintain 45 Symmetric Keys.

If group N had 50 members, it would need to generate and maintain 1225 Symmetric Keys.

Symmetric keys are also susceptible to man-in-the-middle attacks. This attack occurs when an entity poses as a trusted entity. Let i and j be trusted entities. Let k be an untrusted attacker. If k determined the Symmetric key it could send or receive messages posing as i or j.

**How many keys would Public-key Encryption require to protect group N?**

Public Key Encryption requires 2n keys or two keys per person in group N. Public key encryption also does not require ‘pre sharing’ the secret key before communication may start. Each member would need 1 public key and 1 private key.

If group N had 10 members, it would need to generate and maintain 20 Public/Private Keys.

If group N had 50 members, it would need to generate and maintain 100 Public/Private Keys.

Good to know about the Symmetric Encryption vs Public Key Encryption

Looks like you made a typo or Python calculated it wrong:

n(n-1)/2= keys needed

50(50-1)/2= 1,225 symmetric keys needed.

I thought I didn’t have the formula correct when I first saw your article, but I double checked it. Thanks for helping me learn that formula even better! ;)

Yeah, it is a typo, the function I provided works. However the formula you give is a better solution because it O(1) instead of O(n) so I’m going to update the blog post with your corrections.