技术领域Technical field
本发明涉及互联网应用技术领域,特别是涉及一种基于区块链的资金交易方法及装置。The present invention relates to the field of Internet application technologies, and in particular, to a blockchain-based fund transaction method and apparatus.
背景技术Background technique
近年来,随着贷款业务的高速发展,贷款风险管控的问题变得越来越严峻。例如,恶意用户可能从每个金融机构都贷一定额度的金额,并且在每家金融机构(或银行)申请贷款时,隐藏其以往的未还款的贷款数额。这样的话,该恶意用户可能会贷出大量贷款,并且此贷款数量可能会大大超出其偿还能力。如果这种行为不能被有效控制,那么这种恶意超额贷款的行为将会对金融系统造成巨大伤害。In recent years, with the rapid development of loan business, the problem of loan risk management and control has become more and more serious. For example, a malicious user may lend a certain amount of money from each financial institution and hide the amount of the previous unpaid loan when each financial institution (or bank) applies for a loan. In this case, the malicious user may lend a large amount of loans, and the amount of this loan may greatly exceed its ability to repay. If this behavior cannot be effectively controlled, then this malicious excess loan behavior will cause great damage to the financial system.
目前,金融机构可以采用一种简单的方法来防止这类行为,那就是:每个金融机构向其他金融机构共享每个用户的贷款信息。但是,这种方法有两个重要的缺点:一方面,银行将用户的贷款信息暴露给其他人,这是对用户隐私的侵犯;另一方面,金融机构将其自身的业务信息暴露给其他机构,这是对机构自身隐私的侵犯。At present, financial institutions can adopt a simple method to prevent such behaviors, that is: each financial institution shares the loan information of each user with other financial institutions. However, this approach has two important drawbacks: on the one hand, the bank exposes the user's loan information to others, which is a violation of user privacy; on the other hand, financial institutions expose their own business information to other institutions. This is a violation of the organization's own privacy.
显然,在现有的金融机构采用的防止用户恶意超额贷款行为的方法中,缺乏保护用户和金融机构隐私的措施,不能保证一个用户的贷款总额小于某个限制。Obviously, in the existing methods used by financial institutions to prevent malicious over-lending of users, there is no measure to protect the privacy of users and financial institutions, and there is no guarantee that the total loan amount of a user is less than a certain limit.
发明内容Summary of the invention
本发明实施例的目的在于提供一种基于区块链的资金交易方法,以避免用户的交易总额超过用户的预设的可交易金额的范围。An object of the embodiments of the present invention is to provide a blockchain-based fund transaction method, so as to avoid that the total transaction amount of the user exceeds the range of the user's preset tradable amount.
具体技术方案如下:The specific technical solutions are as follows:
第一方面,提供了一种基于区块链的资金交易方法,所述方法应用于区块链中的服务器,所述服务器中存储有各账户标识对应的历史交易记录,所述历史交易记录中包括随机承诺和范围证明、账户标识和交易类型标识,所述方法包括:In a first aspect, a blockchain-based fund transaction method is provided, the method being applied to a server in a blockchain, wherein the server stores a historical transaction record corresponding to each account identifier, where the historical transaction record is Including random commitment and scope proof, account identification and transaction type identification, the method includes:
接收客户端发送的本次交易信息,所述本次交易信息中包括交易金额、账户标识和交易类型标识、所述交易金额对应的第一随机承诺和第一范围证明、所述账户标识的当前的剩余可交易金额对应的第二随机承诺和第二范围证明、所述账户标识的第三随机承诺和所述第三随机承诺对应的知识证明;Receiving the transaction information sent by the client, where the transaction information includes a transaction amount, an account identifier, and a transaction type identifier, a first random commitment and a first scope certificate corresponding to the transaction amount, and a current identifier of the account identifier. a second random commitment and a second scope proof corresponding to the remaining tradable amount, a third random commitment of the account identifier, and a knowledge proof corresponding to the third random commitment;
从所述历史交易记录中获取所述账户标识对应的上一次交易记录;Obtaining, from the historical transaction record, a previous transaction record corresponding to the account identifier;
根据预设的验证算法,确定所述交易金额对应的第一随机承诺和第一范围证明、所述账户标识的当前的剩余可交易金额对应的第二随机承诺和第二范围证明、以及所述账户标识的第三随机承诺和所述第三随机承诺对应的知识证明是否有效;Determining, according to a preset verification algorithm, a first random commitment and a first scope certificate corresponding to the transaction amount, a second random commitment and a second scope certificate corresponding to a current remaining tradable amount of the account identifier, and the Whether the third random commitment of the account identifier and the knowledge certificate corresponding to the third random commitment are valid;
若所述第一随机承诺、所述第一范围证明、所述第二随机承诺、所述第二范围证明、所述第三随机承诺和所述第三随机承诺对应的知识证明有效,则根据所述本次交易信息进行本次交易处理。If the first random commitment, the first scope proof, the second random commitment, the second scope proof, the third random commitment, and the third random commitment corresponding to the knowledge prove valid, according to The transaction information is processed in this transaction.
进一步的,所述在接收客户端发送的本次交易信息的步骤之前,还可以包括:Further, before the step of receiving the transaction information sent by the client, the method may further include:
接收客户端发送的账户创建请求信息;其中,所述账户创建请求信息中包括用户标识;Receiving account creation request information sent by the client; wherein the account creation request information includes a user identifier;
在预设的账户信息表中,查找是否包含所述用户标识对应的账户标识;In the preset account information table, searching whether the account identifier corresponding to the user identifier is included;
若所述账户信息表中不包含所述用户标识对应的账户标识,则在接收客户端发送的第四随机承诺对应的知识证明时,根据预设的知识证明验证算法,验证所述第四随机承诺对应的知识证明是否有效;If the account information table does not include the account identifier corresponding to the user identifier, when the knowledge certificate corresponding to the fourth random commitment sent by the client is received, the fourth random is verified according to a preset knowledge verification verification algorithm. Whether the proof of knowledge corresponding to the commitment is valid;
若所述第四随机承诺对应的知识证明有效,则创建所述用户标识对应的账户标识和交易总金额。If the knowledge verification corresponding to the fourth random commitment is valid, the account identifier corresponding to the user identifier and the total transaction amount are created.
第二方面,提供了一种基于区块链的资金交易方法,所述方法应用于客户端,所述方法包括:In a second aspect, a method for a fund transaction based on a blockchain is provided, the method being applied to a client, the method comprising:
获取用户输入的交易申请信息,所述交易申请信息包括账户标识、交易类型标识和交易金额;Obtaining transaction application information input by the user, where the transaction application information includes an account identifier, a transaction type identifier, and a transaction amount;
根据所述交易金额,确定所述交易金额对应的第一随机承诺和第一范围证明;Determining, according to the transaction amount, a first random commitment and a first scope certificate corresponding to the transaction amount;
确定所述账户标识的当前的剩余可交易金额,以及所述账户标识的剩余可交易金额对应的第二随机承诺和第二范围证明;Determining a current remaining tradable amount of the account identifier, and a second random commitment and a second range certificate corresponding to the remaining tradable amount of the account identifier;
根据所述交易金额对应的第一随机承诺和预设的知识证明生成算法,确定所述账户标识的第三随机承诺和所述第三随机承诺对应的知识证明;Determining, according to the first random commitment corresponding to the transaction amount and a preset knowledge proof generation algorithm, a third random commitment of the account identifier and a knowledge certificate corresponding to the third random commitment;
将所述交易申请信息、交易金额对应的第一随机承诺和第一范围证明、所述账户标识的剩余可交易金额对应的第二随机承诺和第二范围证明、所述账户标识的第三随机承诺和所述第三随机承诺对应的知识证明,组成本次交易信息;Transmitting the transaction application information, the first random commitment corresponding to the transaction amount and the first scope certificate, the second random commitment and the second scope certificate corresponding to the remaining tradable amount of the account identifier, and the third random identifier of the account identifier Commitment and the knowledge of the third random commitment corresponding to the knowledge, constitute the transaction information;
将所述本次交易信息发送至区块链中的服务器,以使所述服务器根据预设的验证算法,验证所述本次交易信息是否正确,若正确,则进行本次交易处理。Sending the current transaction information to the server in the blockchain, so that the server verifies whether the current transaction information is correct according to a preset verification algorithm, and if correct, performs the transaction processing.
进一步的,所述在获取用户输入的交易申请信息的步骤之前,可以包括:Further, before the step of acquiring the transaction application information input by the user, the method may include:
向服务器发送账户创建请求信息;其中,所述账户创建请求信息中包括用户标识;Sending account creation request information to the server; wherein the account creation request information includes a user identifier;
获取用户输入的随机数;Obtain a random number entered by the user;
根据所述随机数和预设的随机承诺生成算法,确定第四随机承诺;Determining a fourth random commitment according to the random number and a preset random commitment generation algorithm;
根据预设的知识证明生成算法,确定所述第四随机承诺对应的知识证明;Determining, according to a preset knowledge proof generation algorithm, a knowledge proof corresponding to the fourth random commitment;
将所述第四随机承诺和第四随机承诺对应的知识证明发送至所述服务器。And transmitting the knowledge certificate corresponding to the fourth random commitment and the fourth random commitment to the server.
第三方面,提供了一种基于区块链的资金交易装置,所述装置应用于区块链中的服务器,所述服务器中存储有各账户标识对应的历史交易记录,所述历史交易记录中包括随机承诺和范围证明、账户标识和交易类型标识,所述装置包括:In a third aspect, a blockchain-based fund transaction device is provided, the device being applied to a server in a blockchain, wherein the server stores a historical transaction record corresponding to each account identifier, where the historical transaction record is Including random commitment and scope proof, account identification and transaction type identification, the device includes:
接收模块,用于接收客户端发送的本次交易信息,所述本次交易信息中包括交易金额、账户标识和交易类型标识、所述交易金额对应的第一随机承诺和第一范围证明、所述账户标识的当前的剩余可交易金额对应的第二随机承诺和第二范围证明、所述账户标识的第三随机承诺和所述第三随机承诺对应的知识证明;a receiving module, configured to receive the current transaction information sent by the client, where the transaction information includes a transaction amount, an account identifier, and a transaction type identifier, and the first random commitment and the first scope certificate corresponding to the transaction amount, a second random commitment and a second range certificate corresponding to the current remaining tradable amount of the account identifier, a third random commitment of the account identifier, and a knowledge proof corresponding to the third random commitment;
获取模块,用于从所述历史交易记录中获取所述账户标识对应的上一次交易记录;An obtaining module, configured to obtain, from the historical transaction record, a previous transaction record corresponding to the account identifier;
确定模块,用于根据预设的验证算法,确定所述交易金额对应的第一随机承诺和第一范围证明、所述账户标识的当前的剩余可交易金额对应的第二随机承诺和第二范围证明、以及所述账户标识的第三随机承诺和所述第三随机承诺对应的知识证明是否有效;a determining module, configured to determine, according to a preset verification algorithm, a first random commitment and a first range certificate corresponding to the transaction amount, and a second random commitment and a second range corresponding to a current remaining tradable amount of the account identifier Proof, and whether the third random commitment of the account identifier and the knowledge certificate corresponding to the third random commitment are valid;
本次交易处理模块,用于若所述第一随机承诺、所述第一范围证明、所述第二随机承诺、所述第二范围证明、所述第三随机承诺和所述第三随机承诺对应的知识证明有效,则根据所述本次交易信息进行本次交易处理。The transaction processing module is configured to: if the first random commitment, the first scope proof, the second random commitment, the second scope proof, the third random commitment, and the third random commitment If the corresponding knowledge proves to be valid, the transaction processing is performed according to the current transaction information.
进一步的,所述装置还可以包括:Further, the device may further include:
账户创建请求信息接收模块,用于接收客户端发送的账户创建请求信息;其中,所述账户创建请求信息中包括用户标识;The account creation request information receiving module is configured to receive account creation request information sent by the client, where the account creation request information includes a user identifier;
查找模块,用于在预设的账户信息表中,查找是否包含所述用户标识对应的账户标识;a search module, configured to: in the preset account information table, whether to include an account identifier corresponding to the user identifier;
验证模块,用于若所述账户信息表中不包含所述用户标识对应的账户标识,则在接收客户端发送的第四随机承诺对应的知识证明时,根据预设的知识证明验证算法,验证所述第四随机承诺对应的知识证明是否有效;The verification module is configured to: if the account identifier corresponding to the user identifier is not included in the account information table, when the knowledge certificate corresponding to the fourth random commitment sent by the client is received, the verification algorithm is verified according to a preset knowledge verification algorithm. Whether the knowledge proof corresponding to the fourth random commitment is valid;
创建模块,用于若所述第四随机承诺对应的知识证明有效,则创建所述用户标识对应的账户标识和交易总金额。And a creating module, configured to create an account identifier and a total transaction amount corresponding to the user identifier if the knowledge verification corresponding to the fourth random commitment is valid.
第四方面,提供了一种基于区块链的资金交易装置,所述装置应用于客户端,所述装置包括:In a fourth aspect, a blockchain-based money transaction device is provided, the device being applied to a client, the device comprising:
交易申请信息获取模块,用于获取用户输入的交易申请信息,所述交易申请信息包括账户标识、交易类型标识和交易金额;a transaction application information obtaining module, configured to obtain transaction application information input by a user, where the transaction application information includes an account identifier, a transaction type identifier, and a transaction amount;
第一确定模块,用于根据所述交易金额,确定所述交易金额对应的第一随机承诺和第一范围证明;a first determining module, configured to determine, according to the transaction amount, a first random commitment and a first range certificate corresponding to the transaction amount;
第二确定模块,用于确定所述账户标识的当前的剩余可交易金额,以及所述账户标识的剩余可交易金额对应的第二随机承诺和第二范围证明;a second determining module, configured to determine a current remaining tradable amount of the account identifier, and a second random commitment and a second range certificate corresponding to the remaining tradable amount of the account identifier;
第三确定模块,用于根据所述交易金额对应的第一随机承诺和预设的知识证明生成算法,确定所述账户标识的第三随机承诺和所述第三随机承诺对应的知识证明;a third determining module, configured to determine, according to the first random commitment corresponding to the transaction amount and a preset knowledge proof generation algorithm, a third random commitment of the account identifier and a knowledge certificate corresponding to the third random commitment;
本次交易信息组成模块,用于将所述交易申请信息、交易金额对应的第一随机承诺和第一范围证明、所述账户标识的剩余可交易金额对应的第二随机承诺和第二范围证明、所述账户标识的第三随机承诺和所述第三随机承诺对应的知识证明,组成本次交易信息;The transaction information component module is configured to use the transaction request information, the first random commitment corresponding to the transaction amount and the first scope certificate, and the second random commitment and the second scope certificate corresponding to the remaining tradable amount of the account identifier. And the third random commitment of the account identifier and the knowledge certificate corresponding to the third random commitment constitute the transaction information;
本次交易信息验证模块,用于将所述本次交易信息发送至区块链中的服务器,以使所述服务器根据预设的验证算法,验证所述本次交易信息是否正确,若正确,则进行本次交易处理。The transaction information verification module is configured to send the current transaction information to a server in the blockchain, so that the server verifies whether the current transaction information is correct according to a preset verification algorithm, and if correct, Then proceed with this transaction.
进一步的,所述装置还可以包括:Further, the device may further include:
账户创建请求信息发送模块,用于向服务器发送账户创建请求信息;其中,所述账户创建请求信息中包括用户标识;An account creation request information sending module, configured to send account creation request information to the server, where the account creation request information includes a user identifier;
随机数获取模块,用于获取用户输入的随机数;a random number obtaining module, configured to obtain a random number input by a user;
第四随机承诺确定模块,用于根据所述随机数和预设的随机承诺生成算法,确定第四随机承诺;a fourth random commitment determining module, configured to determine a fourth random commitment according to the random number and a preset random commitment generation algorithm;
知识证明确定模块,用于根据预设的知识证明生成算法,确定所述第四随机承诺对应的知识证明;a knowledge certification determining module, configured to determine a knowledge certificate corresponding to the fourth random commitment according to a preset knowledge proof generation algorithm;
发送模块,用于将所述第四随机承诺和第四随机承诺对应的知识证明发送至所述服务器。And a sending module, configured to send the knowledge certificate corresponding to the fourth random commitment and the fourth random commitment to the server.
第五方面,提供了一种服务器,所述服务器中存储有各账户标识对应的历史交易记录,历史交易记录中包括随机承诺和范围证明、账户标识和交易类型标识,包括处理器、通信接口、存储器和通信总线,其中,处理器,通信接口,存储器通过通信总线完成相互间的通信;In a fifth aspect, a server is provided, where the historical transaction record corresponding to each account identifier is stored in the server, and the historical transaction record includes a random commitment and a scope certificate, an account identifier, and a transaction type identifier, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface, and the memory complete communication with each other through the communication bus;
存储器,用于存放计算机程序;a memory for storing a computer program;
处理器,用于执行存储器上所存放的程序时,实现以下方法步骤:The processor, when used to execute a program stored on the memory, implements the following method steps:
接收客户端发送的本次交易信息,所述本次交易信息中包括交易金额、账户标识和交易类型标识、所述交易金额对应的第一随机承诺和第一范围证明、所述账户标识的当前的剩余可交易金额对应的第二随机承诺和第二范围证明、所述账户标识的第三随机承诺和所述第三随机承诺对应的知识证明;Receiving the transaction information sent by the client, where the transaction information includes a transaction amount, an account identifier, and a transaction type identifier, a first random commitment and a first scope certificate corresponding to the transaction amount, and a current identifier of the account identifier. a second random commitment and a second scope proof corresponding to the remaining tradable amount, a third random commitment of the account identifier, and a knowledge proof corresponding to the third random commitment;
从所述历史交易记录中获取所述账户标识对应的上一次交易记录;Obtaining, from the historical transaction record, a previous transaction record corresponding to the account identifier;
根据预设的验证算法,确定所述交易金额对应的第一随机承诺和第一范围证明、所述账户标识的当前的剩余可交易金额对应的第二随机承诺和第二范围证明、以及所述账户标识的第三随机承诺和所述第三随机承诺对应的知识证明是否有效;Determining, according to a preset verification algorithm, a first random commitment and a first scope certificate corresponding to the transaction amount, a second random commitment and a second scope certificate corresponding to a current remaining tradable amount of the account identifier, and the Whether the third random commitment of the account identifier and the knowledge certificate corresponding to the third random commitment are valid;
若所述第一随机承诺、所述第一范围证明、所述第二随机承诺、所述第二范围证明、所述第三随机承诺和所述第三随机承诺对应的知识证明有效,则根据所述本次交易信息进行本次交易处理。If the first random commitment, the first scope proof, the second random commitment, the second scope proof, the third random commitment, and the third random commitment corresponding to the knowledge prove valid, according to The transaction information is processed in this transaction.
第六方面,提供了一种客户端,包括处理器、通信接口、存储器和通信总线,其中,处理器,通信接口,存储器通过通信总线完成相互间的通信;A sixth aspect provides a client, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory complete communication with each other through the communication bus;
存储器,用于存放计算机程序;a memory for storing a computer program;
处理器,用于执行存储器上所存放的程序时,实现以下方法步骤:The processor, when used to execute a program stored on the memory, implements the following method steps:
获取用户输入的交易申请信息,所述交易申请信息包括账户标识、交易类型标识和交易金额;Obtaining transaction application information input by the user, where the transaction application information includes an account identifier, a transaction type identifier, and a transaction amount;
根据所述交易金额,确定所述交易金额对应的第一随机承诺和第一范围证明;Determining, according to the transaction amount, a first random commitment and a first scope certificate corresponding to the transaction amount;
确定所述账户标识的当前的剩余可交易金额,以及所述账户标识的剩余可交易金额对应的第二随机承诺和第二范围证明;Determining a current remaining tradable amount of the account identifier, and a second random commitment and a second range certificate corresponding to the remaining tradable amount of the account identifier;
根据所述交易金额对应的第一随机承诺和预设的知识证明生成算法,确定所述账户标识的第三随机承诺和所述第三随机承诺对应的知识证明;Determining, according to the first random commitment corresponding to the transaction amount and a preset knowledge proof generation algorithm, a third random commitment of the account identifier and a knowledge certificate corresponding to the third random commitment;
将所述交易申请信息、交易金额对应的第一随机承诺和第一范围证明、所述账户标识的剩余可交易金额对应的第二随机承诺和第二范围证明、所述账户标识的第三随机承诺和所述第三随机承诺对应的知识证明,组成本次交易信息;Transmitting the transaction application information, the first random commitment corresponding to the transaction amount and the first scope certificate, the second random commitment and the second scope certificate corresponding to the remaining tradable amount of the account identifier, and the third random identifier of the account identifier Commitment and the knowledge of the third random commitment corresponding to the knowledge, constitute the transaction information;
将所述本次交易信息发送至区块链中的服务器,以使所述服务器根据预设的验证算法,验证所述本次交易信息是否正确,若正确,则进行本次交易处理。Sending the current transaction information to the server in the blockchain, so that the server verifies whether the current transaction information is correct according to a preset verification algorithm, and if correct, performs the transaction processing.
本发明实施例提供了一种基于区块链的贷款方法及装置,区块链中的服务器接收客户端发送的本次交易信息,并从历史交易记录中获取账户标识对应的上一次交易信息;根据预设的验证算法,确定客户端发送的本次交易信息中的交易金额对应的第一随机承诺、第一范围证明、账户标识的当前的剩余可交易金额对应的第二随机承诺、第二范围证明、账户标识的第三随机承诺和第三随机承诺对应的知识证明是否有效;若所述第一随机承诺和所述第一随机承诺对应的第一范围证明和第二随机承诺、所述第二随机承诺对应的第二范围证明、账户标识的第三随机承诺和第三随机承诺对应的知识证明有效,则根据所述本次交易信息进行本次交易处理。由于本发明实施例中,将随机承诺和范围证明与区块链相结合,从而在保证用户交易金额保密性的同时,能够有效地防止恶意用户在多家金融机构中的恶意超额交易行为。The embodiment of the invention provides a method and a device for loan based on a blockchain. The server in the blockchain receives the transaction information sent by the client, and obtains the last transaction information corresponding to the account identifier from the historical transaction record. Determining, according to a preset verification algorithm, a first random commitment corresponding to the transaction amount in the current transaction information sent by the client, a first range certificate, a second random commitment corresponding to the current remaining tradable amount of the account identifier, and a second Whether the scope certificate, the third random commitment of the account identifier, and the knowledge proof corresponding to the third random commitment are valid; if the first random commitment and the first random commitment correspond to the first scope proof and the second random commitment, the The second range proof corresponding to the second random commitment, the third random commitment of the account identifier, and the knowledge proof corresponding to the third random commitment are valid, and the transaction processing is performed according to the current transaction information. In the embodiment of the present invention, the random commitment and the scope proof are combined with the blockchain, thereby ensuring the malicious excess transaction behavior of the malicious user in a plurality of financial institutions while ensuring the confidentiality of the transaction amount of the user.
当然,实施本发明的任一产品或方法必不一定需要同时达到以上所述的所有优点。Of course, any product or method embodying the present invention necessarily does not necessarily require all of the advantages described above to be achieved at the same time.
附图说明DRAWINGS
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the embodiments or the description of the prior art will be briefly described below. Obviously, the drawings in the following description are only It is a certain embodiment of the present invention, and other drawings can be obtained from those skilled in the art without any creative work.
图1为本发明实施例提供的一种基于区块链的资金交易方法的流程示意图;FIG. 1 is a schematic flowchart diagram of a blockchain-based capital transaction method according to an embodiment of the present invention;
图2为本发明实施例提供的另一种基于区块链的资金交易方法的流程示意图;FIG. 2 is a schematic flowchart diagram of another method for calculating a fund based on a blockchain according to an embodiment of the present invention; FIG.
图3为本发明实施例提供的一种基于区块链的资金交易装置的结构示意图;3 is a schematic structural diagram of a block transaction based on a blockchain according to an embodiment of the present invention;
图4为本发明实施例提供的另一种基于区块链的资金交易装置的结构示意图;4 is a schematic structural diagram of another blockchain-based fund transaction apparatus according to an embodiment of the present invention;
图5为本发明实施例提供的一种电子设备的结构示意图;FIG. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure;
图6为本发明实施例提供的一种电子设备的结构示意图。FIG. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
具体实施方式Detailed ways
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the embodiments of the present invention are clearly and completely described in the following with reference to the accompanying drawings in the embodiments of the present invention. It is obvious that the described embodiments are only a part of the embodiments of the present invention, but not all embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments of the present invention without creative efforts are within the scope of the present invention.
本发明实施例提供的一种基于区块链的资金交易方法,该方法应用于区块链中的服务器,该服务器可以是区块链中的各金融机构设置的服务器。本发明实施例中提供的资金交易方法中的资金交易类型可以包括贷款交易和还款交易。而服务器中存储有各账户标识对应的历史交易记录。A blockchain-based fund transaction method provided by an embodiment of the present invention is applied to a server in a blockchain, and the server may be a server set by each financial institution in the blockchain. The type of fund transaction in the fund transaction method provided in the embodiment of the present invention may include a loan transaction and a repayment transaction. The server stores the historical transaction records corresponding to each account identifier.
其中,历史交易记录可以包括随机承诺和范围证明、账户标识和交易类型标识。交易类型标识为用于区别每个交易记录的类型,即该次交易是贷款交易,还是还款交易;若本次交易是贷款交易,交易类型标识可以为load(中文:负荷);若本次交易是还款交易,交易类型标识可以为repay(中文:偿还)。Among them, historical transaction records may include random commitment and scope proof, account identification and transaction type identification. The transaction type identifier is used to distinguish the type of each transaction record, that is, whether the transaction is a loan transaction or a repayment transaction; if the transaction is a loan transaction, the transaction type identifier can be load (Chinese: load); The transaction is a repayment transaction, and the transaction type identifier can be repay (Chinese: reimbursement).
由于随机承诺和范围证明是根据交易金额计算出的数据,而服务器中只存储有随机承诺和范围证明而未存储交易金额,因此,无法通过查看随机承诺而确定出该随机承诺对应的交易金额。也即,当区块链中的各服务器中只存储各账户标识的随机承诺和范围证明时,各服务器就实现了在隐藏保证用户交易金额保密性。Since the random commitment and the scope proof are the data calculated according to the transaction amount, and the server only stores the random commitment and the scope certificate without storing the transaction amount, the transaction amount corresponding to the random commitment cannot be determined by checking the random commitment. That is, when each server in the blockchain stores only the random commitment and the scope certificate of each account identifier, each server realizes the confidentiality of the hidden guarantee user transaction amount.
基于上述理论基础,在本发明实施例中,多家金融机构组建一个联盟,该联盟内的金融机构将用户的交易数据(比如贷款金额或还款金额等),以随机承诺的方式存储在区块链上。因为随机承诺是可以隐藏交易数据,所以,存储在区块链上的随机承诺,即实现了资源共享,也实现了隐藏随机承诺对应的交易数据。举例而言,当某个用户在联盟内的某个金融机构申请一笔贷款时,此机构可以利用区块链上该用户曾经的所有贷款数据(在该联盟内产生的所有贷款数据),判断“如果把这笔钱贷给这个用户,此用户的贷款总额是否超过其可以贷款的总额度”。如果该用户未通过此判断,则该金融机构将不会向该用户贷款,原因是“该用户在贷这笔钱之后,其所有贷款的总数量将超过其可以贷款的总额度”,从而避免了用户的贷款总额超过用户的最大贷款金额。Based on the above theoretical basis, in the embodiment of the present invention, a plurality of financial institutions form an alliance, and the financial institutions in the alliance store the transaction data of the user (such as the loan amount or the repayment amount) in a random commitment manner. On the blockchain. Because the random promise can hide the transaction data, the random commitment stored on the blockchain realizes resource sharing and also realizes the transaction data corresponding to the hidden random promise. For example, when a user applies for a loan from a financial institution within the alliance, the agency can use the loan data (all loan data generated within the alliance) that the user has in the blockchain to determine "If the money is loaned to this user, does the total loan amount of this user exceed the total amount of the loan it can make?" If the user does not pass this judgment, the financial institution will not lend to the user because “the total amount of all loans of the user after lending the money will exceed the total amount of the loan that can be used”, thereby avoiding The total loan amount of the user exceeds the maximum loan amount of the user.
下面首先对本发明实施例提供的一种基于区块链的资金交易方法进行介绍,参见图1,该方法包括如下步骤:The following is a description of a blockchain-based capital transaction method provided by an embodiment of the present invention. Referring to FIG. 1, the method includes the following steps:
S101:接收客户端发送的本次交易信息。S101: Receive the transaction information sent by the client.
在实施时,区块链中的某个服务器为客户端的某个用户,创建一个唯一的账户标识,并将该账户标识存储在一个预设的账户信息表中。当客户端与区块链中的某个服务器进行资金交易时,客户端生成本次交易信息,并将该交易信息发送给与该客户端进行本次交易的服务器,该服务器在验证过本次交易信息中的随机承诺和范围证明之后,处理本次交易并提取本次交易信息中的部分信息,生成交易记录并存储起来;并且该服务器将该交易记录发送给区块链中的所有服务器;所以,区块链中的每个服务器都存储有相同的交易记录,而且,该交易记录是各个用户在联盟中与各个服务器进行的所有交易记录。In implementation, a server in the blockchain creates a unique account identifier for a user of the client, and stores the account identifier in a preset account information table. When the client conducts a fund transaction with a server in the blockchain, the client generates the transaction information, and sends the transaction information to the server that performs the transaction with the client, and the server has verified the current transaction. After the random commitment and the scope proof in the transaction information, the transaction is processed and part of the information in the transaction information is extracted, the transaction record is generated and stored; and the server sends the transaction record to all servers in the blockchain; Therefore, each server in the blockchain stores the same transaction record, and the transaction record is all transaction records of each user in the alliance with each server.
其中,账户标识是用于区别不同的用户,且与用户标识一一对应。账户标识可以是任何用于标识不同用户的标识信息,例如,账户ID(Identification,识别)、账户名称等,本发明中不做具体限定。The account identifier is used to distinguish different users and is in one-to-one correspondence with the user identifier. The account identifier may be any identification information for identifying different users, for example, an account ID (Identification), an account name, and the like, which are not specifically limited in the present invention.
其中,本次交易信息中可以包括交易金额、账户标识、交易类型标识、该交易金额对应的第一随机承诺和第一范围证明、该账户标识的当前的剩余可交易金额对应的第二随机承诺和第二范围证明、该账户标识的第三随机承诺和第三随机承诺对应的知识证明。The transaction information may include a transaction amount, an account identifier, a transaction type identifier, a first random commitment corresponding to the transaction amount, and a first range certificate, and a second random commitment corresponding to the current remaining tradable amount of the account identifier. And a proof of knowledge corresponding to the second range proof, the third random commitment of the account identifier, and the third random commitment.
可选的,在步骤S101服务器接收客户端发送的本次交易信息之前,服务器可以先接收客户端发送的账户创建请求信息;然后,在预设的账户信息表中,查找是否包含用户标识对应的账户标识;若账户信息表中不包含用户标识对应的账户标识,则服务器在接收客户端发送的第四随机承诺对应的知识证明时,根据预设的知识证明验证算法,验证第四随机承诺对应的知识证明是否有效;若第四随机承诺对应的知识证明有效,则创建用户标识对应的账户标识和交易总金额。Optionally, before the server receives the transaction information sent by the client, the server may first receive the account creation request information sent by the client; and then, in the preset account information table, whether the user identifier is included in the preset account information table. If the account information table does not include the account identifier corresponding to the user identifier, the server, when receiving the knowledge certificate corresponding to the fourth random commitment sent by the client, verifies the fourth random commitment according to the preset knowledge proof verification algorithm. Whether the knowledge proof is valid; if the knowledge proof corresponding to the fourth random commitment is valid, the account identifier corresponding to the user identifier and the total transaction amount are created.
其中,账户创建请求信息中可以包括用户标识,用户标识为用于区别不同用户的标识信息,可以为用户ID、用户名称等,这里不做限定。The account creation request information may include a user identifier, and the user identifier is used to distinguish the identifier information of the different users, and may be a user ID, a user name, and the like, which are not limited herein.
在实施时,服务器在接收到客户端发送的本次交易信息时,服务器在预设的账号信息表中,查找是否存储有本次交易信息中的账户标识。若服务器中预设的账户信息表中存储有上述本次交易信息中的账户标识,说明本账户标识对应的用户标识不是第一次与金融机构进行资金交易,则执行步骤S102;若服务器中预设的账户信息表中未存储上述本次交易信息中的账户标识,说明该用户标识为第一次与金融机构进行资金交易,则服务器需要为该用户标识创建一个账户标识。In the implementation, when the server receives the transaction information sent by the client, the server searches the preset account information table to find whether the account identifier in the transaction information is stored. If the account identifier in the current transaction information is stored in the account information table preset in the server, indicating that the user identifier corresponding to the account identifier is not the first time to conduct a fund transaction with the financial institution, step S102 is performed; The account information in the transaction information table is not stored in the account information table, indicating that the user identifier is the first time to conduct a fund transaction with the financial institution, and the server needs to create an account identifier for the user identifier.
进一步的,服务器可以接收客户端发送的第四随机承诺和第四随机承诺对应的知识证明;并根据预设的知识证明验证算法,验证上述第四随机承诺对应的知识证明是否有效。若上述第四随机承诺对应的知识证明有效,则服务器为用户标识创建用户标识对应的账户,并设置该账户的账户标识和交易总金额。Further, the server may receive the knowledge proof corresponding to the fourth random commitment and the fourth random commitment sent by the client, and verify whether the knowledge proof corresponding to the fourth random commitment is valid according to the preset knowledge verification verification algorithm. If the knowledge verification corresponding to the fourth random commitment is valid, the server creates an account corresponding to the user identifier for the user identifier, and sets an account identifier and a total transaction amount of the account.
在本发明实施例中,客户端可以根据用户输入的随机数k,计算R=kH;其中,点R的坐标为(x2,y2);令r=x2,如果r=0,则重新选择随机数k;根据预设的哈希函数,计算数值m的哈希值:z=Hash(m);再计算s=k-1(z+r×sk),如果s=0,则重新选择随机数k。最后对计算结果s的取余数,得到s′,将{r,s′}确定为上述第四随机承诺对应的知识证明。In the embodiment of the present invention, the client may calculate R=kH according to the random number k input by the user; wherein, the coordinate of the point R is (x2 , y2 ); let r=x2 , if r=0, then Reselect the random number k; calculate the hash value of the value m according to the preset hash function: z=Hash(m); then calculate s=k-1 (z+r×sk), if s=0, then Reselect the random number k. Finally, the remainder of the calculation result s is obtained, and s' is obtained, and {r, s'} is determined as the knowledge proof corresponding to the fourth random commitment.
在本发明实施例中,可以采用如下知识证明验证算法,验证第四随机承诺对应的知识证明{r,s′},具体计算公式如下:In the embodiment of the present invention, the following knowledge can be used to prove the verification algorithm to verify the knowledge proof {r, s'} corresponding to the fourth random commitment, and the specific calculation formula is as follows:
z=Hash(m)z=Hash(m)
w=S′-1w=S'-1
(x1,y1)=z×w×H+r×w×pk(x1 , y1 )=z×w×H+r×w×pk
其中,m为客户端发送的哈希值,该哈希值可以是客户端根据预设的哈希函数,计算出的用户ID对应的哈希值、业务序列号对应的哈希值或金融机构ID等信息对应的哈希值中的一种或多种,r和s′为第四随机承诺对应的知识证明中的签名,pk为公钥,H的坐标为(x0,y0)。Where m is a hash value sent by the client, and the hash value may be a hash value corresponding to the user ID calculated by the client according to the preset hash function, a hash value corresponding to the service serial number, or a financial institution. One or more of the hash values corresponding to the ID and the like, r and s' are the signatures in the knowledge proof corresponding to the fourth random promise, pk is the public key, and the coordinates of H are (x0 , y0 ).
如果(x1,y1)=0,则证明上述第四随机承诺对应的知识证明{r,s′}为无效;如果(x1,y1)≠0、且x1=r,则证明上述第四随机承诺对应的知识证明{r,s′}为有效。If (x1 , y1 )=0, it is proved that the knowledge proof {r, s'} corresponding to the fourth random commitment is invalid; if (x1 , y1 ) ≠ 0, and x1 = r, then the proof The knowledge proof {r, s'} corresponding to the fourth random commitment described above is valid.
本申请实施例中,服务器在验证上述第四随机承诺对应的知识证明为有效,并为用户标识创建对应的账户标识和交易总金额之后,服务器还可以根据创建的用户标识对应的交易总金额S,确定账户标识与本联盟中所有金融机构进行资金交易的总金额S对应的随机承诺。In the embodiment of the present application, after the server verifies that the knowledge certificate corresponding to the fourth random commitment is valid, and creates a corresponding account identifier and a transaction total amount for the user identifier, the server may further obtain a transaction total amount corresponding to the created user identifier. A random commitment corresponding to the total amount S of the account transactions with all financial institutions in the alliance.
其中,服务器中预设的随机承诺的计算公式为:The calculation formula of the random commitment preset in the server is:
CM=n×G+k×HCM=n×G+k×H
CM为随机承诺,n为用户输入的交易金额,k为用户输入的随机数,H的坐标为(x0,y0)),G为坐标点(x01,y01)。CM is a random commitment, n is the transaction amount input by the user, k is the random number input by the user, the coordinate of H is (x0 , y0 )), and G is the coordinate point (x01 , y01 ).
根据客户端发送的账户标识的第四随机承诺和服务器为该账户标识创建的交易总金额S可知,账户标识的交易总金额对应的随机承诺为:The fourth random promise based on the account ID sent by the client And the total transaction amount S created by the server for the account identification, the random commitment corresponding to the total transaction amount of the account identification is:
其中,CM0为账户标识的可交易总金额对应的随机承诺,S为账户标识与本联盟中所有金融机构进行资金交易的总金额,G的坐标为(x01,y01),为第四随机承诺。Where CM0 is the stochastic commitment corresponding to the total tradable amount of the account identification, and S is the total amount of the account identification and the financial transactions of all financial institutions in the alliance, and the coordinate of G is (x01 , y01 ), For the fourth random commitment.
之后,服务器将该账户标识、该账户标识的可交易总金额、该账户标识的可交易总金额对应的随机承诺、可交易总金额的随机承诺对应的知识证明和交易类型标识存储在区块链中。当服务器将上述账户标识、账户标识的可交易总金额、账户标识的可交易总金额对应的随机承诺、第四随机承诺和第四随机承诺对应的知识证明和交易类型标识,发送给区块链中的其他服务器进行存储时,其他服务器,可以对上述信息中的可交易总金额的随机承诺对应的知识证明进行验证,具体验证方法如上述知识证明的验证描述过程。若验证通过,区块链中的其他服务器则存储上述账户标识、账户标识的可交易总金额、账户标识的可交易总金额对应的随机承诺、第四随机承诺和第四随机承诺对应的知识证明和交易类型标识;否则,区块链中的其他服务器则丢弃账户标识、账户标识的可交易总金额、账户标识的可交易总金额对应的随机承诺、第四随机承诺和第四随机承诺对应的知识证明和交易类型标识。Thereafter, the server stores the account identifier, the tradable total amount of the account identifier, the random commitment corresponding to the tradable total amount of the account identifier, the knowledge proof corresponding to the random commitment of the total tradable amount, and the transaction type identifier in the blockchain. in. When the server sends the above account identifier, the tradable total amount of the account identifier, the stochastic commitment corresponding to the tradable total amount of the account identifier, the fourth random commitment and the knowledge certificate and the transaction type identifier corresponding to the fourth random commitment, to the blockchain When other servers in the storage are stored, other servers may verify the knowledge proof corresponding to the random commitment of the total tradable amount in the above information, and the specific verification method is the verification description process of the above knowledge proof. If the verification is passed, the other servers in the blockchain store the above account identifier, the total tradable amount of the account identifier, the random commitment corresponding to the total tradable amount of the account identifier, the fourth random commitment, and the knowledge proof corresponding to the fourth random commitment. And the transaction type identifier; otherwise, the other servers in the blockchain discard the account identifier, the total tradable amount of the account identifier, the random commitment corresponding to the total tradable amount of the account identifier, the fourth random commitment, and the fourth random commitment Knowledge proof and transaction type identification.
在本发明实施例中,所有的随机承诺对应的知识证明的验证过程都可以采用上述相同的验证算法。同理,本发明实施例只是提供了一种可选的知识证明的验证算法,其他任何可用于随机承诺对应的知识证明的验证算法都可以应用到本发明实施例中,这里不做具体限定。In the embodiment of the present invention, the verification process of the knowledge proof corresponding to all the random commitments may adopt the same verification algorithm as described above. For the same reason, the embodiment of the present invention provides only an optional verification algorithm of the knowledge proof. Any other verification algorithm that can be used for the corresponding proof of the knowledge of the random commitment can be applied to the embodiment of the present invention, which is not specifically limited herein.
S102:从历史交易记录中获取账户标识对应的上一次交易记录。S102: Obtain a previous transaction record corresponding to the account identifier from the historical transaction record.
在实施中,服务器将区块链中的每次交易的交易信息都存储在区块链上,并将本次交易信息之前的所有交易信息称为历史交易记录;其中,历史交易记录中可以包括随机承诺和范围证明、账户标识和交易类型标识。In the implementation, the server stores the transaction information of each transaction in the blockchain on the blockchain, and refers to all transaction information before the transaction information as a historical transaction record; wherein the historical transaction record may include Random commitment and scope proof, account identification and transaction type identification.
服务器在存储有历史交易记录的区块链中,获取与上述账户标识对应的上一次交易信息,通过读取该账户标识对应的上一次交易信息中记录的该账户标识对应的当前的剩余可交易金额对应的第二随机承诺,服务器根据预设的随机承诺交易金额查看方法,查看第二随机承诺中账户标识对应的当前的剩余可交易金额,将账户标识对应的当前的剩余可交易金额与该客户端发送的本次交易申请中账户标识本次申请的交易金额比较,如果客户端发送的本次交易申请中账户标识本次申请的交易金额大于和/或等于该账户标识对应的当前的剩余可交易金额,则服务器向客户端发送本次交易申请失败信息;如果客户端发送的本次交易申请中账户标识本次申请的交易金额小于该账户标识对应的当前的剩余可交易金额,服务器则执行步骤S104。The server obtains the last transaction information corresponding to the account identifier in the blockchain storing the historical transaction record, and reads the current remaining tradable corresponding to the account identifier recorded in the last transaction information corresponding to the account identifier. The second random commitment corresponding to the amount, the server according to the preset random commitment transaction amount viewing method, viewing the current remaining tradable amount corresponding to the account identifier in the second random commitment, and the current remaining tradable amount corresponding to the account identifier and the The account number in the transaction request sent by the client is compared with the transaction amount of the current application. If the account identifier of the current transaction in the transaction request sent by the client is greater than and/or equal to the current surplus corresponding to the account identifier The tradable amount, the server sends the transaction request failure information to the client; if the account identifier in the transaction request sent by the client is less than the current remaining tradable amount corresponding to the account identifier, the server Step S104 is performed.
可选的,如果客户端发送的本次交易信息为某用户标识的第一次交易申请,那么,服务器查询到的该账户标识对应的上一次交易信息中的剩余可交易金额对应的承诺,正好也是该用户可交易总额度的承诺(建账时所得到的)。但如果后续客户端再次发送交易申请,当服务器查询该账户标识最近一次交易信息时,服务器查到的就会是当前的剩余可交易金额的随机承诺。Optionally, if the transaction information sent by the client is the first transaction request of the user identifier, the commitment corresponding to the remaining tradable amount in the previous transaction information corresponding to the account identifier queried by the server is exactly It is also the commitment of the user to trade the total amount (obtained when the account was created). However, if the subsequent client sends the transaction request again, when the server queries the account to identify the latest transaction information, the server will find the random commitment of the current remaining tradable amount.
举例而言,服务器为账户标识为P的用户创建的交易总额度为S,该客户端第一次发送的交易申请信息中,该用户申请的贷款金额为n1,那么,当客户端第二次发送交易申请信息时,服务器获取到的该账户标识对应的上一次剩余可交易金额对应的承诺中,记录的该账户标识对应的当前剩余可贷款金额为S-n1;同理,如果该用户第二次申请的贷款金额为n2,则当客户端发送第三次交易申请信息时,服务器获取到的该账户标识对应的上一次剩余可交易金额对应的承诺中,记录的该账户标识对应的当前剩余可贷款金额为S-n1-n2,依次类推。可以理解的是,如果客户端发送的交易申请信息中,交易类型标识为repay,即还款交易,则服务器在执行完本次交易之后,该用户的剩余可交易金额对应的承诺中,记录的该账户标识对应的当前剩余可交易金额为S-n1+n2,其中,n2为客户端发送的本次交易信息中的还款金额。For example, the total transaction amount created by the server for the user whose account identifier is P is S. In the transaction application information sent by the client for the first time, the loan amount applied by the user is n1, then, when the client is the second time When the transaction application information is sent, the current remaining loanable amount corresponding to the account identifier recorded by the server corresponding to the previous remaining tradable amount corresponding to the account identifier is S-n1; similarly, if the user is the first The loan amount of the second application is n2, when the client sends the third transaction application information, the current account corresponding to the last remaining tradable amount corresponding to the account identifier obtained by the server, the current account corresponding to the recorded account identifier The remaining loanable amount is S-n1-n2, and so on. It can be understood that if the transaction type identifier is the repay, that is, the repayment transaction, in the transaction application information sent by the client, the server records the commitment corresponding to the remaining tradable amount of the user after executing the transaction. The current remaining tradable amount corresponding to the account identifier is S-n1+n2, where n2 is the repayment amount in the transaction information sent by the client.
S103:根据预设的验证算法,确定本次交易信息中交易金额对应的第一随机承诺和第一范围证明、以及账户标识的当前的剩余可交易金额对应的第二随机承诺和第二范围证明、以及账户标识的第三随机承诺和第三随机承诺对应的知识是否有效。S103: Determine, according to a preset verification algorithm, a first random commitment and a first scope certificate corresponding to the transaction amount in the transaction information, and a second random commitment and a second scope certificate corresponding to the current remaining tradable amount of the account identifier. And whether the knowledge corresponding to the third random commitment of the account identifier and the third random promise is valid.
在实施中,范围证明是利用包含两个公钥的环签名的算法构成的,其是客户端为了证明客户端发送的随机承诺中的交易金额在某个范围之内,客户端为服务器提供的数据证据。In the implementation, the scope proof is constructed by an algorithm that uses a ring signature containing two public keys, which is provided by the client to prove that the transaction amount in the random commitment sent by the client is within a certain range. Data evidence.
随机承诺对应的范围证明采用的验证,其实质是对构成范围证明的环签名的验证,具体的,验证构成范围证明的环签名的计算公式如下:The verification of the scope corresponding to the random promise proves that the essence of the verification is the verification of the ring signature constituting the scope proof. Specifically, the calculation formula of the ring signature that proves the proof of the scope is as follows:
T0=c0×pk0+z0×HT0 =c0 ×pk0 +z0 ×H
T1=c1×pk1+z1×HT1 = c1 × pk1 + z1 × H
h=Hash(pk0,pk1,T0,T1)h=Hash(pk0 , pk1 , T0 , T1 )
其中,pk0为用户的公钥,pk1和pk2为预设的其他用户的公钥,H的坐标为(x0,y0),z1和c1为用户输入的随机数,T0、T1、c0和z0为环签名中的参数。Where pk0 is the public key of the user, pk1 and pk2 are preset public keys of other users, the coordinates of H are (x0 , y0 ), z1 and c1 are random numbers input by the user, T0 , T1 , c0, and z0 are the parameters in the ring signature.
如果计算结果h与客户端发送的范围证明中的参数c1的进行逐比特模2运算得到的值与客户端发送的环签名中的参数c0相等,则证明上述环签名有效,由于范围证明是由一系列的环签名构成的,所以,环签名有效则该环签名构成的范围证明也有效。其中,范围证明的计算过程将在后续描述中介绍。If the calculation result h is performed with the parameter c1 in the range certificate sent by the client, the bit-by-bit modulo 2 operation is performed. If the obtained value is equal to the parameter c0 in the ring signature sent by the client, it proves that the ring signature is valid. Since the range certificate is composed of a series of ring signatures, if the ring signature is valid, the range of the ring signature is proved. Also effective. Among them, the calculation process of the scope proof will be introduced in the following description.
可选的,在上述步骤,服务器根据预设的验证算法,确定本次交易信息中交易金额对应的第一随机承诺、第一范围证明和账户标识的当前的剩余可交易金额对应的第二随机承诺和第二范围证明、以及账户标识的第三随机承诺和第三随机承诺对应的知识有效之后,还可以判断如下公式是否成立:Optionally, in the foregoing step, the server determines, according to the preset verification algorithm, a first random commitment corresponding to the transaction amount in the transaction information, a first range certificate, and a second random corresponding to the current remaining tradable amount of the account identifier. After the commitment and the second scope proof, and the knowledge corresponding to the third random commitment and the third random commitment of the account identifier are valid, it is also possible to determine whether the following formula holds:
GM1,1=GM0-GM1,0GM1,1 =GM0 -GM1,0
其中,CM1,1为账户标识当前的剩余可交易金额对应的第二随机承诺,CM0为账户标识对应的总交易金额对应随机承诺和CM1,0为本次交易信息中交易金额对应的第一随机承诺,n1为本次交易信息中用户申请的交易金额,G的坐标为(x01,y01),为账户标识的第三随机承诺。Where CM1,1 is the second random commitment corresponding to the current remaining tradable amount of the account identifier, and CM0 is the total transaction amount corresponding to the account identifier corresponding to the random commitment and CM1,0 corresponding to the transaction amount in the transaction information The first random promise, n1 is the transaction amount requested by the user in the transaction information, and the coordinate of G is (x01 , y01 ), The third random commitment identified for the account.
如果上述和CM1,1=CM0-CM1,0等式成立,则服务器执行步骤S104;如果上述等式和CM1,1=CM0-CM1,0等式不成立,则服务器向客户端发送本次交易申请失败信息。If above And CM1,1 =CM0 -CM1,0 equation is established, then the server performs step S104; if the above equation And the CM1,1 = CM0 -CM1,0 equation does not hold, the server sends the transaction request failure information to the client.
S104:若第一随机承诺、第一范围证明、第二随机承诺和第二范围证明、第三随机承诺和第三随机承诺对应的知识证明有效,则根据本次交易信息进行本次交易处理。S104: If the knowledge of the first random commitment, the first scope proof, the second random commitment and the second random proof, the third random commitment, and the third random commitment are valid, the transaction processing is performed according to the transaction information.
在实施时,服务器在根据预设的验证算法,证明了上述第一随机承诺、第一范围证明、第二随机承诺、第二范围证明、第三随机承诺和第三随机承诺对应的知识证明有效之后,服务器根据本次交易信息中记录的交易类型标识,进行本次交易处理。In implementation, the server proves that the knowledge of the first random commitment, the first scope proof, the second random commitment, the second scope proof, the third random commitment, and the third random commitment is valid according to a preset verification algorithm. After that, the server performs the transaction processing according to the transaction type identifier recorded in the transaction information.
若本次交易信息中记录的交易类型标识为贷款标识(即load),则服务器将本次交易信息中用户申请贷款的金额发送给客户端。若本次交易信息中记录的交易类型标识为还款标识(即repay),则服务器接收客户端发送的本次交易信息中记录的还款金额。If the transaction type recorded in the transaction information is identified as a loan identifier (ie, load), the server sends the amount of the user's application for the loan in the transaction information to the client. If the transaction type recorded in the transaction information is identified as a repayment identifier (ie, repay), the server receives the repayment amount recorded in the transaction information sent by the client.
进一步的,在服务器处理完上述交易之后,服务器还可以将客户端发送的本次交易信息中的交易金额对应的第一随机承诺和第一范围证明、账户标识当前的剩余可交易金额对应的第二随机承诺和第二随机承诺对应的第二范围证明、账户标识和交易类型标识,作为历史交易记录,存储在区块链中。Further, after the server processes the transaction, the server may further correspond to the first random commitment corresponding to the transaction amount in the current transaction information sent by the client, and the first range certificate and the current remaining tradable amount of the account identifier. The second range certificate, the account identifier and the transaction type identifier corresponding to the second random commitment and the second random commitment are stored as historical transaction records in the blockchain.
本发明实施例提供了一种贷款方法,区块链中的服务器接收客户端发送的本次交易信息,然后,从历史交易记录中获取账户标识对应的上一次交易信息;根据预设的验证算法,确定本次交易信息中交易金额对应的第一随机承诺、第一范围证明、账户标识的当前的剩余可交易金额对应的第二随机承诺、第二范围证明、账户标识的第三随机承诺和第三随机承诺对应的知识证明是否有效;若第一随机承诺和所述第一随机承诺对应的第一范围证明和第二随机承诺、第二随机承诺对应的第二范围证明、账户标识的第三随机承诺和第三随机承诺对应的知识证明有效,则根据本次交易信息进行本次交易处理。由于本发明实施例中,将随机承诺和范围证明与区块链相结合,从而在保证用户交易金额保密性的同时,能够有效地防止恶意用户在多家金融机构中的恶意超额交易行为。The embodiment of the invention provides a loan method. The server in the blockchain receives the transaction information sent by the client, and then obtains the last transaction information corresponding to the account identifier from the historical transaction record; according to the preset verification algorithm Determining a first random commitment corresponding to the transaction amount in the transaction information, a first scope certificate, a second random commitment corresponding to the current remaining tradable amount of the account identifier, a second scope proof, and a third random commitment of the account identifier Whether the knowledge proof corresponding to the third random commitment is valid; if the first random commitment and the first random commitment correspond to the first scope proof and the second random commitment, the second random commitment corresponds to the second scope proof, and the account identifier If the knowledge corresponding to the three random commitments and the third random commitment is valid, the transaction processing is performed according to the transaction information. In the embodiment of the present invention, the random commitment and the scope proof are combined with the blockchain, thereby ensuring the malicious excess transaction behavior of the malicious user in a plurality of financial institutions while ensuring the confidentiality of the transaction amount of the user.
参见图2,图2为本发明实施例的另一基于区块链的资金交易方法的流程示意图,该方法应用于客户端,包括如下步骤:Referring to FIG. 2, FIG. 2 is a schematic flowchart diagram of another blockchain-based capital transaction method according to an embodiment of the present invention. The method is applied to a client, and includes the following steps:
S201:获取用户输入的交易申请信息。S201: Obtain transaction application information input by the user.
在实施时,客户端每次与区块链中的任何一个服务器进行资金交易时,都需要先向输入交易申请信息。其中,交易申请信息可以包括账户标识、交易类型标识和交易金额。同理,交易类型标识为用于区别本次交易为贷款交易,还是还款交易;若本次交易是贷款交易,交易类型标识可以为load;若本次交易是还款交易,交易类型标识可以为repay。In the implementation, each time the client conducts a fund transaction with any one of the servers in the blockchain, it needs to first input the transaction request information. The transaction application information may include an account identifier, a transaction type identifier, and a transaction amount. Similarly, the transaction type identifier is used to distinguish whether the transaction is a loan transaction or a repayment transaction; if the transaction is a loan transaction, the transaction type identifier can be load; if the transaction is a repayment transaction, the transaction type identifier can be For repay.
客户端在接收到用户输入的交易申请信息时,需要判断发送该交易申请信息的用户是否是第一次发送交易申请信息;若不是,则直接执行步骤S202;When receiving the transaction application information input by the user, the client needs to determine whether the user who sent the transaction application information is the first time to send the transaction application information; if not, directly execute step S202;
客户端在接收到用户输入的交易申请信息时,需要判断发送该交易申请信息的用户是否是第一次发送交易申请信息;若不是,则直接执行步骤S202;可选的,若客户端判断发送该交易申请信息的用户是第一次发送交易申请信息,则客户端向服务器发送账户创建请求信息;其中,账户创建请求信息中包括用户标识;并客户端获取用户输入的随机数;根据用户输入的随机数和预设的随机承诺生成算法,确定第四随机承诺;根据预设的知识证明生成算法,确定第四随机承诺对应的知识证明;将第四随机承诺和第四随机承诺对应的知识证明发送至上述服务器。When receiving the transaction application information input by the user, the client needs to determine whether the user who sent the transaction application information is the first time to send the transaction application information; if not, directly execute step S202; optionally, if the client determines to send the message The user of the transaction application information is the first time to send the transaction application information, and the client sends the account creation request information to the server; wherein the account creation request information includes the user identifier; and the client obtains the random number input by the user; The random number and the preset random commitment generation algorithm determine the fourth random commitment; determine the knowledge proof corresponding to the fourth random commitment according to the preset knowledge proof generation algorithm; and the knowledge corresponding to the fourth random promise and the fourth random promise The certificate is sent to the above server.
在实施时,预设的随机承诺生成算法的计算公式,可以如下:In the implementation, the calculation formula of the preset random commitment generation algorithm can be as follows:
CM=n×G+k×HCM=n×G+k×H
其中,CM为随机承诺,k为用户输入的随机数,H的坐标为(x0,y0)。Among them, CM is a random promise, k is a random number input by the user, and the coordinate of H is (x0 , y0 ).
由于本步骤中是用户第一次输入的交易申请信息时,为了在服务器设备中给该用户标识创建账户标识时,进行的第四随机承诺计算过程,所以,交易金额n的取值为零,则客户端得到的第四随机承诺为其中,Since the transaction request information input by the user for the first time is in this step, in order to create an account identifier for the user identifier in the server device, the fourth random commitment calculation process is performed, so the transaction amount n has a value of zero. Then the fourth random commitment obtained by the client is among them,
可选的,在本发明实施例中提供的随机承诺生成算法只是众多随机承诺生成算法中的一种,其他任何用于生成随机承诺的生成算法都可以应用于本发明实施例中,这里不做具体限定。Optionally, the random commitment generation algorithm provided in the embodiment of the present invention is only one of a plurality of random commitment generation algorithms, and any other generation algorithm for generating a random commitment may be applied to the embodiment of the present invention. Specifically limited.
在实施时,客户端可以根据用户输入的随机数k,计算R=kH;其中,点R的坐标为(x2,y2);令r=x2,如果r=0,则重新选择随机数k;根据预设的哈希函数,计算数值m的哈希值:z=Hash(m);再计算s=k-1(z+r×sk),如果s=0,则重新选择随机数k。最后对计算结果s的取余数,得到s′,将{r,s′}确定为上述第四随机承诺对应的知识证明。In implementation, the client can calculate R=kH according to the random number k input by the user; wherein the coordinates of the point R are (x2 , y2 ); let r=x2 , if r=0, reselect the random Number k; according to the preset hash function, calculate the hash value of the value m: z = Hash (m); then calculate s = k-1 (z + r × sk), if s = 0, then re-select random Number k. Finally, the remainder of the calculation result s is obtained, and s' is obtained, and {r, s'} is determined as the knowledge proof corresponding to the fourth random commitment.
S202:根据交易金额,确定交易金额对应的第一随机承诺和第一随机承诺对应的第一范围证明。S202: Determine, according to the transaction amount, a first random proof corresponding to the transaction amount and a first range proof corresponding to the first random commitment.
在实施时,由于范围证明是利用包含有两个公钥的环签名的算法构成的,因此,计算随机承诺对应的范围证明,就是计算环签名。In implementation, since the range proof is constructed using an algorithm that includes a ring signature with two public keys, the calculation of the range corresponding to the random promise is to calculate the ring signature.
具体生成环签名的步骤如下:The steps to generate a ring signature are as follows:
用户拥有自己的公钥pk0和私钥sk0,以及一个其他人的公钥pk1。客户端可以根据用户输入的三个不同的随机数k1、k2和k3,和预设的公钥pk0,pk1和私钥sk0,可以得到T1=k1×pk1+k2×H和T0=k3×H;再根据预设的哈希函数,可以得到:The user has his own public key pk0 and private key sk0 , and one other person's public key pk1 . The client can obtain T1 =k1 ×pk1 + according to three different random numbers k1 , k2 and k3 input by the user, and the preset public key pk0 , pk1 and private key sk0 . k2 ×H and T0 =k3 ×H; according to the preset hash function, we can get:
Hash(pk0,pk1,T0,T1)Hash(pk0 , pk1 , T0 , T1 )
并通过Hash(pk0,pk1,T0,T1)与k1进行逐比特模2加运算,得到:And through Hash (pk0 , pk1 , T0 , T1 ) and k1 bit-by-bit modulo 2 addition operation, to obtain:
和z0=k3-c0sk0 And z0 =k3 -c0 sk0
并将{pk0,pk1,c0,k1,z0,k2}称为一个以{pk0,pk1}为公钥的环签名。该环签名的有效性能够证明,签名者一定持有pk0,pk1中某个公钥对应的私钥,否则签名者无法生成有效的环签名。但验证者无法判断签名者持有的是pk0的私钥sk0,还是pk1的私钥sk1。签名者可以调整{pk0,pk1}中公钥的顺序,即用户也可以产生以{pk1,pk0}为公钥的环签名。但需要强调的是,如果公钥顺序为{pk1,pk0},那么在计算哈希值时,输入的顺序应该为Hash(pk1,pk0,T1,T0),并且最终的环签名也应该为{pk1,pk0,k,c0,k2,z0}。And {pk0 , pk1 , c0 , k1 , z0 , k2 } is called a ring signature with {pk0 , pk1 } as the public key. The validity of the ring signature can prove that the signer must hold the private key corresponding to a public key in pk0 and pk1 , otherwise the signer cannot generate a valid ring signature. However, the verifier can not determine the signer is held by the private key sk0 pk0, or private key sk pk1 of1. The signer can adjust the order of the public keys in {pk0 , pk1 }, that is, the user can also generate a ring signature with {pk1 , pk0 } as the public key. However, it should be emphasized that if the public key order is {pk1 , pk0 }, then in the calculation of the hash value, the input order should be Hash (pk1 , pk0 , T1 , T0 ), and the final The ring signature should also be {pk1 , pk0 , k, c0 , k2 , z0 }.
由于范围证明是利用包含两个公钥的环签名的算法构成的,其是客户端为了证明客户端发送的随机承诺中的交易金额在某个范围之内,客户端为服务器提供的数据证据。只要客户端可以生成上述环签名,且该环签名是有效的,则客户端就证明了随机承诺CM=n×G+k×H中的n属于(0,2d+1)。Since the scope proof is constructed by an algorithm that uses a ring signature containing two public keys, it is the data evidence provided by the client for the server in order to prove that the transaction amount in the random commitment sent by the client is within a certain range. As long as the client can generate the above ring signature and the ring signature is valid, the client proves that n in the random commitment CM=n×G+k×H belongs to (0,2d+1 ).
生成n的范围证明的过程如下:The process of generating a range proof of n is as follows:
客户端将上述中的n转化为2进制形式,具体如下:The client converts the above n into a binary form, as follows:
n=nd2d+nd-12d-1+…+n12+n0n=nd 2d +nd-1 2d-1 +...+n1 2+n0
其中,nm=0或1,m的取值为0,1,2,...,d。Where nm =0 or 1, and the value of m is 0, 1, 2, ..., d.
客户端以{nm2m×G+km×H,nm2m×G+km×H-2m×G}作为环签名的公钥,以km为环签名的私钥,计算一个环签名σm。如果该环签名σm是有效的,其可以证明nm一定是0或1。The client uses {nm 2m ×G+km ×H,nm 2m ×G+km ×H-2m ×G} as the public key of the ring signature, and the private key signed by km as the ring. Calculate a ring signature σm . If the ring signature σm is valid, it can prove that nm must be 0 or 1.
以此方法,客户端可以生成所有σd,σd-1,…,σ1,σ0。如果σd,σd-1,…,σ1,σ0都有效,则证明n属于(0,2d+1)。{σd,σd-1,...,σ1,σ0}就是n的范围证明。In this way, the client can generate all σd , σd-1 ,..., σ1 , σ0 . If σd , σd-1 ,..., σ1 , σ0 are all valid, it is proved that n belongs to (0, 2d+1 ). {σd , σd-1 ,..., σ1 , σ0 } is the proof of the range of n.
m取值为1,2,…,d,具体生成σm的过程如下:The value of m is 1, 2, ..., d. The process of generating σm is as follows:
当nm=0时:When nm =0:
此时{nm2mG+kmH,nm2mG+kmH-2mG}={kmH,kmH-2mG},因为km是由用户在客户端输入的随机数和kmH是关于H的离散对数;因此,客户端生成的上述{nm2mG+kmH,nm2mG+kmH-2mG}为公钥的有效环签名。At this time {nm 2m G+km H,nm 2m G+km H-2m G}={km H,km H-2m G}, because km is by the customer at the customer The random number and km H of the input are the discrete logarithm of H; therefore, the above {nm 2m G+km H,nm 2m G+km H-2m G} generated by the client is A valid ring signature for the public key.
当nm=1时:When nm =1:
此时{nm2mG+kmH,nm2mG+kmH-2mG}={nm2mG+kmH,kmH},因为km是由用户在客户端输入的随机数和kmH是关于H的离散对数;因此,客户端生成的上述{nm2mG+kmH,nm2mG+kmH-2mG}为公钥的有效环签名。At this time {nm 2m G+km H,nm 2m G+km H-2m G}={nm 2m G+km H,km H}, because km is by the user The random number entered at the client and km H are the discrete logarithm of H; therefore, the above {nm 2m G+km H,nm 2m G+km H-2m G generated by the client } is the valid ring signature for the public key.
当nm≠1且nm≠0时:When nm ≠1 and nm ≠0:
此时公钥为{nm2mG+kmH,nm2mG+kmH-2mG},因为km是由用户在客户端输入的随机数和kmH是关于H的离散对数;因此,用户未在客户端中输入上述{nm2mG+kmH,nm2mG+kmH-2mG}中的任何一个公钥对应的私钥,所以客户端无法产生一个已{nm2mG+kmH,nm2mG+kmH-2mG}为公钥的环签名。At this time, the public key is {nm 2m G+km H, nm 2m G+km H-2m G}, because km is the random number and km H input by the user at the client. The discrete logarithm of H; therefore, the user does not enter the private key corresponding to any one of the above {nm 2m G+km H, nm 2m G+km H-2m G} in the client Key, so the client cannot generate a ring signature with {nm 2m G+km H,nm 2m G+km H-2m G} as the public key.
因此,只要客户端已{nm2mG+kmH,nm2mG+kmH-2mG}为公钥,产生一个环签名,且环签名是有效的,那么nm的取值为0或1,从而范围证明就证明了该范围证明对应的随机承诺中的某个数据是没有超出预设的范围。Therefore, as long as the client has {nm 2m G+km H, nm 2m G+km H-2m G} is the public key, a ring signature is generated, and the ring signature is valid, then nm The value of the value is 0 or 1, so that the range proof proves that the range proves that a certain data in the corresponding random commitment does not exceed the preset range.
关于该步骤中交易金额对应的第一随机承诺的具体实现以及相关解释内容可以参见上述步骤S101中随机承诺的计算过程,在此不做赘述。For the specific implementation of the first random commitment corresponding to the transaction amount in this step and the related explanation, refer to the calculation process of the random commitment in the above step S101, and no further description is provided herein.
S203:确定账户标识的当前的剩余可交易金额,以及账户标识的剩余可交易金额对应的第二随机承诺和第二范围证明。S203: Determine a current remaining tradable amount of the account identifier, and a second random commitment and a second range proof corresponding to the remaining tradable amount of the account identifier.
在实施时,关于该步骤中剩余可交易金额对应的第二随机承诺和第二范围证明的具体实现以及相关解释内容可以参见上述步骤S101中随机承诺的计算过程和步骤S202中范围证明的计算过程,在此不做赘述。In implementation, for the specific implementation of the second random commitment and the second scope proof corresponding to the remaining tradable amount in the step, and related related content, refer to the calculation process of the random commitment in the above step S101 and the calculation process of the scope proof in step S202. I will not repeat them here.
S204:根据交易金额对应的第一随机承诺和预设的知识证明生成算法,确定账户标识的第三随机承诺和第三随机承诺对应的知识证明。S204: Determine a third random commitment corresponding to the account identifier and a knowledge certificate corresponding to the third random commitment according to the first random commitment corresponding to the transaction amount and the preset knowledge proof generation algorithm.
在实施时,在步骤S201中得到交易金额对应的第一随机承诺CM=n×G+k×H时,客户端将第一随机承诺中的kH称为账户标识的第三随机承诺;再通过步骤S101中随机承诺对应的知识证明的计算过程,可以得到第三随机承诺对应的知识证明。其中,账户标识的第三随机承诺对应的知识证明可以证明第三随机承诺确实是用户输入的交易金额n对应的随机承诺。In implementation, when the first random commitment CM=n×G+k×H corresponding to the transaction amount is obtained in step S201, the client refers to kH in the first random commitment as the third random commitment of the account identifier; In step S101, the calculation process of the corresponding knowledge proof is randomly promised, and the knowledge proof corresponding to the third random commitment can be obtained. The knowledge proof corresponding to the third random commitment of the account identifier may prove that the third random commitment is indeed a random commitment corresponding to the transaction amount n input by the user.
S205:将交易申请信息、交易金额对应的第一随机承诺和第一范围证明和账户标识的剩余可交易金额对应的第二随机承诺和第二范围证明、账户标识的第三随机承诺和所述第三随机承诺对应的知识证明,组成本次交易信息。S205: a second random commitment and a second scope proof corresponding to the transaction request information, the first random commitment corresponding to the transaction amount, and the first range certificate and the remaining tradable amount of the account identifier, the third random commitment of the account identifier, and the The knowledge certificate corresponding to the third random commitment constitutes the transaction information.
S206:将本次交易信息发送至区块链中的服务器,以使服务器根据预设的验证算法,验证本次交易信息是否正确,若正确,则进行本次交易处理。S206: Send the transaction information to the server in the blockchain, so that the server verifies whether the transaction information is correct according to a preset verification algorithm, and if correct, performs the transaction processing.
在本发明实施例中,所有随机承诺对应的范围证明的验证过程都是应用相同的验证算法,相关解释内容可以参见上述图1所示的方法实施例,在此不做赘述。In the embodiment of the present invention, the verification process of the range proof corresponding to all the random commitments is to apply the same verification algorithm. For the related explanation, refer to the method embodiment shown in FIG. 1 above, and no further details are provided herein.
本发明实施例提供了一种基于区块链的贷款方法,区块链中的服务器接收客户端发送的本次交易信息,然后,从历史交易记录中获取账户标识对应的上一次交易信息;根据预设的验证算法,确定本次交易信息中交易金额对应的第一随机承诺、第一范围证明、账户标识的当前的剩余可交易金额对应的第二随机承诺、第二范围证明、账户标识的第三随机承诺和第三随机承诺对应的知识证明是否有效;若第一随机承诺和所述第一随机承诺对应的第一范围证明和第二随机承诺、第二随机承诺对应的第二范围证明、账户标识的第三随机承诺和第三随机承诺对应的知识证明有效,则根据所述本次交易信息进行本次交易处理。由于本发明实施例中,将随机承诺和范围证明与区块链相结合,从而在保证用户交易金额保密性的同时,能够有效地防止恶意用户在多家金融机构中的恶意超额交易行为。The embodiment of the invention provides a blockchain-based loan method. The server in the blockchain receives the transaction information sent by the client, and then obtains the last transaction information corresponding to the account identifier from the historical transaction record; The preset verification algorithm determines the first random commitment corresponding to the transaction amount in the transaction information, the first scope certificate, the second random commitment corresponding to the current remaining tradable amount of the account identifier, the second scope certificate, and the account identifier Whether the knowledge proof corresponding to the third random commitment and the third random commitment is valid; if the first random commitment and the first random proof correspond to the first scope proof and the second random commitment, the second random commitment corresponds to the second scope proof If the third random commitment of the account identifier and the knowledge verification corresponding to the third random commitment are valid, the transaction processing is performed according to the transaction information. In the embodiment of the present invention, the random commitment and the scope proof are combined with the blockchain, thereby ensuring the malicious excess transaction behavior of the malicious user in a plurality of financial institutions while ensuring the confidentiality of the transaction amount of the user.
为了描述更加清楚,下面通过一个具体实施例对本发明实施例提供的一种基于区块链的资金交易方法进行详细说明。For a clearer description, a blockchain-based capital transaction method provided by an embodiment of the present invention is described in detail below through a specific embodiment.
假设用户标识为12的用户第一次向区块链中的金融机构B申请贷款;首先,金融机构B为用户12创建账户P,具体包括如下步骤:Assume that the user whose user ID is 12 applies for the loan to the financial institution B in the blockchain for the first time. First, the financial institution B creates the account P for the user 12, which includes the following steps:
步骤一:客户端向服务器B发送账户创建请求信息,其中,账户创建请求信息中包括用户标识12。Step 1: The client sends the account creation request information to the server B, where the account creation request information includes the user identifier 12.
步骤二:用户12选择一个随机数k,根据客户端预设的随机承诺生成算法,确定出第四随机承诺。Step 2: The user 12 selects a random number k, and determines a fourth random commitment according to a random commitment generation algorithm preset by the client.
步骤三:客户端根据预设的知识证明生成算法,确定第四随机承诺对应的知识证明。Step 3: The client proves the generation algorithm according to the preset knowledge, and determines the knowledge proof corresponding to the fourth random commitment.
步骤四:客户端将第四随机承诺和第四随机承诺对应的知识证明发送至服务器B;Step 4: The client sends the knowledge certificate corresponding to the fourth random commitment and the fourth random commitment to the server B;
当金融机构B(服务器B)接收到客户端发送的第四随机承诺和第四随机承诺对应的知识证明时,根据预设的知识证明验证算法,验证第四随机承诺对应的知识证明是否有效,若有效,则金融机构B为该用户标识12的用户创建账户标识P,并为该用户设置该用户在联盟中的所有金融机构的可贷款总金额S,计算该用户在联盟中的所有金融机构的可贷款总金额S对应的随机承诺;然后,金融机构B将该用户的账户标识、账户标识的可交易总金额、账户标识的可交易总金额对应的随机承诺、第四随机承诺和第四随机承诺对应的知识证明,存储在交易类型标识为贷款的区块链中。When the financial institution B (server B) receives the knowledge certificate corresponding to the fourth random commitment and the fourth random commitment sent by the client, according to the preset knowledge proof verification algorithm, it is verified whether the knowledge proof corresponding to the fourth random promise is valid, If valid, the financial institution B creates an account identifier P for the user of the user identifier 12, and sets the total loan amount S of the financial institution of the user in the alliance for the user, and calculates all financial institutions of the user in the alliance. The stochastic commitment corresponding to the total amount S of the loan; then, the financial institution B's account identification, the tradable total amount of the account identification, the tradable total amount corresponding to the account identification, the fourth random commitment and the fourth The knowledge proof corresponding to the random commitment is stored in the blockchain in which the transaction type is identified as a loan.
然后,用户12输入第一次交易申请信息,其中,第一次交易申请信息包括账户标识P、交易类型标识load和交易金额n;客户端根据用户12输入的交易申请信息中的交易金额n,确定交易金额n对应的第一随机承诺和第一范围证明;客户端向金融机构B发送账户标识P的当前的剩余可交易金额获取信息,并接收金融机构B发送的账户标识P的当前的剩余可交易金额,并根据账户标识P的当前的剩余可交易金额,确定第二随机承诺和第二范围证明;根据第一次交易金额n1对应的第一随机承诺和预设的知识证明生成算法,确定账户标识P的第三随机承诺和第三随机承诺对应的知识证明;然后,客户端将交易申请信息、交易金额对应的第一随机承诺和第一范围证明、账户标识的剩余可交易金额对应的第二随机承诺和第二范围证明、账户标识的第三随机承诺和第三随机承诺对应的知识证明,组成本次交易信息;并将将本次交易信息发送至金融机构B。Then, the user 12 inputs the first transaction application information, wherein the first transaction application information includes an account identifier P, a transaction type identifier load, and a transaction amount n; the transaction amount n in the transaction application information input by the client according to the user 12, Determining a first random commitment and a first range proof corresponding to the transaction amount n; the client sends the current remaining tradable amount acquisition information of the account identifier P to the financial institution B, and receives the current surplus of the account identifier P sent by the financial institution B The tradable amount, and determining the second random commitment and the second range proof according to the current remaining tradable amount of the account identifier P; the first random commitment corresponding to the first transaction amount n1 and the preset knowledge proof generation algorithm, Determining the third random commitment of the account identifier P and the knowledge certificate corresponding to the third random commitment; then, the client corresponding to the transaction application information, the first random commitment corresponding to the transaction amount, the first scope certificate, and the remaining tradable amount of the account identifier Second random commitment and second scope proof, third random commitment of account identification and third random commitment Should demonstrate knowledge of the composition of the transaction information; and sends the transaction information to financial institutions B.
由于本次是用户第一次向金融机构B进行贷款申请,所以此时,账户标识P的当前的剩余可交易金额就是该用户在本联盟中所有金融机构中可贷款的总金额S,如果此次是用户第二次向金融机构B发送贷款申请,则金融机构B发送给客户端的该账户标识对应的上一次剩余可交易金额对应的承诺中,记录的该账户标识对应的当前剩余可贷款金额为S-n1;其中,n1为用户向金融机构B申请的贷款金额。Since this is the first time the user applies for a loan to financial institution B, at this time, the current remaining tradable amount of the account identifier P is the total amount S of the loan that the user can make in all financial institutions in the alliance, if this The second time is that the user sends a loan application to the financial institution B for the second time, and the current remaining loanable amount corresponding to the account identifier recorded in the commitment corresponding to the last remaining tradable amount corresponding to the account identifier sent by the financial institution B to the client Is S-n1; where n1 is the loan amount that the user applies to financial institution B.
之后,金融机构B在接收到客户端发送的本次交易信息之后,从贷款区块链中获取到账户标识P对应的上一次交易信息,并根据预设的验证算法,验证上述第一随机承诺、第一范围证明、第二随机承诺、第二范围证明、第三随机承诺和第三随机承诺对应的知识证明是否有效;若第一随机承诺、第一范围证明、第二随机承诺、第二范围证明、第三随机承诺和第三随机承诺对应的知识证明都有效,则金融机构B将用户12申请的贷款金额,发送给客户端;服务器B将第一随机承诺和第一范围证明、账户标识P和交易类型标识Load,组成历史交易记录,并将历史交易记录存储在服务器中的贷款区块链中。After receiving the transaction information sent by the client, the financial institution B obtains the last transaction information corresponding to the account identifier P from the loan blockchain, and verifies the first random commitment according to a preset verification algorithm. Whether the proof of knowledge corresponding to the first range proof, the second random promise, the second scope proof, the third random commitment, and the third random commitment is valid; if the first random commitment, the first scope proof, the second random commitment, the second The proof of scope, the third random commitment and the third random commitment corresponding to the knowledge proof are valid, then the financial institution B sends the loan amount applied by the user 12 to the client; the server B will first the first random commitment and the first scope certificate, the account The identification P and the transaction type identifier Load constitute a historical transaction record, and the historical transaction record is stored in the loan blockchain in the server.
可选的,当用户12在金融机构B申请了第一笔贷款之后,该用户则需要在金融机构B规定的时间内还款;假设用户12在第一次贷款之后,进行第一次还款,则用户12在向金融机构B进行还款的步骤如下:Optionally, when the user 12 applies for the first loan at the financial institution B, the user needs to repay the time specified by the financial institution B; suppose the user 12 makes the first repayment after the first loan. The steps for the user 12 to make a repayment to the financial institution B are as follows:
步骤一:用户12在客户端中输入第一次交易申请信息,其中,第一次交易申请信息包括账户标识P、交易类型标识repay和还款金额n1;客户端根据用户12输入的交易申请信息中的还款金额n1,确定还款金额n1对应的第一随机承诺和第一范围证明;客户端向金融机构B发送账户标识P的当前的剩余可交易金额获取信息,并接收金融机构B发送的账户标识P的当前的剩余可交易金额,并根据账户标识P的当前的剩余可交易金额,确定第二随机承诺和第二范围证明;根据第一次还款金额n1对应的第一随机承诺和预设的知识证明生成算法,确定账户标识P的第三随机承诺和第三随机承诺对应的知识证明;然后,客户端将交易申请信息、交易金额对应的第一随机承诺和第一范围证明、账户标识的剩余可交易金额对应的第二随机承诺和第二范围证明、账户标识的第三随机承诺和第三随机承诺对应的知识证明,组成本次交易信息;并将将本次交易信息发送至金融机构B。Step 1: The user 12 inputs the first transaction application information in the client, wherein the first transaction application information includes an account identifier P, a transaction type identifier repay and a repayment amount n1; and the transaction request information input by the client according to the user 12 In the repayment amount n1, the first random commitment and the first scope proof corresponding to the repayment amount n1 are determined; the client sends the current remaining tradable amount acquisition information of the account identifier P to the financial institution B, and the receiving financial institution B sends The current remaining tradable amount of the account identifier P, and determining the second random commitment and the second range proof according to the current remaining tradable amount of the account identifier P; the first random commitment corresponding to the first repayment amount n1 And a preset knowledge proof generation algorithm, determining a third random commitment of the account identifier P and a knowledge proof corresponding to the third random commitment; then, the client submits the transaction application information, the first random commitment corresponding to the transaction amount, and the first scope proof The second random commitment and the second scope proof corresponding to the remaining tradable amount of the account identifier, and the third random promise of the account identifier The third random commitment corresponding knowledge proof, the composition of the transaction information; and sends the transaction information to financial institutions B.
用户的每一次还款,可以弥补账户标识P的当前的剩余可交易金额,例如,假设账户标识P的当前的剩余可交易金额为S-n1;其中,n1为用户向金融机构B申请的贷款金额;当金融机构B在接收到客户端发送的本次交易信息之后,从贷款区块链中获取到账户标识P对应的上一次交易信息,并根据预设的验证算法,验证上述第一随机承诺、第一范围证明、第二随机承诺、第二范围证明、第三随机承诺和第三随机承诺对应的知识证明是否有效;若第一随机承诺、第一范围证明、第二随机承诺、第二范围证明、第三随机承诺和第三随机承诺对应的知识证明都有效,金融机构B接收客户端发送的还款金额n1;此时,在用户进行了第一次还款交易之后,用户在金额机构B的剩余可交易金额就变成了S-n1+n1;之后,服务器B将第一随机承诺和第一范围证明、账户标识P和交易类型标识repay,组成历史交易记录,并将历史交易记录存储在服务器中的还款区块链中。Each repayment of the user can make up the current remaining tradable amount of the account identifier P, for example, assuming that the current remaining tradable amount of the account identifier P is S-n1; wherein n1 is the loan applied by the user to the financial institution B Amount; when the financial institution B receives the transaction information sent by the client, obtains the last transaction information corresponding to the account identifier P from the loan blockchain, and verifies the first random according to a preset verification algorithm. Whether the proof of knowledge corresponding to the commitment, the first scope proof, the second random commitment, the second scope proof, the third random commitment, and the third random commitment is valid; if the first random commitment, the first scope proof, the second random commitment, the first The knowledge proof corresponding to the second scope proof, the third random promise and the third random promise is valid, and the financial institution B receives the repayment amount n1 sent by the client; at this time, after the user performs the first repayment transaction, the user is The remaining tradable amount of the amount institution B becomes S-n1+n1; after that, the server B will first random commitment and first scope proof, account identification P and transaction class Logo repay, composed of transaction history, payment history and a block transaction records stored in the server chain.
本发明实施例提供了一种贷款方法,区块链中的服务器接收客户端发送的本次交易信息,然后,从历史交易记录中获取账户标识对应的上一次交易信息;根据预设的验证算法,确定本次交易信息中交易金额对应的第一随机承诺、第一范围证明、账户标识的当前的剩余可交易金额对应的第二随机承诺、第二范围证明、账户标识的第三随机承诺和第三随机承诺对应的知识证明是否有效;若所述第一随机承诺和所述第一随机承诺对应的第一范围证明和第二随机承诺、所述第二随机承诺对应的第二范围证明、账户标识的第三随机承诺和第三随机承诺对应的知识证明有效,则根据所述本次交易信息进行本次交易处理。由于本发明实施例中,将随机承诺和范围证明与区块链相结合,从而在保证用户交易金额保密性的同时,能够有效地防止恶意用户在多家金融机构中的恶意超额交易行为。The embodiment of the invention provides a loan method. The server in the blockchain receives the transaction information sent by the client, and then obtains the last transaction information corresponding to the account identifier from the historical transaction record; according to the preset verification algorithm Determining a first random commitment corresponding to the transaction amount in the transaction information, a first scope certificate, a second random commitment corresponding to the current remaining tradable amount of the account identifier, a second scope proof, and a third random commitment of the account identifier Whether the knowledge proof corresponding to the third random commitment is valid; if the first random commitment and the first random commitment correspond to the first scope proof and the second random commitment, the second random commitment corresponds to the second scope proof, If the third random commitment of the account identifier and the knowledge verification corresponding to the third random promise are valid, the transaction processing is performed according to the current transaction information. In the embodiment of the present invention, the random commitment and the scope proof are combined with the blockchain, thereby ensuring the malicious excess transaction behavior of the malicious user in a plurality of financial institutions while ensuring the confidentiality of the transaction amount of the user.
基于相同的技术构思,相应于图1所示方法实施例,本发明实施例还提供了一种基于区块链的资金交易装置,如图3所示,该装置应用于区块链中的服务器,服务器中存储有各账户标识对应的历史交易记录,历史交易记录中包括随机承诺和范围证明、账户标识和交易类型标识,该装置包括:Based on the same technical concept, corresponding to the method embodiment shown in FIG. 1, the embodiment of the present invention further provides a block chain-based fund transaction device. As shown in FIG. 3, the device is applied to a server in a blockchain. The server stores a historical transaction record corresponding to each account identifier. The historical transaction record includes a random commitment and a scope certificate, an account identifier, and a transaction type identifier. The device includes:
接收模块301,用于接收客户端发送的本次交易信息,本次交易信息中包括交易金额、账户标识和交易类型标识、交易金额对应的第一随机承诺和第一范围证明、账户标识的当前的剩余可交易金额对应的第二随机承诺和第二范围证明、账户标识的第三随机承诺和第三随机承诺对应的知识证明;The receiving module 301 is configured to receive the current transaction information sent by the client, where the transaction information includes a transaction amount, an account identifier, a transaction type identifier, a first random commitment corresponding to the transaction amount, a first scope certificate, and an current account identifier. The second stochastic commitment and the second scope proof corresponding to the remaining tradable amount, the third stochastic commitment of the account identifier, and the knowledge proof corresponding to the third stochastic commitment;
获取模块302,用于从历史交易记录中获取账户标识对应的上一次交易记录;The obtaining module 302 is configured to obtain, from the historical transaction record, a previous transaction record corresponding to the account identifier;
确定模块303,用于根据预设的验证算法,确定交易金额对应的第一随机承诺和第一范围证明、账户标识的当前的剩余可交易金额对应的第二随机承诺和第二范围证明、以及账户标识的第三随机承诺和第三随机承诺对应的知识证明是否有效;a determining module 303, configured to determine, according to a preset verification algorithm, a first random commitment and a first scope certificate corresponding to the transaction amount, a second random commitment and a second scope proof corresponding to the current remaining tradable amount of the account identifier, and Whether the third random commitment of the account identifier and the knowledge certificate corresponding to the third random commitment are valid;
本次交易处理模块304,用于若第一随机承诺、第一范围证明、第二随机承诺、第二范围证明、第三随机承诺和第三随机承诺对应的知识证明有效,则根据本次交易信息进行本次交易处理。The transaction processing module 304 is configured to: if the knowledge of the first random commitment, the first scope proof, the second random commitment, the second scope proof, the third random commitment, and the third random commitment is valid, according to the transaction Information is processed for this transaction.
在本发明实施例中,上述装置还可以包括:In the embodiment of the present invention, the foregoing apparatus may further include:
账户创建请求信息接收模块,用于接收客户端发送的账户创建请求信息;其中,账户创建请求信息中包括用户标识;The account creation request information receiving module is configured to receive account creation request information sent by the client, where the account creation request information includes a user identifier;
查找模块,用于在预设的账户信息表中,查找是否包含用户标识对应的账户标识;The searching module is configured to: in the preset account information table, find whether the account identifier corresponding to the user identifier is included;
验证模块,用于若账户信息表中不包含用户标识对应的账户标识,则在接收客户端发送的第四随机承诺对应的知识证明时,根据预设的知识证明验证算法,验证第四随机承诺对应的知识证明是否有效;The verification module is configured to: if the account information table does not include the account identifier corresponding to the user identifier, and when receiving the knowledge certificate corresponding to the fourth random commitment sent by the client, verify the fourth random commitment according to the preset knowledge proof verification algorithm Whether the corresponding knowledge proof is valid;
创建模块,用于若第四随机承诺对应的知识证明有效,则创建用户标识对应的账户标识和交易总金额。And a module is configured to create an account identifier corresponding to the user identifier and a total transaction amount if the knowledge proof corresponding to the fourth random commitment is valid.
基于相同的技术构思,相应于图2所示方法实施例,本发明实施例还提供了一种资金交易装置,如图4所示,该装置应用于客户端,该装置包括:Based on the same technical concept, corresponding to the method embodiment shown in FIG. 2, the embodiment of the present invention further provides a fund transaction device. As shown in FIG. 4, the device is applied to a client, and the device includes:
交易申请信息获取模块401,用于获取用户输入的交易申请信息,交易申请信息包括账户标识、交易类型标识和交易金额;The transaction application information obtaining module 401 is configured to obtain transaction application information input by the user, where the transaction application information includes an account identifier, a transaction type identifier, and a transaction amount;
第一确定模块402,用于根据交易金额,确定交易金额对应的第一随机承诺和第一范围证明;The first determining module 402 is configured to determine, according to the transaction amount, a first random commitment and a first range certificate corresponding to the transaction amount;
第二确定模块403,用于确定账户标识的当前的剩余可交易金额,以及账户标识的剩余可交易金额对应的第二随机承诺和第二范围证明;a second determining module 403, configured to determine a current remaining tradable amount of the account identifier, and a second random commitment and a second range certificate corresponding to the remaining tradable amount of the account identifier;
第三确定模块404,用于根据交易金额对应的第一随机承诺和预设的知识证明生成算法,确定账户标识的第三随机承诺和第三随机承诺对应的知识证明;The third determining module 404 is configured to determine, according to the first random commitment corresponding to the transaction amount and the preset knowledge proof generation algorithm, the third random commitment of the account identifier and the knowledge certificate corresponding to the third random commitment;
本次交易信息组成模块405,用于将交易申请信息、交易金额对应的第一随机承诺和第一范围证明、账户标识的剩余可交易金额对应的第二随机承诺和第二范围证明、账户标识的第三随机承诺和第三随机承诺对应的知识证明,组成本次交易信息;The transaction information component module 405 is configured to use the transaction request information, the first random commitment corresponding to the transaction amount and the first scope certificate, the second random commitment corresponding to the remaining tradable amount of the account identifier, and the second scope certificate and the account identifier. The third random commitment and the third random commitment corresponding to the knowledge proof, constitute the transaction information;
本次交易信息验证模块406,用于将本次交易信息发送至区块链中的服务器,以使服务器根据预设的验证算法,验证本次交易信息是否正确,若正确,则进行本次交易处理。The transaction information verification module 406 is configured to send the transaction information to the server in the blockchain, so that the server verifies whether the transaction information is correct according to a preset verification algorithm, and if correct, performs the transaction. deal with.
在本发明实施例中,上述装置还可以包括:In the embodiment of the present invention, the foregoing apparatus may further include:
账户创建请求信息发送模块,用于向服务器发送账户创建请求信息;其中,账户创建请求信息中包括用户标识;An account creation request information sending module, configured to send account creation request information to the server; wherein the account creation request information includes a user identifier;
随机数获取模块,用于获取用户输入的随机数;a random number obtaining module, configured to obtain a random number input by a user;
第四随机承诺确定模块,用于根据随机数和预设的随机承诺生成算法,确定第四随机承诺;a fourth random commitment determining module, configured to determine a fourth random commitment according to a random number and a preset random commitment generation algorithm;
知识证明确定模块,用于根据预设的知识证明生成算法,确定第四随机承诺对应的知识证明;a knowledge certification determining module, configured to determine a knowledge certificate corresponding to the fourth random commitment according to a preset knowledge proof generation algorithm;
发送模块,用于将第四随机承诺和第四随机承诺对应的知识证明发送至所述服务器。And a sending module, configured to send the knowledge certificate corresponding to the fourth random commitment and the fourth random commitment to the server.
本发明实施例提供了一种基于区块链的贷款装置,区块链中的服务器接收客户端发送的本次交易信息,并从历史交易记录中获取账户标识对应的上一次交易信息;根据预设的验证算法,确定客户端发送的本次交易信息中的交易金额对应的第一随机承诺、第一范围证明、账户标识的当前的剩余可交易金额对应的第二随机承诺、第二范围证明、账户标识的第三随机承诺和第三随机承诺对应的知识证明是否有效;若第一随机承诺和所述第一随机承诺对应的第一范围证明和第二随机承诺、第二随机承诺对应的第二范围证明、账户标识的第三随机承诺和第三随机承诺对应的知识证明有效,则根据本次交易信息进行本次交易处理。由于本发明实施例中,将随机承诺和范围证明与区块链相结合,从而在保证用户交易金额保密性的同时,能够有效地防止恶意用户在多家金融机构中的恶意超额交易行为。The embodiment of the invention provides a blockchain-based loan device, wherein the server in the blockchain receives the transaction information sent by the client, and obtains the previous transaction information corresponding to the account identifier from the historical transaction record; The verification algorithm is configured to determine a first random commitment corresponding to the transaction amount in the transaction information sent by the client, a first range certificate, a second random commitment corresponding to the current remaining tradable amount of the account identifier, and a second scope certificate Whether the third random commitment of the account identifier and the knowledge certificate corresponding to the third random commitment are valid; if the first random commitment and the first random proof correspond to the first scope proof and the second random commitment and the second random commitment If the second scope proof, the third random commitment of the account identifier, and the knowledge proof corresponding to the third random commitment are valid, the transaction processing is performed according to the transaction information. In the embodiment of the present invention, the random commitment and the scope proof are combined with the blockchain, thereby ensuring the malicious excess transaction behavior of the malicious user in a plurality of financial institutions while ensuring the confidentiality of the transaction amount of the user.
本发明实施例还提供了一种服务器,服务器中存储有各账户标识对应的历史交易记录,历史交易记录中包括随机承诺和范围证明、账户标识和交易类型标识,如图5所示,包括处理器501、通信接口502、存储器503和通信总线504,其中,处理器501,通信接口502,存储器503通过通信总线504完成相互间的通信,The embodiment of the invention further provides a server, wherein the server stores a historical transaction record corresponding to each account identifier, and the historical transaction record includes a random commitment and a range certificate, an account identifier, and a transaction type identifier, as shown in FIG. 5, including processing. The device 501, the communication interface 502, the memory 503, and the communication bus 504, wherein the processor 501, the communication interface 502, and the memory 503 complete communication with each other through the communication bus 504.
存储器503,用于存放计算机程序;a memory 503, configured to store a computer program;
处理器501,用于执行存储器503上所存放的程序时,实现本发明实施例提供的一种资金交易方法。该方法包括:The processor 501 is configured to implement a fund transaction method provided by an embodiment of the present invention when the program stored in the memory 503 is executed. The method includes:
接收客户端发送的本次交易信息,本次交易信息中包括交易金额、账户标识和交易类型标识、交易金额对应的第一随机承诺和第一范围证明、账户标识的当前的剩余可交易金额对应的第二随机承诺和第二范围证明、账户标识的第三随机承诺和所述第三随机承诺对应的知识证明;Receiving the transaction information sent by the client, the transaction information includes the transaction amount, the account identifier and the transaction type identifier, the first random commitment corresponding to the transaction amount, the first scope certificate, and the current remaining tradable amount of the account identifier. a second random commitment and a second scope proof, a third random commitment of the account identifier, and a knowledge proof corresponding to the third random promise;
从历史交易记录中获取账户标识对应的上一次交易记录;Obtain the last transaction record corresponding to the account identifier from the historical transaction record;
根据预设的验证算法,确定交易金额对应的第一随机承诺和第一范围证明、账户标识的当前的剩余可交易金额对应的第二随机承诺和第二范围证明、以及账户标识的第三随机承诺和第三随机承诺对应的知识证明是否有效;Determining, according to a preset verification algorithm, a first random commitment corresponding to the transaction amount and a first range certificate, a second random commitment and a second range certificate corresponding to the current remaining tradable amount of the account identifier, and a third randomness of the account identifier Whether the proof of knowledge corresponding to the commitment and the third random commitment is valid;
若第一随机承诺、第一范围证明、第二随机承诺、第二范围证明、第三随机承诺和第三随机承诺对应的知识证明有效,则根据本次交易信息进行本次交易处理。If the knowledge of the first random commitment, the first scope proof, the second random commitment, the second scope proof, the third random commitment, and the third random commitment is valid, the transaction processing is performed according to the transaction information.
关于该方法各个步骤的具体实现以及相关解释内容可以参见上述图1所示的方法实施例,在此不做赘述。For the specific implementation of the various steps of the method and the related explanations, refer to the method embodiment shown in FIG. 1 above, and no further details are provided herein.
另外,处理器501执行存储器503上所存放的程序而实现的一种资金交易方法的其他实现方式,与前述方法实施例部分所提及的实现方式相同,这里也不再赘述。In addition, other implementation manners of a fund transaction method implemented by the processor 501 executing the program stored in the memory 503 are the same as those mentioned in the foregoing method embodiment, and are not described herein again.
本发明实施例还提供了一种客户端,如图6所示,包括处理器601、通信接口602、存储器603和通信总线604,其中,处理器601,通信接口602,存储器603通过通信总线604完成相互间的通信,The embodiment of the present invention further provides a client, as shown in FIG. 6, including a processor 601, a communication interface 602, a memory 603, and a communication bus 604. The processor 601, the communication interface 602, and the memory 603 pass through the communication bus 604. Complete communication with each other,
存储器603,用于存放计算机程序;a memory 603, configured to store a computer program;
处理器601,用于执行存储器303上所存放的程序时,实现本发明实施例提供的一种资金交易方法。The processor 601 is configured to implement a fund transaction method provided by an embodiment of the present invention when executing a program stored in the memory 303.
具体的,上述一种基于区块链的资金交易方法,该方法应用于客户端,该方法包括:Specifically, the foregoing blockchain-based capital transaction method is applied to a client, and the method includes:
获取用户输入的交易申请信息,交易申请信息包括账户标识、交易类型标识和交易金额;Obtaining transaction application information input by the user, the transaction application information includes an account identification, a transaction type identifier, and a transaction amount;
根据交易金额,确定交易金额对应的第一随机承诺和第一范围证明;Determining the first random commitment and the first scope certificate corresponding to the transaction amount according to the transaction amount;
确定账户标识的当前的剩余可交易金额,以及账户标识的剩余可交易金额对应的第二随机承诺和第二范围证明;Determining a current remaining tradable amount of the account identification, and a second random commitment and a second range certificate corresponding to the remaining tradable amount of the account identification;
根据交易金额对应的第一随机承诺和预设的知识证明生成算法,确定账户标识的第三随机承诺和第三随机承诺对应的知识证明;Determining, according to the first random commitment corresponding to the transaction amount and the preset knowledge proof generation algorithm, the third random commitment of the account identifier and the knowledge certificate corresponding to the third random commitment;
将交易申请信息、交易金额对应的第一随机承诺和第一范围证明、账户标识的剩余可交易金额对应的第二随机承诺和第二范围证明、账户标识的第三随机承诺和第三随机承诺对应的知识证明,组成本次交易信息;The transaction request information, the first random commitment corresponding to the transaction amount and the first scope certificate, the second random commitment and the second scope certificate corresponding to the remaining tradable amount of the account identifier, the third random commitment of the account identifier, and the third random commitment The corresponding knowledge proves that the information of this transaction is composed;
将本次交易信息发送至区块链中的服务器,以使服务器根据预设的验证算法,验证本次交易信息是否正确,若正确,则进行本次交易处理。The transaction information is sent to the server in the blockchain, so that the server verifies whether the transaction information is correct according to the preset verification algorithm, and if correct, the transaction processing is performed.
关于该方法各个步骤的具体实现以及相关解释内容可以参见上述图2所示的方法实施例,在此不做赘述。For the specific implementation of the various steps of the method and the related explanations, refer to the method embodiment shown in FIG. 2 above, and no further details are provided herein.
另外,处理器601执行存储器603上所存放的程序而实现的一种资金交易方法的其他实现方式,与前述方法实施例部分所提及的实现方式相同,这里也不再赘述。In addition, other implementation manners of a fund transaction method implemented by the processor 601 executing the program stored in the memory 603 are the same as those mentioned in the foregoing method embodiment, and are not described herein again.
上述电子设备提到的通信总线可以是外设部件互连标准(Peripheral ComponentInterconnect,PCI)总线或扩展工业标准结构(Extended Industry StandardArchitecture,EISA)总线等。该通信总线可以分为地址总线、数据总线、控制总线等。为便于表示,图中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。The communication bus mentioned in the above electronic device may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The communication bus can be divided into an address bus, a data bus, a control bus, and the like. For ease of representation, only one thick line is shown in the figure, but it does not mean that there is only one bus or one type of bus.
通信接口用于上述电子设备与其他设备之间的通信。The communication interface is used for communication between the above electronic device and other devices.
存储器可以包括随机存取存储器(Random Access Memory,RAM),也可以包括非易失性存储器(Non-Volatile Memory,NVM),例如至少一个磁盘存储器。可选的,存储器还可以是至少一个位于远离前述处理器的存储装置。The memory may include a random access memory (RAM), and may also include a non-volatile memory (NVM), such as at least one disk storage. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
上述的处理器可以是通用处理器,包括中央处理器(Central Processing Unit,CPU)、网络处理器(Network Processor,NP)等;还可以是数字信号处理器(Digital SignalProcessing,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。The above processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; or may be a digital signal processor (DSP), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), Field-Programmable Gate Array (FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware component.
在本发明提供的又一实施例中,还提供了一种计算机可读存储介质,该计算机可读存储介质中存储有指令,当其在计算机上运行时,使得计算机执行上述实施例中任一所述的基于区块链的资金交易方法。In still another embodiment provided by the present invention, there is provided a computer readable storage medium having stored therein instructions for causing a computer to execute any of the above embodiments when it is run on a computer The blockchain based method of capital transaction.
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产生按照本发明实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线(DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘Solid State Disk(SSD))等。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, it 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 the computer program instructions are loaded and executed on a computer, the processes or functions described in accordance with embodiments of the present invention are generated in whole or in part. The computer can be a general purpose computer, a special purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer readable storage medium or transferred from one computer readable storage medium to another computer readable storage medium, for example, the computer instructions can be from a website site, computer, server or data center Transfer to another website site, computer, server, or data center by wire (eg, coaxial cable, fiber optic, digital subscriber line (DSL), or wireless (eg, infrared, wireless, microwave, etc.). The computer readable storage medium can be any available media that can be accessed by a computer or a data storage device such as a server, data center, or the like that includes one or more available media. The usable medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a DVD), or a semiconductor medium (such as a solid state disk (SSD)).
需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。It should be noted that, in this context, relational terms such as first and second are used merely to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply these entities or operations. There is any such actual relationship or order between them. Furthermore, the term "comprises" or "comprises" or "comprises" or any other variations thereof is intended to encompass a non-exclusive inclusion, such that a process, method, article, or device that comprises a plurality of elements includes not only those elements but also Other elements, or elements that are inherent to such a process, method, item, or device. An element that is defined by the phrase "comprising a ..." does not exclude the presence of additional equivalent elements in the process, method, item, or device that comprises the element.
本说明书中的各个实施例均采用相关的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于装置、电子设备以及计算机可读存储介质实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。The various embodiments in the present specification are described in a related manner, and the same or similar parts between the various embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the apparatus, the electronic device, and the computer readable storage medium embodiment, since it is substantially similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the description of the method embodiment.
以上所述仅为本发明的较佳实施例而已,并非用于限定本发明的保护范围。凡在本发明的精神和原则之内所作的任何修改、等同替换、改进等,均包含在本发明的保护范围内。The above is only the preferred embodiment of the present invention and is not intended to limit the scope of the present invention. Any modifications, equivalents, improvements, etc. made within the spirit and scope of the invention are intended to be included within the scope of the invention.
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201811332698.1ACN109447791B (en) | 2018-11-09 | 2018-11-09 | A method and device for fund transaction based on blockchain |
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201811332698.1ACN109447791B (en) | 2018-11-09 | 2018-11-09 | A method and device for fund transaction based on blockchain |
| Publication Number | Publication Date |
|---|---|
| CN109447791Atrue CN109447791A (en) | 2019-03-08 |
| CN109447791B CN109447791B (en) | 2021-07-16 |
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201811332698.1AActiveCN109447791B (en) | 2018-11-09 | 2018-11-09 | A method and device for fund transaction based on blockchain |
| Country | Link |
|---|---|
| CN (1) | CN109447791B (en) |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN110597541A (en)* | 2019-09-16 | 2019-12-20 | 腾讯科技(深圳)有限公司 | Interface updating processing method, device, equipment and storage medium based on block chain |
| CN111325533A (en)* | 2019-12-31 | 2020-06-23 | 深圳大学 | A decentralized trading method, trading system and computer equipment |
| CN111815322A (en)* | 2020-06-08 | 2020-10-23 | 北京邮电大学 | An Ethereum-based distributed payment method with optional privacy services |
| WO2021027531A1 (en)* | 2019-08-12 | 2021-02-18 | 深圳前海微众银行股份有限公司 | Block chain transaction record processing method and device |
| CN112488831A (en)* | 2020-11-20 | 2021-03-12 | 东软集团股份有限公司 | Block chain network transaction method and device, storage medium and electronic equipment |
| CN112950338A (en)* | 2021-02-26 | 2021-06-11 | 浙江工商大学 | Block chain-based sealed bidding domain name auction method |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20100142704A1 (en)* | 2008-10-28 | 2010-06-10 | International Business Machines Corporation | Cryptographic encoding and decoding of secret data |
| CN103401839A (en)* | 2013-07-02 | 2013-11-20 | 河海大学 | Attribute protection based multiple authorization center encryption method |
| US20160358165A1 (en)* | 2015-06-08 | 2016-12-08 | Blockstream Corporation | Cryptographically concealing amounts transacted on a ledger while preserving a network's ability to verify the transaction |
| US9614676B1 (en)* | 2013-03-13 | 2017-04-04 | Hrl Laboratories, Llc | Cryptographically-secure packed proactive secret sharing (PPSS) protocol |
| US20170149796A1 (en)* | 2015-11-25 | 2017-05-25 | Yaron Gvili | Selectivity in privacy and verification with applications |
| CN107666388A (en)* | 2016-07-28 | 2018-02-06 | 郑珂威 | Block chain information encryption method based on complete homomorphic cryptography method |
| CN107911216A (en)* | 2017-10-26 | 2018-04-13 | 矩阵元技术(深圳)有限公司 | A kind of block chain transaction method for secret protection and system |
| CN108021821A (en)* | 2017-11-28 | 2018-05-11 | 北京航空航天大学 | Multicenter block chain transaction intimacy protection system and method |
| CN108200079A (en)* | 2018-01-19 | 2018-06-22 | 深圳四方精创资讯股份有限公司 | Block chain method for secret protection and device based on symmetrical and asymmetric Hybrid Encryption |
| CN108418689A (en)* | 2017-11-30 | 2018-08-17 | 矩阵元技术(深圳)有限公司 | A zero-knowledge proof method and medium suitable for blockchain privacy protection |
| CN108711105A (en)* | 2018-05-16 | 2018-10-26 | 四川吉鼎科技有限公司 | A kind of Secure Transaction verification method and system based on block chain |
| CN108764874A (en)* | 2018-05-17 | 2018-11-06 | 深圳前海微众银行股份有限公司 | Anonymous refund method, system and storage medium based on block chain |
| CN108769054A (en)* | 2018-06-14 | 2018-11-06 | 北京邮电大学 | A kind of block chain transaction verification method and device based on equivalent test promise |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20100142704A1 (en)* | 2008-10-28 | 2010-06-10 | International Business Machines Corporation | Cryptographic encoding and decoding of secret data |
| US9614676B1 (en)* | 2013-03-13 | 2017-04-04 | Hrl Laboratories, Llc | Cryptographically-secure packed proactive secret sharing (PPSS) protocol |
| CN103401839A (en)* | 2013-07-02 | 2013-11-20 | 河海大学 | Attribute protection based multiple authorization center encryption method |
| US20160358165A1 (en)* | 2015-06-08 | 2016-12-08 | Blockstream Corporation | Cryptographically concealing amounts transacted on a ledger while preserving a network's ability to verify the transaction |
| US20170149796A1 (en)* | 2015-11-25 | 2017-05-25 | Yaron Gvili | Selectivity in privacy and verification with applications |
| CN107666388A (en)* | 2016-07-28 | 2018-02-06 | 郑珂威 | Block chain information encryption method based on complete homomorphic cryptography method |
| CN107911216A (en)* | 2017-10-26 | 2018-04-13 | 矩阵元技术(深圳)有限公司 | A kind of block chain transaction method for secret protection and system |
| CN108021821A (en)* | 2017-11-28 | 2018-05-11 | 北京航空航天大学 | Multicenter block chain transaction intimacy protection system and method |
| CN108418689A (en)* | 2017-11-30 | 2018-08-17 | 矩阵元技术(深圳)有限公司 | A zero-knowledge proof method and medium suitable for blockchain privacy protection |
| CN108200079A (en)* | 2018-01-19 | 2018-06-22 | 深圳四方精创资讯股份有限公司 | Block chain method for secret protection and device based on symmetrical and asymmetric Hybrid Encryption |
| CN108711105A (en)* | 2018-05-16 | 2018-10-26 | 四川吉鼎科技有限公司 | A kind of Secure Transaction verification method and system based on block chain |
| CN108764874A (en)* | 2018-05-17 | 2018-11-06 | 深圳前海微众银行股份有限公司 | Anonymous refund method, system and storage medium based on block chain |
| CN108769054A (en)* | 2018-06-14 | 2018-11-06 | 北京邮电大学 | A kind of block chain transaction verification method and device based on equivalent test promise |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| WO2021027531A1 (en)* | 2019-08-12 | 2021-02-18 | 深圳前海微众银行股份有限公司 | Block chain transaction record processing method and device |
| CN110597541A (en)* | 2019-09-16 | 2019-12-20 | 腾讯科技(深圳)有限公司 | Interface updating processing method, device, equipment and storage medium based on block chain |
| CN111325533A (en)* | 2019-12-31 | 2020-06-23 | 深圳大学 | A decentralized trading method, trading system and computer equipment |
| CN111325533B (en)* | 2019-12-31 | 2024-05-14 | 深圳大学 | A decentralized trading method, trading system and computer device |
| CN111815322A (en)* | 2020-06-08 | 2020-10-23 | 北京邮电大学 | An Ethereum-based distributed payment method with optional privacy services |
| CN111815322B (en)* | 2020-06-08 | 2023-11-07 | 北京邮电大学 | Distributed payment method with selectable privacy service based on Ethernet |
| CN112488831A (en)* | 2020-11-20 | 2021-03-12 | 东软集团股份有限公司 | Block chain network transaction method and device, storage medium and electronic equipment |
| CN112950338A (en)* | 2021-02-26 | 2021-06-11 | 浙江工商大学 | Block chain-based sealed bidding domain name auction method |
| Publication number | Publication date |
|---|---|
| CN109447791B (en) | 2021-07-16 |
| Publication | Publication Date | Title |
|---|---|---|
| CN109447791B (en) | A method and device for fund transaction based on blockchain | |
| CA3049761C (en) | Method for providing payment gateway service using utxo-based protocol and server using same | |
| CN109716707B (en) | Server apparatus and method for distributed electronic recording and transaction history | |
| WO2020024995A1 (en) | Privacy transaction method and system, and device | |
| JP6756041B2 (en) | Information protection systems and methods | |
| US20210167971A1 (en) | Confidential blockchain transactions | |
| WO2016138606A1 (en) | Secure account management using tokens | |
| CN110009349A (en) | Method and device for generating and verifying linkable ring signature in blockchain | |
| US11856107B2 (en) | Methods and systems for exchanging confidential information via a blockchain | |
| US20200250655A1 (en) | Efficient, environmental and consumer friendly consensus method for cryptographic transactions | |
| CN110084600B (en) | Processing and verifying method, device, equipment and medium for resolution transaction request | |
| CN111431908B (en) | An access processing method, device, management server and readable storage medium | |
| CN112533209A (en) | Black product identification method and black product identification device | |
| CN111488626B (en) | Blockchain-based data processing method, device, equipment and medium | |
| CN111292057A (en) | A blockchain-based business processing method | |
| CN111639938A (en) | Data processing method, device, equipment and medium | |
| CN108769054A (en) | A kind of block chain transaction verification method and device based on equivalent test promise | |
| US20220309514A1 (en) | Method of proving ownership and ownership transfer history using decentralized id | |
| CN111783049A (en) | A method and system for processing user information based on blockchain | |
| CN114514550A (en) | Partitioning requests into blockchains | |
| US12407513B2 (en) | Sharing and requesting private data using cryptography | |
| CN113901424A (en) | Method and device for selective disclosure of digital identity attributes | |
| CN110598479B (en) | A data processing method, device and computer readable storage medium | |
| CN115619395A (en) | Blockchain-based data processing method and related equipment | |
| CN110781503B (en) | Data calling method, device and computer readable storage medium |
| 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 |