Disclosure of Invention
The invention provides a block chain-based digital commodity transaction method, a block chain-based digital commodity transaction device and a computer-readable storage medium, and mainly aims to solve the problem of low safety of block chain-based digital commodity transaction.
In order to achieve the above object, the present invention provides a block chain-based digital commodity transaction method, including:
obtaining quantum blocks in a preset time period, and connecting the quantum blocks according to a time sequence to obtain a quantum block chain, wherein the quantum blocks at least comprise two quantum blocks, and the quantum blocks are:
wherein,
represents the first
The expression of the quantum block is shown,
is shown as
A sub-block of quantities,
the number of the quantum blocks is represented,
which represents a pre-set time parameter that is,
representing a preset quantum parameter;
receiving a transaction establishing instruction triggered by a transaction node of the quantum block chain, determining a transaction information transfer user according to the instruction, and generating a pair of quantum keys for the transaction information transfer user based on the quantum block chain, wherein the quantum keys comprise a main public key;
performing hash calculation on the related transaction information of the transaction information transfer user to obtain a transaction hash value, encrypting the transaction hash value and the related transaction information by using a main public key in the quantum key to obtain an encrypted hash value and encrypted related information, and performing information fusion on the encrypted hash value and the encrypted related information to obtain encrypted transaction information;
generating a signature for the encrypted transaction information by using a ring signature algorithm to obtain a transaction ring signature;
performing signature verification on the transaction ring signature, and writing the related transaction information into the quantum block chain when the signature verification is passed;
acquiring commodity information corresponding to the transaction information transfer user prestored in the quantum block chain by the node, and performing zero knowledge certification on the related transaction information and the commodity information so that the miner node of the quantum block chain performs transaction verification according to a zero knowledge certification result;
and when the transaction verification passes, storing a digital commodity transaction success record in the quantum blockchain.
Optionally, the connecting the quantum blocks in time order to obtain a quantum block chain includes:
acquiring a preset quantum block chain structure, and screening out quantum blocks with preset number from the quantum blocks;
randomly combining a preset number of quantum blocks to obtain a plurality of combined quantum blocks, and storing the combined quantum blocks into the quantum block chain structure to obtain a quantum block chain.
Optionally, the preset quantum block chain structure is:
wherein,
it is shown that the chain structure of the quantum blocks,
the number of the quantum blocks is represented,
which represents a pre-set time parameter that is,
is shown as
A quantum block.
Optionally, the generating a pair of quantum keys for the transaction information transfer user based on the quantum block chain includes:
generating a sequence of qubit pairs for the transaction information transfer user using the chain of qubits;
splitting the qubit pair sequence into a first qubit pair subsequence and a second qubit pair subsequence according to a preset splitting rule;
taking the first qubit subsequence as a main public key and the second qubit subsequence as a main private key;
and summarizing the main public key and the main private key to obtain a pair of quantum keys.
Optionally, the signing and generating the encrypted transaction information by using a ring signature algorithm to obtain a transaction ring signature includes:
acquiring a public key set of a preset input ring in the ring signature algorithm, the encrypted transaction information and a quantum key corresponding to the encrypted transaction information;
encrypting the encrypted transaction information again based on the public key set of the preset input ring to obtain double encrypted information;
calculating to obtain a symmetrical value corresponding to the double encryption information through a preset information symmetrical formula and the transaction hash value;
and constructing a multi-element array according to the public key set, the symmetric value and the double encryption information, and taking the multi-element array as the transaction ring signature.
Optionally, the preset information symmetry formula is:
wherein,
for the purpose of the transaction hash value,
for a plurality of double encrypted information, v is a fixed parameter,
and the symmetric value is corresponding to the double encryption information.
Optionally, the signature verification of the transaction ring signature includes:
acquiring a verification data set, wherein the verification data set comprises a verification public key and information to be verified;
encrypting the information to be verified by using the verification public key to obtain encrypted verification information;
inputting the encrypted verification information into the transaction ring signature, and judging that the signature verification is passed when the transaction ring signature is established;
and inputting the encryption verification information into the transaction ring signature, and judging that the signature verification is not passed when the transaction ring signature is not established.
Optionally, the performing zero-knowledge proof on the related transaction information and the commodity information includes:
acquiring a preset certification function, and performing binding verification processing on the related transaction information and the encrypted transaction information by using the certification function to obtain a first binding verification result;
if the first binding verification result is that the verification is passed, the certification function is used for carrying out binding verification processing on the commodity information and the encrypted commodity information to obtain a second binding verification result;
if the second binding verification result is that the verification is passed, calculating cosine similarity between the encrypted transaction information and the encrypted commodity information by using a cosine similarity formula;
when the cosine similarity is smaller than a preset similarity threshold, judging that the zero knowledge proof fails;
and when the cosine similarity is greater than or equal to the similarity threshold, judging that the zero knowledge proof is successful.
Optionally, the performing, by using the attestation function, binding verification processing on the related transaction information and the encrypted transaction information to obtain a first binding verification result includes:
generating certification processing is carried out on the related transaction information and the encrypted transaction information by using a preset certification generating function to obtain a certification;
and inputting the generation certification and the related transaction information into a verification certification function to obtain a first binding verification result.
In order to solve the above problems, the present invention also provides a block chain-based digital goods transaction apparatus, comprising:
the system comprises a block chain construction module, a quantum block chain construction module and a transaction information transfer module, wherein the block chain construction module is used for acquiring quantum blocks in a preset time period, connecting the quantum blocks according to a time sequence to obtain a quantum block chain, the quantum blocks at least comprise two quantum blocks, receiving a transaction establishment instruction triggered by a transaction node of the quantum block chain, determining a transaction information transfer user according to the instruction, and generating a pair of quantum keys for the transaction information transfer user based on the quantum block chain, and the quantum keys comprise main public keys;
the transaction information encryption module is used for carrying out hash calculation on the related transaction information of the transaction information transfer user to obtain a transaction hash value, carrying out encryption processing on the transaction hash value and the related transaction information by using a main public key in the quantum key to obtain an encrypted hash value and encrypted related information, and carrying out information fusion on the encrypted hash value and the encrypted related information to obtain encrypted transaction information;
the signature verification module is used for generating a signature for the encrypted transaction information by using a ring signature algorithm to obtain a transaction ring signature, performing signature verification on the transaction ring signature, and writing the related transaction information into the quantum block chain when the signature verification is passed;
and the transaction verification module is used for acquiring commodity information corresponding to the transaction information transfer user prestored in the quantum block chain by the node, performing zero knowledge certification on the related transaction information and the commodity information so as to ensure that the miner node of the quantum block chain performs transaction verification according to the result of the zero knowledge certification, and storing a digital commodity transaction success record in the quantum block chain when the transaction verification is passed.
In order to solve the above problem, the present invention also provides an electronic device, including:
a memory storing at least one instruction; and
and the processor executes the instructions stored in the memory to realize the block chain-based digital commodity transaction method.
In order to solve the above problem, the present invention further provides a computer-readable storage medium, which stores at least one instruction, where the at least one instruction is executed by a processor in an electronic device to implement the above block chain-based digital goods transaction method.
In the embodiment of the invention, quantum blocks are connected according to the time sequence to obtain the quantum block chain, and the quantum block chain can resist the risk of counterfeiting, provide strong safety protection for block chain users and resist quantum computation attack. The related transaction information is encrypted, the data security is protected, the problem of information leakage caused by commodity transaction on a quantum block chain by directly utilizing a plaintext is solved, zero knowledge certification is carried out on the related transaction information and the commodity information, the verification of the digital commodity transaction is guaranteed to be a verifiable process, and the verification process of the digital commodity transaction is more transparent and visual. Therefore, the block chain-based digital commodity transaction method, the block chain-based digital commodity transaction device, the electronic equipment and the computer-readable storage medium can solve the problem of low safety of digital commodity transaction.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The embodiment of the invention provides a block chain-based digital commodity transaction method. The execution subject of the block chain-based digital commodity transaction method includes, but is not limited to, at least one of a server, a terminal, and the like that can be configured to execute the method provided by the embodiment of the present invention. In other words, the blockchain-based digital goods transaction method may be performed by software or hardware installed in a terminal device or a server device, and the software may be a blockchain platform. The server includes but is not limited to: a single server, a server cluster, a cloud server or a cloud server cluster, and the like.
Referring to fig. 1, a flow chart of a block chain-based digital commodity transaction method according to an embodiment of the present invention is shown. In this embodiment, the block chain-based digital commodity transaction method includes:
and S1, obtaining quantum blocks in a preset time period, and connecting the quantum blocks according to a time sequence to obtain a quantum block chain, wherein the quantum blocks at least comprise two quantum blocks.
In the embodiment of the present invention, useful quantum data is stored in the quantum blocks, and a plurality of quantum blocks may be connected by adopting a quantum entanglement state in time to obtain a quantum block chain. Compared with the prior block chain technology, the quantum block chain is based on the quantum unclonable principle, so that the risk of counterfeiting can be resisted, and meanwhile, the quantum block chain combines the quantum password and the quantum principle, so that strong safety protection is provided for block chain users, and quantum computing attack can be resisted.
In detail, the quantum block comprises at least two quantum blocks, wherein the quantum blocks are:
wherein,
represents the first
The expression of the quantum block is shown,
is shown as
A sub-block of quantities,
the number of the quantum blocks is represented,
which is indicative of a pre-set time parameter,
representing a preset quantum parameter.
E.g. by analogy, the first
The quantum block is
The quantum block at least comprises two quantum blocks, namely the quantum block
And quantum block
。
Specifically, the connecting the quantum blocks according to the time sequence to obtain a quantum block chain includes:
acquiring a preset quantum block chain structure, and screening out a preset number of quantum blocks from the quantum blocks;
randomly combining a preset number of quantum blocks to obtain a plurality of combined quantum blocks, and storing the combined quantum blocks into the quantum block chain structure to obtain a quantum block chain.
In detail, the preset number is selected differently according to a specific scheme, and quantum blocks with the preset number are combined with the quantum block chain structure to obtain a quantum block chain.
Further, the preset quantum block chain structure is as follows:
wherein,
it is shown that the chain structure of the quantum blocks,
the number of the quantum blocks is represented,
which represents a pre-set time parameter that is,
is shown as
A quantum block.
For example, assume that the first three quantum blocks are respectively
,
And
generating the quantum block chain structure by the quantum block chain structure
。
S2, receiving a transaction establishing instruction triggered by a transaction node of the quantum block chain, determining a transaction information transfer user according to the instruction, and generating a pair of quantum keys for the transaction information transfer user based on the quantum block chain, wherein the quantum keys comprise a master public key.
In the embodiment of the present invention, the transaction node refers to a certain client or server accessing the quantum block chain, and the client or server is a system platform for performing business operations in organization structures such as units. The instruction refers to a code which is sent by the node and needs to perform a specific operation. For example, in the embodiment of the present invention, the node represents a transaction party, and the instruction for creating a transaction is an instruction for issuing funds sent by a transaction party to a bank.
Specifically, the instruction is triggered after a node receives an instruction of other nodes. The instruction comprises information about the transaction user, and the transaction information transfer user can be further determined according to the instruction.
Further, the generating a pair of quantum keys for the transaction information transfer user based on the quantum block chain includes:
generating a sequence of qubit pairs for the transaction information transfer user using the chain of qubits;
splitting the qubit pair sequence into a first qubit pair subsequence and a second qubit pair subsequence according to a preset splitting rule;
taking the first qubit pair subsequence as a main public key and the second qubit pair subsequence as a main private key;
and summarizing the main public key and the main private key to obtain a pair of quantum keys.
In detail, a sequence of qubit pairs is generated for the transaction information transferring user using the chain of quantum blocks
The quantum blockchain generates a pair of quantum keys for each user. Splitting the sequence of qubit pairs into a first sequence of qubit pairs according to a preset splitting rule
And a second qubit pair subsequence
. And taking the first qubit subsequence as a main public key and the second qubit subsequence as a main private key.
S3, performing hash calculation on the related transaction information of the transaction information transfer user to obtain a transaction hash value, encrypting the transaction hash value and the related transaction information by using the main public key in the quantum key to obtain an encrypted hash value and encrypted related information, and performing information fusion on the encrypted hash value and the encrypted related information to obtain encrypted transaction information.
In the embodiment of the invention, the preset hash function can be used for carrying out hash calculation on the related transaction information of the transaction information transfer user to obtain the transaction hash value. The preset hash function may be a hash () function.
Specifically, the encrypting the transaction hash value and the related transaction information by using the master public key in the quantum key means that the transaction hash value and the related transaction information are collected, and the collected information is encrypted by using the master public key in the quantum key to obtain encrypted transaction information.
And S4, generating a signature for the encrypted transaction information by using a ring signature algorithm to obtain a transaction ring signature.
In the embodiment of the present invention, the ring signature algorithm is a signature technology, and generally, there is a group of public keys, and a signer knows a private key corresponding to a public key in the group of public keys (only needs to know one public key). This allows a ring signature to be generated using the set of public keys and the corresponding private key. The verifier can verify that the ring signature was indeed generated by the owner of a private key in the set of public keys, but does not know which private key corresponds to which public key.
Specifically, the signing and generating the encrypted transaction information by using a ring signature algorithm to obtain a transaction ring signature includes:
acquiring a public key set of a preset input ring in the ring signature algorithm, the encrypted transaction information and a quantum key corresponding to the encrypted transaction information;
carrying out secondary encryption processing on the encrypted transaction information based on the public key set of the preset input ring to obtain dual encrypted information;
calculating to obtain a symmetrical value corresponding to the double encryption information through a preset information symmetrical formula and the transaction hash value;
and constructing a multi-element array according to the public key set, the symmetric value and the double encryption information, and taking the multi-element array as the transaction ring signature.
In detail, the public key set of the preset input ring comprises a plurality of public keys, for example, the public key is
、
…
The encrypted transaction information is
,
,…,
。
Further, the preset information symmetry formula is as follows:
wherein,
for the purpose of the transaction hash value,
for a plurality of double encrypted information, v is a fixed parameter,
and the symmetric value is corresponding to the double encryption information.
S5, performing signature verification on the transaction ring signature, and writing the relevant transaction information into the quantum block chain when the signature verification is passed.
In an embodiment of the present invention, the signature verification of the transaction ring signature includes:
acquiring a verification data set, wherein the verification data set comprises a verification public key and information to be verified;
encrypting the information to be verified by using the verification public key to obtain encrypted verification information;
inputting the encrypted verification information into the transaction ring signature, and judging that the signature verification is passed when the transaction ring signature is established;
and inputting the encryption verification information into the transaction ring signature, and judging that the signature verification is not passed when the transaction ring signature is not established.
In detail, the verification data set is data proposed for signature verification of the transaction ring signature.
Specifically, when the signature verification passes, the related transaction information is written into the quantum block chain.
S6, commodity information corresponding to the transaction information transfer user pre-stored in the quantitative block chain by the node is obtained, zero knowledge certification is conducted on the related transaction information and the commodity information, and therefore the miner node of the quantitative block chain conducts transaction verification according to the result of the zero knowledge certification.
In the embodiment of the present invention, the commodity information corresponding to the transaction information transfer user refers to the relevant reference information such as the commodity name, the commodity number, and the commodity specification corresponding to the commodity transaction. The Zero-Knowledge Proof (Zero-Knowledge Proof) refers to the prover being able to convince the verifier that some argument is correct without providing the verifier with any useful information. Zero knowledge proof is essentially an agreement involving two or more parties, i.e., a series of steps that are required by two or more parties to complete a task.
Specifically, the zero-knowledge proof of the related transaction information and the commodity information includes:
acquiring a preset certification function, and performing binding verification processing on the related transaction information and the encrypted transaction information by using the certification function to obtain a first binding verification result;
if the first binding verification result is that the verification is passed, the certification function is used for carrying out binding verification processing on the commodity information and the encrypted commodity information to obtain a second binding verification result;
if the second binding verification result is that the verification is passed, calculating cosine similarity between the encrypted transaction information and the encrypted commodity information by using a cosine similarity formula;
when the cosine similarity is smaller than a preset similarity threshold, judging that the zero knowledge proof fails;
and when the cosine similarity is greater than or equal to the similarity threshold, judging that the zero knowledge proof is successful.
Specifically, the binding verification processing of the relevant transaction information and the encrypted transaction information by using the attestation function to obtain a first binding verification result includes:
generating certification processing is carried out on the related transaction information and the encrypted transaction information by using a preset certification generating function to obtain a certification;
and inputting the generation certification and the related transaction information into a verification certification function to obtain a first binding verification result.
The preset certification function comprises a generation certification function and a verification certification function.
In detail, the proof of generation function is pi = Prvoe (x, w), where pi represents proof of generation, x is plaintext, and w is ciphertext, in this embodiment of the present invention, x is the relevant transaction information, w is the encrypted transaction information, the proof of verification function is Yes = Verify (x, pi), Yes is one of the first binding verification results, and generally, the first binding verification result includes Yes and No, Yes represents proof correct and No represents proof error.
Specifically, the calculating the cosine similarity between the encrypted transaction information and the encrypted commodity information by using a cosine similarity formula includes:
wherein,
the similarity between the two signals is a cosine similarity,
、
vectors corresponding to the encrypted transaction information and the encrypted commodity information respectively,
、
respectively, the modulus corresponding to the two vectors.
Further, before the cosine similarity between the encrypted transaction information and the encrypted commodity information is calculated by using a cosine similarity formula, vectorizing the encrypted transaction information and the encrypted commodity information according to a preset word2vec algorithm.
And S7, when the transaction passes the verification, storing a digital commodity transaction success record in the quantum block chain.
In the embodiment of the invention, when the transaction verification is passed, the successful record of the digital commodity transaction is stored in the quantum block chain, so that the digital commodity transaction is realized, and the safety and the accuracy of the record of the digital commodity transaction are improved.
In the embodiment of the invention, quantum blocks are connected according to the time sequence to obtain the quantum block chain, and the quantum block chain can resist the risk of counterfeiting, provide strong safety protection for block chain users and resist quantum computation attack. The related transaction information is encrypted, the data security is protected, the problem of information leakage caused by commodity transaction on a quantum block chain by directly utilizing a plaintext is solved, zero knowledge certification is carried out on the related transaction information and the commodity information, the verification of the digital commodity transaction is guaranteed to be a verifiable process, and the verification process of the digital commodity transaction is more transparent and visual. Therefore, the digital commodity transaction method based on the block chain can solve the problem of low safety of digital commodity transaction.
Fig. 2 is a functional block diagram of a digital commodity transaction apparatus based on a blockchain according to an embodiment of the present invention.
The digital commodity transaction apparatus 100 based on the blockchain according to the present invention may be installed in an electronic device. According to the implemented functions, the blockchain-based digital commodity transaction apparatus 100 may include a blockchain construction module 101, a transaction information encryption module 102, a signature verification module 103, and a transaction verification module 104. The module of the present invention, which may also be referred to as a unit, refers to a series of computer program segments that can be executed by a processor of an electronic device and that can perform a fixed function, and that are stored in a memory of the electronic device.
In the present embodiment, the functions regarding the respective modules/units are as follows:
the block chain construction module 101 is configured to obtain quantum blocks within a preset time period, connect the quantum blocks according to a time sequence to obtain a quantum block chain, where the quantum blocks at least include two quantum blocks, receive an instruction for creating a transaction triggered by a transaction node of the quantum block chain, determine a transaction information transfer user according to the instruction, and generate a pair of quantum keys for the transaction information transfer user based on the quantum block chain, where each quantum key includes a master public key;
the transaction information encryption module 102 is configured to perform hash calculation on the relevant transaction information of the transaction information transfer user to obtain a transaction hash value, encrypt the transaction hash value and the relevant transaction information by using a master public key in the quantum key to obtain an encrypted hash value and encrypted relevant information, and perform information fusion on the encrypted hash value and the encrypted relevant information to obtain encrypted transaction information;
the signature verification module 103 is configured to perform signature generation on the encrypted transaction information by using a ring signature algorithm to obtain a transaction ring signature, perform signature verification on the transaction ring signature, and write the relevant transaction information into the quantum block chain when the signature verification passes;
the transaction verification module 104 is configured to obtain commodity information corresponding to the transaction information transfer user prestored in the quantum block chain by the node, perform zero knowledge certification on the relevant transaction information and the commodity information, so that the miner node of the quantum block chain performs transaction verification according to a result of the zero knowledge certification, and when the transaction verification passes, store a digital commodity transaction success record in the quantum block chain.
In detail, the block chain-based digital commodity transaction apparatus 100 includes the following modules:
the method comprises the steps of firstly, obtaining quantum blocks in a preset time period, and connecting the quantum blocks according to a time sequence to obtain a quantum block chain, wherein the quantum blocks at least comprise two quantum blocks.
In the embodiment of the present invention, useful quantum data is stored in the quantum blocks, and a plurality of quantum blocks may be connected by adopting a quantum entanglement state in time to obtain a quantum block chain. Compared with the prior block chain technology, the quantum block chain is based on the quantum unclonable principle, so that the risk of counterfeiting can be resisted, and meanwhile, the quantum block chain combines the quantum password and the quantum principle, so that strong safety protection is provided for block chain users, and quantum computing attack can be resisted.
In detail, the quantum block comprises at least two quantum blocks, wherein the quantum blocks are:
wherein,
represents the first
The expression of the quantum block is shown,
is shown as
A sub-block of quantities,
the number of the quantum blocks is represented,
which represents a pre-set time parameter that is,
representing preset quantum parameters.
E.g. by analogy, the first
The quantum block is
The quantum block at least comprises two quantum blocks, namely the quantum block
And quantum block
. Specifically, the connecting the quantum blocks according to the time sequence to obtain a quantum block chain includes:
acquiring a preset quantum block chain structure, and screening out quantum blocks with preset number from the quantum blocks;
randomly combining a preset number of quantum blocks to obtain a plurality of combined quantum blocks, and storing the combined quantum blocks into the quantum block chain structure to obtain a quantum block chain.
In detail, the preset number is selected differently according to a specific scheme, and quantum blocks with the preset number are combined with the quantum block chain structure to obtain a quantum block chain.
Further, the preset quantum block chain structure is as follows:
wherein,
it is shown that the chain structure of the quantum blocks,
the number of the quantum blocks is represented,
which is indicative of a pre-set time parameter,
is shown as
A quantum block.
For example, assume that the first three quantum blocks are respectively
,
And
generating the quantum block chain structure by the quantum block chain structure
。
Step two, receiving a transaction establishing instruction triggered by a transaction node of the quantum block chain, determining a transaction information transfer user according to the instruction, and generating a pair of quantum keys for the transaction information transfer user based on the quantum block chain, wherein the quantum keys comprise a main public key.
In the embodiment of the present invention, the transaction node refers to a certain client or server accessing the quantum block chain, and the client or server is a system platform for performing business operations in organization structures such as units. The instruction refers to a code which is sent by the node and needs to perform a specific operation. For example, in the embodiment of the present invention, the node represents a transaction party, and the instruction for creating a transaction is an instruction for issuing funds sent by a transaction party to a bank.
Specifically, the instruction is triggered after a node receives an instruction of other nodes. The instruction comprises information about the transaction user, and the transaction information transfer user can be further determined according to the instruction.
Further, the generating a pair of quantum keys for the transaction information transfer user based on the quantum block chain includes:
generating a sequence of qubit pairs for the transaction information transfer user using the chain of qubits;
splitting the qubit pair sequence into a first qubit pair subsequence and a second qubit pair subsequence according to a preset splitting rule;
taking the first qubit subsequence as a main public key and the second qubit subsequence as a main private key;
and summarizing the main public key and the main private key to obtain a pair of quantum keys.
In detail, a sequence of qubit pairs is generated for the transaction information transferring user using the chain of quantum blocks
Quantum regionThe blockchain generates a pair of quantum keys for each user. Splitting the sequence of qubit pairs into a first sequence of qubit pairs according to a preset splitting rule
And a second qubit pair subsequence
. And taking the first qubit subsequence as a main public key and the second qubit subsequence as a main private key.
Performing hash calculation on the related transaction information of the transaction information transfer user to obtain a transaction hash value, encrypting the transaction hash value and the related transaction information by using the main public key in the quantum key to obtain an encrypted hash value and encrypted related information, and performing information fusion on the encrypted hash value and the encrypted related information to obtain encrypted transaction information.
In the embodiment of the invention, the preset hash function can be used for carrying out hash calculation on the related transaction information of the transaction information transfer user to obtain the transaction hash value. The preset hash function may be a hash () function.
Specifically, the encrypting the transaction hash value and the related transaction information by using the master public key in the quantum key means that the transaction hash value and the related transaction information are collected, and the collected information is encrypted by using the master public key in the quantum key to obtain encrypted transaction information.
And fourthly, carrying out signature generation on the encrypted transaction information by using a ring signature algorithm to obtain a transaction ring signature.
In the embodiment of the present invention, the ring signature algorithm is a signature technology, and generally, there is a group of public keys, and a signer knows a private key corresponding to a public key in the group of public keys (only needs to know one public key). This allows a ring signature to be generated using the set of public keys and the corresponding private key. The verifier can verify that the ring signature is indeed generated by the owner of a private key of the set of public keys, but does not know which private key corresponds to which public key.
Specifically, the signing and generating the encrypted transaction information by using a ring signature algorithm to obtain a transaction ring signature includes:
acquiring a public key set of a preset input ring in the ring signature algorithm, the encrypted transaction information and a quantum key corresponding to the encrypted transaction information;
encrypting the encrypted transaction information again based on the public key set of the preset input ring to obtain double encrypted information;
calculating to obtain a symmetrical value corresponding to the double encryption information through a preset information symmetrical formula and the transaction hash value;
and constructing a multi-element array according to the public key set, the symmetric value and the double encryption information, and taking the multi-element array as the transaction ring signature.
In detail, the public key set of the preset input ring comprises a plurality of public keys, for example, the public key is
、
…
The encrypted transaction information is
,
,…,
。
Further, the preset information symmetry formula is as follows:
wherein,
for the purpose of the transaction hash value,
for a plurality of double encrypted information, v is a fixed parameter,
and the symmetric value is corresponding to the double encryption information.
And fifthly, signature verification is carried out on the transaction ring signature, and when the signature verification is passed, the related transaction information is written into the quantum block chain.
In an embodiment of the present invention, the signature verification of the transaction ring signature includes:
acquiring a verification data set, wherein the verification data set comprises a verification public key and information to be verified;
encrypting the information to be verified by using the verification public key to obtain encrypted verification information;
inputting the encrypted verification information into the transaction ring signature, and judging that the signature verification is passed when the transaction ring signature is established;
and inputting the encryption verification information into the transaction ring signature, and judging that the signature verification is not passed when the transaction ring signature is not established.
In detail, the verification data set is data proposed for signature verification of the transaction ring signature.
Specifically, when the signature verification passes, the related transaction information is written into the quantum block chain.
And sixthly, acquiring commodity information corresponding to the transaction information transfer user prestored in the quantum block chain by the node, and performing zero knowledge certification on the related transaction information and the commodity information so that the miner node of the quantum block chain performs transaction verification according to a result of the zero knowledge certification.
In the embodiment of the present invention, the commodity information corresponding to the transaction information transfer user refers to the relevant reference information such as the commodity name, the commodity number, and the commodity specification corresponding to the commodity transaction. The Zero-Knowledge Proof (Zero-Knowledge Proof) refers to the prover being able to convince the verifier that some argument is correct without providing the verifier with any useful information. Zero knowledge proof is essentially a protocol involving two or more parties, i.e., a series of steps that are required by two or more parties to complete a task.
Specifically, the zero-knowledge proof of the related transaction information and the commodity information includes:
acquiring a preset certification function, and performing binding verification processing on the related transaction information and the encrypted transaction information by using the certification function to obtain a first binding verification result;
if the first binding verification result is that the verification is passed, the certification function is used for carrying out binding verification processing on the commodity information and the encrypted commodity information to obtain a second binding verification result;
if the second binding verification result is that the verification is passed, calculating cosine similarity between the encrypted transaction information and the encrypted commodity information by using a cosine similarity formula;
when the cosine similarity is smaller than a preset similarity threshold, judging that the zero knowledge proof fails;
and when the cosine similarity is greater than or equal to the similarity threshold, judging that the zero knowledge proof is successful.
Specifically, the performing, by using the attestation function, binding verification processing on the related transaction information and the encrypted transaction information to obtain a first binding verification result includes:
generating certification processing is carried out on the related transaction information and the encrypted transaction information by using a preset certification generating function to obtain a certification;
and inputting the generation certification and the related transaction information into a verification certification function to obtain a first binding verification result.
The preset certification function comprises a generation certification function and a verification certification function.
In detail, the proof of generation function is pi = Prvoe (x, w), where pi represents proof of generation, x is plaintext, and w is ciphertext, in this embodiment of the present invention, x is the relevant transaction information, w is the encrypted transaction information, the proof of verification function is Yes = Verify (x, pi), Yes is one of the first binding verification results, and generally, the first binding verification result includes Yes and No, Yes represents proof correct and No represents proof error.
Specifically, the calculating the cosine similarity between the encrypted transaction information and the encrypted commodity information by using a cosine similarity formula includes:
wherein,
the similarity between the two signals is a cosine similarity,
、
vectors corresponding to the encrypted transaction information and the encrypted commodity information respectively,
、
respectively, the modulus corresponding to the two vectors.
Further, before the cosine similarity between the encrypted transaction information and the encrypted commodity information is calculated by using a cosine similarity formula, vectorizing the encrypted transaction information and the encrypted commodity information according to a preset word2vec algorithm.
And seventhly, when the transaction passes the verification, storing the transaction success record of the digital commodity in the quantum block chain.
In the embodiment of the invention, when the transaction verification is passed, the successful record of the digital commodity transaction is stored in the quantum block chain, so that the digital commodity transaction is realized, and the safety and the accuracy of the record of the digital commodity transaction are improved.
In the embodiment of the invention, quantum blocks are connected according to the time sequence to obtain the quantum block chain, and the quantum block chain can resist the risk of counterfeiting, provide strong safety protection for block chain users and resist quantum computation attack. The related transaction information is encrypted, the data security is protected, the problem of information leakage caused by commodity transaction on a quantum block chain by directly utilizing a plaintext is solved, zero knowledge certification is carried out on the related transaction information and the commodity information, the verification of the digital commodity transaction is guaranteed to be a verifiable process, and the verification process of the digital commodity transaction is more transparent and visual. Therefore, the digital commodity transaction device based on the blockchain can solve the problem of low safety of digital commodity transaction based on the blockchain.
Fig. 3 is a schematic structural diagram of an electronic device for implementing a block chain-based digital commodity transaction method according to an embodiment of the present invention.
The electronic device may comprise a processor 10, a memory 11, a communication interface 12 and a bus 13, and may further comprise a computer program, such as a blockchain based digital goods transaction program, stored in the memory 11 and executable on the processor 10.
The memory 11 includes at least one type of readable storage medium, which includes flash memory, removable hard disk, multimedia card, card-type memory (e.g., SD or DX memory, etc.), magnetic memory, magnetic disk, optical disk, etc. The memory 11 may in some embodiments be an internal storage unit of the electronic device, for example a removable hard disk of the electronic device. The memory 11 may also be an external storage device of the electronic device in other embodiments, such as a plug-in mobile hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the electronic device. Further, the memory 11 may also include both an internal storage unit and an external storage device of the electronic device. The memory 11 may be used not only to store application software installed in the electronic device and various types of data, such as codes of a digital commodity transaction program based on a block chain, etc., but also to temporarily store data that has been output or is to be output.
The processor 10 may be composed of an integrated circuit in some embodiments, for example, a single packaged integrated circuit, or may be composed of a plurality of integrated circuits packaged with the same or different functions, including one or more Central Processing Units (CPUs), microprocessors, digital Processing chips, graphics processors, and combinations of various control chips. The processor 10 is a Control Unit (Control Unit) of the electronic device, connects various components of the electronic device by using various interfaces and lines, and executes various functions and processes data of the electronic device by running or executing programs or modules (e.g., a digital commodity transaction program based on a block chain, etc.) stored in the memory 11 and calling data stored in the memory 11.
The communication interface 12 is used for communication between the electronic device and other devices, and includes a network interface and a user interface. Optionally, the network interface may include a wired interface and/or a wireless interface (e.g., WI-FI interface, bluetooth interface, etc.), which are typically used to establish a communication connection between the electronic device and other electronic devices. The user interface may be a Display (Display), an input unit such as a Keyboard (Keyboard), and optionally a standard wired interface, a wireless interface. Alternatively, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, or the like. The display, which may also be referred to as a display screen or display unit, is suitable, among other things, for displaying information processed in the electronic device and for displaying a visualized user interface.
The bus 13 may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The bus 13 may be divided into an address bus, a data bus, a control bus, etc. The bus 13 is arranged to enable connection communication between the memory 11 and at least one processor 10 or the like.
Fig. 3 shows only an electronic device having components, and those skilled in the art will appreciate that the structure shown in fig. 3 does not constitute a limitation of the electronic device, and may include fewer or more components than those shown, or some components may be combined, or a different arrangement of components.
For example, although not shown, the electronic device may further include a power supply (such as a battery) for supplying power to each component, and preferably, the power supply may be logically connected to the at least one processor 10 through a power management device, so that functions such as charge management, discharge management, and power consumption management are implemented through the power management device. The power supply may also include any component of one or more dc or ac power sources, recharging devices, power failure detection circuitry, power converters or inverters, power status indicators, and the like. The electronic device may further include various sensors, a bluetooth module, a Wi-Fi module, and the like, which are not described herein again.
Further, the electronic device may further include a network interface, and optionally, the network interface may include a wired interface and/or a wireless interface (such as a WI-FI interface, a bluetooth interface, etc.), which are generally used to establish a communication connection between the electronic device and other electronic devices.
Optionally, the electronic device may further comprise a user interface, which may be a Display (Display), an input unit (such as a Keyboard), and optionally a standard wired interface, a wireless interface. Alternatively, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, or the like. The display, which may also be referred to as a display screen or display unit, is suitable, among other things, for displaying information processed in the electronic device and for displaying a visualized user interface.
It is to be understood that the described embodiments are for purposes of illustration only and that the scope of the appended claims is not limited to such structures.
The memory 11 in the electronic device stores a blockchain-based digital commodity transaction program which is a combination of instructions that, when executed in the processor 10, enable:
obtaining quantum blocks in a preset time period, and connecting the quantum blocks according to a time sequence to obtain a quantum block chain, wherein the quantum blocks at least comprise two quantum blocks;
receiving a transaction establishing instruction triggered by a transaction node of the quantum block chain, determining a transaction information transfer user according to the instruction, and generating a pair of quantum keys for the transaction information transfer user based on the quantum block chain, wherein the quantum keys comprise a main public key;
performing hash calculation on the related transaction information of the transaction information transfer user to obtain a transaction hash value, encrypting the transaction hash value and the related transaction information by using a main public key in the quantum key to obtain an encrypted hash value and encrypted related information, and performing information fusion on the encrypted hash value and the encrypted related information to obtain encrypted transaction information;
generating a signature for the encrypted transaction information by using a ring signature algorithm to obtain a transaction ring signature;
performing signature verification on the transaction ring signature, and writing the related transaction information into the quantum block chain when the signature verification is passed;
acquiring commodity information corresponding to the transaction information transfer user prestored in the quantum block chain by the node, and performing zero knowledge certification on the related transaction information and the commodity information so that the miner node of the quantum block chain performs transaction verification according to a zero knowledge certification result;
and when the transaction verification passes, storing a digital commodity transaction success record in the quantum blockchain.
Specifically, the specific implementation method of the processor 10 for the instruction may refer to the description of the relevant steps in the embodiment corresponding to fig. 1, which is not described herein again.
Further, the electronic device integrated module/unit, if implemented in the form of a software functional unit and sold or used as a separate product, may be stored in a computer readable storage medium. The computer readable storage medium may be volatile or non-volatile. For example, the computer-readable medium may include: any entity or device capable of carrying said computer program code, recording medium, U-disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM).
The present invention also provides a computer-readable storage medium, storing a computer program which, when executed by a processor of an electronic device, may implement:
obtaining quantum blocks in a preset time period, and connecting the quantum blocks according to a time sequence to obtain a quantum block chain, wherein the quantum blocks at least comprise two quantum blocks;
receiving a transaction establishing instruction triggered by a transaction node of the quantum block chain, determining a transaction information transfer user according to the instruction, and generating a pair of quantum keys for the transaction information transfer user based on the quantum block chain, wherein the quantum keys comprise a main public key;
performing hash calculation on the related transaction information of the transaction information transfer user to obtain a transaction hash value, encrypting the transaction hash value and the related transaction information by using a main public key in the quantum key to obtain an encrypted hash value and encrypted related information, and performing information fusion on the encrypted hash value and the encrypted related information to obtain encrypted transaction information;
generating a signature for the encrypted transaction information by using a ring signature algorithm to obtain a transaction ring signature;
performing signature verification on the transaction ring signature, and writing the related transaction information into the quantum block chain when the signature verification is passed;
obtaining commodity information corresponding to the transaction information transfer user prestored in the quantum block chain by the node, and performing zero knowledge certification on the relevant transaction information and the commodity information so as to enable the miners' nodes of the quantum block chain to perform transaction verification according to the result of the zero knowledge certification;
and when the transaction verification passes, storing a digital commodity transaction success record in the quantum blockchain.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus, device and method can be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is only one logical functional division, and other divisions may be realized in practice.
The modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
In addition, functional modules in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional module.
It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential attributes thereof.
The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference signs in the claims shall not be construed as limiting the claim concerned.
The block chain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
Furthermore, it is obvious that the word "comprising" does not exclude other elements or steps, and the singular does not exclude the plural. A plurality of units or means recited in the system claims may also be implemented by one unit or means in software or hardware. The terms second, etc. are used to denote names, but not any particular order.
Finally, it should be noted that the above embodiments are only for illustrating the technical solutions of the present invention and not for limiting, and although the present invention is described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications or equivalent substitutions may be made on the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.