.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/crypto/blind_signatures/plot_01_blind_signatures.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code or to run this example in your browser via JupyterLite. .. rst-class:: sphx-glr-example-title .. _sphx_glr_api_gallery_crypto_blind_signatures_plot_01_blind_signatures.py: Chaum's blind signatures: authenticate a message the signer cannot see (1982) ============================================================================= Chaum's construction separates authorization from knowledge of a message. This experiment exposes RSA's multiplicative blinding identity with tiny integers; a usable payment system needs encoding, issuance, and spent-token rules. What to look for ---------------- Follow the original message, its hidden form, and the final signature. The final check succeeds after removing the hiding factor; this is only the signing step of a payment system. Read cells in order. An ``assert`` that produces no output has passed. The final exercise asks you to change an input and explain the result. The history behind this experiment: :doc:`/history/crypto_breakthroughs`. See :doc:`/exercises/crypto` for a worked solution to the exercise. .. GENERATED FROM PYTHON SOURCE LINES 24-37 .. code-block:: Python import matplotlib.pyplot as plt import blockchainkit as bk key = bk.crypto.rsa_keypair() message, factor = 42, 7 blinded = bk.crypto.rsa_blind(message, factor, key) blind_signature = key.decrypt(blinded) # Private exponentiation by the signer. signature = bk.crypto.rsa_unblind(blind_signature, factor, key) assert key.encrypt(signature) == message assert signature == key.decrypt(message) print(f"Message {message}; blinded request {blinded}; final signature {signature}") .. rst-class:: sphx-glr-script-out .. code-block:: none Message 42; blinded request 2508; final signature 3065 .. GENERATED FROM PYTHON SOURCE LINES 38-40 The signer sees the middle column, not the blinding factor ---------------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 40-67 .. code-block:: Python fig, ax = plt.subplots(figsize=(10, 3.8)) ax.set(xlim=(0, 1), ylim=(0, 1)) ax.axis("off") labels = [ (0.15, 0.65, f"Holder\nm = {message}\nr = {factor}"), (0.5, 0.65, f"Signer receives\nm r^e mod n\n= {blinded}"), (0.85, 0.65, f"Signer returns\n(blinded)^d\n= {blind_signature}"), (0.5, 0.15, f"Holder removes r\ns = {signature}\ns^e mod n = {message}"), ] for x, y, label in labels: ax.text( x, y, label, ha="center", va="center", bbox={"boxstyle": "round,pad=0.6", "fc": "#eef2ff", "ec": "#6366f1"}, ) for start, end in [ ((0.26, 0.65), (0.37, 0.65)), ((0.64, 0.65), (0.74, 0.65)), ((0.85, 0.44), (0.63, 0.22)), ]: ax.annotate("", xy=end, xytext=start, arrowprops={"arrowstyle": "->", "lw": 1.5}) ax.set_title("Authorization and message visibility are different properties") fig.tight_layout() .. image-sg:: /api/gallery/crypto/blind_signatures/images/sphx_glr_plot_01_blind_signatures_001.png :alt: Authorization and message visibility are different properties :srcset: /api/gallery/crypto/blind_signatures/images/sphx_glr_plot_01_blind_signatures_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 68-72 Exercise -------- Try an r that shares a factor with n. Why can it not be removed? Explain why blind signatures alone do not prevent spending the same token twice. .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.279 seconds) .. _sphx_glr_download_api_gallery_crypto_blind_signatures_plot_01_blind_signatures.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: lite-badge .. image:: images/jupyterlite_badge_logo.svg :target: ../../../../lite/lab/index.html?path=api/gallery/crypto/blind_signatures/plot_01_blind_signatures.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_01_blind_signatures.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_01_blind_signatures.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_01_blind_signatures.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_