The Wayback Machine - https://web.archive.org/web/20240817235201/https://www.geeksforgeeks.org/schnorr-identification-scheme/
Open In App

Schnorr Identification Scheme

Last Updated : 05 Sep, 2020
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

Schnorr signature is known for its simplicity and is among the first whose security is based on the intractability of certain discrete logarithm problems. The Schnorr digital signature scheme is different from the identification scheme. An identification scheme is used for the holder of the private key to prove to you that they hold the private key. A signature scheme in addition proves that the key holder used their private key with a specific message as an input value in order to generate a verifiable digital signature on that specific message. 

Schnorr Identification Scheme with the discrete logarithm

Meaning of equivalence ‘≡’

The elements of the integers modulo (often shortened to “mod”) 36 are 0, 1, . . . , 34, 35. Then 41 is equivalent to 5 modulo 36, written 41 ≡ 5 mod 36, because when 41 is divided by 36 the remainder is 5.

Similarly, we also have 57 ≡ 5 mod 26.

Discrete logarithm:

Discrete logarithms are logarithms defined with regard to multiplicative cyclic groups. If G is a multiplicative cyclic group and g is a generator of G, then from the definition of cyclic groups, we know every element h in G can be written as gx for some x. The discrete logarithm to the base g of h in the group G is defined to be x .

If the group is A, and the generator is 2, then the discrete logarithm of 1 is 4 because 24 ≡ 1 mod 5.

Logarithm logb(a) is a number x such that bx = a, for given numbers a and b. Analogously, in any group G, powers bk can be defined for all integers k, and the discrete logarithm logb(a) is an integer k such that bk = a.

We have the following 3 parameters:

  • g is the Generator,
  • x is the secret value
  • p is the prime number.

Algorithm

The prover Sanchita has a proving public key of (g, X) where g is a generator, and X=gx(modN). After Sanchita generates her public proving key, she will then be challenged by Sachin to produce the correct result. A discrete logarithm is an integer x satisfying the equation ax≡b(modm) where a and m are relatively prime.

With Schnorr identification, Sanchita (the prover) has a proving public key of (N, g, X) and a proving secret key of (N, x). N is a prime number for the modulus operation, and x is the secret, and where:

X←gx(modN)

On the registration of the secret, Sanchita generates a random value (y), and then computes Y:

Y←gy(modN)

This value is sent to Sachin (who is the verifier). Sachin then generates a random value (c) and sends this to Sanchita. This is a challenge for Sanchita to produce the correct result. Sanchita then computes:

z←(y+xc)(modN)

He then sends this to Sachin in order to prove that he knows x. Sachin then computes two values:

val1 = YXc(modN)
val2 = gz(modN)

If the values are the same (val1≡val2), Sanchita has proven that she knows x.

This works because:

YXc = gygxc = gy+cx
gz = gy+cx

Python3




import random
import sys
  
PRIMENO = 89
generator = 3
  
  
secretVal = random.randint(1, 97)
  
X = pow(generator, secretVal) % PRIMENO
y = random.randint(1, 97)
Y = pow(generator, y) % PRIMENO
  
print("Sanchita (the Prover) generates these values:")
print("secretVal(secret)= ", secretVal)
print("PRIMENO= ", PRIMENO)
print("X= ", X)
  
print("\nSanchita generates a random value (y):")
print("y=", y)
  
print("\nSanchita computes Y = generator^y \
(mod PRIMENO) and passes to Sachin:")
  
print("Y=", Y)
  
print("\nSachin generates a random value (c) and\
passes to Sanchita:")
  
c = random.randint(1, 97)
print("c=", c)
print("\nSanchita calculates z = y.secretVal^c \
(mod PRIMENO) and send to Sachin (the Verifier):")
  
z = (y + c * secretVal)
  
print("z=", z)
  
print("\nSachin now computes val=generator^z (mod PRIMENO)\
and (Y X^c (mod PRIMENO)) and determines if they are the same\primeNo")
  
val1 = pow(generator, z) % PRIMENO
val2 = (Y * (X**c)) % PRIMENO
  
print("val1= ", val1, end=' ')
print(" val2= ", val2)
  
if (val1 == val2):
    print("Sanchita has proven that she knows x")
else:
    print("Failure to prove")


Output:

schnorr identification scheme python

Application:

  • It has its use case in cryptographic research
  • It is used in the implementation of Zero-Knowledge Proof.
  • It provides a more secure way for authentication without the prover revealing its secret key.


Similar Reads

Schnorr Digital Signature
In cryptography, a Schnorr signature is a digital signature produced by the Schnorr signature algorithm that was described by Claus Schnorr. It is a digital signature scheme known for its simplicity, is efficient and generates short signatures. It is one of the protocols used to implement "Proof Of Knowledge".In cryptography, a proof of knowledge i
4 min read
Tag identification Message formats
The format of the Query message is shown in the figure given below, as an example of a reader-to-tag message. The downlink rates are limited, from 27 kbps up to 128 kbps so the message is compact. To identify the message as a Query the Command field carries the code 1000. The physical layer parameters for reader transmissions and tag responses are
2 min read
Color Identification in Images using Python - OpenCV
An open-source library in Python, OpenCV is basically used for image and video processing. Not only supported by any system, such as Windows, Linux, Mac, etc. but also it can be run in any programming language like Python, C++, Java, etc. OpenCV also allows you to identify color in images. Don’t you know how to find these colors in images? Color Re
3 min read
Introduction of Radio Frequency Identification (RFID)
Radio Frequency Identification (RFID) is a form of wireless communication that incorporates the use of electromagnetic or electrostatic coupling in the radio frequency portion of the electromagnetic spectrum to uniquely identify an object or person. It uses radio frequency to search, identify, track, and communicate with items and people. RFID (Rad
8 min read
RSA Digital Signature Scheme using Python
RSA algorithm is an asymmetric cryptography algorithm. Asymmetric actually means that it works on two different keys i.e. Public Key and Private Key. As the name describes that the Public Key is given to everyone and the Private key is kept private. An example of asymmetric cryptography : A client (for example browser) sends its public key to the s
4 min read
Implementing Shamir's Secret Sharing Scheme in Python
Secret Sharing schemes are used in the distribution of a secret value among multiple participants (shareholders) by dividing the secret into fragments (shares). This is done in a manner that prevents a single shareholder from having any useful knowledge of the original secret at all. The only way to retrieve the original secret is to combine the sh
7 min read
Winternitz One Time Signature Scheme
Winternitz One Time Signature (WOTS) is a quantum resistant digital signature scheme that uses relatively small key and signature sizes. As it is a one-time signature scheme, it can only be used to securely sign one message. Suppose Alice wants to digitally sign her message to Bob, the process can be explained in 3 steps: Key Generation, Signature
2 min read
Lamport One Time Signature Scheme
Lamport One Time Signature is a method for constructing a digital signature and typically involved the use of a cryptographic hash function. As it is a one-time signature scheme, it can only be used to securely sign one message. Suppose Alice wants to digitally sign her message to Bob, the process can be explained in 3 steps: Key GenerationSignatur
3 min read
RJ14 and RJ21 Color Scheme
RJ14 and RJ21 connectors are types of registered jack (RJ) connectors that are commonly used in telecommunications. These connectors are used to connect telephone lines and other types of communication equipment. In this article, we will discuss the color schemes for RJ14 and RJ21 connectors, as well as provide some examples of how these connectors
3 min read
Merkle-Damgard Scheme in Cryptography
Pre-requisites: Cryptography and its Types MD scheme(discovered by Ralph Merkle) is used to build collision-resistant cryptographic hash functions from collision-resistant one-way compression functions. It is used in algorithms like SHA-1, SHA-256, etc. This scheme can be divided into two stages: Stage 1: Design a fixed-length, collision-resistant
4 min read
Python Programs
Python Examples: Practice with Python program examples is always a good choice to scale up your logical understanding and programming skills and this article will provide you with the best sets of Python code examples. The below Python section contains a wide collection of Python programming examples. These Python code examples cover a wide range o
13 min read
Python Tutorial | Learn Python Programming
This Programming Language Python Tutorial is very well suited for beginners and also for experienced programmers. This specially designed free Python tutorial will help you learn Python programming most efficiently, with all topics from basics to advanced (like Web-scraping, Django, Learning, etc.) with examples. What is Python?Python is a high-lev
9 min read
30 OOPs Interview Questions and Answers (2024)
Object-Oriented Programming, or OOPs, is a programming paradigm that implements the concept of objects in the program. It aims to provide an easier solution to real-world problems by implementing real-world entities such as inheritance, abstraction, polymorphism, etc. in programming. OOPs concept is widely used in many popular languages like Java,
15+ min read
Python Exercise with Practice Questions and Solutions
Python Exercise: Practice makes you perfect in everything. This proverb always proves itself correct. Just like this, if you are a Python learner, then regular practice of Python exercises makes you more confident and sharpens your skills. So, to test your skills, go through these Python exercises with solutions. Python is a widely used general-pur
7 min read
Python Projects - Beginner to Advanced
In this guide, we'll explore a range of Python projects suitable for beginners to advanced programmers. These Python projects are designed to help you gain practical experience with Python programming while building real-world applications. Whether you're just starting out or looking to deepen your understanding of Python, there's something here fo
8 min read
Top 50+ Python Interview Questions and Answers (Latest 2024)
Python is the most used language in top companies such as Intel, IBM, NASA, Pixar, Netflix, Facebook, JP Morgan Chase, Spotify, and many more because of its performance and its powerful libraries. To get into these companies and organizations as a Python developer, you need to master some important Python Interview Questions to crack their Python O
15+ min read
How to Install PIP on Windows ?
PIP is a package management system used to install and manage software packages/libraries written in Python. PIP stands for Preferred Installer Program or Pip Installs Packages. We can install Python packages using the Python pip install command in Command Prompt. Pip Install a Python Package These files are stored in a large "online repository" te
6 min read
Read JSON file using Python
The full form of JSON is JavaScript Object Notation. It means that a script (executable) file which is made of text in a programming language, is used to store and transfer the data. Python supports JSON through a built-in package called JSON. To use this feature, we import the JSON package in Python script. The text in JSON is done through quoted-
6 min read
Python Data Types
Python Data types are the classification or categorization of data items. It represents the kind of value that tells what operations can be performed on a particular data. Since everything is an object in Python programming, Python data types are classes and variables are instances (objects) of these classes. The following are the standard or built
15+ min read
Taking input in Python
Developers often have a need to interact with users, either to get data or to provide some sort of result. Most programs today use a dialog box as a way of asking the user to provide some type of input. While Python provides us with two inbuilt functions to read the input from the keyboard. input ( prompt ) raw_input ( prompt ) input (): This funct
5 min read
Python Program to Check Prime Number
Given a positive integer N, the task is to write a Python program to check if the number is Prime or not in Python. Examples: Input: n = 11Output: TrueInput: n = 1Output: FalseExplanation: A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. The first few prime numbers are {2, 3, 5, 7, 11, ….}. Py
7 min read
f-strings in Python
Python offers a powerful feature called f-strings (formatted string literals) to simplify string formatting and interpolation. f-strings is introduced in Python 3.6 it provides a concise and intuitive way to embed expressions and variables directly into strings. The idea behind f-strings is to make string interpolation simpler. How to use f-strings
5 min read
Dictionaries in Python
A Python dictionary is a data structure that stores the value in key:value pairs. dict = { 1: 'Python', 2: 'dictionary', 3: 'example' }Example: As you can see from the example, data is stored in key:value pairs in dictionaries, which makes it easier to find values. Python dictionaries are essential for efficient data mapping and manipulation in pro
10 min read
Python map() function
map() function returns a map object(which is an iterator) of the results after applying the given function to each item of a given iterable (list, tuple etc.) Python map() Function Syntax Syntax : map(fun, iter) Parameters: fun: It is a function to which map passes each element of given iterable. iter: It is iterable which is to be mapped. NOTE: Yo
5 min read
TCP/IP Model
The TCP/IP model is a fundamental framework for computer networking. It stands for Transmission Control Protocol/Internet Protocol, which are the core protocols of the Internet. This model defines how data is transmitted over networks, ensuring reliable communication between devices. It consists of four layers: the Link Layer, the Internet Layer, t
13 min read
What is OSI Model? - Layers of OSI Model
OSI stands for Open Systems Interconnection, where open stands to say non-proprietary. It is a 7-layer architecture with each layer having specific functionality to perform. All these 7 layers work collaboratively to transmit the data from one person to another across the globe. The OSI reference model was developed by ISO - 'International Organiza
15+ min read
Basics of Computer Networking
Computer networking is a cornerstone of modern technology, enabling the interconnected systems that power the Internet, business communications, and everyday digital interactions. Understanding the fundamentals of computer networking is essential for anyone involved in technology, from enthusiasts to professionals. This article will explore the bas
12 min read
Enumerate() in Python
Often, when dealing with iterators, we also need to keep a count of iterations. Python eases the programmers' task by providing a built-in function enumerate() for this task. The enumerate () function adds a counter to an iterable and returns it in the form of an enumerating object. This enumerated object can then be used directly for loops or conv
5 min read
Types of Network Topology
Network topology refers to the arrangement of different elements like nodes, links, and devices in a computer network. It defines how these components are connected and interact with each other. Understanding various types of network topologies helps in designing efficient and robust networks. Common types include bus, star, ring, mesh, and tree to
11 min read
Python OOPs Concepts
Object Oriented Programming is a fundamental concept in Python, empowering developers to build modular, maintainable, and scalable applications. By understanding the core OOP principles—classes, objects, inheritance, encapsulation, polymorphism, and abstraction—programmers can leverage the full potential of Python's OOP capabilities to design elega
12 min read
Practice Tags :
three90RightbarBannerImg