CN111447059B - Ciphertext equivalent test method, ciphertext equivalent test device, electronic equipment, storage medium and ciphertext equivalent test system - Google Patents

Ciphertext equivalent test method, ciphertext equivalent test device, electronic equipment, storage medium and ciphertext equivalent test system Download PDF

Info

Publication number
CN111447059B
CN111447059B CN202010238607.9A CN202010238607A CN111447059B CN 111447059 B CN111447059 B CN 111447059B CN 202010238607 A CN202010238607 A CN 202010238607A CN 111447059 B CN111447059 B CN 111447059B
Authority
CN
China
Prior art keywords
ciphertext
segment
plaintext
integer
test
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010238607.9A
Other languages
Chinese (zh)
Other versions
CN111447059A (en
Inventor
朱慧君
闫小斌
刘平
王励成
闫青乐
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Lhasa Koda Technology Co ltd
Original Assignee
Nanyang Institute of Technology
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nanyang Institute of Technology filed Critical Nanyang Institute of Technology
Priority to CN202010238607.9A priority Critical patent/CN111447059B/en
Publication of CN111447059A publication Critical patent/CN111447059A/en
Application granted granted Critical
Publication of CN111447059B publication Critical patent/CN111447059B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/08Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
    • H04L9/0861Generation of secret information including derivation or calculation of cryptographic keys or passwords
    • H04L9/0869Generation of secret information including derivation or calculation of cryptographic keys or passwords involving random numbers or seeds
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/06Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols the encryption apparatus using shift registers or memories for block-wise or stream coding, e.g. DES systems or RC4; Hash functions; Pseudorandom sequence generators
    • H04L9/0618Block ciphers, i.e. encrypting groups of characters of a plain text message using fixed encryption transformation
    • H04L9/0625Block ciphers, i.e. encrypting groups of characters of a plain text message using fixed encryption transformation with splitting of the data block into left and right halves, e.g. Feistel based algorithms, DES, FEAL, IDEA or KASUMI

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Storage Device Security (AREA)

Abstract

The embodiment of the invention provides a ciphertext equivalent test method, a ciphertext equivalent test device, electronic equipment, a storage medium and a ciphertext equivalent test system, wherein the method comprises the following steps: determining a test character string corresponding to the first ciphertext based on the extracted second ciphertext fragment, the extracted fifth ciphertext fragment and the test private key of the first ciphertext; determining a test character string corresponding to the second ciphertext based on the extracted second ciphertext segment of the second ciphertext, the fifth ciphertext segment, and the test private key; converting the test character string corresponding to the first ciphertext into a first coordinate point; converting the test character string corresponding to the second ciphertext into a second coordinate point; determining that the plaintext corresponding to the first ciphertext is identical to the plaintext corresponding to the second ciphertext when the first slope of the straight line formed by the first coordinate point and the origin of coordinates is identical to the second slope of the straight line formed by the second coordinate point and the origin of coordinates; otherwise, determining that the plaintext corresponding to the first ciphertext is different from the plaintext corresponding to the second ciphertext. On the premise of not decrypting the ciphertext, whether the plaintext corresponding to the ciphertext is the same is determined.

Description

Ciphertext equivalent test method, ciphertext equivalent test device, electronic equipment, storage medium and ciphertext equivalent test system
Technical Field
The present invention relates to the field of information processing technologies, and in particular, to a ciphertext equivalent test method, apparatus, electronic device, storage medium, and system.
Background
Cryptography is increasingly used in modern life, for example, in information encryption in online payment systems, password login systems, and cellular communications. Cryptography can be seen to play an important role in protecting data security. Cryptography is a technical science that studies the creation of passwords and the decryption of passwords, including encryption and decryption. Encryption and decryption are typically mutually corresponding.
Currently, common encryption techniques include symmetric encryption techniques and asymmetric encryption techniques. For example, DES (Data Encryption Standard ) encryption algorithm is a typical symmetric encryption technique, and RSA encryption algorithm is a typical asymmetric encryption technique. Asymmetric encryption is the use of encryption and decryption that is not the same key, and typically has two keys, called a "public key" and a "private key", that must be paired for use, otherwise the encrypted file cannot be opened.
However, the inventor found that after encrypting the plaintext by using the RSA encryption algorithm in the prior art, if it is desired to know whether the plaintext corresponding to the two pieces of ciphertext is identical, the two pieces of ciphertext need to be decrypted by using the private key respectively to obtain two pieces of plaintext, and then whether the two pieces of plaintext are identical can be determined by comparing the two pieces of plaintext.
Disclosure of Invention
The embodiment of the invention aims to provide a ciphertext equivalent test method, a ciphertext equivalent test device, electronic equipment, a storage medium and a ciphertext equivalent test system, so as to determine whether plaintext corresponding to ciphertext is identical or not on the premise of not decrypting ciphertext. The specific technical scheme is as follows:
in a first aspect, an embodiment of the present invention provides a ciphertext equivalent test method, where the method includes:
acquiring a first ciphertext to be tested, a test private key of the first ciphertext, a second ciphertext to be tested and a test private key of the second ciphertext, wherein the ciphertext is obtained by encrypting a plaintext based on a public key pair of a point and the plaintext which are positioned on the same straight line as the plaintext in a preset rectangular coordinate system, and the straight line passes through a coordinate origin of the preset rectangular coordinate system;
extracting a second ciphertext segment and a fifth ciphertext segment of the first ciphertext from the first ciphertext, and extracting the second ciphertext segment and the fifth ciphertext segment of the second ciphertext from the second ciphertext;
determining a test character string corresponding to the first ciphertext based on the second ciphertext segment of the first ciphertext, the fifth ciphertext segment of the first ciphertext, and a test private key corresponding to the first ciphertext;
determining a test character string corresponding to the second ciphertext based on the second ciphertext segment of the second ciphertext, the fifth ciphertext segment of the second ciphertext, and a test private key corresponding to the second ciphertext;
Converting the test character string corresponding to the first ciphertext into a first coordinate point in a preset coordinate system; converting the test character string corresponding to the second ciphertext into a second coordinate point in a preset coordinate system;
determining that plaintext corresponding to the first ciphertext is identical to plaintext corresponding to the second ciphertext when a first slope of a straight line formed by the first coordinate point and a coordinate origin of a preset coordinate system is identical to a second slope of a straight line formed by the second coordinate point and the coordinate origin of the preset coordinate system; otherwise, determining that the plaintext corresponding to the first ciphertext is different from the plaintext corresponding to the second ciphertext.
Optionally, the step of encrypting the plaintext to obtain the ciphertext based on a point on the same straight line as the plaintext in the preset rectangular coordinate system and a public key pair of the plaintext includes:
acquiring a plaintext to be encrypted and a public key pair used for encrypting the plaintext; wherein, the plaintext is a character string;
carrying out hash operation on the plaintext by adopting a predetermined first hash algorithm and a predetermined second hash algorithm to obtain a first integer and a second integer corresponding to the plaintext;
taking the first integer and the second integer as first coordinate points in a rectangular coordinate system, and determining a straight line where the coordinate points are located based on the first coordinate points and coordinate origins in the rectangular coordinate system;
Selecting a second coordinate point other than the first coordinate point in the straight line; splicing the two values in the second coordinate point to obtain a spliced character string;
acquiring a third integer and a fourth integer which are randomly selected; encrypting the third integer by adopting a first public key in the public key pair to obtain a first ciphertext segment; encrypting the fourth integer by adopting a second public key in the public key pair to obtain a second ciphertext segment;
converting the third integer into a random number by adopting a third hash algorithm, and performing exclusive-or operation on the plaintext by adopting the random number to obtain a third ciphertext segment;
converting the plaintext and the third integer into a character string with a first preset length by adopting a fourth hash algorithm to obtain a fourth ciphertext segment;
converting the fourth integer, the first ciphertext segment, the second ciphertext segment, the third ciphertext segment and the fourth ciphertext segment into character strings with a second preset length by adopting a fifth hash algorithm, and performing exclusive-or operation on the character strings with the second preset length and the spliced character strings to obtain a fifth ciphertext segment;
and obtaining ciphertext corresponding to the plaintext based on the first ciphertext segment, the second ciphertext segment, the third ciphertext segment, the fourth ciphertext segment and the fifth ciphertext segment.
Optionally, the step of obtaining a public key pair used for encrypting the plaintext includes:
Selecting a first prime number pair and a second prime number pair from a preset prime number table, wherein the first prime number pair and the second prime number pair respectively comprise two prime numbers;
calculating a first product of two prime numbers in the first prime number pair and an Euler function value of the first product; calculating a second product of the two prime numbers in the second prime number pair and an Euler function value of the second product;
selecting a fifth integer and a sixth integer from a preset integer table, wherein the fifth integer is larger than 1 and smaller than the Euler function value of the first product; and the greatest common divisor of the Euler function value of the fifth integer and the first product is 1; the sixth integer is greater than 1 and less than the Euler function value of the second product; and the greatest common divisor of the Euler function value of the sixth integer and the second product is 1;
the fifth integer and the sixth integer are used as a public key pair for encrypting plaintext.
Optionally, after the fifth integer and the sixth integer are used as the public key pair for encrypting the plaintext, the method further comprises:
calculating a first modulo-inverse of the euler function value of the fifth integer for the first product based on the euler function value of the fifth integer for the first product;
calculating a second modulo-inverse of the Euler function value of the sixth integer for the second product based on the Euler function value of the sixth integer for the second product;
And taking the first modulo-inverse element and the second modulo-inverse element as a private key pair corresponding to the public key, wherein the first modulo-inverse element is a decryption private key, and the second modulo-inverse element is a test private key.
Optionally, after determining that the plaintext corresponding to the first ciphertext is identical to the plaintext corresponding to the second ciphertext, the method further includes:
extracting a first ciphertext segment and a third ciphertext segment of the first ciphertext from the first ciphertext; decrypting the first ciphertext based on the first ciphertext segment, the third ciphertext segment, and a decryption private key of the first ciphertext in the first ciphertext;
or alternatively
Extracting a first ciphertext segment and a third ciphertext segment of the second ciphertext from the second ciphertext; and decrypting the second ciphertext based on the first ciphertext fragment, the third ciphertext fragment, and a decryption private key of the second ciphertext in the second ciphertext.
Optionally, determining the test string corresponding to the first ciphertext based on the second ciphertext segment of the first ciphertext, the fifth ciphertext segment of the first ciphertext, and the test private key corresponding to the first ciphertext includes:
based on the first ciphertext C 1 Second ciphertext segment C of (2) 1,2 Test private key d corresponding to first ciphertext 1,2 By the following formula:
Figure BDA0002431827540000041
determining a test character string x corresponding to the first ciphertext 1 ||y 1 The method comprises the steps of carrying out a first treatment on the surface of the Wherein the symbols are
Figure BDA0002431827540000042
Representing an exclusive-or operation,
Figure BDA0002431827540000043
representing the first ciphertext C using a fifth hash algorithm 1 First ciphertext segment C 1,1 Second ciphertext segment C 1,2 Third ciphertext segment C 1,3 Fourth ciphertext segment C 1,4 First ciphertext C 1 Second ciphertext segment C of (2) 1,2 D of (2) 1,2 Converting the second power into a character string with a second preset length;
determining a test string corresponding to the second ciphertext based on the second ciphertext segment of the second ciphertext, the fifth ciphertext segment of the second ciphertext, and a private key corresponding to the second ciphertext, comprising:
based on the second ciphertext C 2 Second ciphertext segment C of (2) 2,2 Test private key d corresponding to the second ciphertext 2,2 By the following formula:
Figure BDA0002431827540000044
determining a test character string x corresponding to the second ciphertext 2 ||y 2 The method comprises the steps of carrying out a first treatment on the surface of the Wherein, the liquid crystal display device comprises a liquid crystal display device,
Figure BDA0002431827540000045
representing the second ciphertext C using a fifth hash algorithm 2 First ciphertext segment C 2,1 Second ciphertext segment C 2,2 Third ciphertext segment C 2,3 Fourth ciphertext segment C 2,4 Second ciphertext C 2 Second ciphertext segment C of (2) 2,2 D of (2) 2,2 To the power, converting the character string into a character string with a second preset length.
In a second aspect, an embodiment of the present invention further provides a ciphertext equivalent test apparatus, where the apparatus includes:
the acquisition module is used for acquiring a first ciphertext to be tested, a test private key of the first ciphertext, a second ciphertext to be tested and a test private key of the second ciphertext, wherein the ciphertext is obtained by encrypting a plaintext based on a point on the same straight line as a plaintext in a preset rectangular coordinate system and a public key pair of the plaintext, and the straight line passes through a coordinate origin of the preset rectangular coordinate system;
The extraction module is used for extracting a second ciphertext segment and a fifth ciphertext segment of the first ciphertext from the first ciphertext, and extracting the second ciphertext segment and the fifth ciphertext segment of the second ciphertext from the second ciphertext;
the test character string determining module is used for determining a test character string corresponding to the first ciphertext based on the second ciphertext segment of the first ciphertext, the fifth ciphertext segment of the first ciphertext and a test private key corresponding to the first ciphertext;
the test character string determining module is further configured to determine a test character string corresponding to the second ciphertext based on the second ciphertext segment of the second ciphertext, the fifth ciphertext segment of the second ciphertext, and a test private key corresponding to the second ciphertext;
the conversion module is used for converting the test character string corresponding to the first ciphertext into a first coordinate point in a preset coordinate system; converting the test character string corresponding to the second ciphertext into a second coordinate point in a preset coordinate system;
the comparison module is used for determining that the plaintext corresponding to the first ciphertext is identical to the plaintext corresponding to the second ciphertext when the first slope of the straight line formed by the first coordinate point and the coordinate origin of the preset coordinate system is identical to the second slope of the straight line formed by the second coordinate point and the coordinate origin of the preset coordinate system; otherwise, determining that the plaintext corresponding to the first ciphertext is different from the plaintext corresponding to the second ciphertext.
Optionally, the ciphertext equivalent test device further includes: a decryption module for: extracting a first ciphertext segment and a third ciphertext segment of the first ciphertext from the first ciphertext; decrypting the first ciphertext based on the first ciphertext segment, the third ciphertext segment, and a decryption private key of the first ciphertext in the first ciphertext;
or alternatively
Extracting a first ciphertext segment and a third ciphertext segment of the second ciphertext from the second ciphertext; and decrypting the second ciphertext based on the first ciphertext fragment, the third ciphertext fragment, and a decryption private key of the second ciphertext in the second ciphertext.
Optionally, the test string determining module is specifically configured to: based on the first ciphertext C 1 Second ciphertext segment C of (2) 1,2 Test private key d corresponding to first ciphertext 1,2 By the following formula:
Figure BDA0002431827540000051
determining a test character string x corresponding to the first ciphertext 1 ||y 1 The method comprises the steps of carrying out a first treatment on the surface of the Wherein the symbols are
Figure BDA0002431827540000052
Representing an exclusive-or operation,
Figure BDA0002431827540000053
representing the first ciphertext C using a fifth hash algorithm 1 First ciphertext segment C 1,1 Second ciphertext segment C 1,2 Third ciphertext segment C 1,3 Fourth ciphertext segment C 1,4 First ciphertext C 1 Second ciphertext segment C of (2) 1,2 D of (2) 1,2 Converting the second power into a character string with a second preset length;
optionally, the test string determining module is further configured to: based on the second ciphertext C 2 Second ciphertext segment C of (2) 2,2 Test private key d corresponding to the second ciphertext 2,2 By the following formula:
Figure BDA0002431827540000054
determining a test character string x corresponding to the second ciphertext 2 ||y 2 The method comprises the steps of carrying out a first treatment on the surface of the Wherein, the liquid crystal display device comprises a liquid crystal display device,
Figure BDA0002431827540000055
representing the second ciphertext C using a fifth hash algorithm 2 First ciphertext segment C 2,1 Second ciphertext segment C 2,2 Third ciphertext segment C 2,3 Fourth ciphertext segment C 2,4 Second ciphertext C 2 Second ciphertext segment C of (2) 2,2 D of (2) 2,2 To the power, converting the character string into a character string with a second preset length.
The embodiment of the invention also provides an encryption device, which comprises:
the public key pair acquisition module is used for acquiring a plaintext to be encrypted and a public key pair used for encrypting the plaintext; wherein, the plaintext is a character string;
the integer acquisition module is used for carrying out hash operation on the plaintext by adopting a first hash algorithm and a second hash algorithm which are determined in advance to obtain a first integer and a second integer corresponding to the plaintext;
the straight line determining module is used for taking the first integer and the second integer as first coordinate points in the rectangular coordinate system and determining the straight line where the coordinate points are located based on the first coordinate points and the coordinate origin in the rectangular coordinate system;
the splicing module is used for selecting a second coordinate point except the first coordinate point in the straight line; splicing the two values in the second coordinate point to obtain a spliced character string;
The ciphertext segment acquisition module is used for acquiring a third integer and a fourth integer which are randomly selected; encrypting the third integer by adopting a first public key in the public key pair to obtain a first ciphertext segment; encrypting the fourth integer by adopting a second public key in the public key pair to obtain a second ciphertext segment;
the ciphertext segment acquisition module is further used for converting a third integer into a random number by adopting a third hash algorithm, and performing exclusive-or operation on a plaintext by adopting the random number to obtain a third ciphertext segment;
the ciphertext segment acquisition module is further used for converting the plaintext and the third integer into a character string with a first preset length by adopting a fourth hash algorithm to obtain a fourth ciphertext segment;
the ciphertext segment acquisition module is further configured to convert the fourth integer, the first ciphertext segment, the second ciphertext segment, the third ciphertext segment, and the fourth ciphertext segment into a character string of a second preset length, and perform an exclusive-or operation on the character string of the second preset length and the spliced character string to obtain a fifth ciphertext segment;
the ciphertext obtaining module is used for obtaining ciphertext corresponding to the plaintext based on the first ciphertext segment, the second ciphertext segment, the third ciphertext segment, the fourth ciphertext segment and the fifth ciphertext segment.
The embodiment of the invention also provides a key generation device, which comprises:
The prime number pair selection module is used for selecting a first prime number pair and a second prime number pair in a preset prime number table, wherein the first prime number pair and the second prime number pair respectively comprise two prime numbers;
the computing module is used for computing a first product of two prime numbers in the first prime number pair and an Euler function value of the first product; calculating a second product of the two prime numbers in the second prime number pair and an Euler function value of the second product;
and the selection module is used for selecting a fifth integer and a sixth integer from a preset integer table, and taking the fifth integer and the sixth integer as a public key pair used for encrypting the plaintext. Wherein the fifth integer is greater than 1 and less than the Euler function value of the first product; and the greatest common divisor of the Euler function value of the fifth integer and the first product is 1; the sixth integer is greater than 1 and less than the Euler function value of the second product; and the greatest common divisor of the Euler function value of the sixth integer and the second product is 1.
Optionally, the key generating device further includes:
the module inverse element calculation module is used for calculating a first module inverse element of the Euler function value of the fifth integer for the first product based on the Euler function value of the fifth integer and the first product; calculating a second modulo-inverse of the Euler function value of the sixth integer for the second product based on the Euler function value of the sixth integer for the second product;
The private key pair obtaining module is used for taking the first modulo inverse element and the second modulo inverse element as a private key pair corresponding to the public key, wherein the first modulo inverse element is a decryption private key, and the second modulo inverse element is a test private key.
The embodiment of the invention also provides electronic equipment, which comprises a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface, and the memory are communicated with each other through the communication bus;
a memory for storing a computer program;
and the processor is used for realizing the steps of the ciphertext equivalent test method according to any one of the embodiments when executing the program stored in the memory.
The embodiment of the invention also provides a computer readable storage medium, wherein a computer program is stored in the computer readable storage medium, and when the computer program is executed by a processor, the steps of the ciphertext equivalent test method according to any one of the embodiments are realized.
The embodiment of the invention also provides a computer program product containing instructions, which when run on a computer, cause the computer to execute the steps of the ciphertext equivalence test method described in any of the embodiments above.
The embodiment of the invention also provides a ciphertext equivalent test system, which at least comprises the ciphertext equivalent test device in any embodiment.
Optionally, the test system further comprises: key generation means and encryption means;
optionally, the key generating device is configured to generate a public key pair and a private key pair, where the private key pair includes a test private key and a decryption private key;
optionally, the encryption device is configured to perform hash operation on the plaintext by using a predetermined first hash algorithm and a predetermined second hash algorithm after obtaining the plaintext to be encrypted and a public key pair used for encrypting the plaintext, so as to obtain a first integer and a second integer corresponding to the plaintext;
the encryption device is also used for taking the first integer and the second integer as first coordinate points in the rectangular coordinate system and determining a straight line where the coordinate points are located based on the first coordinate points and coordinate origins in the rectangular coordinate system;
encryption means for selecting a second coordinate point other than the first coordinate point in the straight line; splicing the two values in the second coordinate point to obtain a spliced character string;
the encryption device is also used for acquiring a third integer and a fourth integer which are randomly selected; encrypting the third integer by adopting a first public key in the public key pair to obtain a first ciphertext segment; encrypting the fourth integer by adopting a second public key in the public key pair to obtain a second ciphertext segment;
The encryption device is further used for converting a third integer into a random number by adopting a third hash algorithm, and performing exclusive-or operation on the plaintext by adopting the random number to obtain a third ciphertext segment;
the encryption device is further used for converting the plaintext and the third integer into a character string with a first preset length by adopting a fourth hash algorithm to obtain a fourth ciphertext segment;
the encryption device is further used for converting the fourth integer, the first ciphertext segment, the second ciphertext segment, the third ciphertext segment and the fourth ciphertext segment into character strings with a second preset length by adopting a fifth hash algorithm, and performing exclusive-or operation on the character strings with the second preset length and the spliced character strings to obtain a fifth ciphertext segment;
the encryption device is further used for obtaining ciphertext corresponding to the plaintext based on the first ciphertext segment, the second ciphertext segment, the third ciphertext segment, the fourth ciphertext segment and the fifth ciphertext segment.
Optionally, the key generating device is specifically configured to select a first prime number pair and a second prime number pair in a preset prime number table, where the first prime number pair and the second prime number pair respectively include two prime numbers;
the key generation device is also used for calculating a first product of two prime numbers in the first prime number pair and an Euler function value of the first product; calculating a second product of the two prime numbers in the second prime number pair and an Euler function value of the second product;
The key generation device is further used for selecting a fifth integer and a sixth integer from a preset integer table, and taking the fifth integer and the sixth integer as a public key pair used for encrypting the plaintext. Wherein the fifth integer is greater than 1 and less than the Euler function value of the first product; and the greatest common divisor of the Euler function value of the fifth integer and the first product is 1; the sixth integer is greater than 1 and less than the Euler function value of the second product; and the greatest common divisor of the Euler function value of the sixth integer and the second product is 1.
The key generation device is also used for calculating a first modulo inverse element of the Euler function value of the fifth integer for the first product based on the Euler function value of the fifth integer and the first product; calculating a second modulo-inverse of the Euler function value of the sixth integer for the second product based on the Euler function value of the sixth integer for the second product;
the key generation device is further used for taking the first modulo-inverse element and the second modulo-inverse element as a private key pair corresponding to the public key, wherein the first modulo-inverse element is a decryption private key, and the second modulo-inverse element is a test private key.
The embodiment of the invention has the beneficial effects that:
according to the ciphertext equivalent test method, device, electronic equipment, storage medium and system provided by the embodiment of the invention, after the first ciphertext to be tested, the test private key of the first ciphertext, the second ciphertext to be tested and the test private key of the second ciphertext are obtained, the second ciphertext segment and the fifth ciphertext segment of the first ciphertext are firstly extracted from the first ciphertext, and the second ciphertext segment and the fifth ciphertext segment of the second ciphertext are extracted from the second ciphertext; then determining a test character string corresponding to the first ciphertext based on the second ciphertext segment of the first ciphertext, the fifth ciphertext segment of the first ciphertext, and a test private key corresponding to the first ciphertext; and determining a test character string corresponding to the second ciphertext based on the second ciphertext segment of the second ciphertext, the fifth ciphertext segment of the second ciphertext, and a test private key corresponding to the second ciphertext; converting the test character string corresponding to the first ciphertext into a first coordinate point in a preset coordinate system; converting the test character string corresponding to the second ciphertext into a second coordinate point in a preset coordinate system; finally, determining that the plaintext corresponding to the first ciphertext is identical to the plaintext corresponding to the second ciphertext when the first slope of the straight line formed by the first coordinate point and the coordinate origin of the preset coordinate system is identical to the second slope of the straight line formed by the second coordinate point and the coordinate origin of the preset coordinate system; otherwise, determining that the plaintext corresponding to the first ciphertext is different from the plaintext corresponding to the second ciphertext. The first ciphertext and the second ciphertext are obtained by encrypting the corresponding plaintext respectively based on the point on the same straight line as the corresponding plaintext in the preset rectangular coordinate system and the public key pair of the corresponding plaintext respectively, and the straight line passes through the origin of coordinates of the preset rectangular coordinate system; therefore, when the first slope is the same as the second slope, it can be explained that the straight line formed by the plaintext corresponding to the first ciphertext and the straight line formed by the plaintext corresponding to the second ciphertext are the same straight line; thus, it can be determined that the plaintext corresponding to the first ciphertext is identical to the plaintext corresponding to the second ciphertext. Therefore, whether the plaintext corresponding to the ciphertext is the same or not can be determined on the premise that the ciphertext is not decrypted. Of course, not all of the above-described advantages need be achieved simultaneously in the practice of any one product or method of the present invention.
Drawings
In order to more clearly illustrate the embodiments of the invention or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, it being obvious that the drawings in the following description are only some embodiments of the invention, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic flow chart of a ciphertext equivalent test method according to an embodiment of the invention;
FIG. 2 is a schematic diagram of a flow chart for encrypting a plaintext in a ciphertext equivalent test method according to an embodiment of the present invention;
FIG. 3 is a schematic flow chart of generating a public key pair in a ciphertext equivalent test method according to an embodiment of the invention;
FIG. 4 is a schematic diagram of a ciphertext equivalent test apparatus according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of an encryption device according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of a key generating device according to an embodiment of the present invention;
fig. 7 is a schematic structural diagram of an electronic device according to an embodiment of the present invention;
fig. 8 is a schematic structural diagram of a ciphertext equivalent test system according to an embodiment of the invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
In order to solve the problems in the prior art, the embodiment of the invention provides a ciphertext equivalent test method, a ciphertext equivalent test device, an electronic device, a storage medium and a ciphertext equivalent test system, so as to determine whether plaintext corresponding to ciphertext is identical or not on the premise of not decrypting ciphertext.
In the following, firstly, a ciphertext equivalent test method according to an embodiment of the present invention is described, as shown in fig. 1, which is a flowchart of a ciphertext equivalent test method according to an embodiment of the present invention, where the method may include:
s110, a first ciphertext to be tested, a test private key of the first ciphertext, a second ciphertext to be tested and a test private key of the second ciphertext are obtained.
The ciphertext is obtained by encrypting the plaintext based on a point which is on the same straight line as the plaintext in a preset rectangular coordinate system and a public key pair of the plaintext, and the straight line passes through a coordinate origin of the preset rectangular coordinate system;
In some examples, the first ciphertext may be obtained by encrypting the plaintext corresponding to the first ciphertext by a point on a straight line formed by the plaintext corresponding to the first ciphertext and a public key pair of the plaintext corresponding to the first ciphertext. The second ciphertext may be obtained by encrypting the plaintext corresponding to the second ciphertext by a pair of a point on a straight line formed by the plaintext corresponding to the second ciphertext and a public key of the plaintext corresponding to the second ciphertext.
S120, extracting a second ciphertext segment and a fifth ciphertext segment of the first ciphertext from the first ciphertext, and extracting the second ciphertext segment and the fifth ciphertext segment of the second ciphertext from the second ciphertext.
In some examples, after obtaining the first ciphertext, the test private key of the first ciphertext, the second ciphertext, and the test private key of the second ciphertext, in order to determine whether the plaintext corresponding to the first ciphertext is identical to the plaintext corresponding to the second ciphertext, the second ciphertext segment and the fifth ciphertext segment of the first ciphertext may be extracted from the first ciphertext, and the second ciphertext segment and the fifth ciphertext segment of the second ciphertext may be extracted from the second ciphertext.
In still other examples, the second ciphertext fragment of the first ciphertext is encrypted using a public key of a plaintext corresponding to the first ciphertext, and the fifth ciphertext fragment of the first ciphertext may be encrypted using a point on a straight line that is formed by the plaintext corresponding to the first ciphertext.
Similarly, the second ciphertext segment of the second ciphertext is encrypted by using a public key of a plaintext corresponding to the second ciphertext, and the fifth ciphertext segment of the second ciphertext may be encrypted by using a point on a straight line formed by the plaintext corresponding to the second ciphertext.
Therefore, in order to determine whether the plaintext corresponding to the first ciphertext and the plaintext corresponding to the second ciphertext are identical, the second ciphertext segment and the fifth ciphertext segment of the first ciphertext and the second ciphertext segment and the fifth ciphertext segment of the second ciphertext may be extracted first.
S130, determining a test character string corresponding to the first ciphertext based on the second ciphertext segment of the first ciphertext, the fifth ciphertext segment of the first ciphertext, and a test private key corresponding to the first ciphertext.
S140, determining a test character string corresponding to the second ciphertext based on the second ciphertext segment of the second ciphertext, the fifth ciphertext segment of the second ciphertext, and the test private key corresponding to the second ciphertext.
S150, converting the test character string corresponding to the first ciphertext into a first coordinate point in a preset coordinate system; and converting the test character string corresponding to the second ciphertext into a second coordinate point in a preset coordinate system.
After the second ciphertext segment and the fifth ciphertext segment of the first ciphertext are extracted, a test character string corresponding to the first ciphertext may be determined based on the second ciphertext segment of the first ciphertext, the fifth ciphertext segment of the first ciphertext, and a test private key corresponding to the first ciphertext.
After the second ciphertext segment and the fifth ciphertext segment of the second ciphertext are extracted, a test string corresponding to the second ciphertext may be determined based on the second ciphertext segment of the second ciphertext, the fifth ciphertext segment of the second ciphertext, and a test private key corresponding to the second ciphertext.
In some examples, when determining the test string corresponding to the first ciphertext based on the second ciphertext fragment of the first ciphertext, the fifth ciphertext fragment of the first ciphertext, and the test private key corresponding to the first ciphertext, the test string corresponding to the first ciphertext may be based on the first ciphertext C 1 Second ciphertext segment C of (2) 1,2 Test private key d corresponding to first ciphertext 1,2 By the following formula:
Figure BDA0002431827540000121
determining a test character string x corresponding to the first ciphertext 1 ||y 1 The method comprises the steps of carrying out a first treatment on the surface of the Wherein the symbols are
Figure BDA0002431827540000122
Representing an exclusive-or operation,
Figure BDA0002431827540000123
representing the first ciphertext C using a fifth hash algorithm 1 First ciphertext segment C 1,1 Second ciphertext segment C 1,2 Third ciphertext segment C 1,3 Fourth ciphertext segment C 1,4 First ciphertext C 1 Second ciphertext segment C of (2) 1,2 D of (2) 1,2 Converting the second power into a character string with a second preset length;
in still other examples, the test string corresponding to the second ciphertext may be based on the second ciphertext C when determining the test string corresponding to the second ciphertext based on the second ciphertext segment of the second ciphertext, the fifth ciphertext segment of the second ciphertext, and the private key corresponding to the second ciphertext 2 Second ciphertext segment C of (2) 2,2 Test private key d corresponding to the second ciphertext 2,2 By the following formula:
Figure BDA0002431827540000124
determining a test character string x corresponding to the second ciphertext 2 ||y 2 The method comprises the steps of carrying out a first treatment on the surface of the Wherein, the liquid crystal display device comprises a liquid crystal display device,
Figure BDA0002431827540000125
representing the second ciphertext C using a fifth hash algorithm 2 First ciphertext segment C 2,1 Second ciphertext segment C 2,2 Third ciphertext segment C 2,3 Fourth ciphertext segment C 2,4 Second ciphertext C 2 Second ciphertext segment C of (2) 2,2 D of (2) 2,2 To the power, converting the character string into a character string with a second preset length.
In still other examples, the first ciphertext and the second ciphertext are each a string.
In yet other examples, the fifth hash algorithm may be expressed as: h 5 :{0,1} 5k →{0,1} 2l Where k denotes a security parameter and l denotes a length, i.e. the fifth hash algorithm denotes converting a string of length 5k containing 0 and 1 into a string of length 2 l.
Respectively obtaining test character strings x corresponding to the first ciphertext 1 ||y 1 Test character string x corresponding to second ciphertext 2 ||y 2 After that, the test character string x corresponding to the first ciphertext can be used for 1 ||y 1 Converting the test character string into a first coordinate point in a preset coordinate system, and converting the test character string x corresponding to the second ciphertext 2 ||y 2 Converting into a second coordinate point in a preset coordinate system;
in some examples, x in the first coordinate point 1 And y 1 Test character string x corresponding to the first ciphertext 1 ||y 1 The length of the test strings is the same, so that the test strings x corresponding to the first ciphertext 1 ||y 1 Is split into two parts to obtain a first coordinate point (x 1 ,y 1 ). When the first coordinate point is a plaintext corresponding to the encrypted first ciphertext, the plaintext corresponding to the first ciphertext is at a point on the same straight line in a preset rectangular coordinate system; that is, the first coordinate point is a coordinate point used when encrypting a plaintext corresponding to the first ciphertext.
Likewise, x in the second coordinate point 2 And y 2 Test character string x corresponding to the second ciphertext 2 ||y 2 The length of the test string x corresponding to the second ciphertext is the same as the first test string x 2 ||y 2 Is split into two parts, so that a second coordinate point (x 2 ,y 2 ) The second coordinate point is a coordinate point used when encrypting a plaintext corresponding to the second ciphertext.
It will be appreciated that step S130 and step S140 may be performed simultaneously or sequentially, respectively, as may be appropriate.
S160, judging whether a first slope of a straight line formed by the first coordinate point and the coordinate origin of the preset coordinate system is the same as a second slope of a straight line formed by the second coordinate point and the coordinate origin of the preset coordinate system, if so, executing the step S170, otherwise, executing the step S180;
S170, determining that the plaintext corresponding to the first ciphertext is identical to the plaintext corresponding to the second ciphertext;
s180, determining that the plaintext corresponding to the first ciphertext is different from the plaintext corresponding to the second ciphertext.
The ciphertext is obtained by encrypting the plaintext based on a point which is on the same straight line as the plaintext in a preset rectangular coordinate system and a public key pair of the plaintext, and the straight line passes through a coordinate origin of the preset rectangular coordinate system;
therefore, if the plaintext corresponding to the first ciphertext is identical to the plaintext corresponding to the second ciphertext, the point used when encrypting the plaintext must be on the same straight line, and since the straight line passes through the origin of coordinates of the preset rectangular coordinate system; therefore, when the first slope corresponding to the first coordinate point is the same as the second slope corresponding to the second coordinate point, it can be explained that the plaintext corresponding to the first ciphertext is the same as the plaintext corresponding to the second ciphertext.
Therefore, when the first coordinate point (x 1 ,y 1 ) A second coordinate point (x 2 ,y 2 ) Then, a first slope of a straight line formed by the first coordinate point and the coordinate origin of the preset coordinate system can be calculated, then a second slope of a straight line formed by the second coordinate point and the coordinate origin of the preset coordinate system can be calculated, and finally whether the plaintext corresponding to the first ciphertext is identical to the plaintext corresponding to the second ciphertext can be determined by judging whether the first slope is identical to the second slope.
The ciphertext equivalent test method provided by the embodiment of the invention can be used for firstly extracting the second ciphertext segment and the fifth ciphertext segment of the first ciphertext from the first ciphertext after acquiring the first ciphertext to be tested, the test private key of the first ciphertext, the second ciphertext to be tested and the test private key of the second ciphertext, and extracting the second ciphertext segment and the fifth ciphertext segment of the second ciphertext from the second ciphertext; then determining a test character string corresponding to the first ciphertext based on the second ciphertext segment of the first ciphertext, the fifth ciphertext segment of the first ciphertext, and a test private key corresponding to the first ciphertext; and determining a test character string corresponding to the second ciphertext based on the second ciphertext segment of the second ciphertext, the fifth ciphertext segment of the second ciphertext, and a test private key corresponding to the second ciphertext; converting the test character string corresponding to the first ciphertext into a first coordinate point in a preset coordinate system; converting the test character string corresponding to the second ciphertext into a second coordinate point in a preset coordinate system; finally, determining that the plaintext corresponding to the first ciphertext is identical to the plaintext corresponding to the second ciphertext when the first slope of the straight line formed by the first coordinate point and the coordinate origin of the preset coordinate system is identical to the second slope of the straight line formed by the second coordinate point and the coordinate origin of the preset coordinate system; otherwise, determining that the plaintext corresponding to the first ciphertext is different from the plaintext corresponding to the second ciphertext. The first ciphertext and the second ciphertext are obtained by encrypting the corresponding plaintext respectively based on the point on the same straight line as the corresponding plaintext in the preset rectangular coordinate system and the public key pair of the corresponding plaintext respectively, and the straight line passes through the origin of coordinates of the preset rectangular coordinate system; therefore, when the first slope is the same as the second slope, it can be explained that the straight line formed by the plaintext corresponding to the first ciphertext and the straight line formed by the plaintext corresponding to the second ciphertext are the same straight line; thus, it can be determined that the plaintext corresponding to the first ciphertext is identical to the plaintext corresponding to the second ciphertext. Therefore, whether the plaintext corresponding to the ciphertext is the same or not can be determined on the premise that the ciphertext is not decrypted.
In some examples, when encrypting a plaintext to obtain a ciphertext based on a public key pair of the plaintext and a point of the plaintext on the same straight line in a preset rectangular coordinate system, as shown in fig. 2, a possible implementation manner is further provided in the embodiment of the present invention, which is a schematic flow diagram of encrypting the plaintext in a ciphertext equivalent test method according to the embodiment of the present invention, where the encryption flow may be applied to encrypting the plaintext corresponding to the first ciphertext or encrypting the plaintext corresponding to the second ciphertext. Referring to fig. 2, the method may include:
s210, acquiring a plaintext to be encrypted and a public key pair used for encrypting the plaintext; wherein, the plaintext is a character string;
s220, carrying out hash operation on the plaintext by adopting a first hash algorithm and a second hash algorithm which are determined in advance, so as to obtain a first integer and a second integer corresponding to the plaintext;
wherein the first hash algorithm and the second hash algorithm are used to convert the character string into an integer. In some examples, the first hash algorithm and the second hash algorithm may be expressed as: h 1 ,H 2 :{0,1} k The character string of length k containing 0 and 1 is converted into an integer Z.
S230, taking the first integer and the second integer as first coordinate points in a rectangular coordinate system, and determining a straight line where the coordinate points are located based on the first coordinate points and coordinate origins in the rectangular coordinate system;
For example, assuming that the plaintext to be encrypted is M, a first hash algorithm may be used to perform hash operation on the plaintext M to obtain a first integer H corresponding to the plaintext M 1 (M) carrying out hash operation on the plaintext M by adopting a second hash algorithm to obtain a second integer H corresponding to the plaintext M 2 (M) and thus a first coordinate point p can be obtained 1 =(H 1 (M),H 2 (M))。
After the first coordinate point is obtained, a straight line where the first coordinate point is located can be obtained based on the first coordinate point and the origin of coordinates in the rectangular coordinate system, and the equation of the straight line is that
Figure BDA0002431827540000151
/>
S240, selecting a second coordinate point except the first coordinate point in the straight line; splicing the two values in the second coordinate point to obtain a spliced character string;
after the straight line where the first coordinate point is located is obtained, a coordinate point other than the first coordinate point may be selected as the second coordinate point on the straight line. In this way, the second coordinate point and the first coordinate point can be made to be on the same straight line. For example, assume that the selected second coordinate point is (x 1 ,y 1 ) Then the two values in the second coordinate point can be spliced, so that the spliced character string x can be obtained 1 ||y 1
S250, obtaining a third integer and a fourth integer which are randomly selected; encrypting the third integer by adopting a first public key in the public key pair to obtain a first ciphertext segment; encrypting the fourth integer by adopting a second public key in the public key pair to obtain a second ciphertext segment;
In some examples, assume that the third integer is r 1 The fourth integer is r 2 The first public key in the public key pair is e 1 The second public key is e 2 The method comprises the steps of carrying out a first treatment on the surface of the Then the first public key e of the public key pair may be employed 1 By the following formula
Figure BDA0002431827540000152
For the third integer r 1 Encrypting to obtain a first ciphertext segment C 1 The method comprises the steps of carrying out a first treatment on the surface of the Using the second public key e of the public key pair 2 By the following formula->
Figure BDA0002431827540000153
For the fourth integer r 2 Encrypting to obtain a second ciphertext segment C 2
S260, converting the third integer into a random number by adopting a third hash algorithm, and carrying out exclusive OR operation on the plaintext by adopting the random number to obtain a third ciphertext segment;
in some examples, the following formula may be used:
Figure BDA0002431827540000154
obtaining a third ciphertext segment C 3 The method comprises the steps of carrying out a first treatment on the surface of the Wherein M is plaintext, H 3 (r 1 ) To apply the third hash algorithm to the third integer r 1 Converted into random numbers.
In yet other examples, the third hash algorithm may be expressed as: h 3 :{0,1} k →{0,1} k That is, a character string of length k including 0 and 1 is converted into a random number of length k.
S270, converting the plaintext and the third integer into a character string with a first preset length by adopting a fourth hash algorithm to obtain a fourth ciphertext segment;
in some examples, the formula C may be used 4 =H 4 (M,r 1 ) Obtaining a fourth ciphertext segment C 4 Wherein H is 4 (M,r 1 ) Representing the plaintext M and the third integer r using a fourth hash algorithm 1 And converting the character string into a character string with a first preset length. In still other examples, the fourth hash algorithm may be expressed as: h 4 :{0,1} 2k →{0,1} k That is, a character string of length 2k including 0 and 1 is converted into a character string of length k.
S280, converting the fourth integer, the first ciphertext segment, the second ciphertext segment, the third ciphertext segment and the fourth ciphertext segment into character strings with a second preset length by adopting a fifth hash algorithm, and performing exclusive-or operation on the character strings with the second preset length and the spliced character strings to obtain a fifth ciphertext segment;
in some examples, the fourth integer r may be used 2 First ciphertext segment C 1 Second ciphertext segment C 2 Third ciphertext segment C 3 Fourth ciphertext segment C 4 Spliced character string x 1 ||y 1 By the following formula:
Figure BDA0002431827540000161
obtaining a fifth ciphertext segment C 5 . Wherein H is 5 (r 2 ,C 1 ,C 2 ,C 3 ,C 4 ) Representing the fourth integer r using a fifth hash algorithm 2 First ciphertext segment C 1 Second ciphertext segment C 2 Third ciphertext segment C 3 Fourth ciphertext segment C 4 And converting into a character string with a second preset length.
S290, obtaining ciphertext corresponding to the plaintext based on the first ciphertext segment, the second ciphertext segment, the third ciphertext segment, the fourth ciphertext segment and the fifth ciphertext segment.
After the five ciphertext segments are obtained, the ciphertext corresponding to the plaintext can be obtained by splicing the first ciphertext segment, the second ciphertext segment, the third ciphertext segment, the fourth ciphertext segment and the fifth ciphertext segment, so that the plaintext can be encrypted.
By the encryption mode of the embodiment of the invention, the ciphertext has the point on the straight line where the corresponding plaintext is located, and whether the plaintext corresponding to the two ciphers is the same or not can be determined by judging the points in the two ciphers.
In still other examples, when the first ciphertext and the second ciphertext are obtained, a ciphertext segment included in the first ciphertext and a ciphertext segment included in the second ciphertext may also be obtained; thus, it is possible to determine which ciphertext segments are included in the first ciphertext and which ciphertext segments are included in the second ciphertext.
In some examples, after determining that the plaintext corresponding to the first ciphertext is the same as the plaintext corresponding to the second ciphertext, the first ciphertext or the second ciphertext may be decrypted. Since the plaintext corresponding to the first ciphertext is identical to the plaintext corresponding to the second ciphertext, either one of the two ciphertexts can be decrypted. For example: decrypting the first ciphertext, further for example: the second ciphertext is decrypted.
In some examples, the first ciphertext segment and the third ciphertext segment of the first ciphertext may be extracted from the first ciphertext when decrypting the first ciphertext; decrypting the first ciphertext based on the first ciphertext segment, the third ciphertext segment, and a decryption private key of the first ciphertext in the first ciphertext;
In yet other examples, the first ciphertext fragment and the third ciphertext fragment of the second ciphertext may be extracted from the second ciphertext when decrypting the second ciphertext; and decrypting the second ciphertext based on the first ciphertext fragment, the third ciphertext fragment, and a decryption private key of the second ciphertext in the second ciphertext.
For example, assume that the ciphertext is ct= (C 1 ,C 2 ,C 3 ,C 4 ,C 5 ) The decryption private key is d 1 Then the formula can be used:
Figure BDA0002431827540000171
obtaining ciphertextAnd the corresponding plaintext realizes decryption of the ciphertext.
Wherein, the liquid crystal display device comprises a liquid crystal display device,
Figure BDA0002431827540000172
representing a first ciphertext segment C of a ciphertext CT using a third hash algorithm 1 D of (2) 1 The power is converted to a random number.
In some examples, when obtaining a public key pair used for encrypting plaintext, the embodiment of the present invention further provides a possible implementation manner, as shown in fig. 3, a flowchart of generating the public key pair in a ciphertext equivalent test method of the embodiment of the present invention may include:
s310, selecting a first prime number pair and a second prime number pair in a preset prime number table;
s320, calculating a first product of two prime numbers in the first prime number pair and an Euler function value of the first product; calculating a second product of the two prime numbers in the second prime number pair and an Euler function value of the second product;
S330, selecting a fifth integer and a sixth integer from a preset integer table, wherein the fifth integer is larger than 1 and smaller than the Euler function value of the first product; and the greatest common divisor of the Euler function value of the fifth integer and the first product is 1; the sixth integer is greater than 1 and less than the Euler function value of the second product; and the greatest common divisor of the Euler function value of the sixth integer and the second product is 1;
and S340, taking the fifth integer and the sixth integer as a public key pair used for encrypting the plaintext.
For example, assume that the first prime pair selected in the preset prime number table is: p is p 1 ,q 1 The second prime number pair is p 2 ,q 2 The following formula can be used:
N 1 =p 1 q 1 ,φ(N 1 )=(p 1 -1)(q 1 -1)
calculating a first prime pair p 1 ,q 1 First product N of two prime numbers in (b) 1 First product N 1 Euler function value of (2)
Figure BDA0002431827540000173
By the following formula:
N 2 =p 2 q 2 ,φ(N 2 )=(p 2 -1)(q 2 -1)
calculating a second prime pair p 2 ,q 2 Second product N of two prime numbers in (B) 2 Second product N 2 Euler function value of (2)
Figure BDA0002431827540000174
Then, a fifth integer and a sixth integer satisfying the condition may be selected based on the euler function value of the first product and the euler function value of the second product, respectively. Finally, the fifth integer and the sixth integer which meet the condition are selected as the public key pair used for encrypting the plaintext.
In some examples, after the fifth integer and the sixth integer are used as the public key pair to encrypt plaintext, a private key pair corresponding to the public key pair may also be determined.
In some examples, a first modulo inverse of the euler function value of the fifth integer for the first product may be calculated based on the euler function value of the fifth integer, the first product; calculating a second modulo-inverse of the Euler function value of the sixth integer for the second product based on the Euler function value of the sixth integer for the second product; and taking the first modulo-inverse element and the second modulo-inverse element as a private key pair corresponding to the public key, wherein the first modulo-inverse element is a decryption private key, and the second modulo-inverse element is a test private key.
In still other examples, the fifth integer e may be based on 1 Euler function value phi (N) of first product 1 ) By the formula:
Figure BDA0002431827540000181
a first modulo inverse d of the Euler function value of the fifth integer for the first product is calculated 1
May be based on a sixth integer e 2 Euler function value of first product
Figure BDA0002431827540000182
By the formula:
Figure BDA0002431827540000183
a second modulo inverse d of the Euler function value of the sixth integer for the second product is calculated 2
And then the first modulo-inverse element d can be used 1 And a second modulo-inverse element d 2 As a private key pair corresponding to the public key, wherein the first modulo inverse element is a decryption private key d 1 Second modulo inverse element d 2 To test the private key.
By the embodiment of the invention, the decryption private key and the test private key are generated, so that different private keys can be used for testing and decrypting respectively, and the ciphertext cannot be decrypted in the testing process, thereby improving the security of the ciphertext.
Corresponding to the above method embodiment, the embodiment of the present invention further provides a ciphertext equivalent testing apparatus, as shown in fig. 4, which is a schematic structural diagram of the ciphertext equivalent testing apparatus according to the embodiment of the present invention, where the apparatus may include:
the obtaining module 410 is configured to obtain a first ciphertext to be tested, a test private key of the first ciphertext, a second ciphertext to be tested, and a test private key of the second ciphertext, where the ciphertext is obtained by encrypting a plaintext based on a point on a same straight line as a plaintext in a preset rectangular coordinate system and a public key pair of the plaintext, and the straight line passes through a coordinate origin of the preset rectangular coordinate system;
the extraction module 420 is configured to extract a second ciphertext segment and a fifth ciphertext segment of the first ciphertext from the first ciphertext, and extract the second ciphertext segment and the fifth ciphertext segment of the second ciphertext from the second ciphertext;
the test character string determining module 430 is configured to determine a test character string corresponding to the first ciphertext based on the second ciphertext segment of the first ciphertext, the fifth ciphertext segment of the first ciphertext, and a test private key corresponding to the first ciphertext;
the test character string determining module 430 is further configured to determine a test character string corresponding to the second ciphertext based on the second ciphertext segment of the second ciphertext, the fifth ciphertext segment of the second ciphertext, and a test private key corresponding to the second ciphertext;
The conversion module 440 is configured to convert the test string corresponding to the first ciphertext into a first coordinate point in a preset coordinate system; converting the test character string corresponding to the second ciphertext into a second coordinate point in a preset coordinate system;
the comparison module 450 is configured to determine that the plaintext corresponding to the first ciphertext is identical to the plaintext corresponding to the second ciphertext when the first slope of the line formed by the first coordinate point and the origin of coordinates of the preset coordinate system is identical to the second slope of the line formed by the second coordinate point and the origin of coordinates of the preset coordinate system; otherwise, determining that the plaintext corresponding to the first ciphertext is different from the plaintext corresponding to the second ciphertext.
The ciphertext equivalent testing device provided by the embodiment of the invention can extract the second ciphertext segment and the fifth ciphertext segment of the first ciphertext from the first ciphertext after acquiring the first ciphertext to be tested, the testing private key of the first ciphertext, the second ciphertext to be tested and the testing private key of the second ciphertext, and extract the second ciphertext segment and the fifth ciphertext segment of the second ciphertext from the second ciphertext; then determining a test character string corresponding to the first ciphertext based on the second ciphertext segment of the first ciphertext, the fifth ciphertext segment of the first ciphertext, and a test private key corresponding to the first ciphertext; and determining a test character string corresponding to the second ciphertext based on the second ciphertext segment of the second ciphertext, the fifth ciphertext segment of the second ciphertext, and a test private key corresponding to the second ciphertext; converting the test character string corresponding to the first ciphertext into a first coordinate point in a preset coordinate system; converting the test character string corresponding to the second ciphertext into a second coordinate point in a preset coordinate system; finally, determining that the plaintext corresponding to the first ciphertext is identical to the plaintext corresponding to the second ciphertext when the first slope of the straight line formed by the first coordinate point and the coordinate origin of the preset coordinate system is identical to the second slope of the straight line formed by the second coordinate point and the coordinate origin of the preset coordinate system; otherwise, determining that the plaintext corresponding to the first ciphertext is different from the plaintext corresponding to the second ciphertext. The first ciphertext and the second ciphertext are obtained by encrypting the corresponding plaintext respectively based on the point on the same straight line as the corresponding plaintext in the preset rectangular coordinate system and the public key pair of the corresponding plaintext respectively, and the straight line passes through the origin of coordinates of the preset rectangular coordinate system; therefore, when the first slope is the same as the second slope, it can be explained that the straight line formed by the plaintext corresponding to the first ciphertext and the straight line formed by the plaintext corresponding to the second ciphertext are the same straight line; thus, it can be determined that the plaintext corresponding to the first ciphertext is identical to the plaintext corresponding to the second ciphertext. Therefore, whether the plaintext corresponding to the ciphertext is the same or not can be determined on the premise that the ciphertext is not decrypted.
In some examples, the ciphertext equivalent test apparatus further comprises: a decryption module for: extracting a first ciphertext segment and a third ciphertext segment of the first ciphertext from the first ciphertext; decrypting the first ciphertext based on the first ciphertext segment, the third ciphertext segment, and a decryption private key of the first ciphertext in the first ciphertext;
or alternatively
Extracting a first ciphertext segment and a third ciphertext segment of the second ciphertext from the second ciphertext; and decrypting the second ciphertext based on the first ciphertext fragment, the third ciphertext fragment, and a decryption private key of the second ciphertext in the second ciphertext.
In some examples, the test string determination module 430 is specifically configured to: based on the first ciphertext C 1 Second ciphertext segment C of (2) 1,2 Test private key d corresponding to first ciphertext 1,2 By the following formula:
Figure BDA0002431827540000201
determining a test character string x corresponding to the first ciphertext 1 ||y 1 The method comprises the steps of carrying out a first treatment on the surface of the Wherein the symbols are
Figure BDA0002431827540000202
Representing an exclusive-or operation,
Figure BDA0002431827540000203
representing the first ciphertext C using a fifth hash algorithm 1 First ciphertext segment C 1,1 Second ciphertext segment C 1,2 Third ciphertext segment C 1,3 Fourth ciphertext segment C 1,4 First ciphertext C 1 Second ciphertext segment C of (2) 1,2 D of (2) 1,2 Converting the second power into a character string with a second preset length;
in some examples, the test string determination module 430 is further to: based on the second ciphertext C 2 Second ciphertext segment C of (2) 2,2 Test private key d corresponding to the second ciphertext 2,2 By the following formula:
Figure BDA0002431827540000204
determining a test character string x corresponding to the second ciphertext 2 ||y 2 The method comprises the steps of carrying out a first treatment on the surface of the Wherein, the liquid crystal display device comprises a liquid crystal display device,
Figure BDA0002431827540000205
representing the second ciphertext C using a fifth hash algorithm 2 First ciphertext segment C 2,1 Second ciphertext segment C 2,2 Third ciphertext segment C 2,3 Fourth ciphertext segment C 2,4 Second ciphertext C 2 Second ciphertext segment C of (2) 2,2 D of (2) 2,2 To the power, converting the character string into a character string with a second preset length. />
On the basis of the ciphertext equivalent test device shown in fig. 4, the embodiment of the invention also provides a structural schematic diagram of an encryption device, as shown in fig. 5, the encryption device may include:
a public key pair obtaining module 510, configured to obtain a plaintext to be encrypted and a public key pair used for encrypting the plaintext; wherein, the plaintext is a character string;
the integer acquisition module 520 is configured to perform a hash operation on the plaintext by using a predetermined first hash algorithm and a predetermined second hash algorithm, so as to obtain a first integer and a second integer corresponding to the plaintext;
the straight line determining module 530 is configured to take the first integer and the second integer as a first coordinate point in the rectangular coordinate system, and determine a straight line where the coordinate point is located based on the first coordinate point and a coordinate origin in the rectangular coordinate system;
A stitching module 540, configured to select a second coordinate point other than the first coordinate point in the straight line; splicing the two values in the second coordinate point to obtain a spliced character string;
a ciphertext block acquisition module 550 for acquiring the randomly selected third integer and fourth integer; encrypting the third integer by adopting a first public key in the public key pair to obtain a first ciphertext segment; encrypting the fourth integer by adopting a second public key in the public key pair to obtain a second ciphertext segment;
the ciphertext segment obtaining module 550 is further configured to convert the third integer into a random number by using a third hash algorithm, and perform an exclusive-or operation on the plaintext by using the random number to obtain a third ciphertext segment;
the ciphertext segment obtaining module 550 is further configured to convert the plaintext and the third integer into a character string of a first preset length by using a fourth hash algorithm, so as to obtain a fourth ciphertext segment;
the ciphertext segment obtaining module 550 is further configured to convert the fourth integer, the first ciphertext segment, the second ciphertext segment, the third ciphertext segment, and the fourth ciphertext segment into a character string of a second preset length, and perform an exclusive-or operation on the character string of the second preset length and the spliced character string to obtain a fifth ciphertext segment;
The ciphertext obtaining module 560 is configured to obtain a ciphertext corresponding to the plaintext based on the first ciphertext segment, the second ciphertext segment, the third ciphertext segment, the fourth ciphertext segment, and the fifth ciphertext segment.
In the encryption device of the embodiment of the invention, when encrypting the plaintext, the point and the public key pair which are positioned on the same straight line with the plaintext in the preset rectangular coordinate system are used for encrypting, and the straight line passes through the origin of coordinates of the preset rectangular coordinate system, so that the encrypted ciphertext also has the characteristics of the straight line, such as the slope of the straight line and the like. Therefore, when the encrypted ciphertext is tested, whether the plaintext corresponding to the two ciphertexts is identical or not is determined by analyzing whether the characteristics of the two ciphertexts are identical or not, and whether the plaintext corresponding to the ciphertext is identical or not can be determined on the premise that the ciphertext is not decrypted.
On the basis of the encryption device shown in fig. 5, the embodiment of the invention also provides a schematic structural diagram of a key generating device, as shown in fig. 6, the key generating device may include:
a prime number pair selecting module 610, configured to select a first prime number pair and a second prime number pair in a preset prime number table, where the first prime number pair and the second prime number pair respectively include two prime numbers;
A calculation module 620, configured to calculate a first product of two prime numbers in the first prime number pair and an euler function value of the first product; calculating a second product of the two prime numbers in the second prime number pair and an Euler function value of the second product;
the selecting module 630 is configured to select a fifth integer and a sixth integer in a preset integer table, and use the fifth integer and the sixth integer as a public key pair used for encrypting plaintext. Wherein the fifth integer is greater than 1 and less than the Euler function value of the first product; and the greatest common divisor of the Euler function value of the fifth integer and the first product is 1; the sixth integer is greater than 1 and less than the Euler function value of the second product; and the greatest common divisor of the Euler function value of the sixth integer and the second product is 1.
In some examples, the key generation apparatus may further include:
the module inverse element calculation module is used for calculating a first module inverse element of the Euler function value of the fifth integer for the first product based on the Euler function value of the fifth integer and the first product; calculating a second modulo-inverse of the Euler function value of the sixth integer for the second product based on the Euler function value of the sixth integer for the second product;
the private key pair obtaining module is used for taking the first modulo inverse element and the second modulo inverse element as a private key pair corresponding to the public key, wherein the first modulo inverse element is a decryption private key, and the second modulo inverse element is a test private key.
By the embodiment of the invention, the decryption private key and the test private key are generated, so that different private keys can be used for testing and decrypting respectively, and the ciphertext cannot be decrypted in the testing process, thereby improving the security of the ciphertext.
The embodiment of the present invention further provides an electronic device, as shown in fig. 7, including a processor 701, a communication interface 702, a memory 703 and a communication bus 704, where the processor 701, the communication interface 702, and the memory 703 perform communication with each other through the communication bus 704,
a memory 703 for storing a computer program;
the processor 701 is configured to execute the program stored in the memory 703, and implement the following steps:
acquiring a first ciphertext to be tested, a test private key of the first ciphertext, a second ciphertext to be tested and a test private key of the second ciphertext, wherein the ciphertext is obtained by encrypting a plaintext based on a public key pair of a point and the plaintext which are positioned on the same straight line as the plaintext in a preset rectangular coordinate system, and the straight line passes through a coordinate origin of the preset rectangular coordinate system;
extracting a second ciphertext segment and a fifth ciphertext segment of the first ciphertext from the first ciphertext, and extracting the second ciphertext segment and the fifth ciphertext segment of the second ciphertext from the second ciphertext;
Determining a test character string corresponding to the first ciphertext based on the second ciphertext segment of the first ciphertext, the fifth ciphertext segment of the first ciphertext, and a test private key corresponding to the first ciphertext;
determining a test character string corresponding to the second ciphertext based on the second ciphertext segment of the second ciphertext, the fifth ciphertext segment of the second ciphertext, and a test private key corresponding to the second ciphertext;
converting the test character string corresponding to the first ciphertext into a first coordinate point in a preset coordinate system; converting the test character string corresponding to the second ciphertext into a second coordinate point in a preset coordinate system;
determining that plaintext corresponding to the first ciphertext is identical to plaintext corresponding to the second ciphertext when a first slope of a straight line formed by the first coordinate point and a coordinate origin of a preset coordinate system is identical to a second slope of a straight line formed by the second coordinate point and the coordinate origin of the preset coordinate system; otherwise, determining that the plaintext corresponding to the first ciphertext is different from the plaintext corresponding to the second ciphertext.
The communication bus mentioned above for the electronic devices may be a peripheral component interconnect standard (Peripheral Component Interconnect, PCI) bus or an extended industry standard architecture (Extended Industry Standard Architecture, EISA) bus, etc. The communication bus may be classified as an address bus, a data bus, a control bus, or the like. For ease of illustration, the figures are shown with only one bold line, but not with only one bus or one type of bus.
The communication interface is used for communication between the electronic device and other devices.
The Memory may include random access Memory (Random Access Memory, RAM) or may include Non-Volatile Memory (NVM), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the aforementioned processor.
The processor may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; but also digital signal processors (Digital Signal Processing, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
In yet another embodiment of the present invention, a computer readable storage medium is provided, where a computer program is stored, and the steps of the ciphertext equivalence test method according to any one of the embodiments are implemented when the computer program is executed by a processor.
In yet another embodiment of the present invention, a computer program product containing instructions that, when executed on a computer, cause the computer to perform the steps of the ciphertext equivalence test method of any of the embodiments described above is also provided.
The embodiment of the invention also provides a ciphertext equivalent test system, as shown in fig. 8, which comprises: a key generation device 810, an encryption device 820, and a ciphertext equivalent test device 830;
key generation means 810 for generating a public key pair and a private key pair, wherein the private key pair comprises a test private key and a decryption private key;
the encrypting device 820 is configured to perform a hash operation on the plaintext by using a predetermined first hash algorithm and a predetermined second hash algorithm after obtaining the plaintext to be encrypted and a public key pair used for encrypting the plaintext, so as to obtain a first integer and a second integer corresponding to the plaintext;
the encryption device 820 is further configured to determine a straight line where the coordinate point is located based on the first coordinate point and the origin of coordinates in the rectangular coordinate system by using the first integer and the second integer as the first coordinate point in the rectangular coordinate system;
encryption means 820 for selecting a second coordinate point other than the first coordinate point in the straight line; splicing the two values in the second coordinate point to obtain a spliced character string;
Encryption means 820 for obtaining a third integer and a fourth integer selected randomly; encrypting the third integer by adopting a first public key in the public key pair to obtain a first ciphertext segment; encrypting the fourth integer by adopting a second public key in the public key pair to obtain a second ciphertext segment;
the encryption device 820 is further configured to convert the third integer into a random number by using a third hash algorithm, and perform an exclusive-or operation on the plaintext by using the random number to obtain a third ciphertext segment;
the encryption device 820 is further configured to convert the plaintext and the third integer into a character string with a first preset length by using a fourth hash algorithm, so as to obtain a fourth ciphertext segment;
the encryption device 820 is further configured to convert the fourth integer, the first ciphertext fragment, the second ciphertext fragment, the third ciphertext fragment, and the fourth ciphertext fragment into a character string of a second preset length, and perform an exclusive-or operation on the character string of the second preset length and the spliced character string to obtain a fifth ciphertext fragment;
the encryption device 820 is further configured to obtain a ciphertext corresponding to the plaintext based on the first ciphertext segment, the second ciphertext segment, the third ciphertext segment, the fourth ciphertext segment, and the fifth ciphertext segment.
The ciphertext equivalent testing device 830 is configured to obtain a first ciphertext to be tested, a test private key of the first ciphertext, a second ciphertext to be tested, and a test private key of the second ciphertext, where the ciphertext is obtained by encrypting a plaintext based on a point on a same straight line as a plaintext in a preset rectangular coordinate system and a public key pair of the plaintext, and the straight line passes through a coordinate origin of the preset rectangular coordinate system;
The ciphertext equivalent testing device 830 is further configured to extract a second ciphertext segment and a fifth ciphertext segment of the first ciphertext from the first ciphertext, and extract the second ciphertext segment and the fifth ciphertext segment of the second ciphertext from the second ciphertext;
the ciphertext equivalent test device 830 is further configured to determine a test character string corresponding to the first ciphertext based on the second ciphertext segment of the first ciphertext, the fifth ciphertext segment of the first ciphertext, and a test private key corresponding to the first ciphertext;
the ciphertext equivalent test device 830 is further configured to determine a test character string corresponding to the second ciphertext based on the second ciphertext segment of the second ciphertext, the fifth ciphertext segment of the second ciphertext, and a test private key corresponding to the second ciphertext;
the ciphertext equivalent test device 830 is further configured to convert a test string corresponding to the first ciphertext into a first coordinate point in a preset coordinate system; converting the test character string corresponding to the second ciphertext into a second coordinate point in a preset coordinate system;
the ciphertext equivalent test device 830 is further configured to determine that, when a first slope of a line formed by the first coordinate point and a coordinate origin of the preset coordinate system is the same as a second slope of a line formed by the second coordinate point and a coordinate origin of the preset coordinate system, a plaintext corresponding to the first ciphertext is the same as a plaintext corresponding to the second ciphertext; otherwise, determining that the plaintext corresponding to the first ciphertext is different from the plaintext corresponding to the second ciphertext.
In some examples, the key generating device 810 is specifically configured to select a first prime number pair and a second prime number pair in a preset prime number table, where the first prime number pair and the second prime number pair respectively include two prime numbers;
the key generating device 810 is further configured to calculate a first product of two prime numbers in the first prime number pair and an euler function value of the first product; calculating a second product of the two prime numbers in the second prime number pair and an Euler function value of the second product;
the key generating device 810 is further configured to select a fifth integer and a sixth integer in a preset integer table, and use the fifth integer and the sixth integer as a public key pair used for encrypting the plaintext. Wherein the fifth integer is greater than 1 and less than the Euler function value of the first product; and the greatest common divisor of the Euler function value of the fifth integer and the first product is 1; the sixth integer is greater than 1 and less than the Euler function value of the second product; and the greatest common divisor of the Euler function value of the sixth integer and the second product is 1.
The key generating means 810 is further configured to calculate a first modulo-inverse element of the euler function value of the fifth integer for the first product based on the euler function value of the fifth integer and the first product; calculating a second modulo-inverse of the Euler function value of the sixth integer for the second product based on the Euler function value of the sixth integer for the second product;
The key generating device 810 is further configured to use a first modulo inverse element and a second modulo inverse element as a private key pair corresponding to the public key, where the first modulo inverse element is a decryption private key, and the second modulo inverse element is a test private key.
In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, produces a flow or function in accordance with embodiments of the present invention, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions may be stored in or transmitted from one computer-readable storage medium to another, for example, by wired (e.g., coaxial cable, optical fiber, digital Subscriber Line (DSL)), or wireless (e.g., infrared, wireless, microwave, etc.). The computer readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that contains an integration of one or more available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid State Disk (SSD)), etc.
It is noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
In this specification, each embodiment is described in a related manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for apparatus, electronic devices and system embodiments, the description is relatively simple as it is substantially similar to method embodiments, as relevant points are found in the partial description of method embodiments.
The foregoing description is only of the preferred embodiments of the present invention and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims (8)

1. A ciphertext equivalent test method, the method comprising:
acquiring a first ciphertext to be tested, a test private key of the first ciphertext, a second ciphertext to be tested and a test private key of the second ciphertext, wherein the ciphertext is obtained by encrypting a plaintext based on a point on the same straight line as the plaintext in a preset rectangular coordinate system and a public key pair of the plaintext, and the straight line passes through a coordinate origin of the preset rectangular coordinate system;
extracting a second ciphertext segment and a fifth ciphertext segment of the first ciphertext from the first ciphertext, and extracting a second ciphertext segment and a fifth ciphertext segment of the second ciphertext from the second ciphertext;
based on the first ciphertext C 1 Second ciphertext segment C of (2) 1,2 A test private key d corresponding to the first ciphertext 1,2 By the following formula:
Figure FDA0004102421240000011
determining a test character string x corresponding to the first ciphertext 1 ||y 1 The method comprises the steps of carrying out a first treatment on the surface of the Wherein the symbols are
Figure FDA0004102421240000012
Representing an exclusive-or operation of
Figure FDA0004102421240000013
Representing the first ciphertext C using a fifth hash algorithm 1 First ciphertext segment C 1,1 Second ciphertext segment C 1,2 Third ciphertext segment C 1,3 Fourth ciphertext segment C 1,4 The first ciphertext C 1 Is the first of (2)Two ciphertext segments C 1,2 D of (2) 1,2 Converting the second power into a character string with a second preset length;
based on the second ciphertext C 2 Second ciphertext segment C of (2) 2,2 A test private key d corresponding to the second ciphertext 2,2 By the following formula:
Figure FDA0004102421240000014
determining a test character string x corresponding to the second ciphertext 2 ||y 2 The method comprises the steps of carrying out a first treatment on the surface of the Wherein the said
Figure FDA0004102421240000015
Representing the second ciphertext C using a fifth hash algorithm 2 First ciphertext segment C 2,1 Second ciphertext segment C 2,2 Third ciphertext segment C 2,3 Fourth ciphertext segment C 2,4 The second ciphertext C 2 Second ciphertext segment C of (2) 2,2 D of (2) 2,2 Converting the second power into a character string with a second preset length;
converting the test character string corresponding to the first ciphertext into a first coordinate point in a preset coordinate system; converting the test character string corresponding to the second ciphertext into a second coordinate point in the preset coordinate system;
determining that plaintext corresponding to the first ciphertext is identical to plaintext corresponding to the second ciphertext when a first slope of a straight line formed by the first coordinate point and a coordinate origin of the preset coordinate system is identical to a second slope of a straight line formed by the second coordinate point and the coordinate origin of the preset coordinate system; otherwise, determining that the plaintext corresponding to the first ciphertext is different from the plaintext corresponding to the second ciphertext;
The method for encrypting the plaintext to obtain the ciphertext based on the point on the same straight line as the plaintext in the preset rectangular coordinate system and the public key pair of the plaintext comprises the following steps:
acquiring a plaintext to be encrypted and a public key pair used for encrypting the plaintext; wherein the plaintext is a character string;
carrying out hash operation on the plaintext by adopting a first hash algorithm and a second hash algorithm which are determined in advance to obtain a first integer and a second integer corresponding to the plaintext;
taking the first integer and the second integer as first coordinate points in a rectangular coordinate system, and determining a straight line where the coordinate points are located based on the first coordinate points and coordinate origins in the rectangular coordinate system;
selecting a second coordinate point other than the first coordinate point in the straight line; splicing the two values in the second coordinate point to obtain a spliced character string;
acquiring a third integer and a fourth integer which are randomly selected; encrypting the third integer by adopting a first public key in the public key pair to obtain a first ciphertext segment; encrypting the fourth integer by adopting a second public key in the public key pair to obtain a second ciphertext segment;
Converting the third integer into a random number by adopting a third hash algorithm, and performing exclusive-or operation on the plaintext by adopting the random number to obtain a third ciphertext segment;
converting the plaintext and the third integer into a character string with a first preset length by adopting a fourth hash algorithm to obtain a fourth ciphertext segment;
converting the fourth integer, the first ciphertext segment, the second ciphertext segment, the third ciphertext segment and the fourth ciphertext segment into character strings with a second preset length by adopting a fifth hash algorithm, and performing exclusive-or operation on the character strings with the second preset length and the spliced character strings to obtain a fifth ciphertext segment;
and obtaining ciphertext corresponding to the plaintext based on the first ciphertext segment, the second ciphertext segment, the third ciphertext segment, the fourth ciphertext segment and the fifth ciphertext segment.
2. The method of claim 1, wherein the step of obtaining a public key pair used to encrypt the plaintext comprises:
selecting a first prime number pair and a second prime number pair from a preset prime number table, wherein the first prime number pair and the second prime number pair respectively comprise two prime numbers;
calculating a first product of two prime numbers in the first prime number pair and an Euler function value of the first product; calculating a second product of two prime numbers in the second prime number pair and an Euler function value of the second product;
Selecting a fifth integer and a sixth integer from a preset integer table, wherein the fifth integer is larger than 1 and smaller than an Euler function value of the first product; and the greatest common divisor of the Euler function value of the fifth integer and the first product is 1; the sixth integer is greater than 1 and less than the Euler function value of the second product; and the greatest common divisor of the Euler function value of the sixth integer and the second product is 1;
the fifth integer and the sixth integer are used as a public key pair used for encrypting the plaintext.
3. The method of claim 2, wherein after said using said fifth integer and said sixth integer as a public key pair for encrypting said plaintext, said method further comprises:
calculating a first modulo-inverse of the euler function value of the fifth integer for the first product based on the euler function value of the fifth integer and the first product;
calculating a second modulo inverse of the euler function value of the sixth integer for the second product based on the euler function value of the sixth integer and the second product;
and taking the first modulo-inverse element and the second modulo-inverse element as a private key pair corresponding to the public key, wherein the first modulo-inverse element is a decryption private key, and the second modulo-inverse element is a test private key.
4. The method of claim 1, wherein after said determining that the plaintext corresponding to the first ciphertext is identical to the plaintext corresponding to the second ciphertext, the method further comprises:
extracting a first ciphertext segment and a third ciphertext segment of the first ciphertext from the first ciphertext; decrypting the first ciphertext based on the first ciphertext segment, the third ciphertext segment, and a decryption private key of the first ciphertext in the first ciphertext;
or alternatively
Extracting a first ciphertext segment and a third ciphertext segment of the second ciphertext from the second ciphertext; and decrypting the second ciphertext based on the first ciphertext segment, the third ciphertext segment, and a decryption private key of the second ciphertext in the second ciphertext.
5. A ciphertext equivalent test apparatus, the apparatus comprising:
the acquisition module is used for acquiring a first ciphertext to be tested, a test private key of the first ciphertext, a second ciphertext to be tested and a test private key of the second ciphertext, wherein the ciphertext is obtained by encrypting a plaintext based on a point on the same straight line as the plaintext in a preset rectangular coordinate system and a public key pair of the plaintext, and the straight line passes through a coordinate origin of the preset rectangular coordinate system;
The extraction module is used for extracting a second ciphertext segment and a fifth ciphertext segment of the first ciphertext from the first ciphertext, and extracting the second ciphertext segment and the fifth ciphertext segment of the second ciphertext from the second ciphertext;
test character string determining module for
Based on the first ciphertext C 1 Second ciphertext segment C of (2) 1,2 A test private key d corresponding to the first ciphertext 1,2 By the following formula:
Figure FDA0004102421240000041
determining a test character string x corresponding to the first ciphertext 1 ||y 1 The method comprises the steps of carrying out a first treatment on the surface of the Wherein the symbols are
Figure FDA0004102421240000042
Representing an exclusive-or operation of
Figure FDA0004102421240000043
Representing the first ciphertext C using a fifth hash algorithm 1 First ciphertext segment C 1,1 Second ciphertext segment C 1,2 Third ciphertext segment C 1,3 Fourth ciphertext segment C 1,4 The first ciphertext C 1 Second ciphertext segment C of (2) 1,2 D of (2) 1,2 Converting the second power into a character string with a second preset length;
the test character string determining module is also used for
Based on the second ciphertext C 2 Second ciphertext segment C of (2) 2,2 A test private key d corresponding to the second ciphertext 2,2 By the following formula:
Figure FDA0004102421240000044
determining a test character string x corresponding to the second ciphertext 2 ||y 2 The method comprises the steps of carrying out a first treatment on the surface of the Wherein the said
Figure FDA0004102421240000045
Representing the second ciphertext C using a fifth hash algorithm 2 First ciphertext segment C 2,1 Second ciphertext segment C 2,2 Third ciphertext segment C 2,3 Fourth ciphertext segment C 2,4 The second ciphertext C 2 Second ciphertext segment C of (2) 2,2 D of (2) 2,2 Converting the second power into a character string with a second preset length;
the conversion module is used for converting the test character string corresponding to the first ciphertext into a first coordinate point in a preset coordinate system; converting the test character string corresponding to the second ciphertext into a second coordinate point in the preset coordinate system;
the comparison module is used for determining that the plaintext corresponding to the first ciphertext is identical to the plaintext corresponding to the second ciphertext when the first slope of the straight line formed by the first coordinate point and the coordinate origin of the preset coordinate system is identical to the second slope of the straight line formed by the second coordinate point and the coordinate origin of the preset coordinate system; otherwise, determining that the plaintext corresponding to the first ciphertext is different from the plaintext corresponding to the second ciphertext;
the public key pair acquisition module is used for acquiring a plaintext to be encrypted and a public key pair used for encrypting the plaintext; wherein the plaintext is a character string;
the integer acquisition module is used for carrying out hash operation on the plaintext by adopting a first hash algorithm and a second hash algorithm which are determined in advance to obtain a first integer and a second integer corresponding to the plaintext;
The straight line determining module is used for taking the first integer and the second integer as first coordinate points in a rectangular coordinate system and determining a straight line where the coordinate points are located based on the first coordinate points and coordinate origins in the rectangular coordinate system;
a splicing module, configured to select a second coordinate point other than the first coordinate point in the straight line; splicing the two values in the second coordinate point to obtain a spliced character string;
the ciphertext segment acquisition module is used for acquiring a third integer and a fourth integer which are randomly selected; encrypting the third integer by adopting a first public key in the public key pair to obtain a first ciphertext segment; encrypting the fourth integer by adopting a second public key in the public key pair to obtain a second ciphertext segment;
the ciphertext segment acquisition module is further configured to convert the third integer into a random number by using a third hash algorithm, and perform an exclusive-or operation on the plaintext by using the random number to obtain a third ciphertext segment;
the ciphertext segment acquisition module is further used for converting the plaintext and the third integer into a character string with a first preset length by adopting a fourth hash algorithm to obtain a fourth ciphertext segment;
The ciphertext segment acquisition module is further configured to convert the fourth integer, the first ciphertext segment, the second ciphertext segment, the third ciphertext segment, and the fourth ciphertext segment into a character string of a second preset length, and perform an exclusive-or operation on the character string of the second preset length and the spliced character string to obtain a fifth ciphertext segment;
the ciphertext obtaining module is configured to obtain a ciphertext corresponding to the plaintext based on the first ciphertext segment, the second ciphertext segment, the third ciphertext segment, the fourth ciphertext segment, and the fifth ciphertext segment.
6. The electronic equipment is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the communication bus;
a memory for storing a computer program;
a processor for carrying out the method steps of any one of claims 1-4 when executing a program stored on a memory.
7. A computer-readable storage medium, characterized in that the computer-readable storage medium has stored therein a computer program which, when executed by a processor, implements the method steps of any of claims 1-4.
8. A ciphertext equivalent test system, the test system comprising at least: the ciphertext equivalent test apparatus of claim 5.
CN202010238607.9A 2020-03-30 2020-03-30 Ciphertext equivalent test method, ciphertext equivalent test device, electronic equipment, storage medium and ciphertext equivalent test system Active CN111447059B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010238607.9A CN111447059B (en) 2020-03-30 2020-03-30 Ciphertext equivalent test method, ciphertext equivalent test device, electronic equipment, storage medium and ciphertext equivalent test system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010238607.9A CN111447059B (en) 2020-03-30 2020-03-30 Ciphertext equivalent test method, ciphertext equivalent test device, electronic equipment, storage medium and ciphertext equivalent test system

Publications (2)

Publication Number Publication Date
CN111447059A CN111447059A (en) 2020-07-24
CN111447059B true CN111447059B (en) 2023-04-28

Family

ID=71651194

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010238607.9A Active CN111447059B (en) 2020-03-30 2020-03-30 Ciphertext equivalent test method, ciphertext equivalent test device, electronic equipment, storage medium and ciphertext equivalent test system

Country Status (1)

Country Link
CN (1) CN111447059B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112347498B (en) * 2020-12-01 2022-10-28 南阳理工学院 Encryption method, encryption device, electronic equipment and readable storage medium
CN112580071B (en) * 2020-12-09 2024-05-14 深圳前海微众银行股份有限公司 Data processing method and device
CN115378666A (en) * 2022-08-04 2022-11-22 山东大学 Public key encryption method and system supporting outsourced ciphertext data equality test

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2001042767A (en) * 1999-07-27 2001-02-16 Kanazawa Inst Of Technology Method and device for evaluating secrecy safety of secret key in public key ciphering system
CN109981265B (en) * 2019-03-12 2021-09-24 武汉大学 Identity-based ciphertext equivalence determination method without using bilinear pairings

Also Published As

Publication number Publication date
CN111447059A (en) 2020-07-24

Similar Documents

Publication Publication Date Title
CN112347498B (en) Encryption method, encryption device, electronic equipment and readable storage medium
CN111447059B (en) Ciphertext equivalent test method, ciphertext equivalent test device, electronic equipment, storage medium and ciphertext equivalent test system
US20220141038A1 (en) Method of rsa signature or decryption protected using a homomorphic encryption
JP6058237B1 (en) Ciphertext conversion apparatus, ciphertext conversion program, and ciphertext conversion method
WO2019114122A1 (en) Encryption method for login information, device, electronic device, and medium
JP2008203548A (en) Key generating method using quadric hyperbolic curve group, decoding method, signature verification method, key stream generating method and device
Gafsi et al. Efficient encryption system for numerical image safe transmission
JP6305638B2 (en) Cryptographic system and key generation device
US20220012186A1 (en) Diversifying a base symmetric key based on a public key
JP2012080152A (en) Encryption system, encryption apparatus, decryption apparatus, encryption system program and encryption method
CN117220865A (en) Longitude and latitude encryption method, longitude and latitude verification device and readable storage medium
JP6719339B2 (en) Cryptographic system, cryptographic method, and cryptographic program
US8954728B1 (en) Generation of exfiltration-resilient cryptographic keys
CN114268447B (en) File transmission method and device, electronic equipment and computer readable medium
CN115632782B (en) Random number generation method, system and equipment based on SM4 counter mode
CN112906059B (en) Proxy signature and verification method, device, system and storage medium
JP2010258708A (en) Information processing device, operation verifying method, and program
JP5945525B2 (en) KEY EXCHANGE SYSTEM, KEY EXCHANGE DEVICE, ITS METHOD, AND PROGRAM
CN111885056A (en) Zero knowledge proving method and device based on block chain and electronic equipment
JP5103407B2 (en) Encrypted numerical binary conversion system, encrypted numerical binary conversion method, encrypted numerical binary conversion program
CN111611595B (en) Data encryption method and device
KR102236242B1 (en) Method for Generating Public Value Using Fuzzy Extractor and Generating Secret Key Using the same Public Value and Second Input
CN115606148A (en) Information leakage mitigation associated with elliptic curve operation
RU2774807C2 (en) Homomorphous encryption for authentication using password
KR20240048985A (en) method for generating homo encrypted message and apparatus for thereof

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20231225

Address after: No. 3605, Floor 5, Building 3, Micro World, Century Avenue, Liuwu New District, Lhasa, Xizang Autonomous Region, 850000

Patentee after: Lhasa Koda Technology Co.,Ltd.

Address before: 473004 No. 80 Changjiang Road, Wancheng District, Nanyang City, Henan Province

Patentee before: NANYANG INSTITUTE OF TECHNOLOGY