WO2024103689A1 - State change method and apparatus, device, and nonvolatile readable storage medium - Google Patents

State change method and apparatus, device, and nonvolatile readable storage medium Download PDF

Info

Publication number
WO2024103689A1
WO2024103689A1 PCT/CN2023/097518 CN2023097518W WO2024103689A1 WO 2024103689 A1 WO2024103689 A1 WO 2024103689A1 CN 2023097518 W CN2023097518 W CN 2023097518W WO 2024103689 A1 WO2024103689 A1 WO 2024103689A1
Authority
WO
WIPO (PCT)
Prior art keywords
state
change
state machine
smart contract
change request
Prior art date
Application number
PCT/CN2023/097518
Other languages
French (fr)
Chinese (zh)
Inventor
麻付强
Original Assignee
苏州元脑智能科技有限公司
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 苏州元脑智能科技有限公司 filed Critical 苏州元脑智能科技有限公司
Publication of WO2024103689A1 publication Critical patent/WO2024103689A1/en

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/10Network architectures or network communication protocols for network security for controlling access to devices or network resources
    • H04L63/105Multiple levels of security
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/14Network architectures or network communication protocols for network security for detecting or protecting against malicious traffic
    • H04L63/1433Vulnerability analysis
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/08Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
    • H04L9/0816Key establishment, i.e. cryptographic processes or cryptographic protocols whereby a shared secret becomes available to two or more parties, for subsequent use
    • H04L9/085Secret sharing or secret splitting, e.g. threshold schemes

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Hardware Design (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The present application discloses a state change method and apparatus, a device, and a nonvolatile readable storage medium. The method comprises: acquiring a state change request initiated by any smart contract participant; according to different levels of changed objects involved in the state change request, triggering state machine managers of corresponding levels to call state machines of the corresponding levels, so as to detect current states of the changed objects, wherein the levels of the changed objects comprise a smart contract layer or a functional function layer inside a smart contract, and the state machine managers and the state machines corresponding to the changed objects of different levels are different; and if the current states of the changed objects meet a change condition, triggering the state machine managers of the corresponding levels to call the state machines of the corresponding levels, so as to change the states of the changed objects according to the state change request. Therefore, in the present application, multi-level life cycle management is designed to perform vulnerability protection on a smart contract, thereby ensuring the stability of a blockchain system.

Description

状态变更方法、装置、设备及非易失性可读存储介质State changing method, device, equipment and non-volatile readable storage medium
相关申请的交叉引用CROSS-REFERENCE TO RELATED APPLICATIONS
本申请要求于2022年11月14日提交中国专利局,申请号为202211417421.5,申请名称为“一种状态变更方法、装置、设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims priority to the Chinese patent application filed with the China Patent Office on November 14, 2022, with application number 202211417421.5, and application name “A state changing method, device, equipment and storage medium”, all contents of which are incorporated by reference in this application.
技术领域Technical Field
本申请涉及区块链技术领域,特别涉及一种状态变更方法、装置、设备及非易失性可读存储介质。The present application relates to the field of blockchain technology, and in particular to a state change method, device, equipment and non-volatile readable storage medium.
背景技术Background technique
区块链应用场景越来越丰富,很多区块链业务实现均是通过编写智能合约完成的。区块链中智能合约控制着链上所有数据和资产,极易成为黑客的攻击目标,区块链的公开透明特性也使得智能合约透明化,大幅降低了攻击成本,同时智能合约一旦部署上链便不可更改,且运行过程不受任何干预,合约中的漏洞一旦引发也难以被修复。智能合约编写过程中,编程语言本身的设计缺陷、开发人员对编程语言的理解偏差等情况都会导致开发出的智能合约存在漏洞。智能合约执行过程中,执行环境和执行所需数据的安全性也会影响执行结果。因此,智能合约安全威胁的来源可分为不安全的合约编程和不可靠的合约执行。但目前针对智能合约的生命周期管理尚不完善,使得智能合约漏洞防护能力较弱。Blockchain application scenarios are becoming more and more abundant, and many blockchain business implementations are completed by writing smart contracts. Smart contracts in blockchain control all data and assets on the chain, making them easy targets for hackers. The open and transparent nature of blockchain also makes smart contracts transparent, greatly reducing the cost of attacks. At the same time, once a smart contract is deployed on the chain, it cannot be changed, and the running process is not subject to any interference. Once a vulnerability in the contract is triggered, it is difficult to repair. In the process of writing smart contracts, design defects in the programming language itself and developers' understanding of the programming language will lead to vulnerabilities in the developed smart contracts. In the process of executing smart contracts, the security of the execution environment and the data required for execution will also affect the execution results. Therefore, the sources of smart contract security threats can be divided into unsafe contract programming and unreliable contract execution. However, the current life cycle management of smart contracts is not perfect, which makes the smart contract vulnerability protection ability weak.
因此,上述技术问题亟待本领域技术人员解决。Therefore, the above technical problems need to be solved by those skilled in the art urgently.
发明内容Summary of the invention
有鉴于此,本申请的目的在于提供一种状态变更方法、装置、设备及非易失性可读存储介质,设计多层次生命周期管理对智能合约进行漏洞防护,保证区块链系统的稳定性。其方案如下:In view of this, the purpose of this application is to provide a state change method, device, equipment and non-volatile readable storage medium, design multi-level life cycle management to protect smart contracts from vulnerabilities, and ensure the stability of the blockchain system. The solution is as follows:
本申请提供了一种状态变更方法,包括:This application provides a state change method, including:
获取由任意智能合约参与方发起的状态变更请求;Get state change requests initiated by any smart contract participant;
根据状态变更请求的变更对象的层级不同触发对应层级的状态机管理器调用对应层级的状态机,以对变更对象的当前状态进行检测;其中,变更对象的层级包括智能合约层或智能合约内部的功能函数层,不同层级的变更对象对应的状态机管理器及状态机不同;According to the different levels of the changed objects in the state change request, the state machine manager of the corresponding level is triggered to call the state machine of the corresponding level to detect the current state of the changed object; wherein the level of the changed object includes the smart contract layer or the function layer inside the smart contract, and the state machine managers and state machines corresponding to the changed objects of different levels are different;
如果变更对象的当前状态满足变更条件,则触发对应层级的状态机管理器调用相应层级的状态机,以根据状态变更请求对变更对象的状态进行变更。If the current state of the change object meets the change condition, the state machine manager of the corresponding level is triggered to call the state machine of the corresponding level to change the state of the change object according to the state change request.
可选的,根据状态变更请求的变更对象的层级不同触发对应层级的状态机管理器调用对应层级的状态机,以对变更对象的当前状态进行检测,包括:Optionally, according to the different levels of the changed object of the state change request, the state machine manager of the corresponding level is triggered to call the state machine of the corresponding level to detect the current state of the changed object, including:
如果状态变更请求的变更对象的层级为智能合约层,则触发第一状态机管理器调用第一状态机,以获取与智能合约对应的当前第一状态机状态;If the level of the change object of the state change request is the smart contract layer, trigger the first state machine manager to call the first state machine to obtain the current first state machine state corresponding to the smart contract;
判断当前第一状态机状态是否满足变更条件;Determine whether the current state of the first state machine meets the change condition;
相应的,如果变更对象的当前状态满足变更条件,触发对应层级的状态机管理器调用相应层级的状态机,以根据状态变更请求对变更对象的状态进行变更,包括:Correspondingly, if the current state of the change object meets the change condition, the state machine manager of the corresponding level is triggered to call the state machine of the corresponding level to change the state of the change object according to the state change request, including:
触发第一状态机管理器调用第一状态机,以根据状态变更请求对智能合约的状态进行变更。Trigger the first state machine manager to call the first state machine to change the state of the smart contract according to the state change request.
可选的,触发第一状态机管理器调用第一状态机,以根据状态变更请求对智能合约的状态进行变更,包括:Optionally, triggering the first state machine manager to call the first state machine to change the state of the smart contract according to the state change request includes:
在状态变更请求被配置为请求智能合约层将第一状态机状态由部署状态变更到执行状态的情况下,检测智能合约是否处于部署状态或者停止状态;In a case where the state change request is configured to request the smart contract layer to change the state of the first state machine from a deployed state to an executed state, detecting whether the smart contract is in a deployed state or a stopped state;
在智能合约处于部署状态或者停止状态的情况下,将智能合约的状态机变更到执行状态,其中,第一状态机状态包括部署状态以及执行状态。When the smart contract is in a deployed state or a stopped state, the state machine of the smart contract is changed to an execution state, wherein the first state machine state includes a deployed state and an execution state.
可选的,判断当前第一状态机状态是否满足变更条件,包括: Optionally, determining whether the current state of the first state machine satisfies a change condition includes:
判断当前第一状态机状态是否属于状态变更请求要求的变更后状态的前置状态,如果是,则判定当前第一状态机状态满足变更条件。It is determined whether the current first state machine state is a pre-state of the changed state required by the state change request, and if so, it is determined that the current first state machine state meets the change condition.
可选的,根据状态变更请求的变更对象的层级不同触发对应层级的状态机管理器调用对应层级的状态机,以对变更对象的当前状态进行检测,包括:Optionally, according to the different levels of the changed object of the state change request, the state machine manager of the corresponding level is triggered to call the state machine of the corresponding level to detect the current state of the changed object, including:
如果状态变更请求的变更对象的层级为智能合约内部的功能函数层,则触发第一状态机管理器调用第一状态机获取与智能合约对应的当前第一状态机状态,同时触发第二状态机管理器调用第二状态机获取与功能函数对应的当前第二状态机状态;If the level of the change object of the state change request is the function layer inside the smart contract, the first state machine manager is triggered to call the first state machine to obtain the current first state machine state corresponding to the smart contract, and the second state machine manager is triggered to call the second state machine to obtain the current second state machine state corresponding to the function;
判断当前第一状态机状态和当前第二状态机状态是否均满足变更条件;Determine whether the current first state machine state and the current second state machine state both meet the change condition;
相应的,如果变更对象的当前状态满足变更条件,触发对应层级的状态机管理器调用相应层级的状态机,以根据状态变更请求对变更对象的状态进行变更,包括:Correspondingly, if the current state of the change object meets the change condition, the state machine manager of the corresponding level is triggered to call the state machine of the corresponding level to change the state of the change object according to the state change request, including:
触发第二状态机管理器调用第二状态机,以根据状态变更请求对功能函数的状态进行变更。The second state machine manager is triggered to call the second state machine to change the state of the functional function according to the state change request.
可选的,触发第二状态机管理器调用第二状态机,以根据状态变更请求对功能函数的状态进行变更,包括:Optionally, triggering the second state machine manager to call the second state machine to change the state of the function according to the state change request includes:
在状态变更请求用于请求功能函数层执行停止状态操作的情况下,检测智能合约是否处于执行状态,以及检测功能函数层是否处于执行状态;In the case where the state change request is used to request the function layer to perform a stop state operation, detecting whether the smart contract is in the execution state, and detecting whether the function layer is in the execution state;
在智能合约处于执行状态,并且功能函数层处于执行状态的情况下,将第二状态机状态变更到停止状态,第二状态机状态包括执行状态和停止状态。When the smart contract is in the execution state and the functional function layer is in the execution state, the second state machine state is changed to the stop state, and the second state machine state includes the execution state and the stop state.
可选的,判断当前第一状态机状态和当前第二状态机状态是否均满足变更条件,包括:Optionally, determining whether both the current first state machine state and the current second state machine state satisfy the change condition includes:
判断当前第二状态机状态是否满足第一状态机状态的层级约束条件,如果是,则判定第一状态机状态和第二状态机状态均满足变更条件。It is determined whether the current second state machine state satisfies the hierarchical constraint condition of the first state machine state. If so, it is determined that both the first state machine state and the second state machine state satisfy the change condition.
判断当前第二状态机状态是否满足第一状态机状态的层级约束条件,包括:Determining whether the current second state machine state satisfies the hierarchical constraint condition of the first state machine state includes:
将第二状态机状态和第一状态机状态进行匹配,其中,第一状态机状态包括部署状态、执行状态、停止状态、升级状态和销毁状态,第二状态机状态包括部署状态、执行状态、停止状态和升级状态;Matching the second state machine state with the first state machine state, wherein the first state machine state includes a deployment state, an execution state, a stop state, an upgrade state, and a destruction state, and the second state machine state includes a deployment state, an execution state, a stop state, and an upgrade state;
在第二状态机状态和第一状态机状态匹配一致的情况下,确定第二状态机状态满足第一状态机状态的层级约束条件。When the second state machine state matches the first state machine state, it is determined that the second state machine state satisfies the hierarchical constraint condition of the first state machine state.
可选的,判断当前第二状态机状态是否满足第一状态机状态的层级约束条件之后,还包括:Optionally, after determining whether the current second state machine state satisfies the hierarchical constraint condition of the first state machine state, the method further includes:
判断当前第二状态机状态是否属于状态变更请求要求的变更后状态的前置状态,如果是,则判定第一状态机状态和第二状态机状态均满足变更条件。It is determined whether the current second state machine state is a pre-state of the changed state required by the state change request. If so, it is determined that both the first state machine state and the second state machine state meet the change condition.
可选的,获取由任意智能合约参与方发起的状态变更请求,包括:Optionally, obtain state change requests initiated by any smart contract participant, including:
获取由任意智能合约参与方发起的状态变更请求及状态变更请求的门限签名;其中,门限签名由智能合约参与方通过门限签名的方式对状态变更请求进行签名得到;Obtain the state change request initiated by any smart contract participant and the threshold signature of the state change request; wherein the threshold signature is obtained by the smart contract participant signing the state change request by means of the threshold signature;
相应的,对变更对象的当前状态进行检测之前,还包括:Accordingly, before checking the current state of the changed object, the following steps are also included:
根据状态变更请求的变更对象的层级不同触发对应层级的状态机管理器基于状态变更请求对门限签名进行验签,如果验签通过,则执行对变更对象的当前状态进行检测的步骤。According to the different levels of the changed object of the state change request, the state machine manager of the corresponding level is triggered to verify the threshold signature based on the state change request. If the verification passes, the step of detecting the current state of the changed object is executed.
可选的,根据状态变更请求的变更对象的层级不同触发对应层级的状态机管理器基于状态变更请求对门限签名进行验签,包括:Optionally, according to the different levels of the change object of the state change request, the state machine manager of the corresponding level is triggered to verify the threshold signature based on the state change request, including:
如果状态变更请求的变更对象的层级为智能合约层,则触发第一状态机管理器基于状态变更请求对门限签名进行验签。If the level of the change object of the state change request is the smart contract layer, the first state machine manager is triggered to verify the threshold signature based on the state change request.
可选的,根据状态变更请求的变更对象的层级不同触发对应层级的状态机管理器基于状态变更请求对门限签名进行验签,包括:Optionally, according to the different levels of the change object of the state change request, the state machine manager of the corresponding level is triggered to verify the threshold signature based on the state change request, including:
如果状态变更请求的变更对象的层级为智能合约内部的功能函数层,则触发第二状态机管理器基于状态变更请求对门限签名进行验签。 If the level of the change object of the state change request is the function layer inside the smart contract, the second state machine manager is triggered to verify the threshold signature based on the state change request.
可选的,的状态变更方法,还包括:Optionally, the state change method also includes:
各个智能合约参与方分别对状态变更请求进行哈希运算得到第一哈希结果,并分别对哈希结果进行签名得到对应的签名份额,以及根据各个签名份额采用门限签名恢复出基准签名份额;Each smart contract participant performs a hash operation on the state change request to obtain a first hash result, and signs the hash result to obtain a corresponding signature share, and uses a threshold signature to restore a base signature share based on each signature share;
各个智能合约参与方根据基准私钥份额、临时私钥份额及临时公钥份额计算出基准签名参数,得到包含基准签名参数与基准签名份额的门限签名。Each smart contract participant calculates the base signature parameters based on the base private key share, temporary private key share and temporary public key share, and obtains a threshold signature containing the base signature parameters and the base signature share.
可选的,的状态变更方法,还包括:Optionally, the state change method also includes:
密钥生成中心通过门限秘密共享算法生成基准私钥及对应的基准私钥份额,并根据目标需求为不同的智能合约参与方分配及下发不同的基准私钥份额;The key generation center generates the base private key and the corresponding base private key share through the threshold secret sharing algorithm, and allocates and issues different base private key shares to different smart contract participants according to target requirements;
各个智能合约参与方生成多个临时私钥份额、多个临时公钥份额并将多个临时私钥份额、多个临时公钥份额分别发送至其他智能合约参与方,以及接收其他智能合约参与方发送的临时私钥份额、临时公钥份额;Each smart contract participant generates multiple temporary private key shares and multiple temporary public key shares and sends the multiple temporary private key shares and multiple temporary public key shares to other smart contract participants, and receives the temporary private key shares and temporary public key shares sent by other smart contract participants;
各个智能合约参与方基于自身临时私钥份额及接收到的临时私钥份额计算临时私钥共享份额,并基于自身临时公钥份额及接收到的临时公钥份额计算临时公钥共享份额;Each smart contract participant calculates a temporary private key share based on its own temporary private key share and the temporary private key share it receives, and calculates a temporary public key share based on its own temporary public key share and the temporary public key share it receives;
各个智能合约参与方根据临时公钥共享份额计算基准签名参数。Each smart contract participant calculates the base signature parameters based on the temporary public key sharing share.
可选地,根据目标需求为不同的智能合约参与方分配及下发不同的基准私钥份额,包括:Optionally, different base private key shares are allocated and issued to different smart contract participants according to target requirements, including:
根据智能合约参与方对应的分配权重确定被分配到智能合约参与方的基准私钥份额的目标数量,其中,分配权重是按照智能合约参与方的可信程度以及对智能合约的影响程度确定的;Determine the target number of base private key shares allocated to smart contract participants according to the allocation weights corresponding to the smart contract participants, wherein the allocation weights are determined according to the trustworthiness of the smart contract participants and the degree of influence on the smart contract;
将目标数量的基准私钥份额下发至对应的智能合约参与方,其中,智能合约参与方包括智能合约制定者、智能合约使用者以及智能合约仲裁者,智能合约制定者对应的目标数量大于或者等于1,智能合约使用者对应的目标数量大于或者等于0,智能合约仲裁者对应的目标数量大于或者等于1。The target number of benchmark private key shares is issued to the corresponding smart contract participants, where the smart contract participants include the smart contract maker, the smart contract user and the smart contract arbitrator. The target number corresponding to the smart contract maker is greater than or equal to 1, the target number corresponding to the smart contract user is greater than or equal to 0, and the target number corresponding to the smart contract arbitrator is greater than or equal to 1.
可选的,状态机管理器基于状态变更请求对门限签名进行验签,包括:Optionally, the state machine manager verifies the threshold signature based on the state change request, including:
状态机管理器从智能合约中获取与基准私钥对应的基准公钥,并对状态变更请求进行哈希运算得到第二哈希结果,以及利用基准签名份额的乘法逆、基准公钥、第二哈希结果计算验签公钥共享份额;The state machine manager obtains the reference public key corresponding to the reference private key from the smart contract, performs a hash operation on the state change request to obtain a second hash result, and calculates the verification public key share using the multiplicative inverse of the reference signature share, the reference public key, and the second hash result;
状态机管理器根据验签公钥共享份额计算验签签名参数,并判断基准签名参数与验签签名参数是否相等,如果是,则判定验签通过。The state machine manager calculates the verification signature parameters based on the shared share of the verification public key, and determines whether the base signature parameters are equal to the verification signature parameters. If so, the verification is considered to be successful.
本申请提供了一种状态变更装置,包括:The present application provides a state changing device, comprising:
请求获取模块,被配置为获取由任意智能合约参与方发起的状态变更请求;A request acquisition module, configured to acquire state change requests initiated by any smart contract participant;
状态分级检测模块,被配置为根据状态变更请求的变更对象的层级不同触发对应层级的状态机管理器调用对应层级的状态机,以对变更对象的当前状态进行检测;其中,变更对象的层级包括智能合约层或智能合约内部的功能函数层,不同层级的变更对象对应的状态机管理器及状态机不同;The state hierarchical detection module is configured to trigger the state machine manager of the corresponding level to call the state machine of the corresponding level according to the different levels of the change object of the state change request, so as to detect the current state of the change object; wherein the level of the change object includes the smart contract layer or the function layer inside the smart contract, and the state machine managers and state machines corresponding to the change objects of different levels are different;
状态变更模块,被配置为如果变更对象的当前状态满足变更条件,则触发对应层级的状态机管理器调用相应层级的状态机,以根据状态变更请求对变更对象的状态进行变更。The state change module is configured to trigger the state machine manager of the corresponding level to call the state machine of the corresponding level if the current state of the change object meets the change condition, so as to change the state of the change object according to the state change request.
本申请提供了一种智能合约虚拟机,其特征在于,包括:变更对象的层级对应的状态机管理器和状态机,其中,变更对象的层级包括智能合约层或智能合约内部的功能函数层,不同层级的变更对象对应的状态机管理器及状态机不同,The present application provides a smart contract virtual machine, characterized in that it includes: a state machine manager and a state machine corresponding to the level of the change object, wherein the level of the change object includes the smart contract layer or the function layer inside the smart contract, and the state machine managers and state machines corresponding to the change objects at different levels are different.
状态机管理器,被配置为对对应的变更对象的当前状态进行检测;并且,如果变更对象的当前状态满足变更条件,则调用相应层级的状态机,以根据状态变更请求对变更对象的状态进行变更。The state machine manager is configured to detect the current state of the corresponding change object; and if the current state of the change object meets the change condition, call the state machine of the corresponding level to change the state of the change object according to the state change request.
本申请提供了一种电子设备,电子设备包括处理器和存储器;其中存储器被配置为存储计算机程序,计算机程序由处理器加载并执行以实现前述状态变更方法。The present application provides an electronic device, which includes a processor and a memory; wherein the memory is configured to store a computer program, and the computer program is loaded and executed by the processor to implement the aforementioned state change method.
本申请提供了一种计算机非易失性可读存储介质,计算机非易失性可读存储介质中存储有计算机可执行指令,计算机可执行指令被处理器加载并执行时,实现前述状态变更方法。The present application provides a computer non-volatile readable storage medium, in which computer executable instructions are stored. When the computer executable instructions are loaded and executed by a processor, the aforementioned state change method is implemented.
本申请中,先获取由任意智能合约参与方发起的状态变更请求;然后根据状态变更请求的变更对象的 层级不同触发对应层级的状态机管理器调用对应层级的状态机,以对变更对象的当前状态进行检测;其中,变更对象的层级包括智能合约层或智能合约内部的功能函数层,不同层级的变更对象对应的状态机管理器及状态机不同;如果变更对象的当前状态满足变更条件,则触发对应层级的状态机管理器调用相应层级的状态机,以根据状态变更请求对变更对象的状态进行变更。可见,本申请设计多层次生命周期管理,由变更对象所处层级的状态机管理器和状态机共同作用来检测变更对象的当前状态,在满足变更条件的情况下进行状态变更。在宏观的智能合约层面上实现整个智能合约的生命周期管理,在微功能函数层面上实现函数级别细粒度的生命周期管理,从而对智能合约进行漏洞防护,保证区块链系统的稳定性。In this application, we first obtain a state change request initiated by any smart contract participant; then, based on the state change request, we change the state of the object to be changed. Different levels trigger the state machine manager of the corresponding level to call the state machine of the corresponding level to detect the current state of the changed object; wherein, the level of the changed object includes the smart contract layer or the functional function layer inside the smart contract, and the state machine managers and state machines corresponding to the changed objects of different levels are different; if the current state of the changed object meets the change conditions, the state machine manager of the corresponding level is triggered to call the state machine of the corresponding level to change the state of the changed object according to the state change request. It can be seen that this application designs multi-level lifecycle management, and the state machine manager and state machine of the level where the changed object is located work together to detect the current state of the changed object, and change the state when the change conditions are met. The lifecycle management of the entire smart contract is realized at the macro level of the smart contract, and the fine-grained lifecycle management of the function level is realized at the micro-function level, so as to protect the smart contract from vulnerabilities and ensure the stability of the blockchain system.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据提供的附图获得其他的附图。In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are merely embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
图1为本申请提供的一种状态变更方法流程图;FIG1 is a flow chart of a state change method provided by the present application;
图2为本申请提供的一种可选的状态变更方法示意图;FIG2 is a schematic diagram of an optional state change method provided by the present application;
图3为本申请提供的一种可选的状态变更方法流程图;FIG3 is a flow chart of an optional state change method provided by the present application;
图4为本申请提供的一种可选的第一状态机的状态图;FIG4 is a state diagram of an optional first state machine provided by the present application;
图5为本申请提供的一种可选的第二状态机的状态图;FIG5 is a state diagram of an optional second state machine provided by the present application;
图6为本申请提供的一种可选的智能合约生命周期执行流程图;FIG6 is an optional smart contract lifecycle execution flow chart provided by the present application;
图7为本申请提供的一种可选的状态变更方法流程图;FIG7 is a flow chart of an optional state change method provided by the present application;
图8为本申请提供的一种可选的门限签名流程图;FIG8 is an optional threshold signature flow chart provided by the present application;
图9为本申请提供的一种可选的验签流程图;FIG9 is an optional signature verification flow chart provided by the present application;
图10为本申请提供的一种状态变更装置结构示意图;FIG10 is a schematic diagram of the structure of a state changing device provided by the present application;
图11为本申请提供的一种状态变更电子设备结构图。FIG. 11 is a structural diagram of a state-changing electronic device provided in the present application.
具体实施方式Detailed ways
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
鉴于智能合约的透明化、不可更改性及难以修复性,使得智能合约极易成为黑客的攻击目标,极易造成区块链系统的不稳定。然而现有针对智能合约的生命周期管理尚不完善,使得智能合约漏洞防护能力较弱。针对上述技术缺陷,本身请提供一种状态变更方案,设计多层次生命周期管理对智能合约进行漏洞防护,保证区块链系统的稳定性。Due to the transparency, immutability and difficulty in repairing of smart contracts, smart contracts are easily targeted by hackers and can easily cause instability in the blockchain system. However, the existing lifecycle management for smart contracts is still imperfect, making the vulnerability protection ability of smart contracts weak. In view of the above technical defects, please provide a state change solution and design multi-level lifecycle management to protect smart contracts from vulnerabilities and ensure the stability of the blockchain system.
图1为本申请实施例提供的一种状态变更方法流程图。参见图1所示,该状态变更方法包括:FIG1 is a flow chart of a state change method provided in an embodiment of the present application. Referring to FIG1 , the state change method includes:
S11:获取由任意智能合约参与方发起的状态变更请求。S11: Get the state change request initiated by any smart contract participant.
本实施例中,智能合约参与方的任意一方都可以发起状态变更请求,智能合约参与方包括智能合约制定者、智能合约使用者、智能合约仲裁者。在进行状态变更时,先获取由任意智能合约参与方发起的状态变更请求。In this embodiment, any party of the smart contract can initiate a state change request, and the smart contract participants include the smart contract developer, the smart contract user, and the smart contract arbitrator. When changing the state, first obtain the state change request initiated by any smart contract participant.
本实施例中,状态变更请求可以为将智能合约由部署状态变更到执行状态,或者将智能合约由执行状态变更到停止状态。本实施例可以实现细粒度函数层级的生命周期管理,因此,状态变更请求可以为将智能合约内部的状态函数由部署状态变更到执行状态,或者将智能合约内部的状态函数由执行状态变更到停止状态。具体的状态变更的逻辑由智能合约及状态函数对应的状态机决定。In this embodiment, the state change request can be to change the smart contract from the deployment state to the execution state, or to change the smart contract from the execution state to the stop state. This embodiment can realize the life cycle management of the fine-grained function level. Therefore, the state change request can be to change the state function inside the smart contract from the deployment state to the execution state, or to change the state function inside the smart contract from the execution state to the stop state. The specific state change logic is determined by the state machine corresponding to the smart contract and the state function.
可以理解,智能合约参与方中的合约制定者设计智能合约,智能合约代码中必须要包含第二状态机函数,负责处理第二生命周期管理。智能合约代码中必须包含一个函数修改器(modifier),可以用来以声明的方式判断各个函数的所处状态。智能合约代码中可以包含多个功能函数。每个智能合约运行前必须判断 第一状态机的状态,如果第一状态机处于“执行”状态,则可以调用合约。It is understandable that the contract maker among the smart contract participants designs the smart contract, and the smart contract code must include the second state machine function, which is responsible for handling the second life cycle management. The smart contract code must include a function modifier, which can be used to determine the state of each function in a declarative manner. The smart contract code can contain multiple functional functions. Each smart contract must be judged before running. The state of the first state machine. If the first state machine is in the "execution" state, the contract can be called.
S12:根据状态变更请求的变更对象的层级不同触发对应层级的状态机管理器调用对应层级的状态机,以对变更对象的当前状态进行检测;其中,变更对象的层级包括智能合约层或智能合约内部的功能函数层,不同层级的变更对象对应的状态机管理器及状态机不同。S12: According to the different levels of the changed object of the state change request, the state machine manager of the corresponding level is triggered to call the state machine of the corresponding level to detect the current state of the changed object; wherein the level of the changed object includes the smart contract layer or the functional function layer within the smart contract, and the state machine managers and state machines corresponding to the changed objects of different levels are different.
本实施例中,在获取到状态变更请求之后,根据状态变更请求的变更对象的层级不同触发对应层级的状态机管理器调用对应层级的状态机,以对变更对象的当前状态进行检测。如前文,变更对象的层级包括智能合约层或智能合约内部的功能函数层,不同层级的变更对象对应的状态机管理器及状态机不同。过程包括(如图2):In this embodiment, after obtaining the state change request, the state machine manager of the corresponding level is triggered to call the state machine of the corresponding level according to the different levels of the change object of the state change request to detect the current state of the change object. As mentioned above, the level of the change object includes the smart contract layer or the function layer inside the smart contract. The state machine manager and state machine corresponding to the change objects of different levels are different. The process includes (as shown in Figure 2):
S121:如果状态变更请求的变更对象的层级为智能合约层,则触发第一状态机管理器调用第一状态机,以获取与智能合约对应的当前第一状态机状态。S121: If the level of the change object of the state change request is the smart contract layer, the first state machine manager is triggered to call the first state machine to obtain the current first state machine state corresponding to the smart contract.
S122:判断当前第一状态机状态是否满足变更条件;S122: Determine whether the current state of the first state machine meets the change condition;
本实施例中,智能合约对应第一状态机管理器和第一状态机,智能合约内部的功能函数对应第一状态机管理器和第一状态机。第一状态机管理器和第一状态机对智能合约的生命周期进行管理,第二状态机管理器和第二状态机对智能合约内部的功能函数的生命周期进行管理。也即第一状态机由第一状态机管理器调度管理,管理整个智能合约的第一生命周期(宏观上整个智能合约的生命周期)。第二状态机由第二状态机管理器调度管理,管理智能合约的第二生命周期(第二状态机作为合约内部的一个函数,运行在合约内部,管理着智能合约内部具体每个函数的生命周期,它属于细粒度的函数级别的生命周期管理)。In this embodiment, the smart contract corresponds to the first state machine manager and the first state machine, and the functional functions within the smart contract correspond to the first state machine manager and the first state machine. The first state machine manager and the first state machine manage the life cycle of the smart contract, and the second state machine manager and the second state machine manage the life cycle of the functional functions within the smart contract. That is, the first state machine is scheduled and managed by the first state machine manager to manage the first life cycle of the entire smart contract (the life cycle of the entire smart contract on a macro level). The second state machine is scheduled and managed by the second state machine manager to manage the second life cycle of the smart contract (the second state machine, as a function within the contract, runs within the contract and manages the life cycle of each specific function within the smart contract. It belongs to fine-grained function-level life cycle management).
本实施例中,如果状态变更请求的变更对象的层级为智能合约层,则触发第一状态机管理器调用第一状态机,以获取与智能合约对应的当前第一状态机状态。需要说明的是,变更对象的当前状态由对应的状态机状态体现,因此需要获取与智能合约对应的当前第一状态机状态。获取到状态信息之后,继续判断当前第一状态机状态是否满足变更条件。In this embodiment, if the level of the change object of the state change request is the smart contract layer, the first state machine manager is triggered to call the first state machine to obtain the current first state machine state corresponding to the smart contract. It should be noted that the current state of the change object is reflected by the corresponding state machine state, so it is necessary to obtain the current first state machine state corresponding to the smart contract. After obtaining the state information, continue to determine whether the current first state machine state meets the change conditions.
S123:如果状态变更请求的变更对象的层级为智能合约内部的功能函数层,则触发第一状态机管理器调用第一状态机获取与智能合约对应的当前第一状态机状态,同时触发第二状态机管理器调用第二状态机获取与功能函数对应的当前第二状态机状态。S123: If the level of the change object of the state change request is the functional layer within the smart contract, the first state machine manager is triggered to call the first state machine to obtain the current first state machine state corresponding to the smart contract, and the second state machine manager is triggered to call the second state machine to obtain the current second state machine state corresponding to the functional function.
S124:判断当前第一状态机状态和当前第二状态机状态是否均满足变更条件。S124: Determine whether the current first state machine state and the current second state machine state both meet the change condition.
本实施例中,如果状态变更请求的变更对象的层级为智能合约内部的功能函数层,则触发第一状态机管理器调用第一状态机获取与智能合约对应的当前第一状态机状态,同时触发第二状态机管理器调用第二状态机获取与功能函数对应的当前第二状态机状态。对于功能函数的状态变更需要结合其所属智能合约状态及自身状态来综合判断。因此,第一状态机管理器和第二状态机管理器需要同时工作以获取智能合约及功能函数的状态。在此基础上,判断当前第一状态机状态和当前第二状态机状态是否均满足变更条件。In this embodiment, if the level of the change object of the state change request is the function layer inside the smart contract, the first state machine manager is triggered to call the first state machine to obtain the current first state machine state corresponding to the smart contract, and the second state machine manager is triggered to call the second state machine to obtain the current second state machine state corresponding to the function function. The state change of the function function needs to be comprehensively judged in combination with the state of the smart contract to which it belongs and its own state. Therefore, the first state machine manager and the second state machine manager need to work at the same time to obtain the state of the smart contract and the function function. On this basis, it is judged whether the current first state machine state and the current second state machine state both meet the change conditions.
S13:如果变更对象的当前状态满足变更条件,则触发对应层级的状态机管理器调用相应层级的状态机,以根据状态变更请求对变更对象的状态进行变更。S13: If the current state of the change object meets the change condition, the state machine manager of the corresponding level is triggered to call the state machine of the corresponding level to change the state of the change object according to the state change request.
本实施例中,如果变更对象的当前状态满足变更条件,则触发对应层级的状态机管理器调用相应层级的状态机,以根据状态变更请求对变更对象的状态进行变更。包括(如图3):In this embodiment, if the current state of the change object meets the change condition, the state machine manager of the corresponding level is triggered to call the state machine of the corresponding level to change the state of the change object according to the state change request. Including (as shown in Figure 3):
S131:如果状态变更请求的变更对象的层级为智能合约层,触发第一状态机管理器调用第一状态机,以根据状态变更请求对智能合约的状态进行变更。S131: If the level of the change object of the state change request is the smart contract layer, trigger the first state machine manager to call the first state machine to change the state of the smart contract according to the state change request.
本实施例中,在对智能合约进行状态检测时,需要判断当前第一状态机状态是否属于状态变更请求要求的变更后状态的前置状态,如果是,则判定当前第一状态机状态满足变更条件。需要说明是,本实施例中的第一状态机的状态包括部署、执行、停止、升级、销毁,如图4所示。第二状态机包括部署、执行、停止、升级,如图5所示。In this embodiment, when the state of the smart contract is detected, it is necessary to determine whether the current state of the first state machine belongs to the pre-state of the changed state required by the state change request. If so, it is determined that the current state of the first state machine meets the change condition. It should be noted that the state of the first state machine in this embodiment includes deployment, execution, stop, upgrade, and destruction, as shown in Figure 4. The second state machine includes deployment, execution, stop, and upgrade, as shown in Figure 5.
本实施例中,状态变更请求要求的变更后状态的前置状态为可以变更为请求要求状态的状态,例如,对于第一状态机,部署状态为执行状态的前置状态,执行状态为停止状态的前置状态。 In this embodiment, the predecessor state of the changed state required by the state change request is a state that can be changed to the requested state. For example, for the first state machine, the deployment state is the predecessor state of the execution state, and the execution state is the predecessor state of the stop state.
S132:如果状态变更请求的变更对象的层级为智能合约内部的功能函数层,触发第二状态机管理器调用第二状态机,以根据状态变更请求对功能函数的状态进行变更。S132: If the level of the change object of the state change request is the functional layer within the smart contract, the second state machine manager is triggered to call the second state machine to change the state of the functional function according to the state change request.
本实施例中,在对智能合约内部的功能函数进行状态检测时,需要先判断当前第二状态机状态是否满足第一状态机状态的层级约束条件,如果是,则判定第一状态机状态和第二状态机状态均满足变更条件。所谓层级约束条件即微观上的智能合约状态机(第二状态机)要遵循宏观的智能合约状态机(第一状态机)的约束,在第一状态机规则允许下进行第二状态机的变更。例如,第一状态机处于停止状态,那么第二状态机不能处于执行、部署、升级状态,必须符合第一状态机的约束。另外,本实施例的每个功能函数在运行前,必须判断所处的状态,如果第一状态机处于“执行”状态且第二状态机处于“执行”状态,则可以执行。如果其第二状态机处于其他状态则禁止执行。In this embodiment, when the state of the functional function inside the smart contract is detected, it is necessary to first determine whether the current state of the second state machine satisfies the hierarchical constraints of the state of the first state machine. If so, it is determined that both the state of the first state machine and the state of the second state machine meet the change conditions. The so-called hierarchical constraints mean that the microscopic smart contract state machine (second state machine) must follow the constraints of the macroscopic smart contract state machine (first state machine), and the second state machine must be changed under the permission of the first state machine rules. For example, if the first state machine is in a stopped state, then the second state machine cannot be in an execution, deployment, or upgrade state, and must comply with the constraints of the first state machine. In addition, before each functional function of this embodiment is run, it must determine the state it is in. If the first state machine is in the "execution" state and the second state machine is in the "execution" state, it can be executed. If its second state machine is in other states, execution is prohibited.
本实施例中,当满足层级约束条件时,还可以进一步判断当前第二状态机状态是否属于状态变更请求要求的变更后状态的前置状态,如果是,则判定第一状态机状态和第二状态机状态均满足变更条件。判断过程与宏观智能合约一致,在此不进行赘述。In this embodiment, when the hierarchical constraint condition is met, it is further possible to determine whether the current second state machine state is a pre-state of the changed state required by the state change request. If so, it is determined that both the first state machine state and the second state machine state meet the change condition. The judgment process is consistent with the macro smart contract and will not be repeated here.
本实施例采用两个状态机,智能合约生命周期执行流程如图6所示,可以实现细粒度智能合约生命周期管理,当某个函数出现漏洞时,可以只需停止相应的函数,稍后进行升级处理,但是不影响智能合约中其他功能的执行,保证区块链系统的稳定性。当整个智能合约出现漏洞时,可以调用第一状态机,实现整个智能合约的状态变更,保护区块链业务的安全。This embodiment uses two state machines, and the smart contract lifecycle execution process is shown in Figure 6, which can realize fine-grained smart contract lifecycle management. When a function has a vulnerability, you only need to stop the corresponding function and upgrade it later, but it will not affect the execution of other functions in the smart contract, ensuring the stability of the blockchain system. When the entire smart contract has a vulnerability, the first state machine can be called to realize the state change of the entire smart contract and protect the security of the blockchain business.
可见,本申请实施例先获取由任意智能合约参与方发起的状态变更请求;然后根据状态变更请求的变更对象的层级不同触发对应层级的状态机管理器调用对应层级的状态机,以对变更对象的当前状态进行检测;其中,变更对象的层级包括智能合约层或智能合约内部的功能函数层,不同层级的变更对象对应的状态机管理器及状态机不同;如果变更对象的当前状态满足变更条件,则触发对应层级的状态机管理器调用相应层级的状态机,以根据状态变更请求对变更对象的状态进行变更。本申请实施例设计多层次生命周期管理,由变更对象所处层级的状态机管理器和状态机共同作用来检测变更对象的当前状态,在满足变更条件的情况下进行状态变更。在宏观的智能合约层面上实现整个智能合约的生命周期管理,在微功能函数层面上实现函数级别细粒度的生命周期管理,从而对智能合约进行漏洞防护,保证区块链系统的稳定性。It can be seen that the embodiment of the present application first obtains the state change request initiated by any smart contract participant; then, according to the different levels of the change object of the state change request, the state machine manager of the corresponding level is triggered to call the state machine of the corresponding level to detect the current state of the change object; wherein, the level of the change object includes the smart contract layer or the functional function layer inside the smart contract, and the state machine manager and state machine corresponding to the change object of different levels are different; if the current state of the change object meets the change condition, the state machine manager of the corresponding level is triggered to call the state machine of the corresponding level to change the state of the change object according to the state change request. The embodiment of the present application designs multi-level life cycle management, and the state machine manager and state machine of the level where the change object is located work together to detect the current state of the change object, and change the state when the change condition is met. The life cycle management of the entire smart contract is realized at the macro level of the smart contract, and the fine-grained life cycle management of the function level is realized at the micro-function level, so as to protect the smart contract from vulnerabilities and ensure the stability of the blockchain system.
图7为本申请实施例提供的一种可选的状态变更方法流程图。参见图7所示,该状态变更方法包括:FIG7 is a flow chart of an optional state change method provided in an embodiment of the present application. Referring to FIG7 , the state change method includes:
S21:获取由任意智能合约参与方发起的状态变更请求及状态变更请求的门限签名;其中,门限签名由智能合约参与方通过门限签名的方式对状态变更请求进行签名得到。S21: Obtain a state change request initiated by any smart contract participant and a threshold signature of the state change request; wherein the threshold signature is obtained by the smart contract participant signing the state change request by means of a threshold signature.
针对智能合约生命周期管理一般用管理员发起,或者基于简单投票规则,没有有效的权限控制。本实施例在前述实施例的基础上设计了基于门限签名的智能合约权限管理原则,实现了有效的智能合约生命周期的权限管理。在获取由任意智能合约参与方发起的状态变更请求的同时,还需要获取到相应的门限签名。门限签名由智能合约参与方通过门限签名的方式对状态变更请求进行签名得到。The life cycle management of smart contracts is generally initiated by administrators or based on simple voting rules, without effective authority control. This embodiment designs a smart contract authority management principle based on threshold signatures on the basis of the previous embodiment, and realizes effective authority management of the smart contract life cycle. While obtaining a state change request initiated by any smart contract participant, it is also necessary to obtain the corresponding threshold signature. The threshold signature is obtained by the smart contract participant signing the state change request by means of a threshold signature.
本实施例中,智能合约参与方进行门限签名的步骤包括(如图8):In this embodiment, the steps for the smart contract participants to perform threshold signature include (as shown in Figure 8):
S211:密钥生成中心通过门限秘密共享算法生成基准私钥及对应的基准私钥份额,并根据目标需求为不同的智能合约参与方分配及下发不同的基准私钥份额。S211: The key generation center generates a base private key and a corresponding base private key share through a threshold secret sharing algorithm, and allocates and issues different base private key shares to different smart contract participants according to target requirements.
本实施例中,智能合约参与方向密钥生成中心请求门限签名密钥生成。密钥生成中心通过门限秘密共享算法生成基准私钥及对应的基准私钥份额,并根据目标需求为不同的智能合约参与方分配及下发不同的基准私钥份额。门限签名采用加权的方式,每个参与方根据可信程度、对智能合约影响程度,分配不同私钥份额,实现权重的分配。In this embodiment, the smart contract participants request the key generation center to generate the threshold signature key. The key generation center generates the base private key and the corresponding base private key share through the threshold secret sharing algorithm, and allocates and issues different base private key shares to different smart contract participants according to the target requirements. The threshold signature adopts a weighted approach, and each participant is allocated different private key shares according to the degree of trustworthiness and the degree of influence on the smart contract to achieve weight distribution.
可选的,密钥生成中心设定椭圆曲线上的公开参数,实现系统的初始化。密钥生成中心生成门限签名的公钥P和私钥d。设置门限签名的门限阈值为t+1,利用Shamir门限秘密共享将私钥分为n份,将n份私钥发送给智能合约参与方。其中,智能合约制定者拥有至少1份私钥份额,智能合约使用者至少拥有0份私钥份额,智能合约仲裁者至少拥有1份私钥份额。每个智能合约参与方具有不同的私钥份额,可以实现不同权重 的控制权限。Optionally, the key generation center sets the public parameters on the elliptic curve to initialize the system. The key generation center generates the public key P and private key d for the threshold signature. Set the threshold of the threshold signature to t+1, use Shamir threshold secret sharing to divide the private key into n shares, and send the n private keys to the smart contract participants. Among them, the smart contract maker has at least 1 private key share, the smart contract user has at least 0 private key shares, and the smart contract arbitrator has at least 1 private key share. Each smart contract participant has a different private key share, which can achieve different weights control permissions.
S212:各个智能合约参与方生成多个临时私钥份额、多个临时公钥份额并将多个临时私钥份额、多个临时公钥份额分别发送至其他智能合约参与方,以及接收其他智能合约参与方发送的临时私钥份额、临时公钥份额。S212: Each smart contract participant generates multiple temporary private key shares and multiple temporary public key shares and sends the multiple temporary private key shares and multiple temporary public key shares to other smart contract participants respectively, and receives the temporary private key shares and temporary public key shares sent by other smart contract participants.
S213:各个智能合约参与方基于自身临时私钥份额及接收到的临时私钥份额计算临时私钥共享份额,并基于自身临时公钥份额及接收到的公钥私钥份额计算临时公钥共享份额。S213: Each smart contract participant calculates a temporary private key sharing share based on its own temporary private key share and the received temporary private key share, and calculates a temporary public key sharing share based on its own temporary public key share and the received public key and private key shares.
S214:各个智能合约参与方根据临时公钥共享份额计算基准签名参数。S214: Each smart contract participant calculates the base signature parameters based on the temporary public key sharing share.
本实施例中,智能合约制定者将公钥P附加到智能合约代码中,作为智能合约的一部分。智能合约参与方对请求执行门限签名技术(这些智能合约参与方至少持有2t+1个私钥份额,2t+1<n。门限签名的特点,门限阈值设置为t+1,那么至少需要2t+1个人参与)。首先各个智能合约参与方生成多个临时私钥份额、多个临时公钥份额并将多个临时私钥份额、多个临时公钥份额分别发送至其他智能合约参与方,以及接收其他智能合约参与方发送的临时私钥份额、临时公钥份额。然后各个智能合约参与方基于自身临时私钥份额及接收到的临时私钥份额计算临时私钥共享份额,并基于自身临时公钥份额及接收到的临时公钥份额计算临时公钥共享份额。接着各个智能合约参与方根据临时公钥共享份额计算基准签名参数。In this embodiment, the smart contract developer attaches the public key P to the smart contract code as part of the smart contract. The smart contract participants execute the threshold signature technology on the request (these smart contract participants hold at least 2t+1 private key shares, 2t+1<n. The characteristic of threshold signature is that the threshold is set to t+1, so at least 2t+1 individuals are required to participate). First, each smart contract participant generates multiple temporary private key shares, multiple temporary public key shares, and sends the multiple temporary private key shares and multiple temporary public key shares to other smart contract participants, and receives the temporary private key shares and temporary public key shares sent by other smart contract participants. Then each smart contract participant calculates the temporary private key sharing share based on its own temporary private key share and the received temporary private key share, and calculates the temporary public key sharing share based on its own temporary public key share and the received temporary public key share. Then each smart contract participant calculates the base signature parameter based on the temporary public key sharing share.
可选的,智能合约参与方各自产生对应的临时私钥的共享份额ki(随机数)。然后根据临时私钥的共享份额计算临时私钥的共享份额ki的逆。根据临时公钥的共享份额ki0G,ki1G,..,ki(2t+1)G计算临时私钥k的公钥(x,y)。根据临时公钥(x,y)计算基准签名参数r。Optionally, each smart contract participant generates a corresponding share of the temporary private key k i (random number). Then, the inverse of the share of the temporary private key k i is calculated based on the share of the temporary private key. The public key (x, y) of the temporary private key k is calculated based on the share of the temporary public key k i0 G, k i1 G, .., k i(2t+1) G. The reference signature parameter r is calculated based on the temporary public key (x, y).
S215:各个智能合约参与方分别对状态变更请求进行哈希运算得到第一哈希结果,并分别对哈希结果进行签名得到对应的签名份额,以及根据各个签名份额采用门限签名恢复出基准签名份额。S215: Each smart contract participant performs a hash operation on the state change request to obtain a first hash result, and signs the hash result to obtain a corresponding signature share, and uses a threshold signature to restore a base signature share based on each signature share.
S216:各个智能合约参与方根据基准私钥份额、临时私钥份额及临时公钥份额计算出基准签名参数,得到包含基准签名参数与基准签名份额的门限签名。S216: Each smart contract participant calculates a base signature parameter based on the base private key share, the temporary private key share, and the temporary public key share to obtain a threshold signature including the base signature parameter and the base signature share.
本实施例中,各个智能合约参与方分别对状态变更请求进行哈希运算得到第一哈希结果,并分别对哈希结果进行签名得到对应的签名份额,以及根据各个签名份额采用门限签名恢复出基准签名份额。然后各个智能合约参与方根据基准私钥份额、临时私钥份额及临时公钥份额计算出基准签名参数,得到包含基准签名参数与基准签名份额的门限签名。In this embodiment, each smart contract participant performs a hash operation on the state change request to obtain a first hash result, and signs the hash result to obtain a corresponding signature share, and restores the reference signature share using a threshold signature based on each signature share. Then, each smart contract participant calculates the reference signature parameter based on the reference private key share, the temporary private key share, and the temporary public key share to obtain a threshold signature containing the reference signature parameter and the reference signature share.
以智能合约“部署”为例,对于第一状态机变更“部署”操作deploy(deploy数据中包括表示智能合约的信息)进行hash运算,得到运算结果e。对e计算签名份额si。利用签名份额si计算得出签名s。最后得到签名结果(r,s)。Taking the smart contract "deployment" as an example, a hash operation is performed on the first state machine change "deployment" operation deploy (deploy data includes information representing the smart contract) to obtain the operation result e. The signature share si is calculated for e. The signature share si is used to calculate the signature s. Finally, the signature result (r, s) is obtained.
S22:根据状态变更请求的变更对象的层级不同触发对应层级的状态机管理器基于状态变更请求对门限签名进行验签。S22: According to the different levels of the change object of the state change request, the state machine manager of the corresponding level is triggered to verify the threshold signature based on the state change request.
本实施例中,在获取到请求及门限签名之后,根据状态变更请求的变更对象的层级不同触发对应层级的状态机管理器基于状态变更请求对门限签名进行验签。如果所述状态变更请求的变更对象的层级为智能合约层,则触发第一状态机管理器基于状态变更请求对门限签名进行验签。如果状态变更请求的变更对象的层级为智能合约内部的功能函数层,则触发第二状态机管理器基于状态变更请求对门限签名进行验签。In this embodiment, after obtaining the request and threshold signature, the state machine manager of the corresponding level is triggered to verify the threshold signature based on the state change request according to the different levels of the change object of the state change request. If the level of the change object of the state change request is the smart contract layer, the first state machine manager is triggered to verify the threshold signature based on the state change request. If the level of the change object of the state change request is the function layer inside the smart contract, the second state machine manager is triggered to verify the threshold signature based on the state change request.
本实施例中,状态机管理器对门限签名进行验签的步骤包括(如图9):In this embodiment, the steps of the state machine manager verifying the threshold signature include (as shown in FIG. 9 ):
S221:状态机管理器从智能合约中获取与基准私钥对应的基准公钥,并对状态变更请求进行哈希运算得到第二哈希结果,以及利用基准签名份额的乘法逆、基准公钥、第二哈希结果计算验签公钥共享份额。S221: The state machine manager obtains the reference public key corresponding to the reference private key from the smart contract, performs a hash operation on the state change request to obtain a second hash result, and calculates the verification public key sharing share using the multiplicative inverse of the reference signature share, the reference public key, and the second hash result.
S222:状态机管理器根据验签公钥共享份额计算验签签名参数,并判断基准签名参数与验签签名参数是否相等,如果是,则判定验签通过。 S222: The state machine manager calculates the signature verification parameters according to the shared share of the signature verification public key, and determines whether the reference signature parameters are equal to the signature verification parameters. If so, the signature verification is determined to be successful.
本实施例中,状态机管理器首先从智能合约中获取与基准私钥对应的基准公钥,并对状态变更请求进行哈希运算得到第二哈希结果,以及利用基准签名份额的乘法逆、基准公钥、第二哈希结果计算验签公钥共享份额。然后状态机管理器根据验签公钥共享份额计算验签签名参数,并判断基准签名参数与验签签名参数是否相等,如果是,则判定验签通过。In this embodiment, the state machine manager first obtains the reference public key corresponding to the reference private key from the smart contract, performs a hash operation on the state change request to obtain a second hash result, and calculates the verification public key share using the multiplicative inverse of the reference signature share, the reference public key, and the second hash result. Then the state machine manager calculates the verification signature parameter based on the verification public key share, and determines whether the reference signature parameter is equal to the verification signature parameter. If so, the verification is determined to be successful.
仍以智能合约“部署”为例,将智能合约第一状态机变更“部署”操作发送到第一状态机管理器中,第一状态机管理器进行签名验证操作。对于第一状态机变更“部署”操作deploy(deploy数据中包括表示智能合约的信息)进行hash运算,得到运算结果e。计算签名s的乘法逆s-1。计算临时公钥(x′,y′)。计算签名参数u,验证u是否等于r。如果相等,则签名通过。第一状态机管理器将智能合约的第一状态机变更到“部署”状态。Still taking the smart contract "deployment" as an example, the "deployment" operation of the first state machine of the smart contract is sent to the first state machine manager, and the first state machine manager performs a signature verification operation. A hash operation is performed on the first state machine change "deployment" operation deploy (the deploy data includes information representing the smart contract) to obtain the operation result e. Calculate the multiplicative inverse s -1 of the signature s. Calculate the temporary public key (x′, y′). Calculate the signature parameter u and verify whether u is equal to r. If they are equal, the signature passes. The first state machine manager changes the first state machine of the smart contract to the "deployment" state.
S23:如果验签通过,则根据状态变更请求的变更对象的层级不同触发对应层级的状态机管理器调用对应层级的状态机,以对变更对象的当前状态进行检测。S23: If the signature verification is passed, the state machine manager of the corresponding level is triggered to call the state machine of the corresponding level according to the different levels of the change object of the state change request, so as to detect the current state of the change object.
S24:如果变更对象的当前状态满足变更条件,则触发对应层级的状态机管理器调用相应层级的状态机,以根据状态变更请求对变更对象的状态进行变更。S24: If the current state of the change object meets the change condition, the state machine manager of the corresponding level is triggered to call the state machine of the corresponding level to change the state of the change object according to the state change request.
本实施例中,关于上述步骤S23和步骤S24的过程,可以参考前述实施例中公开的相应内容,在此不再进行赘述。In this embodiment, regarding the processes of the above-mentioned step S23 and step S24, reference may be made to the corresponding contents disclosed in the above-mentioned embodiments, and no further details will be given here.
可见,本申请实施例为了提高智能合约的生命周期管理的权限控制,采用门限签名方式实现两层智能合约生命周期的状态机变化的权限控制。使得不同的参与方具有不同的私钥份额,即不同的参与方有不同的修改智能合约生命周期的权限。采用门限签名的方式,无需所有参与方进行签名,只需要达到相应的签名门限即可。It can be seen that in order to improve the authority control of the life cycle management of the smart contract, the embodiment of the present application adopts the threshold signature method to realize the authority control of the state machine change of the two-layer smart contract life cycle. Different participants have different private key shares, that is, different participants have different permissions to modify the life cycle of the smart contract. By adopting the threshold signature method, all participants do not need to sign, they only need to reach the corresponding signature threshold.
下面分别对智能合约、智能合约内部的功能函数的状态变更的门限签名及验签过程进行举例说明。The following examples illustrate the threshold signature and signature verification process of smart contracts and the state changes of functional functions within smart contracts.
1、智能合约的执行操作1. Execution of smart contracts
将智能合约的第一状态机的“部署”状态变更到“执行”状态。智能合约参与方对智能合约的“执行”请求进行门限签名技术。首先智能合约参与方各自产生对应的临时私钥的共享份额ki(随机数,这里的ki是重新产生的)。然后根据临时私钥的共享份额计算临时私钥的共享份额ki的逆。根据临时公钥的共享份额ki0G,ki1G,..,ki(2t+1)G计算临时私钥的k公钥(x,y)。根据临时公钥(x,y)计算签名参数r。对于第一状态机变更“执行”请求execute(execute数据中包括表示智能合约的信息)进行hash运算,得到运算结果e。对e计算签名份额si。利用签名份额si计算得出签名s。最后得到签名结果(r,s)。Change the "deployment" state of the first state machine of the smart contract to the "execution" state. The smart contract participants perform threshold signature technology on the "execution" request of the smart contract. First, each smart contract participant generates a corresponding shared share k i of the temporary private key (a random number, where k i is newly generated). Then, the inverse of the shared share k i of the temporary private key is calculated based on the shared share of the temporary private key. The k public key (x, y) of the temporary private key is calculated based on the shared share k i0 G, k i1 G, .., k i(2t+1) G of the temporary public key. The signature parameter r is calculated based on the temporary public key (x, y). A hash operation is performed on the "execution" request execute (the execute data includes information representing the smart contract) for the first state machine change to obtain the operation result e. Calculate the signature share s i for e. The signature s is calculated using the signature share s i . Finally, the signature result (r, s) is obtained.
将智能合约第一状态机变更“执行”操作发送到第一状态机管理器中,第一状态机管理器进行签名验证操作。对于第一状态机变更“执行”操作execute(execute数据中包括表示智能合约的信息)进行hash运算,得到运算结果e。计算签名s的乘法逆s-1。计算临时公钥(x′,y′)。计算签名参数u,验证u是否等于r。如果相等,则签名通过。判断智能合约是否处于“部署”或者“停止”状态,如果处于这两个状态。则第一状态机管理器将智能合约的状态机变更到“执行”状态。Send the "execute" operation of the first state machine change of the smart contract to the first state machine manager, and the first state machine manager performs a signature verification operation. Perform a hash operation on the "execute" operation of the first state machine change (the execute data includes information representing the smart contract) to obtain the operation result e. Calculate the multiplicative inverse s -1 of the signature s. Calculate the temporary public key (x′, y′). Calculate the signature parameter u and verify whether u is equal to r. If they are equal, the signature passes. Determine whether the smart contract is in the "deployment" or "stop" state. If it is in these two states. The first state machine manager changes the state machine of the smart contract to the "execution" state.
2、智能合约的功能函数func1的停止状态操作2. Stop state operation of the function func1 of the smart contract
智能合约参与方对智能合约的函数func1的“停止”操作执行门限签名技术。首先智能合约参与方各自产生对应的临时私钥的共享份额ki(随机数,这里的ki是重新产生的)。然后根据临时私钥的共享份 额计算临时私钥的共享份额ki的逆。根据临时公钥的共享份额ki0G,ki1G,..,ki(2t+1)G计算临时私钥k的公钥(x,y)。根据临时公钥(x,y)计算签名参数r。对于函数func1的第二状态机变更“停止”操作stop(stop数据中包括表示智能合约的信息)进行hash运算,得到运算结果e。对e计算签名份额si。利用签名份额si计算得出签名s。最后得到签名结果(r,s)。The smart contract participants perform threshold signature technology on the "stop" operation of the smart contract function func1. First, each smart contract participant generates a corresponding share of the temporary private key k i (a random number, where k i is newly generated). Then, based on the share of the temporary private key, Calculate the inverse of the shared share k i of the temporary private key. Calculate the public key (x, y) of the temporary private key k based on the shared share k i0 G, k i1 G, .., k i(2t+1) G of the temporary public key. Calculate the signature parameter r based on the temporary public key (x, y). For the second state machine of the function func1, change the "stop" operation stop (the stop data includes information representing the smart contract) to perform a hash operation to obtain the operation result e. Calculate the signature share s i for e. Calculate the signature s using the signature share s i . Finally, obtain the signature result (r, s).
将智能合约的函数func1的第二状态机变更“停止”操作发送到第二状态机管理器中,第二状态机管理器进行签名验证操作。对于函数func1的第二状态机变更“停止”操作stop(stop数据中包括表示智能合约的信息)进行hash运算,得到运算结果e。计算签名s的乘法逆s-1。计算临时公钥(x′,y′)。计算签名参数u,验证u是否等于r。如果相等,则签名通过。判断智能合约是否处于“执行”状态,且函数func1是否处于“执行”状态。如果均处于“执行”状态,则函数func1的第二状态机管理器将函数func1的状态机变更到“停止”状态。此时,第二状态机的操作是在第一状态机的约束下执行的。The second state machine change "stop" operation of the function func1 of the smart contract is sent to the second state machine manager, and the second state machine manager performs a signature verification operation. Perform a hash operation on the second state machine change "stop" operation stop of the function func1 (the stop data includes information representing the smart contract) to obtain the operation result e. Calculate the multiplicative inverse s -1 of the signature s. Calculate the temporary public key (x′, y′). Calculate the signature parameter u and verify whether u is equal to r. If they are equal, the signature passes. Determine whether the smart contract is in the "execution" state and whether the function func1 is in the "execution" state. If both are in the "execution" state, the second state machine manager of the function func1 changes the state machine of the function func1 to the "stop" state. At this time, the operation of the second state machine is performed under the constraints of the first state machine.
特别的,门限签名及验签的算法实现过程如下:In particular, the threshold signature and verification algorithm implementation process is as follows:
密钥生成中心首先设定椭圆曲线上的公开参数,包括p、q、E和G,其中p是大素数,E是定义在有限域Fp上的椭圆曲线,G=(x,y)是椭圆曲线E上q阶的基点。密钥生成中心将智能合约参与方的签名私钥设置为d,公钥为P=dG。利用私钥d实现智能合约生命周期变更的签名。The key generation center first sets the public parameters on the elliptic curve, including p, q, E and G, where p is a large prime number, E is an elliptic curve defined on a finite field Fp , and G = (x, y) is the base point of the qth order on the elliptic curve E. The key generation center sets the signature private key of the smart contract participant to d, and the public key to P = dG. The private key d is used to implement the signature of the smart contract life cycle change.
密钥生成中心执行Shamir门限秘密共享方案,密钥生成中心将椭圆曲线的私钥d拆分成n份,分发给智能合约参与方,这里参与方小于等于n个,根据参与方的重要程度、可信程度,参与方之间协商持有份额的多少。为了方便表示,将n份私钥表示为U1,U2,…,Un′拥有(注意:Ui,Uj可以属于同一个智能合约参与方)。为了实现智能合约变更的安全性,智能合约仲裁者至少拥有1份私钥。任意t+1个或者以上的智能合约参与方一起可以恢复私钥d,从而对智能合约状态机变更的签名。The key generation center implements the Shamir threshold secret sharing scheme. The key generation center splits the private key d of the elliptic curve into n parts and distributes them to the smart contract participants. Here, the number of participants is less than or equal to n. The participants negotiate the number of shares to be held based on the importance and credibility of the participants. For the convenience of representation, the n private keys are represented as U 1 , U 2 , …, Un′ (Note: U i , U j can belong to the same smart contract participant). In order to achieve the security of smart contract changes, the smart contract arbitrator has at least 1 private key. Any t+1 or more smart contract participants can recover the private key d together to sign the changes to the smart contract state machine.
私钥份额生成过程为:The process of generating private key shares is:
1、密钥生成中心在构造t阶多项式其中私钥d=f(0)=a0。ai表示多项式的系数。1. The key generation center constructs a t-order polynomial Wherein the private key d = f(0) = a 0 . a i represents the coefficient of the polynomial.
2、密钥生成中心计算di=f(i),并通过建立SSL可信通道将部分私钥di分别发送给智能合约参与方。2. The key generation center calculates d i = f(i) and sends the partial private key d i to the smart contract participants by establishing an SSL trusted channel.
3、智能合约参与方Ui将di作为自己的私钥秘密保存,不泄露给任何人。3. Smart contract participant U i keeps di as its own private key in secret and does not disclose it to anyone.
此时,任意t+1个智能合约参与方集合C可以通过拉格朗日插值公式 At this time, any set C of t+1 smart contract participants can be interpolated by the Lagrange interpolation formula
临时私钥份额产生:Temporary private key share generation:
1、首先选择2t+1′个智能合约参与方,2t+1′个智能合约参与方各自生成一个2t阶多项式,i={1,2,…,2t+1},j={1,2,…,2t+1},kij∈Zq1. First, 2t+1′ smart contract participants are selected, and each of the 2t+1′ smart contract participants generates a 2t-order polynomial, i = {1, 2, ..., 2t+1}, j = {1, 2, ..., 2t+1}, k ij ∈ Z q .
2、对于第i′个参与者的多项式为:2. The polynomial for the i′th participant is:
fi(x)=ki0+ki1x+...+ki(2t+1)x2tmod q fi (x)= ki0 + ki1x +...+ ki(2t+1) x2tmodq
3、然后每个智能合约参与方ifi(j)j二{1,2,…,2t+1}秘密的发送给其他智能合约参与方,当然也将临时公钥的共享份额ki0G,.ki1G,..,ki(2t+1)G发送给其他智能合约参与方。3. Then each smart contract participant i secretly sends fi (j)j={1, 2,…, 2t+1} to other smart contract participants, and of course also sends the shared shares of the temporary public key k i0 G, .k i1 G, .., k i(2t+1) G to other smart contract participants.
4、其他智能合约参与方各自计算对应的临时私钥的共享份额
ki=∑fj(i),j={1,2,…,2t+1};
4. Other smart contract participants each calculate the corresponding share of the temporary private key
k i =∑fj(i), j={1, 2, ..., 2t+1};
5、同时计算临时私钥份额ki的逆 5. Simultaneously calculate the inverse of the temporary private key share k i
6、计算临时私钥k的公钥 6. Calculate the public key of the temporary private key k
7、计算前面参数r=x mod q。7. Calculate the previous parameter r = x mod q.
t+1签名产生:T+1 signature generation:
1、对于智能合约状态变更事务message进行hash运算得到:
e=sha256(sha256(message))
1. Perform hash calculation on the smart contract status change transaction message to obtain:
e = sha256(sha256(message))
2、计算si,i={1,2,…,2t+1}2. Calculate s i , i = {1, 2, ..., 2t+1}
其中di为私钥对应的共享份额。 Where d i is the shared share corresponding to the private key.
3、采用门限签名恢复s。3. Use threshold signature to recover s.
4、签名为(r,s)。4. The signature is (r, s).
签名验证:Signature Verification:
1、公钥为P=dG,签名为(r,s)1. The public key is P = dG, and the signature is (r, s)
2、对于消息明文进行hash运算得到:e=sha256(sha256(message))2. Perform a hash operation on the plain text of the message to obtain: e = sha256 (sha256 (message))
3、计算s的乘法逆,s-13. Compute the multiplicative inverse of s, s -1 .
4、计算s-1(eG+r(PK))=(x′,y′)4. Calculate s -1 (eG + r (PK)) = (x', y')
5、计算u=x′mod q,验证u是否等于r。 5. Calculate u = x′ mod q and verify whether u is equal to r.
参见图10所示,本申请实施例还相应公开了一种状态变更装置,包括:As shown in FIG10 , the embodiment of the present application further discloses a state changing device, including:
请求获取模块11,被配置为获取由任意智能合约参与方发起的状态变更请求;A request acquisition module 11 is configured to acquire a state change request initiated by any smart contract participant;
状态分级检测模块12,被配置为根据状态变更请求的变更对象的层级不同触发对应层级的状态机管理器调用对应层级的状态机,以对变更对象的当前状态进行检测;其中,变更对象的层级包括智能合约层或智能合约内部的功能函数层,不同层级的变更对象对应的状态机管理器及状态机不同;The state hierarchical detection module 12 is configured to trigger the state machine manager of the corresponding level to call the state machine of the corresponding level according to the different levels of the change object of the state change request, so as to detect the current state of the change object; wherein the level of the change object includes the smart contract layer or the function layer inside the smart contract, and the state machine managers and state machines corresponding to the change objects of different levels are different;
状态变更模块13,被配置为如果变更对象的当前状态满足变更条件,则触发对应层级的状态机管理器调用相应层级的状态机,以根据状态变更请求对变更对象的状态进行变更。The state change module 13 is configured to trigger the state machine manager of the corresponding level to call the state machine of the corresponding level if the current state of the change object meets the change condition, so as to change the state of the change object according to the state change request.
可见,本申请实施例先获取由任意智能合约参与方发起的状态变更请求;然后根据状态变更请求的变更对象的层级不同触发对应层级的状态机管理器调用对应层级的状态机,以对变更对象的当前状态进行检测;其中,变更对象的层级包括智能合约层或智能合约内部的功能函数层,不同层级的变更对象对应的状态机管理器及状态机不同;如果变更对象的当前状态满足变更条件,则触发对应层级的状态机管理器调用相应层级的状态机,以根据状态变更请求对变更对象的状态进行变更。本申请实施例设计多层次生命周期管理,由变更对象所处层级的状态机管理器和状态机共同作用来检测变更对象的当前状态,在满足变更条件的情况下进行状态变更。在宏观的智能合约层面上实现整个智能合约的生命周期管理,在微功能函数层面上实现函数级别细粒度的生命周期管理,从而对智能合约进行漏洞防护,保证区块链系统的稳定性。It can be seen that the embodiment of the present application first obtains the state change request initiated by any smart contract participant; then, according to the different levels of the change object of the state change request, the state machine manager of the corresponding level is triggered to call the state machine of the corresponding level to detect the current state of the change object; wherein, the level of the change object includes the smart contract layer or the functional function layer inside the smart contract, and the state machine manager and state machine corresponding to the change object of different levels are different; if the current state of the change object meets the change condition, the state machine manager of the corresponding level is triggered to call the state machine of the corresponding level to change the state of the change object according to the state change request. The embodiment of the present application designs multi-level life cycle management, and the state machine manager and state machine of the level where the change object is located work together to detect the current state of the change object, and change the state when the change condition is met. The life cycle management of the entire smart contract is realized at the macro level of the smart contract, and the fine-grained life cycle management of the function level is realized at the micro-function level, so as to protect the smart contract from vulnerabilities and ensure the stability of the blockchain system.
在一些可选的实施例中,状态分级检测模块12,包括:In some optional embodiments, the state classification detection module 12 includes:
第一触发单元,被配置为如果状态变更请求的变更对象的层级为智能合约层,则触发第一状态机管理器调用第一状态机,以获取与智能合约对应的当前第一状态机状态;A first triggering unit is configured to trigger the first state machine manager to call the first state machine to obtain a current first state machine state corresponding to the smart contract if the level of the change object of the state change request is the smart contract layer;
第一判断单元,被配置为判断当前第一状态机状态是否满足变更条件;A first judging unit is configured to judge whether the current state of the first state machine satisfies a change condition;
第二触发单元,被配置为如果状态变更请求的变更对象的层级为智能合约内部的功能函数层,则触发第一状态机管理器调用第一状态机获取与智能合约对应的当前第一状态机状态,同时触发第二状态机管理器调用第二状态机获取与功能函数对应的当前第二状态机状态;The second trigger unit is configured to trigger the first state machine manager to call the first state machine to obtain the current first state machine state corresponding to the smart contract, and trigger the second state machine manager to call the second state machine to obtain the current second state machine state corresponding to the function if the level of the change object of the state change request is the function layer inside the smart contract;
第二判断单元,被配置为判断当前第一状态机状态和当前第二状态机状态是否均满足变更条件。The second judgment unit is configured to judge whether the current first state machine state and the current second state machine state both meet the change condition.
在一些可选的实施例中,状态变更模块13,包括:In some optional embodiments, the state change module 13 includes:
第三触发单元,被配置为触发第一状态机管理器调用第一状态机,以根据状态变更请求对智能合约的状态进行变更;A third triggering unit is configured to trigger the first state machine manager to call the first state machine to change the state of the smart contract according to the state change request;
第四触发单元,被配置为触发第二状态机管理器调用第二状态机,以根据状态变更请求对功能函数的状态进行变更。The fourth trigger unit is configured to trigger the second state machine manager to call the second state machine to change the state of the functional function according to the state change request.
在一些可选的实施例中,第一判断单元,被配置为判断当前第一状态机状态是否属于状态变更请求要求的变更后状态的前置状态,如果是,则判定当前第一状态机状态满足变更条件。In some optional embodiments, the first judgment unit is configured to judge whether the current first state machine state is a pre-state of the changed state required by the state change request, and if so, determine that the current first state machine state meets the change condition.
在一些可选的实施例中,第二判断单元,被配置为判断当前第二状态机状态是否满足第一状态机状态的层级约束条件,并判断当前第二状态机状态是否属于状态变更请求要求的变更后状态的前置状态,如果是,则判定第一状态机状态和第二状态机状态均满足变更条件。In some optional embodiments, the second judgment unit is configured to determine whether the current second state machine state satisfies the hierarchical constraint conditions of the first state machine state, and to determine whether the current second state machine state belongs to the predecessor state of the changed state required by the state change request. If so, it is determined that both the first state machine state and the second state machine state meet the change conditions.
在一些可选的实施例中,请求获取模块11,包括:In some optional embodiments, the request obtaining module 11 includes:
第一获取单元,被配置为获取由任意智能合约参与方发起的状态变更请求The first acquisition unit is configured to acquire a state change request initiated by any smart contract participant
第二获取单元,被配置为获取状态变更请求的门限签名;其中,门限签名由智能合约参与方通过门限签名的方式对状态变更请求进行签名得到。The second acquisition unit is configured to obtain a threshold signature of the state change request; wherein the threshold signature is obtained by the smart contract participant signing the state change request by means of a threshold signature.
在一些可选的实施例中,状态变更装置还包括:In some optional embodiments, the state changing device further includes:
验签模块,被配置为根据状态变更请求的变更对象的层级不同触发对应层级的状态机管理器基于状态变更请求对门限签名进行验签,如果验签通过,则执行对变更对象的当前状态进行检测的步骤。The signature verification module is configured to trigger the state machine manager of the corresponding level to verify the threshold signature based on the state change request according to the different levels of the change object of the state change request. If the verification passes, the step of detecting the current state of the change object is executed.
基准私钥份额生成模块,被配置为密钥生成中心通过门限秘密共享算法生成基准私钥及对应的基准私钥份额,并根据目标需求为不同的智能合约参与方分配及下发不同的基准私钥份额; The base private key share generation module is configured as a key generation center to generate a base private key and a corresponding base private key share through a threshold secret sharing algorithm, and allocate and issue different base private key shares to different smart contract participants according to target requirements;
临时公私钥份额生成模块,被配置为各个智能合约参与方生成多个临时私钥份额、多个临时公钥份额并将多个临时私钥份额、多个临时公钥份额分别发送至其他智能合约参与方,以及接收其他智能合约参与方发送的临时私钥份额、临时公钥份额;A temporary public and private key share generation module is configured to generate multiple temporary private key shares and multiple temporary public key shares for each smart contract participant and send the multiple temporary private key shares and multiple temporary public key shares to other smart contract participants respectively, and receive the temporary private key shares and temporary public key shares sent by other smart contract participants;
临时公私钥共享份额生成模块,被配置为各个智能合约参与方基于自身临时私钥份额及接收到的临时私钥份额计算临时私钥共享份额,并基于自身临时公钥份额及接收到的临时公钥份额计算临时公钥共享份额;A temporary public-private key sharing share generation module is configured so that each smart contract participant calculates a temporary private key sharing share based on its own temporary private key share and the received temporary private key share, and calculates a temporary public key sharing share based on its own temporary public key share and the received temporary public key share;
基准签名参数生成模块,被配置为各个智能合约参与方根据临时公钥共享份额计算基准签名参数;A base signature parameter generation module is configured to calculate base signature parameters for each smart contract participant based on a temporary public key sharing share;
门限签名生成模块,被配置为各个智能合约参与方分别对状态变更请求进行哈希运算得到第一哈希结果,并分别对哈希结果进行签名得到对应的签名份额,以及根据各个签名份额采用门限签名恢复出基准签名份额;各个智能合约参与方根据基准私钥份额、临时私钥份额及临时公钥份额计算出基准签名参数,得到包含基准签名参数与基准签名份额的门限签名。The threshold signature generation module is configured so that each smart contract participant respectively performs a hash operation on the state change request to obtain a first hash result, and respectively signs the hash result to obtain a corresponding signature share, and uses the threshold signature to restore the base signature share based on each signature share; each smart contract participant calculates the base signature parameter based on the base private key share, the temporary private key share and the temporary public key share to obtain a threshold signature including the base signature parameter and the base signature share.
在一些可选的实施例中,验签模块,包括:In some optional embodiments, the signature verification module includes:
第一验签单元,被配置为如果状态变更请求的变更对象的层级为智能合约层,则触发第一状态机管理器基于状态变更请求对门限签名进行验签;The first signature verification unit is configured to trigger the first state machine manager to verify the threshold signature based on the state change request if the level of the change object of the state change request is the smart contract layer;
第二验签单元,被配置为如果状态变更请求的变更对象的层级为智能合约内部的功能函数层,则触发第二状态机管理器基于状态变更请求对门限签名进行验签。The second signature verification unit is configured to trigger the second state machine manager to verify the threshold signature based on the state change request if the level of the change object of the state change request is the function layer inside the smart contract.
在一些可选的实施例中,验签模块,被配置为状态机管理器从智能合约中获取与基准私钥对应的基准公钥,并对状态变更请求进行哈希运算得到第二哈希结果,以及利用基准签名份额的乘法逆、基准公钥、第二哈希结果计算验签公钥共享份额;状态机管理器根据验签公钥共享份额计算验签签名参数,并判断基准签名参数与验签签名参数是否相等,如果是,则判定验签通过。In some optional embodiments, the signature verification module is configured as a state machine manager to obtain a reference public key corresponding to a reference private key from a smart contract, perform a hash operation on a state change request to obtain a second hash result, and calculate a verification public key sharing share using the multiplicative inverse of the reference signature share, the reference public key, and the second hash result; the state machine manager calculates the verification signature parameters based on the verification public key sharing share, and determines whether the reference signature parameters are equal to the verification signature parameters. If so, the verification is determined to be successful.
进一步的,本申请实施例还提供了一种电子设备。图11是根据一示例性实施例示出的电子设备20结构图,图中的内容不能认为是对本申请的使用范围的任何限制。Furthermore, an embodiment of the present application also provides an electronic device. FIG11 is a structural diagram of an electronic device 20 according to an exemplary embodiment, and the content in the diagram cannot be regarded as any limitation on the scope of application of the present application.
图11为本申请实施例提供的一种电子设备20的结构示意图。该电子设备20,可以包括:至少一个处理器21、至少一个存储器22、电源23、通信接口24、输入输出接口25和通信总线26。其中,所述存储器22被配置为存储计算机程序,所述计算机程序由所述处理器21加载并执行,以实现前述任一实施例公开的状态变更方法中的相关步骤。FIG11 is a schematic diagram of the structure of an electronic device 20 provided in an embodiment of the present application. The electronic device 20 may include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input/output interface 25, and a communication bus 26. The memory 22 is configured to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the state change method disclosed in any of the aforementioned embodiments.
本实施例中,电源23被配置为为电子设备20上的各硬件设备提供工作电压;通信接口24能够为电子设备20创建与外界设备之间的数据传输通道,其所遵循的通信协议是能够适被配置为本申请技术方案的任意通信协议,在此不对其进行限定;输入输出接口25,被配置为获取外界输入数据或向外界输出数据,其接口类型可以根据应用需要进行选取,在此不进行具体限定。In this embodiment, the power supply 23 is configured to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and the external device, and the communication protocol it follows is any communication protocol that can be configured as the technical solution of the present application, and is not limited here; the input and output interface 25 is configured to obtain external input data or output data to the outside world, and its interface type can be selected according to application needs and is not specifically limited here.
另外,存储器22作为资源存储的载体,可以是只读存储器、随机存储器、磁盘或者光盘等,其上所存储的资源可以包括操作系统221、计算机程序222及数据223等,存储方式可以是短暂存储或者永久存储。In addition, the memory 22, as a carrier for storing resources, can be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon may include an operating system 221, a computer program 222 and data 223, etc. The storage method can be temporary storage or permanent storage.
其中,操作系统221被配置为管理与控制电子设备20上的各硬件设备以及计算机程序222,以实现处理器21对存储器22中海量数据223的运算与处理,其可以是Windows Server、Netware、Unix、Linux等。计算机程序222除了包括能够被配置为完成前述任一实施例公开的由电子设备20执行的状态变更方法的计算机程序之外,还可以进一步包括能够用于完成其他特定工作的计算机程序。数据223可以包括电子设备20收集到的状态变更请求。The operating system 221 is configured to manage and control the hardware devices and computer programs 222 on the electronic device 20 to realize the operation and processing of the massive data 223 in the memory 22 by the processor 21, which can be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program that can be configured to complete the state change method performed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 222 can further include a computer program that can be used to complete other specific tasks. The data 223 can include the state change request collected by the electronic device 20.
进一步的,本申请实施例还公开了一种非易失性可读存储介质,非易失性可读存储介质中存储有计算机程序,所述计算机程序被处理器加载并执行时,实现前述任一实施例公开的状态变更方法步骤。Furthermore, an embodiment of the present application also discloses a non-volatile readable storage medium, in which a computer program is stored. When the computer program is loaded and executed by a processor, the state change method steps disclosed in any of the aforementioned embodiments are implemented.
本说明书中各个实施例采用递进的方式描述,每个实施例重点说明的都是与其它实施例的不同之处,各个实施例之间相同或相似部分互相参见即可。对于实施例公开的装置而言,由于其与实施例公开的方法相对应,所以描述的比较简单,相关之处参见方法部分说明即可。 In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
最后,还需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个…”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
以上对本申请所提供的状态变更请求方法、装置、设备及非易失性可读存储介质进行了详细介绍,本文中应用了具体个例对本申请的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本申请的方法及其核心思想;同时,对于本领域的一般技术人员,依据本申请的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本申请的限制。 The state change request method, device, equipment and non-volatile readable storage medium provided by the present application are introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims (20)

  1. 一种状态变更方法,其特征在于,包括:A state change method, characterized by comprising:
    获取由任意智能合约参与方发起的状态变更请求;Get state change requests initiated by any smart contract participant;
    根据所述状态变更请求的变更对象的层级不同触发对应层级的状态机管理器调用对应层级的状态机,以对所述变更对象的当前状态进行检测;其中,所述变更对象的层级包括智能合约层或智能合约内部的功能函数层,不同层级的所述变更对象对应的状态机管理器及状态机不同;According to the different levels of the change object of the state change request, the state machine manager of the corresponding level is triggered to call the state machine of the corresponding level to detect the current state of the change object; wherein the level of the change object includes the smart contract layer or the function layer inside the smart contract, and the state machine managers and state machines corresponding to the change objects of different levels are different;
    如果所述变更对象的当前状态满足变更条件,则触发对应层级的状态机管理器调用相应层级的状态机,以根据所述状态变更请求对所述变更对象的状态进行变更。If the current state of the change object meets the change condition, the state machine manager of the corresponding level is triggered to call the state machine of the corresponding level to change the state of the change object according to the state change request.
  2. 根据权利要求1所述的状态变更方法,其特征在于,所述根据所述状态变更请求的变更对象的层级不同触发对应层级的状态机管理器调用对应层级的状态机,以对所述变更对象的当前状态进行检测,包括:The state change method according to claim 1 is characterized in that the state machine manager of the corresponding level is triggered to call the state machine of the corresponding level according to the different levels of the change object of the state change request to detect the current state of the change object, including:
    如果所述状态变更请求的变更对象的层级为智能合约层,则触发第一状态机管理器调用第一状态机,以获取与智能合约对应的当前第一状态机状态;If the level of the change object of the state change request is the smart contract layer, triggering the first state machine manager to call the first state machine to obtain the current first state machine state corresponding to the smart contract;
    判断当前第一状态机状态是否满足变更条件;Determine whether the current state of the first state machine meets the change condition;
    相应的,如果所述变更对象的当前状态满足变更条件,所述触发对应层级的状态机管理器调用相应层级的状态机,以根据所述状态变更请求对所述变更对象的状态进行变更,包括:Correspondingly, if the current state of the change object meets the change condition, the triggering of the state machine manager of the corresponding level calls the state machine of the corresponding level to change the state of the change object according to the state change request, including:
    触发所述第一状态机管理器调用所述第一状态机,以根据所述状态变更请求对所述智能合约的状态进行变更。Trigger the first state machine manager to call the first state machine to change the state of the smart contract according to the state change request.
  3. 根据权利要求2所述的状态变更方法,其特征在于,所述触发所述第一状态机管理器调用所述第一状态机,以根据所述状态变更请求对所述智能合约的状态进行变更,包括:The state change method according to claim 2, characterized in that the triggering of the first state machine manager to call the first state machine to change the state of the smart contract according to the state change request comprises:
    在所述状态变更请求用于请求智能合约层将所述第一状态机状态由部署状态变更到执行状态的情况下,检测智能合约是否处于所述部署状态或者停止状态;In a case where the state change request is used to request the smart contract layer to change the state of the first state machine from a deployment state to an execution state, detecting whether the smart contract is in the deployment state or the stop state;
    在所述智能合约处于所述部署状态或者所述停止状态的情况下,将智能合约的状态机变更到执行状态,其中,第一状态机状态包括部署状态以及执行状态。When the smart contract is in the deployed state or the stopped state, the state machine of the smart contract is changed to the executed state, wherein the first state machine state includes the deployed state and the executed state.
  4. 根据权利要求2所述的状态变更方法,其特征在于,所述判断当前第一状态机状态是否满足变更条件,包括:The state changing method according to claim 2, characterized in that the step of determining whether the current state of the first state machine satisfies the change condition comprises:
    判断当前第一状态机状态是否属于所述状态变更请求要求的变更后状态的前置状态,如果是,则判定当前第一状态机状态满足变更条件。It is determined whether the current first state machine state is a pre-state of the changed state required by the state change request, and if so, it is determined that the current first state machine state meets the change condition.
  5. 根据权利要求1所述的状态变更方法,其特征在于,所述根据所述状态变更请求的变更对象的层级不同触发对应层级的状态机管理器调用对应层级的状态机,以对所述变更对象的当前状态进行检测,包括:The state change method according to claim 1 is characterized in that the state machine manager of the corresponding level is triggered to call the state machine of the corresponding level according to the different levels of the change object of the state change request to detect the current state of the change object, including:
    如果所述状态变更请求的变更对象的层级为智能合约内部的功能函数层,则触发第一状态机管理器调用第一状态机获取与智能合约对应的当前第一状态机状态,同时触发第二状态机管理器调用第二状态机获取与所述功能函数对应的当前第二状态机状态;If the level of the change object of the state change request is the function layer inside the smart contract, the first state machine manager is triggered to call the first state machine to obtain the current first state machine state corresponding to the smart contract, and the second state machine manager is triggered to call the second state machine to obtain the current second state machine state corresponding to the function;
    判断当前第一状态机状态和当前第二状态机状态是否均满足变更条件;Determine whether the current first state machine state and the current second state machine state both meet the change conditions;
    相应的,如果所述变更对象的当前状态满足变更条件,所述触发对应层级的状态机管理器调用相应层级的状态机,以根据所述状态变更请求对所述变更对象的状态进行变更,包括:Correspondingly, if the current state of the change object meets the change condition, the triggering of the state machine manager of the corresponding level calls the state machine of the corresponding level to change the state of the change object according to the state change request, including:
    触发所述第二状态机管理器调用所述第二状态机,以根据所述状态变更请求对所述功能函数的状态进行变更。The second state machine manager is triggered to call the second state machine to change the state of the functional function according to the state change request.
  6. 根据权利要求5所述的状态变更方法,其特征在于,所述触发所述第二状态机管理器调用所述第二状态机,以根据所述状态变更请求对所述功能函数的状态进行变更,包括:The state change method according to claim 5, characterized in that the triggering of the second state machine manager to call the second state machine to change the state of the functional function according to the state change request comprises:
    在所述状态变更请求用于请求所述功能函数层执行停止状态操作的情况下,检测所述智能合约是否处 于执行状态,以及检测所述功能函数层是否处于执行状态;In the case where the state change request is used to request the function layer to perform a stop state operation, detecting whether the smart contract is in in an execution state, and detecting whether the functional function layer is in an execution state;
    在所述智能合约处于所述执行状态,并且所述功能函数层处于所述执行状态的情况下,将所述第二状态机状态变更到所述停止状态,所述第二状态机状态包括所述执行状态和所述停止状态。When the smart contract is in the execution state and the functional function layer is in the execution state, the second state machine state is changed to the stop state, and the second state machine state includes the execution state and the stop state.
  7. 根据权利要求5所述的状态变更方法,其特征在于,所述判断当前第一状态机状态和当前第二状态机状态是否均满足变更条件,包括:The state changing method according to claim 5, characterized in that the step of determining whether both the current first state machine state and the current second state machine state satisfy the change condition comprises:
    判断当前第二状态机状态是否满足第一状态机状态的层级约束条件,如果是,则判定第一状态机状态和第二状态机状态均满足变更条件。It is determined whether the current second state machine state satisfies the hierarchical constraint condition of the first state machine state. If so, it is determined that both the first state machine state and the second state machine state satisfy the change condition.
  8. 根据权利要求7所述的状态变更方法,其特征在于,所述判断当前第二状态机状态是否满足第一状态机状态的层级约束条件,包括:The state changing method according to claim 7, characterized in that the step of determining whether the current second state machine state satisfies the hierarchical constraint condition of the first state machine state comprises:
    将第一状态机状态和第二状态机状态进行匹配,其中,所述第一状态机状态包括部署状态、执行状态、停止状态、升级状态和销毁状态,所述第二状态机状态包括部署状态、执行状态、停止状态和升级状态;Matching a first state machine state with a second state machine state, wherein the first state machine state includes a deployment state, an execution state, a stop state, an upgrade state, and a destruction state, and the second state machine state includes a deployment state, an execution state, a stop state, and an upgrade state;
    在所述第二状态机状态和所述第一状态机状态匹配一致的情况下,确定所述第二状态机状态满足所述第一状态机状态的层级约束条件。When the second state machine state matches the first state machine state, it is determined that the second state machine state satisfies the hierarchical constraint condition of the first state machine state.
  9. 根据权利要求7所述的状态变更方法,其特征在于,所述判断当前第二状态机状态是否满足第一状态机状态的层级约束条件之后,还包括:The state change method according to claim 7 is characterized in that after determining whether the current second state machine state satisfies the hierarchical constraint condition of the first state machine state, it further comprises:
    判断当前第二状态机状态是否属于所述状态变更请求要求的变更后状态的前置状态,如果是,则判定第一状态机状态和第二状态机状态均满足变更条件。It is determined whether the current second state machine state is a pre-state of the changed state required by the state change request, and if so, it is determined that both the first state machine state and the second state machine state meet the change condition.
  10. 根据权利要求1至9任一项所述的状态变更方法,其特征在于,所述获取由任意智能合约参与方发起的状态变更请求,包括:The state change method according to any one of claims 1 to 9, characterized in that obtaining a state change request initiated by any smart contract participant comprises:
    获取由任意智能合约参与方发起的状态变更请求及所述状态变更请求的门限签名;其中,所述门限签名由所述智能合约参与方通过门限签名的方式对所述状态变更请求进行签名得到;Obtain a state change request initiated by any smart contract participant and a threshold signature of the state change request; wherein the threshold signature is obtained by the smart contract participant signing the state change request by means of a threshold signature;
    相应的,对所述变更对象的当前状态进行检测之前,还包括:Accordingly, before detecting the current state of the changed object, the following steps are also included:
    根据所述状态变更请求的变更对象的层级不同触发对应层级的状态机管理器基于所述状态变更请求对所述门限签名进行验签,如果验签通过,则执行对所述变更对象的当前状态进行检测的步骤。According to the different levels of the change object of the state change request, the state machine manager of the corresponding level is triggered to verify the threshold signature based on the state change request. If the verification passes, the step of detecting the current state of the change object is executed.
  11. 根据权利要求10所述的状态变更方法,其特征在于,所述根据所述状态变更请求的变更对象的层级不同触发对应层级的状态机管理器基于所述状态变更请求对所述门限签名进行验签,包括:The state change method according to claim 10, characterized in that the triggering of the state machine manager of the corresponding level to verify the threshold signature based on the state change request according to the different levels of the change object of the state change request comprises:
    如果所述状态变更请求的变更对象的层级为智能合约层,则触发第一状态机管理器基于所述状态变更请求对所述门限签名进行验签。If the level of the change object of the state change request is the smart contract layer, the first state machine manager is triggered to verify the threshold signature based on the state change request.
  12. 根据权利要求10所述的状态变更方法,其特征在于,所述根据所述状态变更请求的变更对象的层级不同触发对应层级的状态机管理器基于所述状态变更请求对所述门限签名进行验签,包括:The state change method according to claim 10, characterized in that the triggering of the state machine manager of the corresponding level to verify the threshold signature based on the state change request according to the different levels of the change object of the state change request comprises:
    如果所述状态变更请求的变更对象的层级为智能合约内部的功能函数层,则触发第二状态机管理器基于所述状态变更请求对所述门限签名进行验签。If the level of the change object of the state change request is the functional layer within the smart contract, the second state machine manager is triggered to verify the threshold signature based on the state change request.
  13. 根据权利要求10所述的状态变更方法,其特征在于,还包括:The state changing method according to claim 10, characterized in that it also includes:
    各个所述智能合约参与方分别对所述状态变更请求进行哈希运算得到第一哈希结果,并分别对所述哈希结果进行签名得到对应的签名份额,以及根据各个所述签名份额采用门限签名恢复出基准签名份额;Each of the smart contract participants performs a hash operation on the state change request to obtain a first hash result, and signs the hash result to obtain a corresponding signature share, and restores a reference signature share using a threshold signature according to each of the signature shares;
    各个所述智能合约参与方根据基准私钥份额、临时私钥份额及临时公钥份额计算出基准签名参数,得到包含所述基准签名参数与所述基准签名份额的所述门限签名。Each of the smart contract participants calculates a baseline signature parameter based on the baseline private key share, the temporary private key share, and the temporary public key share to obtain the threshold signature including the baseline signature parameter and the baseline signature share.
  14. 根据权利要求13所述的状态变更方法,其特征在于,还包括:The state changing method according to claim 13, further comprising:
    密钥生成中心通过门限秘密共享算法生成基准私钥及对应的基准私钥份额,并根据目标需求为不同的所述智能合约参与方分配及下发不同的所述基准私钥份额;The key generation center generates a reference private key and a corresponding reference private key share through a threshold secret sharing algorithm, and allocates and issues different reference private key shares to different smart contract participants according to target requirements;
    各个所述智能合约参与方生成多个所述临时私钥份额、多个所述临时公钥份额并将多个所述临时私钥 份额、多个所述临时公钥份额分别发送至其他所述智能合约参与方,以及接收其他所述智能合约参与方发送的所述临时私钥份额、所述临时公钥份额;Each of the smart contract participants generates a plurality of temporary private key shares, a plurality of temporary public key shares and sends the plurality of temporary private key shares to the smart contract. The temporary private key share and the temporary public key share are sent to other smart contract participants respectively, and the temporary private key share and the temporary public key share are received from other smart contract participants;
    各个所述智能合约参与方基于自身所述临时私钥份额及接收到的所述临时私钥份额计算临时私钥共享份额,并基于自身所述临时公钥份额及接收到的所述临时公钥份额计算临时公钥共享份额;Each smart contract participant calculates a temporary private key share based on its own temporary private key share and the received temporary private key share, and calculates a temporary public key share based on its own temporary public key share and the received temporary public key share;
    各个所述智能合约参与方根据所述临时公钥共享份额计算所述基准签名参数。Each of the smart contract participants calculates the reference signature parameters based on the temporary public key sharing share.
  15. 根据权利要求14所述的状态变更方法,其特征在于,根据目标需求为不同的所述智能合约参与方分配及下发不同的所述基准私钥份额,包括:The state change method according to claim 14 is characterized in that different shares of the base private key are allocated and issued to different smart contract participants according to target requirements, including:
    每个所述智能合约参与方根据可信程度和对智能合约影响程度,分配所述基准私钥份额,以实现权重的分配,其中,所述智能合约参与方包括智能合约制定者、智能合约使用者以及智能合约仲裁者,所述智能合约制定者分配的所述基准私钥份额的数量大于或者等于1,所述所述智能合约使用者分配的所述基准私钥份额的数量大于或者等于0,所述智能合约仲裁者分配的所述基准私钥份额的数量大于或者等于1。Each smart contract participant allocates the benchmark private key share according to the degree of trustworthiness and the degree of influence on the smart contract to achieve weight allocation, wherein the smart contract participants include smart contract makers, smart contract users and smart contract arbitrators, the number of benchmark private key shares allocated by the smart contract makers is greater than or equal to 1, the number of benchmark private key shares allocated by the smart contract users is greater than or equal to 0, and the number of benchmark private key shares allocated by the smart contract arbitrators is greater than or equal to 1.
  16. 根据权利要求14所述的状态变更方法,其特征在于,状态机管理器基于所述状态变更请求对所述门限签名进行验签,包括:The state change method according to claim 14, characterized in that the state machine manager verifies the threshold signature based on the state change request, comprising:
    状态机管理器从智能合约中获取与所述基准私钥对应的基准公钥,并对所述状态变更请求进行哈希运算得到第二哈希结果,以及利用所述基准签名份额的乘法逆、所述基准公钥、所述第二哈希结果计算验签公钥共享份额;The state machine manager obtains a reference public key corresponding to the reference private key from the smart contract, performs a hash operation on the state change request to obtain a second hash result, and calculates a verification public key sharing share using the multiplicative inverse of the reference signature share, the reference public key, and the second hash result;
    状态机管理器根据所述验签公钥共享份额计算所述验签签名参数,并判断所述基准签名参数与所述验签签名参数是否相等,如果是,则判定验签通过。The state machine manager calculates the signature verification parameter according to the shared share of the signature verification public key, and determines whether the reference signature parameter is equal to the signature verification parameter. If so, it is determined that the signature verification is passed.
  17. 一种状态变更装置,其特征在于,包括:A state changing device, characterized by comprising:
    请求获取模块,被配置为获取由任意智能合约参与方发起的状态变更请求;A request acquisition module, configured to acquire state change requests initiated by any smart contract participant;
    状态分级检测模块,被配置为根据所述状态变更请求的变更对象的层级不同触发对应层级的状态机管理器调用对应层级的状态机,以对所述变更对象的当前状态进行检测;其中,所述变更对象的层级包括智能合约层或智能合约内部的功能函数层,不同层级的所述变更对象对应的状态机管理器及状态机不同;A state hierarchical detection module is configured to trigger a state machine manager of a corresponding level to call a state machine of a corresponding level according to different levels of the change object of the state change request, so as to detect the current state of the change object; wherein the level of the change object includes a smart contract layer or a function layer within a smart contract, and the state machine managers and state machines corresponding to the change objects of different levels are different;
    状态变更模块,被配置为如果所述变更对象的当前状态满足变更条件,则触发对应层级的状态机管理器调用相应层级的状态机,以根据所述状态变更请求对所述变更对象的状态进行变更。The state change module is configured to trigger the state machine manager of the corresponding level to call the state machine of the corresponding level if the current state of the change object meets the change condition, so as to change the state of the change object according to the state change request.
  18. 一种智能合约虚拟机,其特征在于,包括:变更对象的层级对应的状态机管理器和状态机,其中,所述变更对象的层级包括智能合约层或智能合约内部的功能函数层,不同层级的所述变更对象对应的所述状态机管理器及所述状态机不同,A smart contract virtual machine, characterized in that it comprises: a state machine manager and a state machine corresponding to the level of a change object, wherein the level of the change object comprises a smart contract layer or a function layer within a smart contract, and the state machine manager and the state machine corresponding to the change objects at different levels are different,
    所述状态机管理器,被配置为对对应的所述变更对象的当前状态进行检测;并且,如果所述变更对象的当前状态满足变更条件,则调用相应层级的所述状态机,以根据所述状态变更请求对所述变更对象的状态进行变更。The state machine manager is configured to detect the current state of the corresponding change object; and if the current state of the change object meets the change condition, call the state machine of the corresponding level to change the state of the change object according to the state change request.
  19. 一种电子设备,其特征在于,所述电子设备包括处理器和存储器;其中所述存储器被配置为存储计算机程序,所述计算机程序由所述处理器加载并执行以实现如权利要求1至16任一项所述的状态变更方法。An electronic device, characterized in that the electronic device includes a processor and a memory; wherein the memory is configured to store a computer program, and the computer program is loaded and executed by the processor to implement the state change method as described in any one of claims 1 to 16.
  20. 一种计算机非易失性可读存储介质,其特征在于,被配置为存储计算机可执行指令,所述计算机可执行指令被处理器加载并执行时,实现如权利要求1至16任一项所述的状态变更方法。 A computer non-volatile readable storage medium, characterized in that it is configured to store computer executable instructions, and when the computer executable instructions are loaded and executed by a processor, the state change method according to any one of claims 1 to 16 is implemented.
PCT/CN2023/097518 2022-11-14 2023-05-31 State change method and apparatus, device, and nonvolatile readable storage medium WO2024103689A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202211417421.5 2022-11-14
CN202211417421.5A CN115473747B (en) 2022-11-14 2022-11-14 State changing method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
WO2024103689A1 true WO2024103689A1 (en) 2024-05-23

Family

ID=84338047

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/097518 WO2024103689A1 (en) 2022-11-14 2023-05-31 State change method and apparatus, device, and nonvolatile readable storage medium

Country Status (2)

Country Link
CN (1) CN115473747B (en)
WO (1) WO2024103689A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115473747B (en) * 2022-11-14 2023-03-24 苏州浪潮智能科技有限公司 State changing method, device, equipment and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109522729A (en) * 2018-11-02 2019-03-26 中链科技有限公司 Intelligent contract Status Change method and device
US20220038264A1 (en) * 2018-09-22 2022-02-03 David YAKIRA Decentralized key generation and distribution over a blockchain-based network
CN114358764A (en) * 2021-11-15 2022-04-15 深圳众联数字科技有限公司 Privacy calculation method based on intelligent contracts in block chain and related equipment
CN114666064A (en) * 2022-03-25 2022-06-24 广东启链科技有限公司 Block chain-based digital asset management method, device, storage medium and equipment
CN115145590A (en) * 2021-03-29 2022-10-04 中移(上海)信息通信科技有限公司 Intelligent contract calling request processing device and method and storage medium
CN115473747A (en) * 2022-11-14 2022-12-13 苏州浪潮智能科技有限公司 State changing method, device, equipment and storage medium

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2017202467A1 (en) * 2016-05-26 2017-11-30 Genomcore, S.L. Providing access to sensitive data
CN110138592A (en) * 2019-04-09 2019-08-16 苏宁易购集团股份有限公司 A kind of management method and system of intelligence contract
CN110705974B (en) * 2019-09-03 2022-07-05 杭州趣链科技有限公司 Complete intelligent contract form specification implementation method
CN113708924B (en) * 2021-07-30 2022-09-30 西安邮电大学 Elliptic curve threshold signature method based on block chain

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20220038264A1 (en) * 2018-09-22 2022-02-03 David YAKIRA Decentralized key generation and distribution over a blockchain-based network
CN109522729A (en) * 2018-11-02 2019-03-26 中链科技有限公司 Intelligent contract Status Change method and device
CN115145590A (en) * 2021-03-29 2022-10-04 中移(上海)信息通信科技有限公司 Intelligent contract calling request processing device and method and storage medium
CN114358764A (en) * 2021-11-15 2022-04-15 深圳众联数字科技有限公司 Privacy calculation method based on intelligent contracts in block chain and related equipment
CN114666064A (en) * 2022-03-25 2022-06-24 广东启链科技有限公司 Block chain-based digital asset management method, device, storage medium and equipment
CN115473747A (en) * 2022-11-14 2022-12-13 苏州浪潮智能科技有限公司 State changing method, device, equipment and storage medium

Also Published As

Publication number Publication date
CN115473747A (en) 2022-12-13
CN115473747B (en) 2023-03-24

Similar Documents

Publication Publication Date Title
JP7461417B2 (en) Secure off-chain blockchain transactions
US11410168B2 (en) Method for user management for blockchain-based operations
US20210097528A1 (en) Blockchain hot wallet based on secure enclave and multi-signature authorization
EP3613189B1 (en) Secure blockchain-based consensus
CN110771088B (en) System and method for resolving security-related vulnerabilities arising in connection with blockchain external channels in the event of network failure
US10790976B1 (en) System and method of blockchain wallet recovery
CN109313690B (en) Self-contained encrypted boot policy verification
US9870477B2 (en) Security engine for a secure operating environment
CN110720102A (en) Block chains for general purpose computing
CN111541785A (en) Block chain data processing method and device based on cloud computing
CN110574059A (en) Fast distributed consensus on blockchains
US9641340B2 (en) Certificateless multi-proxy signature method and apparatus
CN118041602A (en) System and method for ensuring correct execution of a computer program using a mediator computer system
WO2020143906A1 (en) Method and apparatus for trust verification
WO2024103689A1 (en) State change method and apparatus, device, and nonvolatile readable storage medium
Al-Bassam et al. Airtnt: Fair exchange payment for outsourced secure enclave computations
Dey et al. An integrated model to make cloud authentication and multi-tenancy more secure
Kelkar et al. Complete knowledge: Preventing encumbrance of cryptographic secrets
CN111859379A (en) Processing method and device for protecting data model
Bentajer et al. Cryptographic key management issues in cloud computing
Alshinwan et al. Integrated cloud computing and blockchain systems: A review
Fournaris et al. From hardware security tokens to trusted computing and trusted systems
Zobaed et al. Confidential computing across edge-to-cloud for machine learning: A survey study
Yau et al. Securing grid workflows with trusted computing
CN111859378B (en) Processing method and device for protecting data model