Search code examples
encryptioncryptographydigital-signaturepublic-key-encryptionencryption-asymmetric

Is there a standard format for what to encrypt as a digital signature?


When sending a message encrypted with asymmetric encryption, e.g.

Long long, very long message here. // encrypted with recipents public key

Signed by John Doe // encrypted with own private key

Does one want to be consistent with their own digital signature? Is there a standard format, or a widly used convention for the signature part? Or even, are there any conventions or is it just completely random what each person wants to put there?

 

Edit:

I guess my question isn't meant to be about standards per se. Rather about conventions if one would send the example format message in an instant messenger or email for example.


Solution

  • You mention in a comment:

    First - the users signs with its private key, not encrypts.. Yes, but doesn't the signing mean encrypting a signature with your private key (so that anyone can check it with your public key), like in my example?

    Though the answer to this comment is generally: no.

    Cryptographic signatures can be constructed in quite a lot of different ways. In RSA, the signing operation resembles some elements of the encryption, but this is a coincidence.

    For example, take some the Schnorr signature scheme for elliptic curves:

    (In this example, G is a base point for some secure elliptic curve E.
     All variables between brackets are scalars modulo the order of E.)
    
    
    Setup:
      Alice has a private key x (random).
      Bob has Alice's public key P_A = [x]G.
    
    Alice signs a message m:
      k := random()
      Q := [k]G
      c := H(Q||P_A||m)
      r := k + c*x
      Alice outputs s := (Q, r)
    
    Bob verifies s over m:
      c := H(Q||P_A||m)
      Check if [r]G == Q + [c]P_A
    

    As you can see, there is no real notion of "encryption" here. It is just a protocol.