# Asymmetric Cipher

## Asymmetric Ciphers

Asymmetric ciphers aka public key cryptography, is more complex than symmetric(in term of usage not cipher implementation), because instead of using the same key to encrypt and decrypt, asymmetric needs public and private key pair.

Common scenarios of asymmetric ciphers are:

- Encrypt data by public key and decrypt by private key
- Sign message(MAC) by private key and verify by public key
- Exchange key between 2 parties publicly

### Key Exchange

Key exchange usually happen when two parties want to establish a secure connection on a public channel, for example TLS Handshake.

- Client and Server each has a key pair, only client has access to the private key
- Server has a key pair, only server has access to the private key
- (Client private key * Base) * Server public key = shared key = Client public key (Base * Server Private key)

Where private * base = public key
`*`

is a math irreversible operation that is associative, e.g. exponent of huge number