GenerateDigitalSignature

GenerateDigitalSignature[expr,key]

generates a digital signature for expr using the specified private key.

Details and Options

  • GenerateDigitalSignature returns a DigitalSignature object.
  • The private key given to GenerateDigitalSignature can be obtained, for example, from GenerateAsymmetricKeyPair["EllipticCurve"].
  • GenerateDigitalSignature allows the option Method->assoc, where the entries in the association assoc are:
  • "Type""EllipticCurve"type of signing algorithm
    "CurveName""secp256k1"elliptic curve to use
    "HashingMethod""SHA256"how to hash the original expression
    "SignatureType"Automaticmode of digital signature generation
  • The only elliptic curve currently supported is secp256k1. Cryptocurrencies using this curve can also be used as settings for "EllipticCurve". That includes "Bitcoin" and "Ethereum" . Using a cryptocurrency will yield the appropriate additional parameters in the DigitalSignature object.
  • "HashingMethod"->None directly constructs a digital signature for expr, and does not hash it. In this case, expr must be a byte array or hex string.
  • "HashingMethod"->"h" effectively hashes expr using Hash[expr,"h"].
  • Possible settings for "SignatureType" include:
  • "Deterministic"use expr as a source of pseudorandomness
    "NonDeterministic"use a system-specific source of randomness
    Automaticuse non-deterministic methods when possible; deterministic otherwise
  • Note: for hashing methods "Adler32", "CRC32" and None, "SignatureType" "Deterministic" uses "SHA256" to derive pseudorandomness from the input.

Examples

open all close all

Basic Examples  (2)

Generate an elliptic-curve based key pair:

In[1]:=
Click for copyable input
Out[1]=

Generate a digital signature using your private key:

In[2]:=
Click for copyable input
In[3]:=
Click for copyable input
Out[3]=

Verify a digital signature using your public key:

In[4]:=
Click for copyable input
Out[4]=

Sign a message using a hashing function of your choice:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
In[3]:=
Click for copyable input
Out[3]=

Verify the signature:

In[4]:=
Click for copyable input
Out[4]=

This is equivalent to manually constructing a digest and using "HashingMethod" -> None:

In[5]:=
Click for copyable input
In[6]:=
Click for copyable input
Out[6]=

Verify the signature:

In[7]:=
Click for copyable input
Out[7]=

Scope  (3)

Options  (3)

Applications  (3)

Possible Issues  (1)

Introduced in 2019
(12.0)