[go: up one dir, main page]

CN109447791B - A method and device for fund transaction based on blockchain - Google Patents

A method and device for fund transaction based on blockchain Download PDF

Info

Publication number
CN109447791B
CN109447791B CN201811332698.1A CN201811332698A CN109447791B CN 109447791 B CN109447791 B CN 109447791B CN 201811332698 A CN201811332698 A CN 201811332698A CN 109447791 B CN109447791 B CN 109447791B
Authority
CN
China
Prior art keywords
transaction
random
commitment
random commitment
account
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201811332698.1A
Other languages
Chinese (zh)
Other versions
CN109447791A (en
Inventor
周李京
王励成
柏雪
胡晓雅
李丽香
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing University of Posts and Telecommunications
Original Assignee
Beijing University of Posts and Telecommunications
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing University of Posts and Telecommunications filed Critical Beijing University of Posts and Telecommunications
Priority to CN201811332698.1A priority Critical patent/CN109447791B/en
Publication of CN109447791A publication Critical patent/CN109447791A/en
Application granted granted Critical
Publication of CN109447791B publication Critical patent/CN109447791B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/03Credit; Loans; Processing thereof
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange

Landscapes

  • Business, Economics & Management (AREA)
  • Accounting & Taxation (AREA)
  • Finance (AREA)
  • Engineering & Computer Science (AREA)
  • Development Economics (AREA)
  • Economics (AREA)
  • Marketing (AREA)
  • Strategic Management (AREA)
  • Technology Law (AREA)
  • Physics & Mathematics (AREA)
  • General Business, Economics & Management (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Financial Or Insurance-Related Operations Such As Payment And Settlement (AREA)

Abstract

本发明实施例提供了一种基于区块链的资金交易方法及装置。该方法包括:区块链中的服务器接收客户端发送的本次交易信息;服务器从历史交易记录中获取账户标识对应的上一次交易信息;根据预设的验证算法,验证客户端发送的本次交易信息中的随机承诺、范围证明和知识证明是否有效;若服务器验证本次交易信息中的随机承诺、范围证明和知识证明是否都有效,服务器则根据所述本次交易信息进行本次交易处理。由于本发明实施例中,将随机承诺和范围证明与区块链相结合,从而在保证用户交易金额保密性的同时,能够有效地防止恶意用户在多家金融机构中的恶意超额交易行为。

Figure 201811332698

Embodiments of the present invention provide a blockchain-based fund transaction method and device. The method includes: the server in the blockchain receives the current transaction information sent by the client; the server obtains the last transaction information corresponding to the account identifier from historical transaction records; and verifies the current transaction sent by the client according to a preset verification algorithm Whether the random commitment, range proof and knowledge proof in the transaction information are valid; if the server verifies whether the random commitment, range proof and knowledge proof in this transaction information are all valid, the server will process this transaction according to the current transaction information . Because the random commitment and range proof are combined with the blockchain in the embodiment of the present invention, while ensuring the confidentiality of the user's transaction amount, it can effectively prevent malicious users from malicious excess transactions in multiple financial institutions.

Figure 201811332698

Description

一种基于区块链的资金交易方法及装置A method and device for fund transaction based on blockchain

技术领域technical field

本发明涉及互联网应用技术领域,特别是涉及一种基于区块链的资金交易方法及装置。The present invention relates to the technical field of Internet applications, in particular to a method and device for capital transaction based on block chain.

背景技术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 severe. For example, malicious users may borrow a certain amount from each financial institution, and hide their past outstanding loan amounts when each financial institution (or bank) applies for a loan. In this case, the malicious user may make a large loan, and the loan amount may greatly exceed his ability to repay. If this behavior cannot be effectively controlled, this malicious over-lending will cause great harm to the financial system.

目前,金融机构可以采用一种简单的方法来防止这类行为,那就是:每个金融机构向其他金融机构共享每个用户的贷款信息。但是,这种方法有两个重要的缺点:一方面,银行将用户的贷款信息暴露给其他人,这是对用户隐私的侵犯;另一方面,金融机构将其自身的业务信息暴露给其他机构,这是对机构自身隐私的侵犯。Currently, there is a simple way that financial institutions can prevent this kind of behavior: each financial institution shares each user's loan information with other financial institutions. However, this method has two important drawbacks: on the one hand, the bank exposes the user's loan information to others, which is a violation of the user's privacy; on the other hand, the financial institution exposes its own business information to other institutions , which is an invasion of the institution's own privacy.

显然,在现有的金融机构采用的防止用户恶意超额贷款行为的方法中,缺乏保护用户和金融机构隐私的措施,不能保证一个用户的贷款总额小于某个限制。Obviously, in the existing methods used by financial institutions to prevent malicious over-loan behavior of users, there is a lack of measures to protect the privacy of users and financial institutions, and it cannot guarantee that a user's total loan amount is less than a certain limit.

发明内容SUMMARY OF THE INVENTION

本发明实施例的目的在于提供一种基于区块链的资金交易方法,以避免用户的交易总额超过用户的预设的可交易金额的范围。The purpose of the embodiments of the present invention is to provide a blockchain-based fund transaction method, so as to avoid the user's total transaction amount from exceeding the user's preset tradable amount range.

具体技术方案如下:The specific technical solutions are as follows:

第一方面,提供了一种基于区块链的资金交易方法,所述方法应用于区块链中的服务器,所述服务器中存储有各账户标识对应的历史交易记录,所述历史交易记录中包括随机承诺和范围证明、账户标识和交易类型标识,所述方法包括:A first aspect provides a blockchain-based fund transaction method, the method is applied to a server in the blockchain, the server stores historical transaction records corresponding to each account identifier, and the historical transaction records in the historical transaction records are stored in the server. Including random commitment and scope proof, account identification and transaction type identification, the method includes:

接收客户端发送的本次交易信息,所述本次交易信息中包括交易金额、账户标识和交易类型标识、所述交易金额对应的第一随机承诺和第一范围证明、所述账户标识的当前的剩余可交易金额对应的第二随机承诺和第二范围证明、所述账户标识的第三随机承诺和所述第三随机承诺对应的知识证明;Receive the current transaction information sent by the client, the current transaction information includes the transaction amount, the account identifier and the transaction type identifier, the first random commitment and the first range certificate corresponding to the transaction amount, and the current account identifier. The second random commitment and the second range proof corresponding to the remaining tradable amount of , the third random commitment of the account identifier and the knowledge proof corresponding to the third random commitment;

从所述历史交易记录中获取所述账户标识对应的上一次交易记录;Obtain the last transaction record corresponding to the account identifier from the historical transaction record;

根据预设的验证算法,确定所述交易金额对应的第一随机承诺和第一范围证明、所述账户标识的当前的剩余可交易金额对应的第二随机承诺和第二范围证明、以及所述账户标识的第三随机承诺和所述第三随机承诺对应的知识证明是否有效;According to a preset verification algorithm, determine the first random commitment and the first range proof corresponding to the transaction amount, the second random commitment and the second range proof corresponding to the current remaining tradable amount of the account identifier, and the Whether the third random commitment identified by the account and the knowledge certificate corresponding to the third random commitment are valid;

若所述第一随机承诺、所述第一范围证明、所述第二随机承诺、所述第二范围证明、所述第三随机承诺和所述第三随机承诺对应的知识证明有效,则根据所述本次交易信息进行本次交易处理。If the first random commitment, the first range proof, the second random commitment, the second range proof, the third random commitment and the knowledge proof corresponding to the third random commitment are valid, then according to The current transaction information is used to process the current transaction.

进一步的,所述在接收客户端发送的本次交易信息的步骤之前,还可以包括:Further, before the step of receiving the current transaction information sent by the client, it may further include:

接收客户端发送的账户创建请求信息;其中,所述账户创建请求信息中包括用户标识;Receive account creation request information sent by the client; wherein, the account creation request information includes a user ID;

在预设的账户信息表中,查找是否包含所述用户标识对应的账户标识;In the preset account information table, find out whether the account identification corresponding to the user identification is included;

若所述账户信息表中不包含所述用户标识对应的账户标识,则在接收客户端发送的第四随机承诺对应的知识证明时,根据预设的知识证明验证算法,验证所述第四随机承诺对应的知识证明是否有效;If the account information table does not contain the account identifier corresponding to the user identifier, when receiving the knowledge certificate corresponding to the fourth random commitment sent by the client, verify the fourth random Whether the knowledge proof corresponding to the commitment is valid;

若所述第四随机承诺对应的知识证明有效,则创建所述用户标识对应的账户标识和交易总金额。If the knowledge certificate 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 blockchain-based fund transaction method is provided, the method is applied to a client, and the method includes:

获取用户输入的交易申请信息,所述交易申请信息包括账户标识、交易类型标识和交易金额;Obtain the transaction application information input by the user, where the transaction application information includes an account identifier, a transaction type identifier and a transaction amount;

根据所述交易金额,确定所述交易金额对应的第一随机承诺和第一范围证明;According to the transaction amount, determine the first random commitment and the first range proof corresponding to the transaction amount;

确定所述账户标识的当前的剩余可交易金额,以及所述账户标识的剩余可交易金额对应的第二随机承诺和第二范围证明;determining the current remaining tradable amount of the account identifier, and the second random commitment and the second range proof corresponding to the remaining tradable amount of the account identifier;

根据所述交易金额对应的第一随机承诺和预设的知识证明生成算法,确定所述账户标识的第三随机承诺和所述第三随机承诺对应的知识证明;According to the first random commitment corresponding to the transaction amount and the preset knowledge proof generation algorithm, determine the third random commitment of the account identifier and the knowledge proof corresponding to the third random commitment;

将所述交易申请信息、交易金额对应的第一随机承诺和第一范围证明、所述账户标识的剩余可交易金额对应的第二随机承诺和第二范围证明、所述账户标识的第三随机承诺和所述第三随机承诺对应的知识证明,组成本次交易信息;The transaction application information, the first random commitment and the first range certificate corresponding to the transaction amount, the second random commitment and the second range certificate corresponding to the remaining tradable amount of the account identifier, and the third random number of the account identifier. The knowledge proof corresponding to the commitment and the third random commitment constitutes the transaction information;

将所述本次交易信息发送至区块链中的服务器,以使所述服务器根据预设的验证算法,验证所述本次交易信息是否正确,若正确,则进行本次交易处理。The current transaction information is sent 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, the current transaction processing is performed.

进一步的,所述在获取用户输入的交易申请信息的步骤之前,可以包括:Further, before the step of acquiring the transaction application information input by the user, it may include:

向服务器发送账户创建请求信息;其中,所述账户创建请求信息中包括用户标识;Sending account creation request information to the server; wherein, the account creation request information includes a user ID;

获取用户输入的随机数;Get the random number entered by the user;

根据所述随机数和预设的随机承诺生成算法,确定第四随机承诺;determining a fourth random commitment according to the random number and a preset random commitment generation algorithm;

根据预设的知识证明生成算法,确定所述第四随机承诺对应的知识证明;determining the knowledge proof corresponding to the fourth random commitment according to a preset knowledge proof generating algorithm;

将所述第四随机承诺和第四随机承诺对应的知识证明发送至所述服务器。Send the fourth random commitment and the knowledge proof corresponding to the fourth random commitment to the server.

第三方面,提供了一种基于区块链的资金交易装置,所述装置应用于区块链中的服务器,所述服务器中存储有各账户标识对应的历史交易记录,所述历史交易记录中包括随机承诺和范围证明、账户标识和交易类型标识,所述装置包括:In a third aspect, a blockchain-based fund transaction device is provided, the device is applied to a server in the blockchain, and the server stores historical transaction records corresponding to each account identifier, and the historical transaction records in the historical transaction records Including random commitment and scope proof, account identification and transaction type identification, the device includes:

接收模块,用于接收客户端发送的本次交易信息,所述本次交易信息中包括交易金额、账户标识和交易类型标识、所述交易金额对应的第一随机承诺和第一范围证明、所述账户标识的当前的剩余可交易金额对应的第二随机承诺和第二范围证明、所述账户标识的第三随机承诺和所述第三随机承诺对应的知识证明;The receiving module is used to receive the current transaction information sent by the client, the current transaction information includes the transaction amount, the account identifier and the transaction type identifier, the first random commitment and the first range certificate corresponding to the transaction amount, the the second random commitment and the second range proof corresponding to the current remaining tradable amount of the account identifier, the third random commitment of the account identifier and the knowledge certificate corresponding to the third random commitment;

获取模块,用于从所述历史交易记录中获取所述账户标识对应的上一次交易记录;an acquisition module, configured to acquire the last transaction record corresponding to the account identifier from the historical transaction record;

确定模块,用于根据预设的验证算法,确定所述交易金额对应的第一随机承诺和第一范围证明、所述账户标识的当前的剩余可交易金额对应的第二随机承诺和第二范围证明、以及所述账户标识的第三随机承诺和所述第三随机承诺对应的知识证明是否有效;A determination module, configured to determine, according to a preset verification algorithm, a first random commitment and a first range proof corresponding to the transaction amount, and a second random commitment and a second range corresponding to the current remaining tradable amount of the account identifier proof, and whether the third random commitment identified by the account and the knowledge proof corresponding to the third random commitment are valid;

本次交易处理模块,用于若所述第一随机承诺、所述第一范围证明、所述第二随机承诺、所述第二范围证明、所述第三随机承诺和所述第三随机承诺对应的知识证明有效,则根据所述本次交易信息进行本次交易处理。This transaction processing module is used for if the first random promise, the first range proof, the second random promise, the second range proof, the third random promise and the third random promise If the corresponding knowledge certificate is valid, the current transaction processing is performed according to the current transaction information.

进一步的,所述装置还可以包括:Further, the device may also include:

账户创建请求信息接收模块,用于接收客户端发送的账户创建请求信息;其中,所述账户创建请求信息中包括用户标识;an account creation request information receiving module, configured to receive account creation request information sent by the client; wherein, the account creation request information includes a user ID;

查找模块,用于在预设的账户信息表中,查找是否包含所述用户标识对应的账户标识;a search module, configured to search in the preset account information table whether the account identification corresponding to the user identification is included;

验证模块,用于若所述账户信息表中不包含所述用户标识对应的账户标识,则在接收客户端发送的第四随机承诺对应的知识证明时,根据预设的知识证明验证算法,验证所述第四随机承诺对应的知识证明是否有效;The verification module is configured to, if the account information table does not contain the account identifier corresponding to the user identifier, when receiving the knowledge certificate corresponding to the fourth random commitment sent by the client, verify the verification algorithm according to the preset knowledge certificate whether the knowledge proof corresponding to the fourth random commitment is valid;

创建模块,用于若所述第四随机承诺对应的知识证明有效,则创建所述用户标识对应的账户标识和交易总金额。A creating module is configured to create an account identifier corresponding to the user identifier and a total transaction amount if the knowledge certificate corresponding to the fourth random commitment is valid.

第四方面,提供了一种基于区块链的资金交易装置,所述装置应用于客户端,所述装置包括:In a fourth aspect, a blockchain-based capital transaction device is provided, the device is applied to a client, and the device includes:

交易申请信息获取模块,用于获取用户输入的交易申请信息,所述交易申请信息包括账户标识、交易类型标识和交易金额;a transaction application information acquisition module, used for acquiring transaction application information input by a user, the transaction application information including 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 proof corresponding to the transaction amount;

第二确定模块,用于确定所述账户标识的当前的剩余可交易金额,以及所述账户标识的剩余可交易金额对应的第二随机承诺和第二范围证明;a second determining module, configured to determine the current remaining tradable amount of the account identifier, and the second random commitment and the second range proof corresponding to the remaining tradable amount of the account identifier;

第三确定模块,用于根据所述交易金额对应的第一随机承诺和预设的知识证明生成算法,确定所述账户标识的第三随机承诺和所述第三随机承诺对应的知识证明;a third determination module, configured to determine the third random commitment of the account identifier and the knowledge certificate corresponding to the third random commitment according to the first random commitment corresponding to the transaction amount and a preset knowledge proof generation algorithm;

本次交易信息组成模块,用于将所述交易申请信息、交易金额对应的第一随机承诺和第一范围证明、所述账户标识的剩余可交易金额对应的第二随机承诺和第二范围证明、所述账户标识的第三随机承诺和所述第三随机承诺对应的知识证明,组成本次交易信息;This transaction information constitutes a module, which is used to combine the transaction application information, the first random commitment and the first range certificate corresponding to the transaction amount, and the second random commitment and the second range certificate corresponding to the remaining tradable amount of the account identifier. , The third random commitment identified by the account and the knowledge certificate corresponding to the third random commitment constitute the transaction information;

本次交易信息验证模块,用于将所述本次交易信息发送至区块链中的服务器,以使所述服务器根据预设的验证算法,验证所述本次交易信息是否正确,若正确,则进行本次交易处理。The current transaction information verification module is used to send the current transaction information to the server in the blockchain, so that the server can verify whether the current transaction information is correct according to the preset verification algorithm. This transaction is processed.

进一步的,所述装置还可以包括:Further, the device may also 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 ID;

随机数获取模块,用于获取用户输入的随机数;The random number acquisition module is used to acquire the random number input by the user;

第四随机承诺确定模块,用于根据所述随机数和预设的随机承诺生成算法,确定第四随机承诺;a fourth random commitment determination module, configured to determine a fourth random commitment according to the random number and a preset random commitment generation algorithm;

知识证明确定模块,用于根据预设的知识证明生成算法,确定所述第四随机承诺对应的知识证明;a knowledge proof determination module, configured to determine a knowledge proof corresponding to the fourth random commitment according to a preset knowledge proof generation algorithm;

发送模块,用于将所述第四随机承诺和第四随机承诺对应的知识证明发送至所述服务器。A sending module, configured to send the fourth random commitment and the knowledge proof corresponding to the fourth random commitment to the server.

第五方面,提供了一种服务器,所述服务器中存储有各账户标识对应的历史交易记录,历史交易记录中包括随机承诺和范围证明、账户标识和交易类型标识,包括处理器、通信接口、存储器和通信总线,其中,处理器,通信接口,存储器通过通信总线完成相互间的通信;A fifth aspect provides a server that stores historical transaction records corresponding to each account identifier, and the historical transaction records include random commitments and scope proofs, account identifiers and transaction type identifiers, including processors, communication interfaces, A memory and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus;

存储器,用于存放计算机程序;memory for storing computer programs;

处理器,用于执行存储器上所存放的程序时,实现以下方法步骤:When the processor is used to execute the program stored in the memory, the following method steps are implemented:

接收客户端发送的本次交易信息,所述本次交易信息中包括交易金额、账户标识和交易类型标识、所述交易金额对应的第一随机承诺和第一范围证明、所述账户标识的当前的剩余可交易金额对应的第二随机承诺和第二范围证明、所述账户标识的第三随机承诺和所述第三随机承诺对应的知识证明;Receive the current transaction information sent by the client, the current transaction information includes the transaction amount, the account identifier and the transaction type identifier, the first random commitment and the first range certificate corresponding to the transaction amount, and the current account identifier. The second random commitment and the second range proof corresponding to the remaining tradable amount of , the third random commitment of the account identifier and the knowledge proof corresponding to the third random commitment;

从所述历史交易记录中获取所述账户标识对应的上一次交易记录;Obtain the last transaction record corresponding to the account identifier from the historical transaction record;

根据预设的验证算法,确定所述交易金额对应的第一随机承诺和第一范围证明、所述账户标识的当前的剩余可交易金额对应的第二随机承诺和第二范围证明、以及所述账户标识的第三随机承诺和所述第三随机承诺对应的知识证明是否有效;According to a preset verification algorithm, determine the first random commitment and the first range proof corresponding to the transaction amount, the second random commitment and the second range proof corresponding to the current remaining tradable amount of the account identifier, and the Whether the third random commitment identified by the account and the knowledge certificate corresponding to the third random commitment are valid;

若所述第一随机承诺、所述第一范围证明、所述第二随机承诺、所述第二范围证明、所述第三随机承诺和所述第三随机承诺对应的知识证明有效,则根据所述本次交易信息进行本次交易处理。If the first random commitment, the first range proof, the second random commitment, the second range proof, the third random commitment and the knowledge proof corresponding to the third random commitment are valid, then according to The current transaction information is used to process the current transaction.

第六方面,提供了一种客户端,包括处理器、通信接口、存储器和通信总线,其中,处理器,通信接口,存储器通过通信总线完成相互间的通信;In a sixth aspect, a client is provided, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus;

存储器,用于存放计算机程序;memory for storing computer programs;

处理器,用于执行存储器上所存放的程序时,实现以下方法步骤:When the processor is used to execute the program stored in the memory, the following method steps are implemented:

获取用户输入的交易申请信息,所述交易申请信息包括账户标识、交易类型标识和交易金额;Obtain the transaction application information input by the user, where the transaction application information includes an account identifier, a transaction type identifier and a transaction amount;

根据所述交易金额,确定所述交易金额对应的第一随机承诺和第一范围证明;According to the transaction amount, determine the first random commitment and the first range proof corresponding to the transaction amount;

确定所述账户标识的当前的剩余可交易金额,以及所述账户标识的剩余可交易金额对应的第二随机承诺和第二范围证明;determining the current remaining tradable amount of the account identifier, and the second random commitment and the second range proof corresponding to the remaining tradable amount of the account identifier;

根据所述交易金额对应的第一随机承诺和预设的知识证明生成算法,确定所述账户标识的第三随机承诺和所述第三随机承诺对应的知识证明;According to the first random commitment corresponding to the transaction amount and the preset knowledge proof generation algorithm, determine the third random commitment of the account identifier and the knowledge proof corresponding to the third random commitment;

将所述交易申请信息、交易金额对应的第一随机承诺和第一范围证明、所述账户标识的剩余可交易金额对应的第二随机承诺和第二范围证明、所述账户标识的第三随机承诺和所述第三随机承诺对应的知识证明,组成本次交易信息;The transaction application information, the first random commitment and the first range certificate corresponding to the transaction amount, the second random commitment and the second range certificate corresponding to the remaining tradable amount of the account identifier, and the third random number of the account identifier. The knowledge proof corresponding to the commitment and the third random commitment constitutes the transaction information;

将所述本次交易信息发送至区块链中的服务器,以使所述服务器根据预设的验证算法,验证所述本次交易信息是否正确,若正确,则进行本次交易处理。The current transaction information is sent 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, the current transaction processing is performed.

本发明实施例提供了一种基于区块链的贷款方法及装置,区块链中的服务器接收客户端发送的本次交易信息,并从历史交易记录中获取账户标识对应的上一次交易信息;根据预设的验证算法,确定客户端发送的本次交易信息中的交易金额对应的第一随机承诺、第一范围证明、账户标识的当前的剩余可交易金额对应的第二随机承诺、第二范围证明、账户标识的第三随机承诺和第三随机承诺对应的知识证明是否有效;若所述第一随机承诺和所述第一随机承诺对应的第一范围证明和第二随机承诺、所述第二随机承诺对应的第二范围证明、账户标识的第三随机承诺和第三随机承诺对应的知识证明有效,则根据所述本次交易信息进行本次交易处理。由于本发明实施例中,将随机承诺和范围证明与区块链相结合,从而在保证用户交易金额保密性的同时,能够有效地防止恶意用户在多家金融机构中的恶意超额交易行为。The embodiments of the present invention provide a blockchain-based loan method and device, wherein the server in the blockchain receives the current transaction information sent by the client, and obtains the last transaction information corresponding to the account identifier from the historical transaction records; According to the preset verification algorithm, determine the first random commitment corresponding to the transaction amount in the current transaction information sent by the client, the first scope proof, the second random commitment corresponding to the current remaining tradable amount of the account identifier, the second Whether the range proof, 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 range proof corresponding to the first random commitment and the second random commitment, the The second range certificate corresponding to the second random commitment, the third random commitment of the account identifier, and the knowledge certificate corresponding to the third random commitment are valid, and the current transaction is processed according to the current transaction information. Because the random commitment and range proof are combined with the blockchain in the embodiment of the present invention, while ensuring the confidentiality of the user's transaction amount, it can effectively prevent malicious users from malicious excess transactions in multiple financial institutions.

当然,实施本发明的任一产品或方法必不一定需要同时达到以上所述的所有优点。Of course, it is not necessary for any product or method to implement the present invention to simultaneously achieve all of the advantages described above.

附图说明Description of drawings

为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to explain the embodiments of the present invention or the technical solutions in the prior art more clearly, the following briefly introduces the accompanying drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only These are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can also be obtained according to these drawings without creative efforts.

图1为本发明实施例提供的一种基于区块链的资金交易方法的流程示意图;1 is a schematic flowchart of a blockchain-based fund transaction method provided by an embodiment of the present invention;

图2为本发明实施例提供的另一种基于区块链的资金交易方法的流程示意图;2 is a schematic flowchart of another blockchain-based capital transaction method provided by an embodiment of the present invention;

图3为本发明实施例提供的一种基于区块链的资金交易装置的结构示意图;3 is a schematic structural diagram of a blockchain-based capital transaction device provided by an embodiment of the present invention;

图4为本发明实施例提供的另一种基于区块链的资金交易装置的结构示意图;4 is a schematic structural diagram of another blockchain-based capital transaction device provided by an embodiment of the present invention;

图5为本发明实施例提供的一种电子设备的结构示意图;5 is a schematic structural diagram of an electronic device according to an embodiment of the present invention;

图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 will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, but not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

本发明实施例提供的一种基于区块链的资金交易方法,该方法应用于区块链中的服务器,该服务器可以是区块链中的各金融机构设置的服务器。本发明实施例中提供的资金交易方法中的资金交易类型可以包括贷款交易和还款交易。而服务器中存储有各账户标识对应的历史交易记录。An embodiment of the present invention provides a blockchain-based fund transaction method, which is applied to a server in the blockchain, and the server may be a server set by each financial institution in the blockchain. The types of capital transactions in the capital transaction method provided in the embodiment of the present invention may include loan transactions and repayment transactions. The server stores historical transaction records corresponding to each account identifier.

其中,历史交易记录可以包括随机承诺和范围证明、账户标识和交易类型标识。交易类型标识为用于区别每个交易记录的类型,即该次交易是贷款交易,还是还款交易;若本次交易是贷款交易,交易类型标识可以为loan(中文:贷款);若本次交易是还款交易,交易类型标识可以为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 loan (Chinese: loan); The transaction is a repayment transaction, and the transaction type identifier can be repay (Chinese: repayment).

由于随机承诺和范围证明是根据交易金额计算出的数据,而服务器中只存储有随机承诺和范围证明而未存储交易金额,因此,无法通过查看随机承诺而确定出该随机承诺对应的交易金额。也即,当区块链中的各服务器中只存储各账户标识的随机承诺和范围证明时,各服务器就实现了在隐藏保证用户交易金额保密性。Since the random commitment and range proof are data calculated based on the transaction amount, and only the random commitment and the range proof are stored in the server without the transaction amount, the transaction amount corresponding to the random commitment cannot be determined by looking at the random commitment. That is, when each server in the blockchain only stores the random commitment and range proof of each account ID, each server realizes the hidden guarantee of the confidentiality of the user's 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 user's transaction data (such as loan amount or repayment amount, etc.) on the blockchain. Because random commitments can hide transaction data, random commitments stored on the blockchain not only realize resource sharing, but also hide the transaction data corresponding to random commitments. For example, when a user applies for a loan at a financial institution in the alliance, the institution can use all the loan data of the user on the blockchain (all loan data generated in the alliance) to determine "If the money is lent to this user, does the user's total loan amount exceed the total amount that he can loan". If the user fails this judgment, the financial institution will not lend to the user because "after the user has loaned this money, the total amount of all his loans will exceed the total amount he can lend", thus avoiding The user's total loan amount exceeds the user's maximum loan amount.

下面首先对本发明实施例提供的一种基于区块链的资金交易方法进行介绍,参见图1,该方法包括如下步骤:The following first introduces a blockchain-based fund transaction method provided by an embodiment of the present invention. Referring to FIG. 1 , the method includes the following steps:

S101:接收客户端发送的本次交易信息。S101: Receive the current transaction information sent by the client.

在实施时,区块链中的某个服务器为客户端的某个用户,创建一个唯一的账户标识,并将该账户标识存储在一个预设的账户信息表中。当客户端与区块链中的某个服务器进行资金交易时,客户端生成本次交易信息,并将该交易信息发送给与该客户端进行本次交易的服务器,该服务器在验证过本次交易信息中的随机承诺和范围证明之后,处理本次交易并提取本次交易信息中的部分信息,生成交易记录并存储起来;并且该服务器将该交易记录发送给区块链中的所有服务器;所以,区块链中的每个服务器都存储有相同的交易记录,而且,该交易记录是各个用户在联盟中与各个服务器进行的所有交易记录。During 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 performs a capital transaction with a server in the blockchain, the client generates the transaction information and sends the transaction information to the server that conducts this transaction with the client. The server has verified this transaction After the random commitment and scope proof in the transaction information, the transaction is processed and part of the information in the transaction information is extracted, a 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 made by each user with each server in the alliance.

其中,账户标识是用于区别不同的用户,且与用户标识一一对应。账户标识可以是任何用于标识不同用户的标识信息,例如,账户ID(Identification,识别)、账户名称等,本发明中不做具体限定。The account identifier is used to distinguish different users, and corresponds to the user identifier one by one. The account identifier may be any identification information used to identify different users, for example, account ID (Identification, identification), account name, etc., which are not specifically limited in the present invention.

其中,本次交易信息中可以包括交易金额、账户标识、交易类型标识、该交易金额对应的第一随机承诺和第一范围证明、该账户标识的当前的剩余可交易金额对应的第二随机承诺和第二范围证明、该账户标识的第三随机承诺和第三随机承诺对应的知识证明。The current transaction information may include transaction amount, account identification, transaction type identification, first random commitment and first range certificate corresponding to the transaction amount, and second random commitment corresponding to the current remaining tradable amount of the account identification The knowledge proof corresponding to the second range proof, the third random commitment identified by the account, and the third random commitment.

可选的,在步骤S101服务器接收客户端发送的本次交易信息之前,服务器可以先接收客户端发送的账户创建请求信息;然后,在预设的账户信息表中,查找是否包含用户标识对应的账户标识;若账户信息表中不包含用户标识对应的账户标识,则服务器在接收客户端发送的第四随机承诺对应的知识证明时,根据预设的知识证明验证算法,验证第四随机承诺对应的知识证明是否有效;若第四随机承诺对应的知识证明有效,则创建用户标识对应的账户标识和交易总金额。Optionally, before the server receives the current transaction information sent by the client in step S101, the server may first receive the account creation request information sent by the client; Account identification; if the account information table does not contain the account identification corresponding to the user identification, the server, when receiving the knowledge proof corresponding to the fourth random commitment sent by the client, verifies the corresponding 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 ID corresponding to the user ID and the total transaction amount are created.

其中,账户创建请求信息中可以包括用户标识,用户标识为用于区别不同用户的标识信息,可以为用户ID、用户名称等,这里不做限定。The account creation request information may include a user ID, and the user ID is identification information used to distinguish different users, and may be a user ID, a user name, etc., which is not limited here.

在实施时,服务器在接收到客户端发送的本次交易信息时,服务器在预设的账号信息表中,查找是否存储有本次交易信息中的账户标识。若服务器中预设的账户信息表中存储有上述本次交易信息中的账户标识,说明本账户标识对应的用户标识不是第一次与金融机构进行资金交易,则执行步骤S102;若服务器中预设的账户信息表中未存储上述本次交易信息中的账户标识,说明该用户标识为第一次与金融机构进行资金交易,则服务器需要为该用户标识创建一个账户标识。During implementation, when the server receives the current transaction information sent by the client, the server searches in the preset account information table whether the account identifier in the current transaction information is stored. If the account identifier in the above-mentioned current transaction information is stored in the preset account information table in the server, it means that the user identifier corresponding to the account identifier is not the first time to conduct a fund transaction with a financial institution, then step S102 is executed; The set account information table does not store the account identifier in the above-mentioned current transaction information, indicating that the user identifier is the first time to conduct a fund transaction with a financial institution, and the server needs to create an account identifier for the user identifier.

进一步的,服务器可以接收客户端发送的第四随机承诺和第四随机承诺对应的知识证明;并根据预设的知识证明验证算法,验证上述第四随机承诺对应的知识证明是否有效。若上述第四随机承诺对应的知识证明有效,则服务器为用户标识创建用户标识对应的账户,并设置该账户的账户标识和交易总金额。Further, the server can receive the fourth random commitment sent by the client and the knowledge proof corresponding to the fourth random commitment; and verify whether the knowledge proof corresponding to the fourth random commitment is valid according to a preset knowledge proof verification algorithm. If the knowledge certificate corresponding to the fourth random commitment is valid, the server creates an account corresponding to the user ID for the user ID, and sets the account ID and the 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 this embodiment of the present invention, the client can calculate R=kH according to the random number k input by the user; wherein, the coordinates of the point R are (x 2 , y 2 ); let r=x 2 , 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 random number k. Finally, take the remainder of the calculation result s to obtain s', and determine {r, s'} as the knowledge proof corresponding to the fourth random commitment.

在本发明实施例中,可以采用如下知识证明验证算法,验证第四随机承诺对应的知识证明{r,s′},具体计算公式如下:In the embodiment of the present invention, the following knowledge proof verification algorithm can be used 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′-1 w=s' -1

(x1,y1)=z×w×H+r×w×pk(x 1 , y 1 )=z×w×H+r×w×pk

其中,m为客户端发送的哈希值,该哈希值可以是客户端根据预设的哈希函数,计算出的用户ID对应的哈希值、业务序列号对应的哈希值或金融机构ID等信息对应的哈希值中的一种或多种,r和s'为第四随机承诺对应的知识证明中的签名,pk为公钥,H的坐标为(x0,y0)。Among them, m is the hash value sent by the client, and the hash value can be the hash value corresponding to the user ID, the hash value corresponding to the business serial number, or the hash value corresponding to the business serial number calculated by the client according to the preset hash function, or a financial institution. One or more of the hash values corresponding to information such as ID, r and s' are the signatures in the knowledge proof corresponding to the fourth random commitment, pk is the public key, and the coordinates of H are (x 0 , y 0 ).

如果(x1,y1)=0,则证明上述第四随机承诺对应的知识证明{r,s′}为无效;如果(x1,y1)≠0、且x1=r,则证明上述第四随机承诺对应的知识证明{r,s′}为有效。If (x 1 , y 1 )=0, it is proved that the knowledge proof {r, s′} corresponding to the fourth random commitment is invalid; if (x 1 , y 1 )≠0, and x 1 =r, then it is proved that The knowledge proof {r, s'} corresponding to the above fourth random commitment is valid.

本申请实施例中,服务器在验证上述第四随机承诺对应的知识证明为有效,并为用户标识创建对应的账户标识和交易总金额之后,服务器还可以根据创建的用户标识对应的交易总金额S,确定账户标识与本联盟中所有金融机构进行资金交易的总金额S对应的随机承诺。In this 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 ID and a total transaction amount for the user ID, the server can also create a corresponding total transaction amount S for the user ID according to the created user ID. , and determine the random commitment corresponding to the account identifier and the total amount S of capital transactions conducted by all financial institutions in the alliance.

其中,服务器中预设的随机承诺的计算公式为:Among them, 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 a random number input by the user, the coordinates of H are (x 0 , y 0 )), and G is the coordinate point (x 01 , y 01 ).

根据客户端发送的账户标识的第四随机承诺

Figure GDA0003046282440000111
和服务器为该账户标识创建的交易总金额S可知,账户标识的交易总金额对应的随机承诺为:A fourth random promise based on the account ID sent by the client
Figure GDA0003046282440000111
From the total transaction amount S created by the server for the account ID, the random commitment corresponding to the total transaction amount of the account ID is:

Figure GDA0003046282440000112
Figure GDA0003046282440000112

其中,CM0为账户标识的可交易总金额对应的随机承诺,S为账户标识与本联盟中所有金融机构进行资金交易的总金额,G的坐标为(x01,y01),

Figure GDA0003046282440000113
为第四随机承诺。Among them, CM 0 is the random commitment corresponding to the total tradable amount of the account identifier, S is the total amount of capital transactions between the account identifier and all financial institutions in the alliance, and the coordinates of G are (x 01 , y 01 ),
Figure GDA0003046282440000113
for the fourth random commitment.

之后,服务器将该账户标识、该账户标识的可交易总金额、该账户标识的可交易总金额对应的随机承诺、可交易总金额的随机承诺对应的知识证明和交易类型标识存储在区块链中。当服务器将上述账户标识、账户标识的可交易总金额、账户标识的可交易总金额对应的随机承诺、第四随机承诺和第四随机承诺对应的知识证明和交易类型标识,发送给区块链中的其他服务器进行存储时,其他服务器,可以对上述信息中的可交易总金额的随机承诺对应的知识证明进行验证,具体验证方法如上述知识证明的验证描述过程。若验证通过,区块链中的其他服务器则存储上述账户标识、账户标识的可交易总金额、账户标识的可交易总金额对应的随机承诺、第四随机承诺和第四随机承诺对应的知识证明和交易类型标识;否则,区块链中的其他服务器则丢弃账户标识、账户标识的可交易总金额、账户标识的可交易总金额对应的随机承诺、第四随机承诺和第四随机承诺对应的知识证明和交易类型标识。After that, the server stores 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 knowledge proof corresponding to the random commitment of the total tradable amount, and the transaction type identifier in the blockchain. middle. When the server sends 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 and transaction type identifier corresponding to the fourth random commitment to the blockchain When storing in other servers in the above information, other servers can verify the knowledge proof corresponding to the random commitment of the total tradable amount in the above information. The specific verification method is as described in the verification description process of the above knowledge proof. If the verification is passed, other servers in the blockchain store the above account ID, the total tradable amount of the account ID, the random commitment corresponding to the total tradable amount of the account ID, the fourth random commitment and the knowledge certificate corresponding to the fourth random commitment and transaction type identifier; otherwise, 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. Proof of knowledge and transaction type identification.

在本发明实施例中,所有的随机承诺对应的知识证明的验证过程都可以采用上述相同的验证算法。同理,本发明实施例只是提供了一种可选的知识证明的验证算法,其他任何可用于随机承诺对应的知识证明的验证算法都可以应用到本发明实施例中,这里不做具体限定。In the embodiment of the present invention, the verification process of the knowledge proof corresponding to all random commitments may use the same verification algorithm as described above. Similarly, the embodiments of the present invention only provide an optional verification algorithm for knowledge proof, and any other verification algorithms that can be used for knowledge proof corresponding to random commitments can be applied to the embodiments of the present invention, which are not specifically limited here.

S102:从历史交易记录中获取账户标识对应的上一次交易记录。S102: Obtain the last transaction record corresponding to the account identifier from the historical transaction record.

在实施中,服务器将区块链中的每次交易的交易信息都存储在区块链上,并将本次交易信息之前的所有交易信息称为历史交易记录;其中,历史交易记录中可以包括随机承诺和范围证明、账户标识和交易类型标识。In implementation, the server stores the transaction information of each transaction in the blockchain on the blockchain, and calls all transaction information before the current transaction information as historical transaction records; the historical transaction records may include Random commitment and range proofs, account IDs, and transaction type IDs.

服务器在存储有历史交易记录的区块链中,获取与上述账户标识对应的上一次交易信息,通过读取该账户标识对应的上一次交易信息中记录的该账户标识对应的当前的剩余可交易金额对应的第二随机承诺,服务器根据预设的随机承诺交易金额查看方法,查看第二随机承诺中账户标识对应的当前的剩余可交易金额,将账户标识对应的当前的剩余可交易金额与该客户端发送的本次交易申请中账户标识本次申请的交易金额比较,如果客户端发送的本次交易申请中账户标识本次申请的交易金额大于和/或等于该账户标识对应的当前的剩余可交易金额,则服务器向客户端发送本次交易申请失败信息;如果客户端发送的本次交易申请中账户标识本次申请的交易金额小于该账户标识对应的当前的剩余可交易金额,服务器则执行步骤S104。The server obtains the last transaction information corresponding to the above account identification in the blockchain storing the historical transaction records, and reads the current remaining tradables corresponding to the account identification recorded in the last transaction information corresponding to the account identification The second random commitment corresponding to the amount, the server checks the current remaining tradable amount corresponding to the account identifier in the second random commitment according to the preset random commitment transaction amount checking method, and compares the current remaining tradable amount corresponding to the account identifier with the current remaining tradable amount corresponding to the account identifier. Compare the transaction amount of the account ID in the current transaction application sent by the client with the transaction amount of the current application, if the transaction amount of the account ID in the current transaction application sent by the client is greater than and/or equal to the current remaining balance corresponding to the account ID tradable amount, the server sends this transaction application failure information to the client; if the transaction amount of the account ID in the current transaction application sent by the client is less than the current remaining tradable amount corresponding to the account ID, the server will Step S104 is performed.

可选的,如果客户端发送的本次交易信息为某用户标识的第一次交易申请,那么,服务器查询到的该账户标识对应的上一次交易信息中的剩余可交易金额对应的承诺,正好也是该用户可交易总额度的承诺(建账时所得到的)。但如果后续客户端再次发送交易申请,当服务器查询该账户标识最近一次交易信息时,服务器查到的就会是当前的剩余可交易金额的随机承诺。Optionally, if the current transaction information sent by the client is the first transaction application for a certain user ID, then the commitment corresponding to the remaining tradable amount in the last transaction information corresponding to the account ID queried by the server is exactly the same. It is also the commitment of the user's total tradable quota (obtained when the account is established). However, if the subsequent client sends a transaction application again, when the server queries the latest transaction information of the account ID, 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 ID is P is S. In the transaction application information sent by the client for the first time, the loan amount applied for by the user is n1. Then, when the client second time When sending the transaction application information, in the commitment corresponding to the last remaining tradable amount corresponding to the account ID obtained by the server, the recorded current remaining loanable amount corresponding to the account ID is S-n1; The loan amount of the second application is n2, then when the client sends the third transaction application information, in the commitment corresponding to the last remaining tradable amount corresponding to the account ID obtained by the server, the current account ID corresponding to the recorded current The remaining loanable amount is S-n1-n2, and so on. It is understandable that, if the transaction application information sent by the client indicates that the transaction type is repay, that is, a repayment transaction, after the server has executed this transaction, in the commitment corresponding to the user's remaining tradable amount, the record is recorded. The current remaining tradable amount corresponding to the account identifier is S-n1+n2, where n2 is the repayment amount in the current transaction information sent by the client.

S103:根据预设的验证算法,确定本次交易信息中交易金额对应的第一随机承诺和第一范围证明、以及账户标识的当前的剩余可交易金额对应的第二随机承诺和第二范围证明、以及账户标识的第三随机承诺和第三随机承诺对应的知识是否有效。S103: According to the preset verification algorithm, determine the first random commitment and the first range certificate corresponding to the transaction amount in the current transaction information, and the second random commitment and the second range certificate corresponding to the current remaining tradable amount of the account identifier , and the third random commitment identified by the account and whether the knowledge corresponding to the third random commitment is valid.

在实施中,范围证明是利用包含两个公钥的环签名的算法构成的,其是客户端为了证明客户端发送的随机承诺中的交易金额在某个范围之内,客户端为服务器提供的数据证据。In the implementation, the range proof is constituted by the algorithm of ring signature containing two public keys, which is provided by the client to the server in order 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 range proof corresponding to the random commitment is essentially the verification of the ring signature that constitutes the range proof. Specifically, the calculation formula for verifying the ring signature that constitutes the range proof is as follows:

T0=c0×pk0+z0×HT 0 =c 0 ×pk 0 +z 0 ×H

T1=c1×pk1+z1×HT 1 =c 1 ×pk 1 +z 1 ×H

h=Hash(pk0,pk1,T0,T1)h=Hash(pk 0 ,pk 1 ,T 0 ,T 1 )

其中,pk0为用户的公钥,pk1和pk2为预设的其他用户的公钥,H的坐标为(x0,y0),z1和c1为用户输入的随机数,T0、T1、c0和z0为环签名中的参数。Among them, pk 0 is the user's public key, pk 1 and pk 2 are the preset public keys of other users, the coordinates of H are (x 0 , y 0 ), z 1 and c 1 are random numbers input by the user, T 0 , T 1 , c 0 and z 0 are parameters in the ring signature.

如果计算结果h与客户端发送的范围证明中的参数c1的进行逐比特模2运算(h⊕c1),得到的值与客户端发送的环签名中的参数c0相等,则证明上述环签名有效,由于范围证明是由一系列的环签名构成的,所以,环签名有效则该环签名构成的范围证明也有效。其中,范围证明的计算过程将在后续描述中介绍。If the calculation result h and the parameter c 1 in the range proof sent by the client perform a bit-by-bit modulo 2 operation (h⊕c 1 ), and the obtained value is equal to the parameter c 0 in the ring signature sent by the client, it proves that the above The ring signature is valid. Since the range proof is composed of a series of ring signatures, if the ring signature is valid, the range proof formed by the ring signature is also valid. Among them, the calculation process of the range proof will be introduced in the subsequent description.

可选的,在上述步骤,服务器根据预设的验证算法,确定本次交易信息中交易金额对应的第一随机承诺、第一范围证明和账户标识的当前的剩余可交易金额对应的第二随机承诺和第二范围证明、以及账户标识的第三随机承诺和第三随机承诺对应的知识有效之后,还可以判断如下公式是否成立:Optionally, in the above step, the server determines, according to a preset verification algorithm, the first random commitment corresponding to the transaction amount in the current transaction information, the first range certificate and the second random amount corresponding to the current remaining tradable amount of the account identifier. After the commitment and the second range proof, as well as the knowledge corresponding to the third random commitment of the account ID and the third random commitment are valid, you can also judge whether the following formula holds:

Figure GDA0003046282440000131
Figure GDA0003046282440000131

CM1,1=CM0-CM1,0 CM 1,1 = CM 0 -CM 1,0

其中,CM1,1为账户标识当前的剩余可交易金额对应的第二随机承诺,CM0为账户标识对应的总交易金额对应随机承诺和CM1,0为本次交易信息中交易金额对应的第一随机承诺,n1为本次交易信息中用户申请的交易金额,G的坐标为(x01,y01),

Figure GDA0003046282440000132
为账户标识的第三随机承诺。Among them, CM 1,1 is the second random commitment corresponding to the current remaining tradable amount of the account identifier, CM 0 is the random commitment corresponding to the total transaction amount corresponding to the account identifier, and CM 1,0 is the transaction amount corresponding to the current transaction information. The first random commitment, n 1 is the transaction amount applied by the user in this transaction information, and the coordinates of G are (x 01 , y 01 ),
Figure GDA0003046282440000132
A third random commitment identified for the account.

如果上述

Figure GDA0003046282440000141
和CM1,1=CM0-CM1,0等式成立,则服务器执行步骤S104;如果上述等式
Figure GDA0003046282440000142
和CM1,1=CM0-CM1,0等式不成立,则服务器向客户端发送本次交易申请失败信息。If the above
Figure GDA0003046282440000141
and CM 1,1 =CM 0 -CM 1,0 equation is established, then the server executes step S104; if the above equation
Figure GDA0003046282440000142
If the equation of and CM 1,1 =CM 0 -CM 1,0 does not hold, the server sends the client a message that the transaction application fails.

S104:若第一随机承诺、第一范围证明、第二随机承诺和第二范围证明、第三随机承诺和第三随机承诺对应的知识证明有效,则根据本次交易信息进行本次交易处理。S104: If the knowledge certificates corresponding to the first random promise, the first range proof, the second random promise and the second range proof, the third random promise and the third random promise are valid, the current transaction is processed according to the current transaction information.

在实施时,服务器在根据预设的验证算法,证明了上述第一随机承诺、第一范围证明、第二随机承诺、第二范围证明、第三随机承诺和第三随机承诺对应的知识证明有效之后,服务器根据本次交易信息中记录的交易类型标识,进行本次交易处理。During implementation, the server proves that the knowledge certificates corresponding to the first random commitment, the first range proof, the second random commitment, the second range proof, the third random commitment and the third random commitment are valid according to the preset verification algorithm After that, the server processes the current transaction according to the transaction type identifier recorded in the current transaction information.

若本次交易信息中记录的交易类型标识为贷款标识(即loan),则服务器将本次交易信息中用户申请贷款的金额发送给客户端。若本次交易信息中记录的交易类型标识为还款标识(即repay),则服务器接收客户端发送的本次交易信息中记录的还款金额。If the transaction type identifier recorded in the current transaction information is a loan identifier (ie loan), the server sends the amount of the loan applied for by the user in the current transaction information to the client. If the transaction type identifier recorded in the current transaction information is a repayment identifier (ie repay), the server receives the repayment amount recorded in the current transaction information sent by the client.

进一步的,在服务器处理完上述交易之后,服务器还可以将客户端发送的本次交易信息中的交易金额对应的第一随机承诺和第一范围证明、账户标识当前的剩余可交易金额对应的第二随机承诺和第二随机承诺对应的第二范围证明、账户标识和交易类型标识,作为历史交易记录,存储在区块链中。Further, after the server has processed the above transaction, the server may also send the first random commitment and the first range certificate corresponding to the transaction amount in the current transaction information sent by the client, and the account identifier corresponding to the current remaining tradable amount. The second random commitment and the second range proof, account identifier and transaction type identifier corresponding to the second random commitment are stored in the blockchain as historical transaction records.

本发明实施例提供了一种贷款方法,区块链中的服务器接收客户端发送的本次交易信息,然后,从历史交易记录中获取账户标识对应的上一次交易信息;根据预设的验证算法,确定本次交易信息中交易金额对应的第一随机承诺、第一范围证明、账户标识的当前的剩余可交易金额对应的第二随机承诺、第二范围证明、账户标识的第三随机承诺和第三随机承诺对应的知识证明是否有效;若第一随机承诺和所述第一随机承诺对应的第一范围证明和第二随机承诺、第二随机承诺对应的第二范围证明、账户标识的第三随机承诺和第三随机承诺对应的知识证明有效,则根据本次交易信息进行本次交易处理。由于本发明实施例中,将随机承诺和范围证明与区块链相结合,从而在保证用户交易金额保密性的同时,能够有效地防止恶意用户在多家金融机构中的恶意超额交易行为。The embodiment of the present invention provides a loan method. The server in the blockchain receives the current transaction information sent by the client, and then obtains the previous transaction information corresponding to the account identifier from the historical transaction records; according to a preset verification algorithm , determine the first random commitment corresponding to the transaction amount in the current transaction information, the first range certificate, the second random commitment corresponding to the current remaining tradable amount of the account identifier, the second range certificate, the account identifier The third random commitment and Whether the knowledge proof corresponding to the third random commitment is valid; if the first random commitment and the first range proof corresponding to the first random commitment and the second random commitment, the second range proof corresponding to the second random commitment, The knowledge corresponding to the three random commitments and the third random commitment is valid, and the transaction is processed according to the current transaction information. Because the random commitment and range proof are combined with the blockchain in the embodiment of the present invention, while ensuring the confidentiality of the user's transaction amount, it can effectively prevent malicious users from malicious excess transactions in multiple financial institutions.

参见图2,图2为本发明实施例的另一基于区块链的资金交易方法的流程示意图,该方法应用于客户端,包括如下步骤:Referring to FIG. 2, FIG. 2 is a schematic flowchart of another blockchain-based fund 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 a user.

在实施时,客户端每次与区块链中的任何一个服务器进行资金交易时,都需要先向输入交易申请信息。其中,交易申请信息可以包括账户标识、交易类型标识和交易金额。同理,交易类型标识为用于区别本次交易为贷款交易,还是还款交易;若本次交易是贷款交易,交易类型标识可以为loan;若本次交易是还款交易,交易类型标识可以为repay。In implementation, every time the client performs a fund transaction with any server in the blockchain, it needs to apply for information to the input transaction first. 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 loan; if the transaction is a repayment transaction, the transaction type identifier can be for repay.

客户端在接收到用户输入的交易申请信息时,需要判断发送该交易申请信息的用户是否是第一次发送交易申请信息;若不是,则直接执行步骤S202;When the client terminal receives the transaction application information input by the user, it needs to determine whether the user who sent the transaction application information is the first time to send the transaction application information; if not, step S202 is directly executed;

客户端在接收到用户输入的交易申请信息时,需要判断发送该交易申请信息的用户是否是第一次发送交易申请信息;若不是,则直接执行步骤S202;可选的,若客户端判断发送该交易申请信息的用户是第一次发送交易申请信息,则客户端向服务器发送账户创建请求信息;其中,账户创建请求信息中包括用户标识;并客户端获取用户输入的随机数;根据用户输入的随机数和预设的随机承诺生成算法,确定第四随机承诺;根据预设的知识证明生成算法,确定第四随机承诺对应的知识证明;将第四随机承诺和第四随机承诺对应的知识证明发送至上述服务器。When the client receives the transaction application information input by the user, it needs to determine whether the user who sent the transaction application information is the first time to send the transaction application information; if not, step S202 is directly executed; If the user of the transaction application information is sending the transaction application information for the first time, the client terminal sends the account creation request information to the server; wherein, the account creation request information includes the user ID; and the client terminal obtains the random number input by the user; according to the user input determine the fourth random commitment; according to the preset knowledge proof generation algorithm, determine the knowledge proof corresponding to the fourth random commitment; combine the fourth random commitment and the knowledge corresponding to the fourth random commitment The proof is sent to the above server.

在实施时,预设的随机承诺生成算法的计算公式,可以如下:During implementation, the calculation formula of the preset random commitment generation algorithm may be as follows:

CM=n×G+k×HCM=n×G+k×H

其中,CM为随机承诺,k为用户输入的随机数,H的坐标为(x0,y0)。Among them, CM is a random commitment, k is a random number input by the user, and the coordinates of H are (x 0 , y 0 ).

由于本步骤中是用户第一次输入的交易申请信息时,为了在服务器设备中给该用户标识创建账户标识时,进行的第四随机承诺计算过程,所以,交易金额n的取值为零,则客户端得到的第四随机承诺为

Figure GDA0003046282440000151
其中,
Figure GDA0003046282440000152
Since this step is the fourth random commitment calculation process performed when the user enters the transaction application information for the first time in order to create an account ID for the user ID in the server device, the value of the transaction amount n is zero, Then the fourth random commitment obtained by the client is
Figure GDA0003046282440000151
in,
Figure GDA0003046282440000152

可选的,在本发明实施例中提供的随机承诺生成算法只是众多随机承诺生成算法中的一种,其他任何用于生成随机承诺的生成算法都可以应用于本发明实施例中,这里不做具体限定。Optionally, the random promise generation algorithm provided in the embodiment of the present invention is only one of many random promise generation algorithms, and any other generation algorithm for generating random promises can be applied to the embodiment of the present invention, which is not described here. Specific restrictions.

在实施时,客户端可以根据用户输入的随机数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′}确定为上述第四随机承诺对应的知识证明。During 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 (x 2 , y 2 ); let r=x 2 , if r=0, re-select the random number 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, take the remainder of the calculation result s to obtain s', and determine {r, s'} as the knowledge proof corresponding to the fourth random commitment.

S202:根据交易金额,确定交易金额对应的第一随机承诺和第一随机承诺对应的第一范围证明。S202: Determine a first random commitment corresponding to the transaction amount and a first range proof corresponding to the first random commitment according to the transaction amount.

在实施时,由于范围证明是利用包含有两个公钥的环签名的算法构成的,因此,计算随机承诺对应的范围证明,就是计算环签名。In the implementation, since the range proof is formed by the algorithm of the ring signature containing two public keys, the calculation of the range proof corresponding to the random commitment is the calculation of the ring signature.

具体生成环签名的步骤如下:The specific 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 pk 0 and private key sk 0 , and a public key pk 1 of other people. The client can obtain T 1 =k 1 ×pk 1 + according to three different random numbers k 1 , k 2 and k 3 input by the user, and the preset public key pk 0 , pk 1 and private key sk 0 k 2 ×H and T 0 =k 3 ×H; and then according to the preset hash function, we can get:

Hash(pk0,pk1,T0,T1)Hash(pk 0 , pk 1 , T 0 , T 1 )

并通过Hash(pk0,pk1,T0,T1)与k1进行逐比特模2加运算,得到:And through Hash(pk 0 , pk 1 , T 0 , T 1 ) and k 1 for bit-by-bit modulo 2 addition, we get:

Figure GDA0003046282440000161
和z0=k3-c0sk0
Figure GDA0003046282440000161
and z 0 =k 3 -c 0 sk 0

并将{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 {pk 0 , pk 1 , c 0 , k 1 , z 0 , k 2 } is called a ring signature with {pk 0 , pk 1 } 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 pk 0 and pk 1 , otherwise the signer cannot generate a valid ring signature. However, the verifier cannot determine whether the signer holds the private key sk 0 of pk 0 or the private key sk 1 of pk 1 . The signer can adjust the order of the public keys in {pk 0 , pk 1 }, that is, the user can also generate a ring signature with {pk 1 , pk 0 } as the public key. But it should be emphasized that if the public key order is {pk 1 , pk 0 }, then when calculating the hash value, the order of the input should be Hash(pk 1 , pk 0 , T 1 , T 0 ), and the final The ring signature should also be {pk 1 , pk 0 , k, c 0 , k 2 , z 0 }.

由于范围证明是利用包含两个公钥的环签名的算法构成的,其是客户端为了证明客户端发送的随机承诺中的交易金额在某个范围之内,客户端为服务器提供的数据证据。只要客户端可以生成上述环签名,且该环签名是有效的,则客户端就证明了随机承诺CM=n×G+k×H中的n属于(0,2d+1)。Since the range proof is constituted by the algorithm of ring signature including two public keys, it is the data evidence provided by the client to 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, 2 d+1 ).

生成n的范围证明的过程如下:The procedure for generating a range proof for n is as follows:

客户端将上述中的n转化为2进制形式,具体如下:The client converts n in the above into binary form, as follows:

n=nd2d+nd-12d-1+…+n12+n0 n=n d 2 d +n d-1 2 d-1 +...+n 1 2+n 0

其中,nm=0或1,m的取值为0,1,2,...,d。Wherein, n m =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 {n m 2 m ×G+k m ×H, nm 2 m ×G+ k m ×H-2 m ×G} as the public key of the ring signature, and km as the private key of the ring signature, Compute a ring signature σ m . If the ring signature σ m is valid, it can prove that n m 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, 2 d+1 ). {σ d , σ d-1 , ..., σ 1 , σ 0 } is the range proof of n.

m取值为1,2,…,d,具体生成σm的过程如下:The value of m is 1, 2, ..., d, and the specific process of generating σ m is as follows:

当nm=0时:When n m = 0:

此时{nm2mG+kmH,nm2mG+kmH-2mG}={kmH,kmH-2mG},因为km是由用户在客户端输入的随机数和kmH是关于H的离散对数;因此,客户端生成的上述{nm2mG+kmH,nm2mG+kmH-2mG}为公钥的有效环签名。At this time { n m 2 m G+ km H, nm 2 m G+ km H-2 m G}= { km H, km H-2 m G}, The random number input by the client and km H is the discrete logarithm with respect to H; therefore, the above {n m 2 m G+km H, nm 2 m G+km H-2 m G } generated by the client is A valid ring signature of the public key.

当nm=1时:When n m = 1:

此时{nm2mG+kmH,nm2mG+kmH-2mG}={nm2mG+kmH,kmH},因为km是由用户在客户端输入的随机数和kmH是关于H的离散对数;因此,客户端生成的上述{nm2mG+kmH,nm2mG+kmH-2mG}为公钥的有效环签名。At this time {n m 2 m G+km H, nm 2 m G+ km H-2 m G }= { n m 2 m G+ km H, km H}, since km is determined by the user The random numbers entered at the client and km H are discrete logarithms with respect to H; therefore, the client-generated above { n m 2 m G+ km H, nm 2 m G+ km H-2 m G } is a valid ring signature for the public key.

当nm≠1且nm≠0时:When n m ≠ 1 and n m ≠ 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 {n m 2 m G+ km H, nm 2 m G+km H-2 m G } , because k m is a random number entered by the user at the client and km H is about The discrete logarithm of H; therefore, the user does not enter the private key corresponding to any of the public keys in the above {n m 2 m G+ km H, nm 2 m G+ km H-2 m G} in the client key, so the client cannot generate a ring signature with { n m 2 m G+ km H, nm 2 m G+ km H-2 m G} as the public key.

因此,只要客户端已{nm2mG+kmH,nm2mG+kmH-2mG}为公钥,产生一个环签名,且环签名是有效的,那么nm的取值为0或1,从而范围证明就证明了该范围证明对应的随机承诺中的某个数据是没有超出预设的范围。Therefore, as long as the client has {n m 2 m G+ km H, nm 2 m G+ km H-2 m G} as the public key to generate a ring signature, and the ring signature is valid, then n m The value of is 0 or 1, so the range proof proves that a certain data in the random commitment corresponding to the range proof 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 related explanation contents, reference may be made to the calculation process of the random commitment in the foregoing step S101 , which will not be repeated here.

S203:确定账户标识的当前的剩余可交易金额,以及账户标识的剩余可交易金额对应的第二随机承诺和第二范围证明。S203: Determine the current remaining tradable amount of the account identifier, and the second random commitment and the second range proof corresponding to the remaining tradable amount of the account identifier.

在实施时,关于该步骤中剩余可交易金额对应的第二随机承诺和第二范围证明的具体实现以及相关解释内容可以参见上述步骤S101中随机承诺的计算过程和步骤S202中范围证明的计算过程,在此不做赘述。During implementation, for the specific implementation of the second random commitment and the second range proof corresponding to the remaining tradable amount in this step and related explanations, please refer to the calculation process of the random commitment in the above step S101 and the calculation process of the range proof in step S202. , which will not be repeated here.

S204:根据交易金额对应的第一随机承诺和预设的知识证明生成算法,确定账户标识的第三随机承诺和第三随机承诺对应的知识证明。S204: According to the first random commitment corresponding to the transaction amount and the preset knowledge proof generation algorithm, determine the third random commitment of the account identifier and the knowledge proof corresponding to the third random commitment.

在实施时,在步骤S201中得到交易金额对应的第一随机承诺CM=n×G+k×H时,客户端将第一随机承诺中的kH称为账户标识的第三随机承诺;再通过步骤S101中随机承诺对应的知识证明的计算过程,可以得到第三随机承诺对应的知识证明。其中,账户标识的第三随机承诺对应的知识证明可以证明第三随机承诺确实是用户输入的交易金额n对应的随机承诺。During implementation, when the first random commitment CM=n×G+k×H corresponding to the transaction amount is obtained in step S201, the client calls kH in the first random commitment as the third random commitment of the account identifier; In the calculation process of the knowledge proof corresponding to the random commitment in step S101, the knowledge proof corresponding to the third random commitment can be obtained. The knowledge proof corresponding to the third random commitment identified by the account can prove that the third random commitment is indeed the random commitment corresponding to the transaction amount n input by the user.

S205:将交易申请信息、交易金额对应的第一随机承诺和第一范围证明和账户标识的剩余可交易金额对应的第二随机承诺和第二范围证明、账户标识的第三随机承诺和所述第三随机承诺对应的知识证明,组成本次交易信息。S205: Compare the transaction application information, the first random commitment and the first range certificate corresponding to the transaction amount, the second random commitment and the second range certificate corresponding to the remaining tradable amount of the account identifier, the third random commitment of the account identifier and the The knowledge proof corresponding to the third random commitment constitutes the transaction information.

S206:将本次交易信息发送至区块链中的服务器,以使服务器根据预设的验证算法,验证本次交易信息是否正确,若正确,则进行本次交易处理。S206: Send the current transaction information to the server in the blockchain, so that the server verifies whether the current transaction information is correct according to the preset verification algorithm, and if correct, the current transaction processing is performed.

在本发明实施例中,所有随机承诺对应的范围证明的验证过程都是应用相同的验证算法,相关解释内容可以参见上述图1所示的方法实施例,在此不做赘述。In this embodiment of the present invention, the same verification algorithm is used in the verification process of the range proofs corresponding to all random commitments, and the relevant explanation content can refer to the method embodiment shown in FIG. 1 above, which will not be repeated here.

本发明实施例提供了一种基于区块链的贷款方法,区块链中的服务器接收客户端发送的本次交易信息,然后,从历史交易记录中获取账户标识对应的上一次交易信息;根据预设的验证算法,确定本次交易信息中交易金额对应的第一随机承诺、第一范围证明、账户标识的当前的剩余可交易金额对应的第二随机承诺、第二范围证明、账户标识的第三随机承诺和第三随机承诺对应的知识证明是否有效;若第一随机承诺和所述第一随机承诺对应的第一范围证明和第二随机承诺、第二随机承诺对应的第二范围证明、账户标识的第三随机承诺和第三随机承诺对应的知识证明有效,则根据所述本次交易信息进行本次交易处理。由于本发明实施例中,将随机承诺和范围证明与区块链相结合,从而在保证用户交易金额保密性的同时,能够有效地防止恶意用户在多家金融机构中的恶意超额交易行为。The embodiment of the present invention provides a loan method based on blockchain, the server in the blockchain receives the current transaction information sent by the client, and then obtains the last transaction information corresponding to the account identifier from the historical transaction records; The preset verification algorithm determines the first random commitment corresponding to the transaction amount in this transaction information, the first range certificate, the second random commitment corresponding to the current remaining tradable amount of the account ID, the second range certificate, and the account ID. Whether the third random commitment and the knowledge proof corresponding to the third random commitment are valid; if the first random commitment and the first range proof corresponding to the first random commitment and the second random commitment and the second random commitment correspond , the third random commitment of the account identifier and the knowledge certificate corresponding to the third random commitment are valid, and the current transaction is processed according to the current transaction information. Because the random commitment and range proof are combined with the blockchain in the embodiment of the present invention, while ensuring the confidentiality of the user's transaction amount, it can effectively prevent malicious users from malicious excess transactions in multiple financial institutions.

为了描述更加清楚,下面通过一个具体实施例对本发明实施例提供的一种基于区块链的资金交易方法进行详细说明。In order to make the description clearer, a block chain-based fund transaction method provided by an embodiment of the present invention will be described in detail below through a specific embodiment.

假设用户标识为12的用户第一次向区块链中的金融机构B申请贷款;首先,金融机构B为用户12创建账户P,具体包括如下步骤:Assume that the user with the user ID 12 applies for a loan to the financial institution B in the blockchain for the first time; first, the financial institution B creates an 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, wherein 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 the random commitment generation algorithm preset by the client.

步骤三:客户端根据预设的知识证明生成算法,确定第四随机承诺对应的知识证明。Step 3: The client determines the knowledge proof corresponding to the fourth random commitment according to the preset knowledge proof generation algorithm.

步骤四:客户端将第四随机承诺和第四随机承诺对应的知识证明发送至服务器B;Step 4: The client sends the fourth random commitment and the knowledge proof corresponding to the fourth random commitment to server B;

当金融机构B(服务器B)接收到客户端发送的第四随机承诺和第四随机承诺对应的知识证明时,根据预设的知识证明验证算法,验证第四随机承诺对应的知识证明是否有效,若有效,则金融机构B为该用户标识12的用户创建账户标识P,并为该用户设置该用户在联盟中的所有金融机构的可贷款总金额S,计算该用户在联盟中的所有金融机构的可贷款总金额S对应的随机承诺;然后,金融机构B将该用户的账户标识、账户标识的可交易总金额、账户标识的可交易总金额对应的随机承诺、第四随机承诺和第四随机承诺对应的知识证明,存储在交易类型标识为贷款的区块链中。When financial institution B (server B) receives the fourth random commitment sent by the client and the knowledge proof corresponding to the fourth random commitment, it verifies whether the knowledge proof corresponding to the fourth random commitment is valid according to the preset knowledge proof verification algorithm, If it is valid, the financial institution B creates an account identifier P for the user with the user identifier 12, and sets the total loanable amount S of all the financial institutions in the alliance for the user, and calculates all the financial institutions in the alliance for the user. the random commitment corresponding to the total loanable amount S of the The knowledge proof corresponding to the random commitment is stored in the blockchain whose transaction type is identified as loan.

然后,用户12输入第一次交易申请信息,其中,第一次交易申请信息包括账户标识P、交易类型标识loan和交易金额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 the account identifier P, the transaction type identifier loan and the transaction amount n; the client terminal, according to the transaction amount n in the transaction application information input by the user 12, Determine the first random commitment and the 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 remaining balance of the account identifier P sent by the financial institution B. The tradable amount, and the second random commitment and the second range proof are determined according to the current remaining tradable amount of the account identifier P; according to the first random commitment corresponding to the first transaction amount n1 and the preset knowledge proof generation algorithm, Determine the third random commitment of the account identifier P and the knowledge certificate corresponding to the third random commitment; then, the client corresponds to the transaction application information, the first random commitment corresponding to the transaction amount, the first range certificate, and the remaining tradable amount of the account identifier. The second random commitment and the second scope proof of , the third random commitment of the account identification and the knowledge proof corresponding to the third random commitment constitute the transaction information; and the transaction information will be sent to financial institution B.

由于本次是用户第一次向金融机构B进行贷款申请,所以此时,账户标识P的当前的剩余可交易金额就是该用户在本联盟中所有金融机构中可贷款的总金额S,如果此次是用户第二次向金融机构B发送贷款申请,则金融机构B发送给客户端的该账户标识对应的上一次剩余可交易金额对应的承诺中,记录的该账户标识对应的当前剩余可贷款金额为S-n1;其中,n1为用户向金融机构B申请的贷款金额。Since this is the first time that the user applies for a loan to financial institution B, the current remaining tradable amount of the account identifier P is the total amount S that the user can borrow in all financial institutions in the alliance. The second time is when the user sends a loan application to financial institution B for the second time. In the commitment corresponding to the last remaining tradable amount corresponding to the account identifier sent by financial institution B to the client, the current remaining loanable amount corresponding to the account identifier is recorded. is S-n1; among them, n1 is the loan amount applied by the user to the financial institution B.

之后,金融机构B在接收到客户端发送的本次交易信息之后,从贷款区块链中获取到账户标识P对应的上一次交易信息,并根据预设的验证算法,验证上述第一随机承诺、第一范围证明、第二随机承诺、第二范围证明、第三随机承诺和第三随机承诺对应的知识证明是否有效;若第一随机承诺、第一范围证明、第二随机承诺、第二范围证明、第三随机承诺和第三随机承诺对应的知识证明都有效,则金融机构B将用户12申请的贷款金额,发送给客户端;服务器B将第一随机承诺和第一范围证明、账户标识P和交易类型标识Loan,组成历史交易记录,并将历史交易记录存储在服务器中的贷款区块链中。After that, after receiving the current 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 above-mentioned first random commitment according to the preset verification algorithm , whether the first range proof, the second random commitment, the second range proof, the third random commitment and the knowledge proof corresponding to the third random commitment are valid; if the first random commitment, the first range proof, the second random commitment, the second random commitment If the range proof, the third random promise and the knowledge proof corresponding to the third random promise are all valid, then the financial institution B sends the loan amount applied by the user 12 to the client; the server B sends the first random promise and the first range proof, the account The identifier P and the transaction type identifier Loan form historical transaction records and store the historical transaction records in the loan blockchain in the server.

可选的,当用户12在金融机构B申请了第一笔贷款之后,该用户则需要在金融机构B规定的时间内还款;假设用户12在第一次贷款之后,进行第一次还款,则用户12在向金融机构B进行还款的步骤如下:Optionally, after the user 12 applies for the first loan at the financial institution B, the user needs to repay the loan within the time specified by the financial institution B; it is assumed that the user 12 makes the first repayment after the first loan , then the steps for the user 12 to repay 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 terminal, wherein the first transaction application information includes the account identifier P, the transaction type identifier repay and the repayment amount n1; the client terminal is based on the transaction application information input by the user 12 In the repayment amount n1, determine the first random commitment and the first range proof corresponding to the repayment amount n1; the client sends the current remaining tradable amount of the account ID P to the financial institution B to obtain the information, and receives the information sent by the financial institution B The current remaining tradable amount of the account identifier P, and according to the current remaining tradable amount of the account identifier P, the second random commitment and the second range proof are determined; according to the first random commitment corresponding to the first repayment amount n1 and the preset knowledge proof generation algorithm to determine the third random commitment of the account ID P and the knowledge proof corresponding to the third random commitment; then, the client sends the transaction application information, the first random commitment corresponding to the transaction amount and the first range proof , the second random commitment and the second range proof corresponding to the remaining tradable amount of the account identifier, the third random commitment corresponding to the account identifier and the knowledge certificate corresponding to the third random commitment, form this transaction information; Sent to Financial Institution 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 for the current remaining tradable amount of the account identifier P. For example, suppose the current remaining tradable amount of the account identifier P is S-n1; where n1 is the loan applied by the user to the financial institution B amount; when financial institution B receives the current transaction information sent by the client, it obtains the last transaction information corresponding to the account identifier P from the loan blockchain, and verifies the above-mentioned first random transaction according to the preset verification algorithm. Whether the knowledge proof corresponding to the commitment, the first range proof, the second random commitment, the second range proof, the third random commitment, and the third random commitment is valid; if the first random commitment, the first range proof, the second random commitment, the third random commitment The knowledge proof corresponding to the second range proof, the third random commitment and the third random commitment are all 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 in the The remaining tradable amount of the money institution B becomes S-n1+n1; after that, the server B combines the first random commitment and the first range proof, the account identifier P and the transaction type identifier repay to form a historical transaction record, and records the historical transaction records. Transaction records are stored in the repayment blockchain in the server.

本发明实施例提供了一种贷款方法,区块链中的服务器接收客户端发送的本次交易信息,然后,从历史交易记录中获取账户标识对应的上一次交易信息;根据预设的验证算法,确定本次交易信息中交易金额对应的第一随机承诺、第一范围证明、账户标识的当前的剩余可交易金额对应的第二随机承诺、第二范围证明、账户标识的第三随机承诺和第三随机承诺对应的知识证明是否有效;若所述第一随机承诺和所述第一随机承诺对应的第一范围证明和第二随机承诺、所述第二随机承诺对应的第二范围证明、账户标识的第三随机承诺和第三随机承诺对应的知识证明有效,则根据所述本次交易信息进行本次交易处理。由于本发明实施例中,将随机承诺和范围证明与区块链相结合,从而在保证用户交易金额保密性的同时,能够有效地防止恶意用户在多家金融机构中的恶意超额交易行为。The embodiment of the present invention provides a loan method. The server in the blockchain receives the current transaction information sent by the client, and then obtains the previous transaction information corresponding to the account identifier from the historical transaction records; according to a preset verification algorithm , determine the first random commitment corresponding to the transaction amount in the current transaction information, the first range certificate, the second random commitment corresponding to the current remaining tradable amount of the account identifier, the second range certificate, the account identifier The third random commitment and Whether the knowledge proof corresponding to the third random commitment is valid; if the first random commitment and the first range proof corresponding to the first random commitment and the second random commitment, the second range proof corresponding to the second random commitment, If the third random commitment identified by the account and the knowledge certificate corresponding to the third random commitment are valid, the current transaction is processed according to the current transaction information. Because the random commitment and range proof are combined with the blockchain in the embodiment of the present invention, while ensuring the confidentiality of the user's transaction amount, it can effectively prevent malicious users from malicious excess transactions in multiple financial institutions.

基于相同的技术构思,相应于图1所示方法实施例,本发明实施例还提供了一种基于区块链的资金交易装置,如图3所示,该装置应用于区块链中的服务器,服务器中存储有各账户标识对应的历史交易记录,历史交易记录中包括随机承诺和范围证明、账户标识和交易类型标识,该装置包括:Based on the same technical concept, corresponding to the method embodiment shown in FIG. 1 , an embodiment of the present invention further provides a blockchain-based fund transaction device. As shown in FIG. 3 , the device is applied to a server in a blockchain. , the server stores historical transaction records corresponding to each account identifier, and the historical transaction records include random commitment and scope proof, account identifier and transaction type identifier, and the device includes:

接收模块301,用于接收客户端发送的本次交易信息,本次交易信息中包括交易金额、账户标识和交易类型标识、交易金额对应的第一随机承诺和第一范围证明、账户标识的当前的剩余可交易金额对应的第二随机承诺和第二范围证明、账户标识的第三随机承诺和第三随机承诺对应的知识证明;The receiving module 301 is used to receive the current transaction information sent by the client, the current transaction information includes the transaction amount, the account identifier and the transaction type identifier, the first random commitment and the first range certificate corresponding to the transaction amount, and the current account identifier. The second random commitment and the second range proof corresponding to the remaining tradable amount of , the third random commitment of the account identifier and the knowledge proof corresponding to the third random commitment;

获取模块302,用于从历史交易记录中获取账户标识对应的上一次交易记录;The obtaining module 302 is used for obtaining the last transaction record corresponding to the account identifier from the historical transaction record;

确定模块303,用于根据预设的验证算法,确定交易金额对应的第一随机承诺和第一范围证明、账户标识的当前的剩余可交易金额对应的第二随机承诺和第二范围证明、以及账户标识的第三随机承诺和第三随机承诺对应的知识证明是否有效;A determination module 303, configured to determine, according to a preset verification algorithm, a first random commitment and a first range 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, and Whether the third random commitment identified by the account and the knowledge proof corresponding to the third random commitment are valid;

本次交易处理模块304,用于若第一随机承诺、第一范围证明、第二随机承诺、第二范围证明、第三随机承诺和第三随机承诺对应的知识证明有效,则根据本次交易信息进行本次交易处理。The current transaction processing module 304 is configured to, if the knowledge certificates corresponding to the first random commitment, the first range proof, the second random commitment, the second range proof, the third random commitment and the third random commitment are valid, then according to the current transaction information to process this transaction.

在本发明实施例中,上述装置还可以包括:In this embodiment of the present invention, the above device may further include:

账户创建请求信息接收模块,用于接收客户端发送的账户创建请求信息;其中,账户创建请求信息中包括用户标识;The account creation request information receiving module is used to receive the account creation request information sent by the client; wherein, the account creation request information includes the user ID;

查找模块,用于在预设的账户信息表中,查找是否包含用户标识对应的账户标识;A search module, configured to search whether the account identification corresponding to the user identification is included in the preset account information table;

验证模块,用于若账户信息表中不包含用户标识对应的账户标识,则在接收客户端发送的第四随机承诺对应的知识证明时,根据预设的知识证明验证算法,验证第四随机承诺对应的知识证明是否有效;The verification module is used to verify the fourth random commitment according to the preset knowledge proof verification algorithm when receiving the knowledge certificate corresponding to the fourth random commitment sent by the client if the account information table does not contain the account identifier corresponding to the user identifier Whether the corresponding knowledge proof is valid;

创建模块,用于若第四随机承诺对应的知识证明有效,则创建用户标识对应的账户标识和交易总金额。The creation module is configured to create an account ID corresponding to the user ID and the total transaction amount if the knowledge certificate 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 , an 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 acquisition module 401 is used to acquire transaction application information input by the user, the transaction application information includes an account identifier, a transaction type identifier and a transaction amount;

第一确定模块402,用于根据交易金额,确定交易金额对应的第一随机承诺和第一范围证明;The first determination module 402 is configured to determine the first random commitment and the first range proof corresponding to the transaction amount according to the transaction amount;

第二确定模块403,用于确定账户标识的当前的剩余可交易金额,以及账户标识的剩余可交易金额对应的第二随机承诺和第二范围证明;The second determination module 403 is configured to determine the current remaining tradable amount of the account identifier, and the second random commitment and the second range proof corresponding to the remaining tradable amount of the account identifier;

第三确定模块404,用于根据交易金额对应的第一随机承诺和预设的知识证明生成算法,确定账户标识的第三随机承诺和第三随机承诺对应的知识证明;The third determination module 404 is configured to determine the third random commitment of the account identifier and the knowledge certificate corresponding to the third random commitment according to the first random commitment corresponding to the transaction amount and the preset knowledge certificate generation algorithm;

本次交易信息组成模块405,用于将交易申请信息、交易金额对应的第一随机承诺和第一范围证明、账户标识的剩余可交易金额对应的第二随机承诺和第二范围证明、账户标识的第三随机承诺和第三随机承诺对应的知识证明,组成本次交易信息;This transaction information constitutes a module 405, which is used to combine the transaction application information, the first random commitment and the first range certificate corresponding to the transaction amount, the second random commitment and the second range certificate corresponding to the remaining tradable amount of the account identifier, and the account identifier The third random commitment and the knowledge proof corresponding to the third random commitment constitute the transaction information;

本次交易信息验证模块406,用于将本次交易信息发送至区块链中的服务器,以使服务器根据预设的验证算法,验证本次交易信息是否正确,若正确,则进行本次交易处理。The current transaction information verification module 406 is used to send the current transaction information to the server in the blockchain, so that the server can verify whether the current transaction information is correct according to the preset verification algorithm, and if it is correct, the current transaction is performed deal with.

在本发明实施例中,上述装置还可以包括:In this embodiment of the present invention, the above device may further include:

账户创建请求信息发送模块,用于向服务器发送账户创建请求信息;其中,账户创建请求信息中包括用户标识;The account creation request information sending module is used to send the account creation request information to the server; wherein, the account creation request information includes the user ID;

随机数获取模块,用于获取用户输入的随机数;The random number acquisition module is used to acquire the random number input by the user;

第四随机承诺确定模块,用于根据随机数和预设的随机承诺生成算法,确定第四随机承诺;The fourth random commitment determination module is used to determine the fourth random commitment according to the random number and the preset random commitment generation algorithm;

知识证明确定模块,用于根据预设的知识证明生成算法,确定第四随机承诺对应的知识证明;The knowledge proof determination module is used to determine the knowledge proof corresponding to the fourth random commitment according to the preset knowledge proof generation algorithm;

发送模块,用于将第四随机承诺和第四随机承诺对应的知识证明发送至所述服务器。A sending module, configured to send the fourth random commitment and the knowledge proof corresponding to the fourth random commitment to the server.

本发明实施例提供了一种基于区块链的贷款装置,区块链中的服务器接收客户端发送的本次交易信息,并从历史交易记录中获取账户标识对应的上一次交易信息;根据预设的验证算法,确定客户端发送的本次交易信息中的交易金额对应的第一随机承诺、第一范围证明、账户标识的当前的剩余可交易金额对应的第二随机承诺、第二范围证明、账户标识的第三随机承诺和第三随机承诺对应的知识证明是否有效;若第一随机承诺和所述第一随机承诺对应的第一范围证明和第二随机承诺、第二随机承诺对应的第二范围证明、账户标识的第三随机承诺和第三随机承诺对应的知识证明有效,则根据本次交易信息进行本次交易处理。由于本发明实施例中,将随机承诺和范围证明与区块链相结合,从而在保证用户交易金额保密性的同时,能够有效地防止恶意用户在多家金融机构中的恶意超额交易行为。The embodiment of the present invention provides a loan device based on blockchain, the server in the blockchain receives the current transaction information sent by the client, and obtains the last transaction information corresponding to the account identifier from the historical transaction records; Set the verification algorithm to determine the first random commitment corresponding to the transaction amount in the current transaction information sent by the client, the first range certificate, and the second random commitment and the second range certificate corresponding to the current remaining tradable amount of the account ID. , whether the third random commitment identified by the account and the knowledge proof corresponding to the third random commitment are valid; The second range proof, the third random commitment of the account identifier, and the knowledge certificate corresponding to the third random commitment are valid, and this transaction is processed according to the current transaction information. Because the random commitment and range proof are combined with the blockchain in the embodiment of the present invention, while ensuring the confidentiality of the user's transaction amount, it can effectively prevent malicious users from malicious excess transactions in multiple financial institutions.

本发明实施例还提供了一种服务器,服务器中存储有各账户标识对应的历史交易记录,历史交易记录中包括随机承诺和范围证明、账户标识和交易类型标识,如图5所示,包括处理器501、通信接口502、存储器503和通信总线504,其中,处理器501,通信接口502,存储器503通过通信总线504完成相互间的通信,The embodiment of the present invention also provides a server, in which historical transaction records corresponding to each account identifier are stored, and the historical transaction records include random commitment and scope proof, account identifier and transaction type identifier, as shown in FIG. The processor 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 the communication with each other through the communication bus 504,

存储器503,用于存放计算机程序;a memory 503 for storing computer programs;

处理器501,用于执行存储器503上所存放的程序时,实现本发明实施例提供的一种资金交易方法。该方法包括:The processor 501 is configured to implement a fund transaction method provided by the embodiment of the present invention when executing the program stored in the memory 503 . The method includes:

接收客户端发送的本次交易信息,本次交易信息中包括交易金额、账户标识和交易类型标识、交易金额对应的第一随机承诺和第一范围证明、账户标识的当前的剩余可交易金额对应的第二随机承诺和第二范围证明、账户标识的第三随机承诺和所述第三随机承诺对应的知识证明;Receive the current transaction information sent by the client. The current transaction information includes the transaction amount, the account ID and the transaction type ID, the first random commitment and the first range certificate corresponding to the transaction amount, and the current remaining tradable amount corresponding to the account ID. The second random commitment and the second range proof of , the third random commitment of the account identifier and the knowledge proof corresponding to the third random commitment;

从历史交易记录中获取账户标识对应的上一次交易记录;Obtain the last transaction record corresponding to the account ID from the historical transaction record;

根据预设的验证算法,确定交易金额对应的第一随机承诺和第一范围证明、账户标识的当前的剩余可交易金额对应的第二随机承诺和第二范围证明、以及账户标识的第三随机承诺和第三随机承诺对应的知识证明是否有效;According to the preset verification algorithm, determine the first random commitment and the first range certificate corresponding to the transaction amount, the second random commitment and the second range certificate corresponding to the current remaining tradable amount of the account identifier, and the third random number of the account identifier. Whether the knowledge proof corresponding to the commitment and the third random commitment is valid;

若第一随机承诺、第一范围证明、第二随机承诺、第二范围证明、第三随机承诺和第三随机承诺对应的知识证明有效,则根据本次交易信息进行本次交易处理。If the knowledge certificates corresponding to the first random promise, the first range proof, the second random promise, the second range proof, the third random promise and the third random promise are valid, the transaction will be processed according to the current transaction information.

关于该方法各个步骤的具体实现以及相关解释内容可以参见上述图1所示的方法实施例,在此不做赘述。For the specific implementation of each step of the method and related explanation contents, reference may be made to the method embodiment shown in FIG. 1 above, which will not be repeated here.

另外,处理器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 the implementation manners mentioned in the foregoing method embodiment section, and will not be repeated here.

本发明实施例还提供了一种客户端,如图6所示,包括处理器601、通信接口602、存储器603和通信总线604,其中,处理器601,通信接口602,存储器603通过通信总线604完成相互间的通信,An 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 , wherein 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 for storing computer programs;

处理器601,用于执行存储器303上所存放的程序时,实现本发明实施例提供的一种资金交易方法。The processor 601 is configured to implement a fund transaction method provided by the embodiment of the present invention when executing the program stored in the memory 303 .

具体的,上述一种基于区块链的资金交易方法,该方法应用于客户端,该方法包括:Specifically, the above-mentioned method for fund transaction based on blockchain, the method is applied to the client, and the method includes:

获取用户输入的交易申请信息,交易申请信息包括账户标识、交易类型标识和交易金额;Obtain the transaction application information input by the user, the transaction application information includes account ID, transaction type ID and transaction amount;

根据交易金额,确定交易金额对应的第一随机承诺和第一范围证明;According to the transaction amount, determine the first random commitment and the first range proof corresponding to the transaction amount;

确定账户标识的当前的剩余可交易金额,以及账户标识的剩余可交易金额对应的第二随机承诺和第二范围证明;determining the current remaining tradable amount of the account identifier, and the second random commitment and the second range proof corresponding to the remaining tradable amount of the account identifier;

根据交易金额对应的第一随机承诺和预设的知识证明生成算法,确定账户标识的第三随机承诺和第三随机承诺对应的知识证明;According to the first random commitment corresponding to the transaction amount and the preset knowledge proof generation algorithm, determine the third random commitment of the account identifier and the knowledge proof corresponding to the third random commitment;

将交易申请信息、交易金额对应的第一随机承诺和第一范围证明、账户标识的剩余可交易金额对应的第二随机承诺和第二范围证明、账户标识的第三随机承诺和第三随机承诺对应的知识证明,组成本次交易信息;The transaction application information, the first random commitment and the first range certificate corresponding to the transaction amount, the second random commitment and the second range certificate corresponding to the remaining tradable amount of the account identifier, and the third random commitment and the third random commitment of the account identifier. The corresponding knowledge proof constitutes the transaction information;

将本次交易信息发送至区块链中的服务器,以使服务器根据预设的验证算法,验证本次交易信息是否正确,若正确,则进行本次交易处理。Send the transaction information to the server in the blockchain, so that the server can verify whether the transaction information is correct according to the preset verification algorithm. If it is correct, the transaction processing will be performed.

关于该方法各个步骤的具体实现以及相关解释内容可以参见上述图2所示的方法实施例,在此不做赘述。For the specific implementation of each step of the method and related explanation contents, reference may be made to the method embodiment shown in FIG. 2 above, which will not be repeated here.

另外,处理器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 the implementation manners mentioned in the foregoing method embodiment section, and will not be repeated here.

上述电子设备提到的通信总线可以是外设部件互连标准(Peripheral ComponentInterconnect,PCI)总线或扩展工业标准结构(Extended Industry StandardArchitecture,EISA)总线等。该通信总线可以分为地址总线、数据总线、控制总线等。为便于表示,图中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。The communication bus mentioned in the above electronic device may be a peripheral component interconnect standard (Peripheral Component Interconnect, PCI) bus or an Extended Industry Standard Architecture (Extended Industry Standard Architecture, EISA) bus or the like. The communication bus can be divided into an address bus, a data bus, a control bus, and the like. For ease of presentation, only one thick line is used 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 random access memory (Random Access Memory, RAM), and may also include non-volatile memory (Non-Volatile Memory, NVM), such as at least one disk memory. 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-mentioned processor may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; may also be a digital signal processor (Digital Signal Processing, DSP), an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), Field-Programmable Gate Array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

在本发明提供的又一实施例中,还提供了一种计算机可读存储介质,该计算机可读存储介质中存储有指令,当其在计算机上运行时,使得计算机执行上述实施例中任一所述的基于区块链的资金交易方法。In yet another embodiment provided by the present invention, a computer-readable storage medium is also provided, where instructions are stored in the computer-readable storage medium, when the computer-readable storage medium is run on a computer, the computer is made to execute any one of the above-mentioned embodiments. The described blockchain-based capital transaction method.

在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产生按照本发明实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线(DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘Solid State Disk(SSD))等。In the above-mentioned embodiments, it may be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented in software, it can 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, all or part of the processes or functions described in the embodiments of the present invention are generated. The computer may be a general purpose computer, special purpose computer, computer network, or other programmable device. The computer instructions may be stored in or transmitted from one computer readable storage medium to another computer readable storage medium, for example, the computer instructions may be downloaded from a website site, computer, server or data center Transmission to another website site, computer, server, or data center is by wire (eg, coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (eg, infrared, wireless, microwave, etc.). The computer-readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that includes an integration of one or more available media. The usable media may be magnetic media (eg, floppy disks, hard disks, magnetic tapes), optical media (eg, DVD), or semiconductor media (eg, Solid State Disk (SSD)), among others.

需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。It should be noted that, in this document, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any relationship between these entities or operations. any such actual relationship or sequence exists. Moreover, the terms "comprising", "comprising" or any other variation thereof are intended to encompass a non-exclusive inclusion such that a process, method, article or device that includes a list of elements includes not only those elements, but also includes not explicitly listed or other elements inherent to such a process, method, article or apparatus. Without further limitation, an element qualified by the phrase "comprising a..." does not preclude the presence of additional identical elements in a process, method, article or apparatus that includes the element.

本说明书中的各个实施例均采用相关的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于装置、电子设备以及计算机可读存储介质实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。Each embodiment in this specification is described in a related manner, and the same and similar parts between the various embodiments may be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the apparatus, electronic device, and computer-readable storage medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and reference may be made to some descriptions of the method embodiments for related parts.

以上所述仅为本发明的较佳实施例而已,并非用于限定本发明的保护范围。凡在本发明的精神和原则之内所作的任何修改、等同替换、改进等,均包含在本发明的保护范围内。The above descriptions are only preferred embodiments of the present invention, and are not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims (10)

1.一种基于区块链的资金交易方法,其特征在于,所述方法应用于区块链中的服务器,所述服务器中存储有各账户标识对应的历史交易记录,所述历史交易记录中包括随机承诺和范围证明、账户标识和交易类型标识,所述方法包括:1. A method for capital transaction based on blockchain, characterized in that the method is applied to a server in the blockchain, and the server stores the corresponding historical transaction records of each account identifier, and the historical transaction records in the historical transaction records are stored in the server. Including random commitment and scope proof, account identification and transaction type identification, the method includes: 接收客户端发送的本次交易信息,所述本次交易信息中包括交易金额、账户标识和交易类型标识、所述交易金额对应的第一随机承诺和第一范围证明、所述账户标识的当前的剩余可交易金额对应的第二随机承诺和第二范围证明、所述账户标识的第三随机承诺和所述第三随机承诺对应的知识证明;Receive the current transaction information sent by the client, the current transaction information includes the transaction amount, the account identifier and the transaction type identifier, the first random commitment and the first range certificate corresponding to the transaction amount, and the current account identifier. The second random commitment and the second range proof corresponding to the remaining tradable amount of , the third random commitment of the account identifier and the knowledge proof corresponding to the third random commitment; 从所述历史交易记录中获取所述账户标识对应的上一次交易记录;Obtain the last transaction record corresponding to the account identifier from the historical transaction record; 根据预设的验证算法,确定所述交易金额对应的第一随机承诺和第一范围证明、所述账户标识的当前的剩余可交易金额对应的第二随机承诺和第二范围证明、以及所述账户标识的第三随机承诺和所述第三随机承诺对应的知识证明是否有效;According to a preset verification algorithm, determine the first random commitment and the first range proof corresponding to the transaction amount, the second random commitment and the second range proof corresponding to the current remaining tradable amount of the account identifier, and the Whether the third random commitment identified by the account and the knowledge certificate corresponding to the third random commitment are valid; 所述根据预设的验证算法,确定所述交易金额对应的第一随机承诺和第一范围证明、所述账户标识的当前的剩余可交易金额对应的第二随机承诺和第二范围证明、以及所述账户标识的第三随机承诺和所述第三随机承诺对应的知识证明是否有效之后,还包括:判断如下公式是否成立:determining, according to a preset verification algorithm, a first random commitment and a first range proof corresponding to the transaction amount, a second random commitment and a second range proof corresponding to the current remaining tradable amount of the account identifier, and After the third random commitment identified by the account and the knowledge certificate corresponding to the third random commitment are valid, the method further includes: judging whether the following formula holds: CM1,0=n1×G+CM1 *CM 1,0 =n 1 ×G+CM 1 * ; CM11=CM0-CM1,0CM 1 , 1 =CM 0 -CM 1,0 ; 其中,CM1,1为所述账户标识当前的剩余可交易金额对应的第二随机承诺,CM0为所述账户标识对应的总交易金额对应随机承诺和CM1,0为所述交易金额对应的第一随机承诺,n1为所述交易信息中用户申请的交易金额,G的坐标为(x01,y01),CM1*为所述账户标识的第三随机承诺;Wherein, CM 1 , 1 is the second random commitment corresponding to the current remaining tradable amount of the account identifier, CM 0 is the random commitment corresponding to the total transaction amount corresponding to the account identifier, and CM 1, 0 is the corresponding random commitment of the transaction amount The first random commitment of , n 1 is the transaction amount applied by the user in the transaction information, the coordinates of G are (x 01 , y 01 ), and CM 1 * is the third random commitment identified by the account; 如果CM1,0=n1×G+CM1 *和CM1,1=CM0-CM1,0等式成立,则服务器根据所述本次交易信息进行本次交易处理;如果CM1,0=n1×G+CM1 *和CM11=CM0-CM1,0等式不成立,则服务器向客户端发送本次交易申请失败信息。If the equation of CM 1,0 =n 1 ×G+CM 1 * and CM 1,1 =CM 0 -CM 1,0 is established, the server will process this transaction according to the current transaction information; if CM 1, 0 =n 1 ×G+CM 1 * and CM 1 , 1 =CM 0 -CM 1,0 if the equation does not hold, the server sends the client a failure message of this transaction application. 2.根据权利要求1所述方法,其特征在于,所述接收客户端发送的本次交易信息之前,还包括:2. The method according to claim 1, wherein before receiving the current transaction information sent by the client, the method further comprises: 接收客户端发送的账户创建请求信息;其中,所述账户创建请求信息中包括用户标识;Receive account creation request information sent by the client; wherein, the account creation request information includes a user ID; 在预设的账户信息表中,查找是否包含所述用户标识对应的账户标识;In the preset account information table, find out whether the account identification corresponding to the user identification is included; 若所述账户信息表中不包含所述用户标识对应的账户标识,则在接收客户端发送的第四随机承诺对应的知识证明时,根据预设的知识证明验证算法,验证所述第四随机承诺对应的知识证明是否有效;If the account information table does not contain the account identifier corresponding to the user identifier, when receiving the knowledge certificate corresponding to the fourth random commitment sent by the client, verify the fourth random Whether the knowledge proof corresponding to the commitment is valid; 若所述第四随机承诺对应的知识证明有效,则创建所述用户标识对应的账户标识和交易总金额。If the knowledge certificate corresponding to the fourth random commitment is valid, the account identifier corresponding to the user identifier and the total transaction amount are created. 3.一种基于区块链的资金交易方法,其特征在于,所述方法应用于客户端,所述方法包括:3. A blockchain-based fund transaction method, wherein the method is applied to a client, and the method comprises: 获取用户输入的交易申请信息,所述交易申请信息包括账户标识、交易类型标识和交易金额;Obtain the transaction application information input by the user, where the transaction application information includes an account identifier, a transaction type identifier and a transaction amount; 根据所述交易金额,确定所述交易金额对应的第一随机承诺和第一范围证明;According to the transaction amount, determine the first random commitment and the first range proof corresponding to the transaction amount; 确定所述账户标识的当前的剩余可交易金额,以及所述账户标识的剩余可交易金额对应的第二随机承诺和第二范围证明;determining the current remaining tradable amount of the account identifier, and the second random commitment and the second range proof corresponding to the remaining tradable amount of the account identifier; 根据所述交易金额对应的第一随机承诺和预设的知识证明生成算法,确定所述账户标识的第三随机承诺和所述第三随机承诺对应的知识证明;According to the first random commitment corresponding to the transaction amount and the preset knowledge proof generation algorithm, determine the third random commitment of the account identifier and the knowledge proof corresponding to the third random commitment; 将所述交易申请信息、交易金额对应的第一随机承诺和第一范围证明、所述账户标识的剩余可交易金额对应的第二随机承诺和第二范围证明、所述账户标识的第三随机承诺和所述第三随机承诺对应的知识证明,组成本次交易信息;The transaction application information, the first random commitment and the first range certificate corresponding to the transaction amount, the second random commitment and the second range certificate corresponding to the remaining tradable amount of the account identifier, and the third random number of the account identifier. The knowledge proof corresponding to the commitment and the third random commitment constitutes the transaction information; 将所述本次交易信息发送至区块链中的服务器,以使所述服务器根据预设的验证算法,验证所述本次交易信息是否正确,若正确,判断如下公式是否成立:Send the current transaction information to the server in the blockchain, so that the server verifies whether the current transaction information is correct according to the preset verification algorithm. If it is correct, determine whether the following formula holds: CM1,0=n1×G+CM1 *CM 1,0 =n 1 ×G+CM 1 * ; CM11=CM0-CM1,0CM 1 , 1 =CM 0 -CM 1,0 ; 其中,CM1,1为所述账户标识当前的剩余可交易金额对应的第二随机承诺,CM0为所述账户标识对应的总交易金额对应随机承诺和CM1,0为所述交易金额对应的第一随机承诺,n1为所述交易信息中用户申请的交易金额,G的坐标为(x01,y01),CM1*为所述账户标识的第三随机承诺;Wherein, CM 1 , 1 is the second random commitment corresponding to the current remaining tradable amount of the account identifier, CM 0 is the random commitment corresponding to the total transaction amount corresponding to the account identifier, and CM 1, 0 is the corresponding random commitment of the transaction amount The first random commitment of , n 1 is the transaction amount applied by the user in the transaction information, the coordinates of G are (x 01 , y 01 ), and CM 1 * is the third random commitment identified by the account; 如果CM1,0=n1×G+CM1 *和CM1,1=CM0-CM1,0等式成立,则服务器根据所述本次交易信息进行本次交易处理;如果CM1,0=n1×G+CM1 *和CM11=CM0-CM1,0等式不成立,则服务器向客户端发送本次交易申请失败信息。If the equation of CM 1,0 =n 1 ×G+CM 1 * and CM 1,1 =CM 0 -CM 1,0 is established, the server will process this transaction according to the current transaction information; if CM 1, 0 =n 1 ×G+CM 1 * and CM 1 , 1 =CM 0 -CM 1,0 if the equation does not hold, the server sends the client a failure message of this transaction application. 4.根据权利要求3所述方法,其特征在于,所述获取用户输入的交易申请信息之前,包括:4. The method according to claim 3, wherein before acquiring the transaction application information input by the user, the method comprises: 向服务器发送账户创建请求信息;其中,所述账户创建请求信息中包括用户标识;Sending account creation request information to the server; wherein, the account creation request information includes a user ID; 获取用户输入的随机数;Get the random number entered by the user; 根据所述随机数和预设的随机承诺生成算法,确定第四随机承诺;determining a fourth random commitment according to the random number and a preset random commitment generation algorithm; 根据预设的知识证明生成算法,确定所述第四随机承诺对应的知识证明;determining the knowledge proof corresponding to the fourth random commitment according to a preset knowledge proof generating algorithm; 将所述第四随机承诺和第四随机承诺对应的知识证明发送至所述服务器。Send the fourth random commitment and the knowledge proof corresponding to the fourth random commitment to the server. 5.一种基于区块链的资金交易装置,其特征在于,所述装置应用于区块链中的服务器,所述服务器中存储有各账户标识对应的历史交易记录,所述历史交易记录中包括随机承诺和范围证明、账户标识和交易类型标识,所述装置包括:5. A blockchain-based capital transaction device, characterized in that the device is applied to a server in the blockchain, and the server stores historical transaction records corresponding to each account identifier, and in the historical transaction records Including random commitment and scope proof, account identification and transaction type identification, the device includes: 接收模块,用于接收客户端发送的本次交易信息,所述本次交易信息中包括交易金额、账户标识和交易类型标识、所述交易金额对应的第一随机承诺和第一范围证明、所述账户标识的当前的剩余可交易金额对应的第二随机承诺和第二范围证明、所述账户标识的第三随机承诺和所述第三随机承诺对应的知识证明;The receiving module is used to receive the current transaction information sent by the client, the current transaction information includes the transaction amount, the account identifier and the transaction type identifier, the first random commitment and the first range certificate corresponding to the transaction amount, the the second random commitment and the second range proof corresponding to the current remaining tradable amount of the account identifier, the third random commitment of the account identifier and the knowledge certificate corresponding to the third random commitment; 获取模块,用于从所述历史交易记录中获取所述账户标识对应的上一次交易记录;an acquisition module, configured to acquire the last transaction record corresponding to the account identifier from the historical transaction record; 确定模块,用于根据预设的验证算法,确定所述交易金额对应的第一随机承诺和第一范围证明、所述账户标识的当前的剩余可交易金额对应的第二随机承诺和第二范围证明、以及所述账户标识的第三随机承诺和所述第三随机承诺对应的知识证明是否有效;A determination module, configured to determine, according to a preset verification algorithm, a first random commitment and a first range proof corresponding to the transaction amount, and a second random commitment and a second range corresponding to the current remaining tradable amount of the account identifier proof, and whether the third random commitment identified by the account and the knowledge proof corresponding to the third random commitment are valid; 本次交易处理模块,用于若所述第一随机承诺、所述第一范围证明、所述第二随机承诺、所述第二范围证明、所述第三随机承诺和所述第三随机承诺对应的知识证明有效,则判断如下公式是否成立:This transaction processing module is used for if the first random promise, the first range proof, the second random promise, the second range proof, the third random promise and the third random promise If the corresponding knowledge proof is valid, then judge whether the following formula holds: CM1,0=n1×G+CM1 *CM 1,0 =n 1 ×G+CM 1 * ; CM11=CM0-CM1,0CM 1 , 1 =CM 0 -CM 1,0 ; 其中,CM1,1为所述账户标识当前的剩余可交易金额对应的第二随机承诺,CM0为所述账户标识对应的总交易金额对应随机承诺和CM1,0为所述交易金额对应的第一随机承诺,n1为所述交易信息中用户申请的交易金额,G的坐标为(x01,y01),CM1*为所述账户标识的第三随机承诺;Wherein, CM 1 , 1 is the second random commitment corresponding to the current remaining tradable amount of the account identifier, CM 0 is the random commitment corresponding to the total transaction amount corresponding to the account identifier, and CM 1, 0 is the corresponding random commitment of the transaction amount The first random commitment of , n 1 is the transaction amount applied by the user in the transaction information, the coordinates of G are (x 01 , y 01 ), and CM 1 * is the third random commitment identified by the account; 如果CM1,0=n1×G+CM1 *和CM1,1=CM0-CM1,0等式成立,则服务器根据所述本次交易信息进行本次交易处理;如果CM1,0=n1×G+CM1 *和CM11=CM0-CM1,0等式不成立,则服务器向客户端发送本次交易申请失败信息。If the equation of CM 1,0 =n 1 ×G+CM 1 * and CM 1,1 =CM 0 -CM 1,0 is established, the server will process this transaction according to the current transaction information; if CM 1, 0 =n 1 ×G+CM 1 * and CM 1 , 1 =CM 0 -CM 1,0 if the equation does not hold, the server sends the client a failure message of this transaction application. 6.根据权利要求5所述的装置,其特征在于,所述装置还包括:6. The apparatus according to claim 5, wherein the apparatus further comprises: 账户创建请求信息接收模块,用于接收客户端发送的账户创建请求信息;其中,所述账户创建请求信息中包括用户标识;an account creation request information receiving module, configured to receive account creation request information sent by the client; wherein, the account creation request information includes a user ID; 查找模块,用于在预设的账户信息表中,查找是否包含所述用户标识对应的账户标识;a search module, configured to search in the preset account information table whether the account identification corresponding to the user identification is included; 验证模块,用于若所述账户信息表中不包含所述用户标识对应的账户标识,则在接收客户端发送的第四随机承诺对应的知识证明时,根据预设的知识证明验证算法,验证所述第四随机承诺对应的知识证明是否有效;The verification module is configured to, if the account information table does not contain the account identifier corresponding to the user identifier, when receiving the knowledge certificate corresponding to the fourth random commitment sent by the client, verify the verification algorithm according to the preset knowledge certificate whether the knowledge proof corresponding to the fourth random commitment is valid; 创建模块,用于若所述第四随机承诺对应的知识证明有效,则创建所述用户标识对应的账户标识和交易总金额。A creating module is configured to create an account identifier corresponding to the user identifier and a total transaction amount if the knowledge certificate corresponding to the fourth random commitment is valid. 7.一种基于区块链的资金交易装置,其特征在于,所述装置应用于客户端,所述装置包括:7. A fund transaction device based on blockchain, wherein the device is applied to a client, and the device comprises: 交易申请信息获取模块,用于获取用户输入的交易申请信息,所述交易申请信息包括账户标识、交易类型标识和交易金额;a transaction application information acquisition module, used for acquiring transaction application information input by a user, the transaction application information including 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 proof corresponding to the transaction amount; 第二确定模块,用于确定所述账户标识的当前的剩余可交易金额,以及所述账户标识的剩余可交易金额对应的第二随机承诺和第二范围证明;a second determining module, configured to determine the current remaining tradable amount of the account identifier, and the second random commitment and the second range proof corresponding to the remaining tradable amount of the account identifier; 第三确定模块,用于根据所述交易金额对应的第一随机承诺和预设的知识证明生成算法,确定所述账户标识的第三随机承诺和所述第三随机承诺对应的知识证明;a third determination module, configured to determine the third random commitment of the account identifier and the knowledge certificate corresponding to the third random commitment according to the first random commitment corresponding to the transaction amount and a preset knowledge proof generation algorithm; 本次交易信息组成模块,用于将所述交易申请信息、交易金额对应的第一随机承诺和第一范围证明、所述账户标识的剩余可交易金额对应的第二随机承诺和第二范围证明、所述账户标识的第三随机承诺和所述第三随机承诺对应的知识证明,组成本次交易信息;This transaction information constitutes a module, which is used to combine the transaction application information, the first random commitment and the first range certificate corresponding to the transaction amount, and the second random commitment and the second range certificate corresponding to the remaining tradable amount of the account identifier. , The third random commitment identified by the account and the knowledge certificate corresponding to the third random commitment constitute the transaction information; 本次交易信息验证模块,用于将所述本次交易信息发送至区块链中的服务器,以使所述服务器根据预设的验证算法,验证所述本次交易信息是否正确,若正确,则判断如下公式是否成立:The current transaction information verification module is used to send the current transaction information to the server in the blockchain, so that the server can verify whether the current transaction information is correct according to the preset verification algorithm. Then judge whether the following formula holds: CM1,0=n1×G+CM1 *CM 1,0 =n 1 ×G+CM 1 * ; CM11=CM0-CM1,0CM 1 , 1 =CM 0 -CM 1,0 ; 其中,CM1,1为所述账户标识当前的剩余可交易金额对应的第二随机承诺,CM0为所述账户标识对应的总交易金额对应随机承诺和CM1,0为所述交易金额对应的第一随机承诺,n1为所述交易信息中用户申请的交易金额,G的坐标为(x01,y01),CM1*为所述账户标识的第三随机承诺;Wherein, CM 1 , 1 is the second random commitment corresponding to the current remaining tradable amount of the account identifier, CM 0 is the random commitment corresponding to the total transaction amount corresponding to the account identifier, and CM 1, 0 is the corresponding random commitment of the transaction amount The first random commitment of , n 1 is the transaction amount applied by the user in the transaction information, the coordinates of G are (x 01 , y 01 ), and CM 1 * is the third random commitment identified by the account; 如果CM1,0=n1×G+CM1 *和CM1,1=CM0-CM1,0等式成立,则服务器根据所述本次交易信息进行本次交易处理;如果CM1,0=n1×G+CM1 *和CM11=CM0-CM1,0等式不成立,则服务器向客户端发送本次交易申请失败信息。If the equation of CM 1,0 =n 1 ×G+CM 1 * and CM 1,1 =CM 0 -CM 1,0 is established, the server will process this transaction according to the current transaction information; if CM 1, 0 =n 1 ×G+CM 1 * and CM 1 , 1 =CM 0 -CM 1,0 if the equation does not hold, the server sends the client a failure message of this transaction application. 8.根据权利要求7所述的装置,其特征在于,所述装置还包括:8. The apparatus according to claim 7, wherein the apparatus further comprises: 账户创建请求信息发送模块,用于向服务器发送账户创建请求信息;其中,所述账户创建请求信息中包括用户标识;an account creation request information sending module, used for sending account creation request information to the server; wherein, the account creation request information includes a user ID; 随机数获取模块,用于获取用户输入的随机数;The random number acquisition module is used to acquire the random number input by the user; 第四随机承诺确定模块,用于根据所述随机数和预设的随机承诺生成算法,确定第四随机承诺;a fourth random commitment determination module, configured to determine a fourth random commitment according to the random number and a preset random commitment generation algorithm; 知识证明确定模块,用于根据预设的知识证明生成算法,确定所述第四随机承诺对应的知识证明;a knowledge proof determination module, configured to determine a knowledge proof corresponding to the fourth random commitment according to a preset knowledge proof generation algorithm; 发送模块,用于将所述第四随机承诺和第四随机承诺对应的知识证明发送至所述服务器。A sending module, configured to send the fourth random commitment and the knowledge proof corresponding to the fourth random commitment to the server. 9.一种服务器,其特征在于,包括处理器、通信接口、存储器和通信总线,其中,处理器,通信接口,存储器通过通信总线完成相互间的通信;9. A server, characterized in that it comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; 存储器,用于存放计算机程序;memory for storing computer programs; 处理器,用于执行存储器上所存放的程序时,实现权利要求1-2任一项所述的方法。The processor is configured to implement the method described in any one of claims 1-2 when executing the program stored in the memory. 10.一种客户端,其特征在于,包括处理器、通信接口、存储器和通信总线,其中,处理器,通信接口,存储器通过通信总线完成相互间的通信;10. A client, comprising a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; 存储器,用于存放计算机程序;memory for storing computer programs; 处理器,用于执行存储器上所存放的程序时,实现权利要求3-4任一项所述的方法。The processor is configured to implement the method described in any one of claims 3-4 when executing the program stored in the memory.
CN201811332698.1A 2018-11-09 2018-11-09 A method and device for fund transaction based on blockchain Active CN109447791B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811332698.1A CN109447791B (en) 2018-11-09 2018-11-09 A method and device for fund transaction based on blockchain

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811332698.1A CN109447791B (en) 2018-11-09 2018-11-09 A method and device for fund transaction based on blockchain

Publications (2)

Publication Number Publication Date
CN109447791A CN109447791A (en) 2019-03-08
CN109447791B true CN109447791B (en) 2021-07-16

Family

ID=65552475

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811332698.1A Active CN109447791B (en) 2018-11-09 2018-11-09 A method and device for fund transaction based on blockchain

Country Status (1)

Country Link
CN (1) CN109447791B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110471923B (en) * 2019-08-12 2024-01-16 深圳前海微众银行股份有限公司 Processing method and device for blockchain transaction records
CN110597541B (en) * 2019-09-16 2021-09-17 腾讯科技(深圳)有限公司 Interface updating processing method, device, equipment and storage medium based on block chain
CN111325533B (en) * 2019-12-31 2024-05-14 深圳大学 A decentralized trading method, trading system and computer device
CN111815322B (en) * 2020-06-08 2023-11-07 北京邮电大学 Distributed payment method with selectable privacy service based on Ethernet
CN112488831B (en) * 2020-11-20 2024-08-23 东软集团股份有限公司 Block chain network transaction method and device, storage medium and electronic equipment
CN112950338B (en) * 2021-02-26 2024-08-06 浙江工商大学 Sealed bidding domain name auction method based on blockchain

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9614676B1 (en) * 2013-03-13 2017-04-04 Hrl Laboratories, Llc Cryptographically-secure packed proactive secret sharing (PPSS) protocol
CN108021821A (en) * 2017-11-28 2018-05-11 北京航空航天大学 Multicenter block chain transaction intimacy protection system and method
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

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8744077B2 (en) * 2008-10-28 2014-06-03 International Business Machines Corporation Cryptographic encoding and decoding of secret data
CN103401839B (en) * 2013-07-02 2016-06-01 河海大学 A kind of many authorization center encryption method based on attribute protection
WO2016200885A1 (en) * 2015-06-08 2016-12-15 Blockstream Corporation Cryptographically concealing amounts transacted on a ledger while preserving a network's ability to verify the transaction
US10791123B2 (en) * 2015-11-25 2020-09-29 Yaron Gvili Selectivity in privacy and verification with applications
CN107666388B (en) * 2016-07-28 2019-11-01 郑珂威 Block chain information encryption method based on complete homomorphic cryptography method
CN107911216B (en) * 2017-10-26 2020-07-14 矩阵元技术(深圳)有限公司 A method and system for privacy protection of blockchain transactions
CN108418689B (en) * 2017-11-30 2020-07-10 矩阵元技术(深圳)有限公司 Zero-knowledge proof method and medium suitable for block chain 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

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9614676B1 (en) * 2013-03-13 2017-04-04 Hrl Laboratories, Llc Cryptographically-secure packed proactive secret sharing (PPSS) protocol
CN108021821A (en) * 2017-11-28 2018-05-11 北京航空航天大学 Multicenter block chain transaction intimacy protection system and method
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

Also Published As

Publication number Publication date
CN109447791A (en) 2019-03-08

Similar Documents

Publication Publication Date Title
CN109447791B (en) A method and device for fund transaction based on blockchain
US20210160068A1 (en) Data sharing method, apparatus, and system, and electronic device
WO2020024995A1 (en) Privacy transaction method and system, and device
JP2020528222A (en) Handling of transaction activities based on smart contracts in blockchain Caution Methods and devices for protecting data
WO2016138606A1 (en) Secure account management using tokens
US11856107B2 (en) Methods and systems for exchanging confidential information via a blockchain
EP3839791B1 (en) Identification and authorization of transactions via smart contracts
CN111815322A (en) An Ethereum-based distributed payment method with optional privacy services
CN110009349A (en) Method and device for generating and verifying linkable ring signature in blockchain
WO2024011863A1 (en) Communication method and apparatus, sim card, electronic device, and terminal device
CN111431908B (en) An access processing method, device, management server and readable storage medium
CN111783049A (en) A method and system for processing user information based on blockchain
CN108769054A (en) A kind of block chain transaction verification method and device based on equivalent test promise
CN111639938A (en) Data processing method, device, equipment and medium
CN114514550A (en) Partitioning requests into blockchains
CN111488626A (en) Blockchain-based data processing method, device, equipment and medium
CN112785410B (en) Relying Party Risk Adjustment Indicator System and Method
CN113901424A (en) Method and device for selective disclosure of digital identity attributes
CN110598479B (en) A data processing method, device and computer readable storage medium
US12309169B2 (en) Accessing data on a blockchain with proof of data verification
WO2022068234A1 (en) Encryption method and apparatus based on shared root key, device and medium
CN114945931B (en) Method and apparatus for mitigating bill financing fraud
CN115619395A (en) Blockchain-based data processing method and related equipment
CN111275506A (en) Bill issuing method and block link point equipment
CN114830159B (en) Method and apparatus for mitigating ticket financing fraud

Legal Events

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