I am attempting a workflow to exemplify the process of digital signature using asymmetric cryptography.
If I understand correctly then the public key and the private key in an asymmetric cryptographic key pair are inverse functions. Ergo, if the private key is the function F, then the public key is G=F^(-1), and F(G(x))=x.
If I understand correctly then a digitally signed email consists of: a) a plaintext message, let's call it M; b) some cyphertext, let's call it C.
Lets suppose that H is a publicly known hash function, such as sha1.
When sending a digitally signed email I would first hash the original plaintext message: H(M)=M'. Then I would scramble-up the hash value using my private key: F(M')=C.
Now when I send the email I include both M and C. If the integrity of the digitally signed email has not been compromised, then the recipient will find that G(C) = H(M).
My question is not regarding the underlying theory, because I think I understand it well enough. (If what I described above is incorrect then please tell me.) Infact, my question is in regards to implementation and manual verification of the workflow. What programs\commands are available to implement each step that was described above? I have satisfactorilly used the following command at the linux command line to invoke the sha1 hash function:
echo -n "hello world" | sha1sum | awk '{print $1}'
I need a command to transform some text using the function that is my private key. And I need a command to transforms some text using the function that is my public key. I prefer something that enables me manually verify each step of the process.
EDIT I know that a pre-built tool like gpg is a more practical way to do digital signatures in an actual use-case. My goal is to have an alternative workflow that generates the same results as gpg. It is important to be able to cross-validate the process. Furthermore, I would like to be able to teach some hypothetical underling about digital signatures, and to do this I want to be able to break-down the process into a series of well understood steps. And because the main purpose is to do cross-validation, and not to actually authenticate\non-repudiate some important communication, therefore the inherrent weaknesses of this approach does not concern me.