From cf9b87dc088ca98a7daafd3d716846e2ce5125f9 Mon Sep 17 00:00:00 2001 From: Miloslav Ciz Date: Fri, 14 Jan 2022 22:22:28 -0600 Subject: [PATCH] Add digital signature --- digital_signature.md | 9 +++++++++ rsa.md | 24 ++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 digital_signature.md create mode 100644 rsa.md diff --git a/digital_signature.md b/digital_signature.md new file mode 100644 index 0000000..d87dd17 --- /dev/null +++ b/digital_signature.md @@ -0,0 +1,9 @@ +# Digital Signature + +Digital signature is a method of mathematically (with [cryptographical](cryptography.md) algorithms) proving that, with a high probability, a digital message or document has been produced by a specific sender, i.e. it is something aka traditional signature which gives a "proof" that something has been written by a specific person. + +It works on the basis of [asymmetric cryptography](asymmetric_cryptography.md): the signature of a message is a pair of a public key and a number (the signature) which can only have been produced by the owner of the private key associated with the public key. This signature is dependent on the message data itself, i.e. if the message is modified, the signature will no longer be valid, preventing anyone who doesn't posses the private key from modifying the message. The signature number can for example be a [hash](hash.md) of the message decoded with the private key -- anyone can check that the signature encoded with the public key gives the document hash, proving that whoever computed the signature number must have possessed the private key. + +Signatures can be computed e.g. with the [RSA](rsa.md) algorithm. + +The nice thing here is that **[anonymity](anonymity.md) can be kept with digital signatures**; no private information such as the signer's real name is required to be revealed, only his public key. Someone may ask why we then even sign documents if we don't know by whom it is signed lol? But of course the answer is obvious: many times we don't need to know the identity of the signer, we just need to know that different messages have all been written by the same person, and this is what a digital signature can ensure. And of course, if we want, a public key can have a real identity assigned if desirable, it's just that it's not required. \ No newline at end of file diff --git a/rsa.md b/rsa.md new file mode 100644 index 0000000..1e85511 --- /dev/null +++ b/rsa.md @@ -0,0 +1,24 @@ +# RSA + +TODO + +generating keys: + +1. *p := large random prime* +2. *q := large random prime* +3. *n := p * q* +4. *f := (p - 1) * (q - 1)* (this step may differ in other versions) +5. *e := 65537* (most common, other constants exist) +6. *d := solve for x: x * e = 1 mod f* +7. *public key := (n,e)* +8. *private key := d* + +message encryption: + +1. *m := message encoded as a number < n* +2. *encrypted := m^e mod n* + +message decryption: + +1. *m := encrypted^d mod n* +2. *decrypted := decode message from number m* \ No newline at end of file