KR102308185B1 - Method for performing smart contract based on block chain network and smart contract performing system therefor - Google Patents

Method for performing smart contract based on block chain network and smart contract performing system therefor Download PDF

Info

Publication number
KR102308185B1
KR102308185B1 KR1020190065522A KR20190065522A KR102308185B1 KR 102308185 B1 KR102308185 B1 KR 102308185B1 KR 1020190065522 A KR1020190065522 A KR 1020190065522A KR 20190065522 A KR20190065522 A KR 20190065522A KR 102308185 B1 KR102308185 B1 KR 102308185B1
Authority
KR
South Korea
Prior art keywords
contract
smart contract
terminal
network
nodes
Prior art date
Application number
KR1020190065522A
Other languages
Korean (ko)
Other versions
KR20200139012A (en
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 홍익대학교 산학협력단
Priority to KR1020190065522A priority Critical patent/KR102308185B1/en
Publication of KR20200139012A publication Critical patent/KR20200139012A/en
Application granted granted Critical
Publication of KR102308185B1 publication Critical patent/KR102308185B1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
    • H04L9/321Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials involving a third party or a trusted authority
    • 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/008Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols involving homomorphic encryption
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/06Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols the encryption apparatus using shift registers or memories for block-wise or stream coding, e.g. DES systems or RC4; Hash functions; Pseudorandom sequence generators
    • H04L9/0618Block ciphers, i.e. encrypting groups of characters of a plain text message using fixed encryption transformation

Abstract

동형 암호(homomorphic encryption)를 이용하여 기밀화된 스마트 계약(smart contract)을 수행하는 방법 및 이에 적합한 스마트 계약 수행 시스템이 개시된다.
본 발명의 스마트 계약 수행 방법은
상기 계약 당사자 단말이 동형 암호화된 변수를 포함하는 스마트 계약을 블록체인 네트워크에 업로드하는 과정;
상기 제1분산 합의 네트워크에 참여한 노드들이 스마트 계약의 유효성을 검증하는 과정;
상기 제1분산 합의 네트워크에 참여한 노드들 중에서 정족수를 만족하는 노드들에 의해 스마트 계약의 유효성이 검증되면, 상기 계약 이행 단말이 스마트 계약의 계약 내용을 이행하는 과정; 및
동형 암호 비교 연산이 있는 경우, 상기 계약 이행 단말이 제2 분산 합의 네트워크에 참여한 노드들의 합의에 의해 동형 암호 비교 연산 결과를 복호화하는 과정;
계약 이행 단말이 복호화 결과를 계약 당사자 단말에 제공하는 과정; 및
정족수 이상의 계약 이행 단말이 적합한 계약 이행이 이루어진 것으로 합의된 경우, 상기 계약 당사자 단말이 스마트 계약을 종료하는 과정;
을 포함한다.
Disclosed are a method for performing a confidential smart contract using homomorphic encryption and a smart contract execution system suitable therefor.
The smart contract execution method of the present invention is
uploading, by the contract party terminal, a smart contract including a homomorphic encrypted variable to a block chain network;
a process in which nodes participating in the first distributed consensus network verify the validity of a smart contract;
when the validity of the smart contract is verified by the nodes that satisfy the quorum among the nodes participating in the first distributed consensus network, the contract execution terminal executes the contract contents of the smart contract; and
when there is a homomorphic encryption comparison operation, the contract execution terminal decrypts a homomorphic encryption comparison operation result by consensus of nodes participating in a second distributed consensus network;
a process in which the contract fulfillment terminal provides a decryption result to the contract party terminal; and
a process in which the contract party terminal terminates the smart contract when the contract fulfillment terminal with more than a quorum agrees that the appropriate contract execution has been made;
includes

Description

블록체인 네트워크 기반의 스마트 계약의 수행 방법 및 이에 적합한 스마트 계약 수행 시스템 {Method for performing smart contract based on block chain network and smart contract performing system therefor}Method for performing smart contract based on block chain network and smart contract performing system suitable therefor

본 발명은 블록체인 기반의 스마트 계약 수행 방법에 관한 것으로서 더욱 상세하게는 동형 암호(homomorphic encryption)를 이용하여 기밀화된 스마트 계약(smart contract)을 수행하는 방법 및 이에 적합한 스마트 계약 수행 시스템에 관한 것이다.The present invention relates to a blockchain-based smart contract execution method, and more particularly, to a method for performing a confidential smart contract using homomorphic encryption and a smart contract execution system suitable therefor. .

블록체인(block chain) 기술은 거래정보를 특정 기관이나 중앙 서버 등에 저장하지 않고 네트워크상에 분산하여 저장하고 참여자 모두가 공동으로 기록, 관리하는 기술로 하나의 블록에는 지나온 10분간의 거래내역과 직전 블록의 해시, 난스(nonce)가 포함되어 있으며, 이 블록들을 계속 연결시키면 블록체인이 형성되는 구조이다.Blockchain technology does not store transaction information in a specific institution or central server, but distributes and stores it on the network, and records and manages it jointly by all participants. The block hash and nonce are included, and if these blocks are continuously connected, a block chain is formed.

도 1은 블록체인 구조를 도시한다.1 shows the blockchain structure.

도 1을 참조하면, 각 블록에는 타임스탬프가 있고, 시스템 참여자들이 합의했을 때, 새 데이터가 입력되었을 때만 블록체인을 업데이트 할 수 있고 절대 삭제할 수 없는 분산형 전자 암호화 장부 또는 데이터베이스 플랫폼을 갖는다.Referring to Figure 1, each block has a timestamp, and when system participants agree, the blockchain can be updated only when new data is entered, and it has a distributed electronic cryptographic ledger or database platform that can never be deleted.

네트워크와 사용자가 안전하게 공유할 수 있도록 변경이 불가능하게 디지털 데이터를 저장하는데 있어 블록체인은 원장에서 소유자를 확인하기 위해 공개키 암호화 방식(암호화와 복호화에 서로 다른 키를 사용하는 방식)을 적용한다. 이름이나 주민번호 대신 공개키 쌍의 절반을 기록하고 나머지 절반의 개인키를 갖고 있는 사람만이 소유자가 되며 다음 거래를 결정한다. In storing digital data immutably so that the network and users can safely share it, the blockchain applies public key cryptography (a method of using different keys for encryption and decryption) to verify the owner in the ledger. Instead of a name or social security number, half of the public key pair is recorded, and only the person with the other half of the private key becomes the owner and decides on the next transaction.

도 2는 블록체인의 작동 과정을 보인다.Figure 2 shows the operation process of the blockchain.

도 2를 참조하면, 블록체인은 P2P(Pear to Pear) 분산 네트워크를 기반으로 하며, 네트워크 참여자들의 검증과 동의를 통해 거래정보 블록을 형성하고 거래 정보를 분산·저장하는 것으로서, 블록체인이 형성되는 핵심 과정은 다음의 두 단계로 구성된다. Referring to Figure 2, the block chain is based on a P2P (Pear to Pear) distributed network, and forms a block of transaction information through verification and consent of network participants and distributes and stores transaction information. The core process consists of two steps:

첫 번째 단계는 이중지불의 위험이 없는 거래 정보나 기록을 모아 유효한 개별 블록을 형성하는 ‘채굴(Mining)’이라고 불리는 과정으로 네트워크 참여자들 가운데 일부가 채굴자로 활동하며 해시 함수에서 블록 생성 조건에 맞는 수(Nonce)를 찾는다. The first stage is a process called 'mining' that collects transaction information or records without the risk of double-spending to form valid individual blocks. Find the Nonce.

올바른 난스(Nonce) 값을 처음 찾아낸 노드(Node)가 블록을 생성하여 블록체인 네트워크에 업로드하면 블록체인 네트워크에 참여하고 있는 각 노드(Node)는 전송된 난스값이 올바른지 유무와 거래가 정당한지를 확인한 뒤, 해당 블록이 승인되고 타임스탬프가 찍혀서 직전 블록의 뒤에 접속된다. When the node that first finds the correct nonce value creates a block and uploads it to the blockchain network, each node participating in the blockchain network checks whether the transmitted nonce value is correct and whether the transaction is justified. , the block is acknowledged and timestamped and accessed after the previous block.

이 과정에 임의의 정보 조작이나 변경이 될 경우 검증작업에 의해 고아 블록으로 분류되어 소멸된다. 조건에 부합하는 난스를 찾아내어 유효한 새 블록을 완성한 채굴자에게는 소정의 인센티브가 주어진다. If any information is manipulated or changed during this process, it is classified as an orphan block and destroyed by verification work. A certain incentive is given to miners who find a nonce that meets the conditions and complete a new valid block.

도 3은 블록체인의 블록 구조를 보인다.3 shows the block structure of a blockchain.

여기서, 머클루트(Merkle Roots)는 블록에 있는 모든 트랜잭션 정보를 요약한 해쉬 값으로 블록헤더에 존재하는 데이터이다. Here, Merkle Roots is a hash value that summarizes all transaction information in the block and is data existing in the block header.

유효한 후보 블록이 형성되면 두 번째 단계로 넘어가게 되는데, 이 단계에서는 생성된 후보 블록이 전체 네트워크 참여자들에게 전달되고, 각 네트워크 참여자들은 전송 받은 새로운 블록의 유효성과 블록에 포함된 거래의 유효성을 검증하며, 50% 이상 참여자들의 동의를 거쳐 유효성이 확인되면 비로소 후보 블록은 이전 블록과 체인으로 연결되어 블록체인 원장으로 완성된다. When a valid candidate block is formed, it goes to the second stage. In this stage, the generated candidate block is delivered to all network participants, and each network participant verifies the validity of the new block received and the validity of the transaction included in the block. When validity is confirmed through the consent of more than 50% of the participants, the candidate block is connected to the previous block and chained to complete the blockchain ledger.

이렇게 각 채굴자들이 블록 만들기 경쟁을 하는 이유는 인센티브(한 개의 유효 블록당 12.5비트코인) 때문으로 전 세계에서 수많은 채굴자들이 엄청난 컴퓨터 자원과 전력을 소모하며 채굴작업을 벌이고 있다.The reason why each miner competes in block making is because of incentives (12.5 bitcoins per valid block), so many miners around the world are consuming huge amounts of computer resources and power to mine.

이렇게 지나치게 소모적으로 보이는 채굴작업이 블록체인 형성과정에 포함되어 있는 이유는 The reason why such an excessively consuming mining operation is included in the process of forming the blockchain

첫째, 수많은 경쟁자들이 서로 경쟁하고 감시함으로써 거래의 유효성을 철저히 검증하게 하는 것이며 First, it allows numerous competitors to thoroughly validate the transaction by competing and monitoring each other.

둘째, 누구도 신규 블록을 독점적으로 만들지 못하게 함으로써 임의의 조작이나 개입을 첫 단계부터 차단하기 위한 것이고, Second, it is to block arbitrary manipulation or intervention from the first step by preventing anyone from exclusively creating new blocks.

셋째, 어려운 채굴과정을 통해 신규 블록의 형성 속도를 평균 10분정도로 맞춰 거래의 수집과 배포, 거래의 유효성 확인 등이 무리 없이 진행 될 수 있도록 하는 데도 목적이 있다. Third, through the difficult mining process, the new block formation speed is set to about 10 minutes on average, so that the collection and distribution of transactions and validation of transactions can proceed without unreasonableness.

거래내역이 블록에 포함되면 특히 그 블록 위에 새로운 블록이 쌓이게 되고 그 거래 내역은 전혀 변경할 수 없게 되고(불가역성) 어디서나 그 거래를 확인할 수 있게 된다(공개성). When a transaction history is included in a block, in particular, a new block is stacked on top of the block, and the transaction history cannot be changed at all (irreversibility), and the transaction can be confirmed anywhere (publicity).

블록체인의 개념이 처음으로 제안된 이후, 계약 내용의 이행을 강제하고 위반을 인식할 수 있는 스마트 계약(smart contract) 기술이 추가되면서 블록체인은 단순히 암호화폐에만 활용되지 않고, 다양한 분야에서 적용되는 추세다. Since the concept of blockchain was first proposed, smart contract technology that can force the implementation of contract contents and recognize violations has been added. trend.

여기서, ‘스마트 계약‘이란 블록체인 기술을 이용한 중요 기능으로 일정 조건을 만족시키면 거래가 자동으로 실행되도록 하는 프로그램이다. Here, ‘smart contract’ is an important function using block chain technology, and it is a program that automatically executes a transaction when certain conditions are satisfied.

도 4는 블록체인 기반의 스마트 계약 생성 및 실행 과정을 도시한다.4 shows the process of creating and executing a blockchain-based smart contract.

스마트 계약은 스마트 계약 코드를 포함한다. 이러한 스마트 계약은 템플릿을 이용하여 생성될 수 있다. 템플릿은 법률 산문과 스마트 계약 코드가 혼합된 재사용 가능한 문서이다. 이러한 템플릿은 메타 데이터, 조건문, 계산, 스마트 계약 논리, 서명, ID 등을 포함할 수 있다.A smart contract contains smart contract code. Such a smart contract can be created using a template. A template is a reusable document that is a mixture of legal prose and smart contract code. These templates can include metadata, conditional statements, calculations, smart contract logic, signatures, IDs, and more.

스마트 계약을 컴파일하여 바이트 코드(즉, 스마트 계약 실행 프로그램)를 얻고, 이 바이트 코드를 블록에 삽입하여 블록체인에 업로드한다. 블록 체인에 올려진 블록의 유효성은 블록체인 내부에서 분산 합의 절차를 통하여 검증된다.By compiling the smart contract, you get the bytecode (i.e. the smart contract execution program), inserting this bytecode into a block and uploading it to the blockchain. The validity of a block placed on the block chain is verified through a distributed consensus procedure within the block chain.

스마트 계약 실행자는 계약 실행 결과를 블록에 삽입하여 블록체인에 업로드한다. 블록 체인에 올려진 블록의 유효성은 역시 블록체인 내부에서 분산 합의 절차를 통하여 검증되고, 검증이 완료되면 계약이 완료된 것으로 인정된다. The smart contract executor inserts the contract execution result into the block and uploads it to the blockchain. The validity of the block placed on the block chain is also verified through the distributed consensus procedure within the block chain, and when the verification is completed, the contract is recognized as complete.

이러한 스마트 계약을 이용하여 소유권 이전 계약이나 상속 및 증여 등에 사용될 수 있는데, 계약 이행을 위한 조건을 스마트 계약서에 명기해 놓으면, 조건 충족과 동시에 계약 내용의 이행이 자동 실현되므로 계약 이행을 촉구하기 위한 추가적인 관리 비용이나 계약 불이행의 위험 또한 원천적으로 배제된다. These smart contracts can be used for ownership transfer contracts, inheritance and gifting, etc. If the conditions for contract execution are specified in the smart contract, the fulfillment of the contract contents is automatically realized as soon as the conditions are satisfied. Management costs and the risk of contract default are also fundamentally excluded.

그런데 블록체인은 탈중앙성과 무결성을 모두 만족시키기 위하여 블록 내부의 구체적인 거래 내역을 블록체인에 참여하는 모든 노드에 공개하고 있다. 내용이 공개되어야만 계약에 따른 거래가 이루어지고 있는지 분산 합의 알고리즘 등을 통해서 확인이 가능한 것이다. 그러나 이로 인하여 블록체인을 통해서 기밀성을 보장하는 거래를 수행하기는 어렵다는 근본적인 한계점을 지니고 있다 However, in order to satisfy both decentralization and integrity, the block chain discloses the specific transaction details within the block to all nodes participating in the block chain. Only when the contents are disclosed, it is possible to check whether a transaction is being made according to the contract through a distributed consensus algorithm, etc. However, due to this, it has a fundamental limitation that it is difficult to perform a transaction that guarantees confidentiality through the block chain.

1. Gentry, C. (2009, May). Fully homomorphic encryption using ideal lattices. In Stoc (Vol. 9, No. 2009, pp. 169-178). 1. Gentry, C. (2009, May). Fully homomorphic encryption using ideal lattices. In Stoc (Vol. 9, No. 2009, pp. 169-178). 2. Buterin, V. (2014). A next-generation smart contract and decentralized application platform. white paper.2. Buterin, V. (2014). A next-generation smart contract and decentralized application platform. white paper.

본 발명은 상기의 문제점을 해결하기 위하여 고안된 것으로서, 사용자가 별도의 프라이빗(private) 블록체인 네트워크를 구축할 필요가 없이 기밀성을 확보하면서 기존 블록체인 생태계에서 기밀성과 무결성을 동시에 보장하는 블록체인 네트워크 기반의 스마트 계약 수행 방법을 제공하는 것을 그 목적으로 한다.The present invention is designed to solve the above problems, and it is based on a blockchain network that ensures confidentiality and integrity in the existing blockchain ecosystem while securing confidentiality without the need for users to build a separate private blockchain network. Its purpose is to provide a method for executing smart contracts of

본 발명의 다른 목적은 상기의 방법에 적합한 시스템을 제공하는 것에 있다.Another object of the present invention is to provide a system suitable for the above method.

상기의 목적을 달성하는 본 발명에 따른 블록체인 네트워크 기반의 스마트 계약 수행 방법은The blockchain network-based smart contract execution method according to the present invention that achieves the above object is

계약 당사자 단말, 스마트 계약의 유효성을 검증하기 위한 제1분산 합의 네트워크, 조건에 따른 계약 이행의 적합성을 판단하는 계약 이행 단말, 조건에 따른 계약 이행의 적합성을 검증하기 위한 제2분산 합의 네트워크를 포함하는 블록체인 네트워크 기반의 스마트 계약 수행 방법에 있어서,Includes a contract party terminal, a first distributed consensus network to verify the validity of a smart contract, a contract fulfillment terminal to determine the suitability of contract execution according to conditions, and a second distributed consensus network to verify the suitability of contract execution according to conditions In a method of performing a smart contract based on a blockchain network,

상기 계약 당사자 단말이 동형 암호화된 변수를 포함하는 스마트 계약을 블록체인 네트워크에 업로드하는 과정;uploading, by the contract party terminal, a smart contract including a homomorphic encrypted variable to a block chain network;

상기 제1분산 합의 네트워크에 참여한 노드들이 스마트 계약의 유효성을 검증하는 과정;a process in which nodes participating in the first distributed consensus network verify the validity of a smart contract;

상기 제1분산 합의 네트워크에 참여한 노드들 중에서 정족수를 만족하는 노드들에 의해 스마트 계약의 유효성이 검증되면, 상기 계약 이행 단말이 스마트 계약의 계약 내용을 이행하는 과정; 및when the validity of the smart contract is verified by the nodes satisfying the quorum among the nodes participating in the first distributed consensus network, the contract execution terminal executes the contract contents of the smart contract; and

동형 암호 비교 연산이 있는 경우, 상기 계약 이행 단말이 제2 분산 합의 네트워크에 참여한 노드들의 합의에 의해 동형 암호 비교 연산 결과를 복호화하는 과정;when there is a homomorphic encryption comparison operation, the contract execution terminal decrypts a homomorphic encryption comparison operation result by consensus of nodes participating in a second distributed consensus network;

계약 이행 단말이 복호화 결과를 계약 당사자 단말에 제공하는 과정; 및a process in which the contract fulfillment terminal provides a decryption result to the contract party terminal; and

정족수 이상의 계약 이행 단말이 적합한 계약 이행이 이루어진 것으로 합의된 경우, 상기 계약 당사자 단말이 스마트 계약을 종료하는 과정;a process in which the contract party terminal terminates the smart contract when the contract fulfillment terminal with more than a quorum agrees that the appropriate contract execution has been made;

을 포함한다.includes

여기서, 스마트 계약의 유효성을 검증하는 과정은 블록체인 네트워크에 참여한 노드들이 스마트 계약의 전자 서명, 스마트 계약을 전달한 리더, 스마트 계약에 사상된 시퀀스 넘버(sequence number)를 검증하는 과정;Here, the process of verifying the validity of the smart contract is a process in which nodes participating in the blockchain network verify the electronic signature of the smart contract, the leader who delivered the smart contract, and the sequence number mapped to the smart contract;

검증한 노드 수가 정족수를 넘을 경우 해당 스마트 계약의 유효성이 검증된 것으로 처리하는 과정;If the number of verified nodes exceeds the quorum, the process of treating the validity of the smart contract as verified;

을 포함하는 것을 특징으로 한다.It is characterized in that it includes.

여기서, 상기 복호화 과정은 Here, the decoding process is

상기 계약 이행 단말이 스마트 계약에 포함된 동형 암호 비교 연산을 연산하는 과정; 및calculating, by the contract fulfillment terminal, a homomorphic cryptographic comparison operation included in the smart contract; and

동형 암호 비교 연산 결과를 제2 분산 합의 네트워크에 참여한 노드들로부터 검증받는 과정;a process of verifying a homomorphic cryptographic comparison operation result from nodes participating in a second distributed consensus network;

을 포함하는 것을 특징으로 한다.It is characterized in that it includes.

여기서, 제2 분산 합의 네트워크에 참여하는 노드들이 동형 암호 비교 연산 결과에 해당하는 평문을 공유하고, 각 노드들은 상기 계약 이행 단말에서 제공되는 암호문을 복호하여 공유된 평문과 비교하여 일치 여부를 판단하고, 판단 결과를 이웃 노드들에 전파하고, 각 노드들은 이웃 노드들로부터 수령한 값들 중 정족수 이상의 노드들이 합의한 값을 선정하고 선정된 값을 합의를 착수한 노드(리더)에 전달하며,Here, the nodes participating in the second distributed consensus network share the plaintext corresponding to the homomorphic encryption comparison operation result, and each node decrypts the ciphertext provided by the contract fulfillment terminal and compares it with the shared plaintext to determine whether it is consistent , propagates the judgment result to neighboring nodes, each node selects a value agreed upon by nodes with a quorum or more among the values received from the neighboring nodes, and delivers the selected value to the node (leader) that initiated the agreement,

상기 리더는 정족수 이상의 노드들이 합의한 값을 선정하여 합의의 결과로서 채택하여 상기 계약 이행 단말에 제공하는 것을 특징으로 한다.The leader selects a value agreed upon by the nodes having a quorum or more, adopts it as a result of the agreement, and provides it to the contract fulfillment terminal.

여기서, 리더는 상기 제2 분산 합의 네트워크의 분산 합의에 의해 선정되는 것을 특징으로 한다.Here, the leader is selected by the distributed consensus of the second distributed consensus network.

여기서, 리더가 장애로 인하여 더 이상 가용되지 않는 경우는 정해진 순서에 따라 다음 리더가 선정되고 분산 합의에 의해 승인되는 것을 특징으로 한다.Here, when the leader is no longer available due to a failure, the next leader is selected in a predetermined order and approved by distributed consensus.

상기의 다른 목적을 달성하는 본 발명에 따른 블록체인 기반의 스마트 계약 수행 시스템은The blockchain-based smart contract execution system according to the present invention that achieves the above other object is

동형 암호화된 스마트 계약을 상기 블록체인 네트워크에 업로드하는 계약 당사자 단말;a contract party terminal for uploading a homomorphic encrypted smart contract to the block chain network;

상기 블록체인 네트워크에 참여한 노드들로 이루어지며, 스마트 계약의 유효성을 검증하기 위한 제1분산 합의 네트워크;a first distributed consensus network consisting of nodes participating in the blockchain network and for verifying the validity of a smart contract;

상기 블록체인 네트워크에 참여한 노드에 의해 구현되며, 조건에 따른 계약 이행의 적합성을 판단하는 계약 이행 단말;a contract fulfillment terminal implemented by nodes participating in the block chain network and determining suitability of contract execution according to conditions;

상기 블록체인 네트워크에 참여한 노드들로 이루어지며, 조건에 따른 계약 이행의 적합성을 검증하기 위한 제2분산 합의 네트워크를 포함하며,Consists of nodes participating in the blockchain network, and includes a second distributed consensus network to verify the suitability of contract execution according to conditions,

여기서, here,

상기 계약 당사자 단말은 자연어로 작성된 스마트 계약을 바이트 코드로 변환하는 템플릿-코드 사상 모듈 및 바이트 코드 중에서 암호화할 변수를 선택하여 암호화하는 전처리 모듈을 포함하며,The contract party terminal includes a template-code mapping module that converts a smart contract written in natural language into byte code, and a pre-processing module that selects and encrypts a variable to be encrypted from among the byte code,

상기 계약 이행 단말은 조건에 따른 계약 이행을 판단하고, 동형 암호 비교 연산이 있을 경우 상기 제2 분산 네트워크와의 합의에 의해 동형 암호 비교 연산 결과를 복호화하는 것을 특징으로 한다.The contract fulfillment terminal determines the contract fulfillment according to the condition, and if there is a homomorphic encryption comparison operation, it decrypts the homomorphic encryption comparison operation result by agreement with the second distributed network.

여기서, 상기 제2 분산 합의 네트워크에 참여하는 노드들이 동형 암호 비교 연산 결과에 해당하는 평문을 공유하고, 각 노드들은 상기 계약 이행 단말에서 제공되는 암호문을 복호하여 공유된 평문과 비교하여 일치 여부를 판단하고, 판단 결과를 이웃 노드들에 전파하고, 각 노드들은 이웃 노드들로부터 수령한 값들 중 정족수 이상의 노드들이 합의한 값을 선정하고 선정된 값을 합의를 착수한 노드(리더)에 전달하며,Here, the nodes participating in the second distributed consensus network share the plaintext corresponding to the homomorphic encryption comparison operation result, and each node decrypts the ciphertext provided by the contract fulfillment terminal and compares it with the shared plaintext to determine whether they match and propagates the judgment result to neighboring nodes, each node selects a value agreed upon by nodes with a quorum or more among the values received from neighboring nodes, and delivers the selected value to the node (leader) that initiated the agreement,

상기 리더는 정족수 이상의 노드들이 합의한 값을 선정하여 합의의 결과로서 채택하여 상기 계약 이행 단말에 제공하는 것을 특징으로 한다.The leader selects a value agreed upon by the nodes having a quorum or more, adopts it as a result of the agreement, and provides it to the contract fulfillment terminal.

여기서, 상기 리더는 상기 제2 분산 합의 네트워크의 분산 합의에 의해 선정되는 것을 특징으로 한다.Here, the leader is selected by the distributed consensus of the second distributed consensus network.

여기서, 상기 리더가 장애로 인하여 더 이상 가용되지 않는 경우는 정해진 순서에 따라 다음 리더가 선정되고 분산 합의에 의해 승인되는 것을 특징으로 한다.Here, when the leader is no longer available due to a failure, the next leader is selected in a predetermined order and approved by distributed agreement.

여기서, 상기 제2 분산 합의 네트워크에 참여하는 노드들은 상기 계약 이행 단말로부터 수신한 암호문과 공유된 평문을 비교함에 의해 암호문을 복호화하는 복호화 모듈을 포함하는 것을 특징으로 한다.Here, the nodes participating in the second distributed consensus network may include a decryption module that decrypts the encrypted text by comparing the shared plain text with the encrypted text received from the contract fulfillment terminal.

여기서, 상기 계약 당사자 단말은 상기 계약 이행 단말로부터 정족수 이상의 합의가 있을 경우 계약이 적합하게 완료된 것으로 판단하여 스마트 계약을 종료하는 것을 특징으로 한다.Here, the contract party terminal determines that the contract is suitably completed when there is a quorum or more agreement from the contract execution terminal, and terminates the smart contract.

본 발명에 따르면, 동형암호를 이용하여 smart contract를 작성하게 됨으로써 사용자는 별도의 프라이빗 블록체인 네트워크를 구축할 필요가 없이 기밀성을 확보하면서 기존 블록체인 생태계에서 기밀성과 무결성을 동시에 보장하는 스마트 계약을 수행할 수 있게 하는 효과가 있다. According to the present invention, by creating a smart contract using the homomorphic encryption, the user does not need to build a separate private blockchain network and secures confidentiality while simultaneously ensuring confidentiality and integrity in the existing blockchain ecosystem. It has the effect of making it possible.

도 1은 블록체인 구조를 도시한다.
도 2는 블록체인의 작동 과정을 보인다.
도 3은 블록체인의 블록 구조를 보인다.
도 4는 블록체인 기반의 스마트 계약 생성 및 실행 과정을 도시한다.
도 5는 본 발명이 적용되는 블록체인 네트워크의 구성을 보인다.
도 6은 암호화된 스마트 계약의 유효성을 검증하기 위한 PBFT 분산 합의 알고리즘의 개요를 보인다.
도 7은 본 발명에 따른 동형암호를 이용한 스마트 계약 수행 과정을 개략적으로 과정도이다.
도 8은 본 발명에 따른 스마트 계약 수행 방법을 보이는 흐름도이다.
도 9는 본 발명에 따른 블록체인 기반의 스마트 계약 수행 시스템의 구성을 보인다.
도 10은 본 발명에 따른 스마트 계약 수행 방법을 보이는 과정도이다.
도 11은 블록체인에서 스마트 계약서의 유효성을 검증하는 과정을 보이는 흐름도이다.
도 12는 계약 이행 단말에 의한 스마트 계약 합의 과정을 보이는 흐름도이다.
도 13은 계약 이행 단말에 의한 스마트 계약의 이행 과정을 보이는 흐름도이다.
도 14는 비교 연산기의 예를 보인다.
1 shows the blockchain structure.
Figure 2 shows the operation process of the blockchain.
3 shows the block structure of a blockchain.
4 shows the process of creating and executing a blockchain-based smart contract.
5 shows the configuration of a blockchain network to which the present invention is applied.
6 shows an overview of the PBFT distributed consensus algorithm for validating encrypted smart contracts.
7 is a schematic flowchart of a smart contract execution process using homomorphic encryption according to the present invention.
8 is a flowchart showing a smart contract execution method according to the present invention.
9 shows the configuration of a blockchain-based smart contract execution system according to the present invention.
10 is a process diagram showing a smart contract execution method according to the present invention.
11 is a flowchart showing the process of verifying the validity of a smart contract in a blockchain.
12 is a flowchart illustrating a smart contract agreement process by a contract fulfillment terminal.
13 is a flowchart illustrating a smart contract implementation process by a contract fulfillment terminal.
14 shows an example of a comparison operator.

이하, 첨부된 도면을 참조하여 본 발명의 구성 및 동작을 상세히 설명하기로 한다.Hereinafter, the configuration and operation of the present invention will be described in detail with reference to the accompanying drawings.

도 5는 본 발명이 적용되는 블록체인 시스템의 구성을 보인다.5 shows the configuration of a block chain system to which the present invention is applied.

도 5를 참조하면, 본 발명이 적용되는 블록체인 시스템에는 계약 당사자 단말(10), 계약 이행 단말(20), 스마트 계약의 유효성을 판단하기 위한 분산 합의 네트워크(제1 분산 합의 네트워크, 30), 동형 암호 연산의 복호화를 위한 제2분산 합의 네트워크(40)가 포함된다. 5, the blockchain system to which the present invention is applied includes a contract party terminal 10, a contract fulfillment terminal 20, a distributed consensus network for determining the validity of a smart contract (first distributed consensus network, 30), A second distributed consensus network 40 for decrypting homomorphic cryptographic operations is included.

제1 분산 합의 네트워크(30)는 블록체인 네트워크 기반에서 분산 합의를 통해 스마트 계약의 유효성을 검증하기 위한 네트워크이다.The first distributed consensus network 30 is a network for verifying the validity of a smart contract through distributed consensus based on a blockchain network.

여기서, 제2 분산 합의 네트워크(40)는 블록체인 네트워크 기반에서 동형 암호 비교 연산에 의해 조건에 따른 계약 이행의 적합성을 검증하기 위한 분산 합의 네트워크이다. 제2 분산 합의 네트워크(40)에 참여할 노드들은 기본적으로 블록체인 네트워크에서 분산 합의에 참여하는 기준에 따른다. 보통은 전부 참여하거나, 스테이크(stake)가 높은 노드들, 즉 보유 가상암호화폐가 상대적으로 많고 트랜잭션(transaction)에 참여도가 낮은 노드들이 우선적으로 선정될 수도 있다(이더리움(Ethereum) 방식). Here, the second distributed consensus network 40 is a distributed consensus network for verifying the suitability of contract execution according to conditions by homomorphic cryptographic comparison operation based on a block chain network. Nodes to participate in the second distributed consensus network 40 basically follow the criteria for participating in distributed consensus in the blockchain network. Usually, all participants, or nodes with high stakes, that is, nodes with relatively large number of virtual cryptocurrencies and low participation in transactions, may be selected preferentially (Ethereum method).

이더리움 방식을 취하는 경우 잘못된 검증을 하는 것에 대해서 보상을 할 수 있도록 검증 노드들이 저당 (Collateral)을 잡힌다. 스테이크(Stake)가 높은 노드들일수록 저당을 잃는 것을 두려워하여 제대로 된 검증을 하게 된다. 이 검증 체계는 스마트 계약 체결의 신속성에 대한 요청에 따라서 탄력적으로 설정 가능하다. In case of taking the Ethereum method, verification nodes are collateralized to compensate for incorrect verification. Nodes with higher stakes are afraid of losing their mortgage, so they perform proper verification. This verification system can be set flexibly according to the request for speedy smart contract execution.

먼저, 계약 당사자 단말(10)은 스마트 계약을 작성하고, 암호화하고자 하는 변수를 동형암호를 이용하여 암호화한 암호문을 포함하는 암호화된 스마트 계약을 작성하여 블록체인 네트워크에 업로드한다. First, the contract party terminal 10 writes a smart contract, creates an encrypted smart contract including a ciphertext obtained by encrypting a variable to be encrypted using a homomorphic encryption, and uploads it to the blockchain network.

구체적으로, 계약 당사자 단말(10)은 스마트 계약을 작성하고, 작성된 스마트 계약을 바이트 코드(스마트 계약 실행문)로 컴파일하고, 컴파일된 바이트 코드 중에서 계약에 포함되는 변수를 동형 암호를 이용하여 암호화하여 암호화된 스마트 계약을 작성하고, 적성된 암호화된 스마트 계약을 삽입한 블록을 생성하고, 생성된 블록을 블록체인에 업로드한다.Specifically, the contract party terminal 10 creates a smart contract, compiles the created smart contract into byte code (smart contract execution statement), and encrypts variables included in the contract among the compiled byte codes using homomorphic encryption. Write an encrypted smart contract, create a block with the aptitude encrypted smart contract inserted, and upload the created block to the blockchain.

여기서, 동형암호는 패스워드(password), 대칭 키 암호화, 비대칭 암호화에 이은 제4세대 암호로서, 암호화된 상태에서의 산술적인 계산이 가능한 암호를 칭한다. 즉, ‘암호문(cipher) 사이에 연산한 값’을 통해서도 ‘평문에서 연산한 값’을 알아낼 수 있다. Here, the homomorphic encryption is a fourth-generation encryption following password, symmetric key encryption, and asymmetric encryption, and refers to encryption capable of arithmetic calculation in an encrypted state. In other words, it is possible to find out the ‘value calculated in the plaintext’ even through the ‘value calculated between ciphers’.

동형암호는 복호화하지 않은 상태(암호가 걸린 상태)에서 사칙 연산을 할 수 있는 수학 알고리즘으로 분석 결과는 암호를 걸기 전의 데이터로 분석한 결과와 똑같이 나오므로 상대방에 대한 정보 없이도 상태에 대한 변화를 합법적으로 증명할 수 있는 방식에 널리 사용될 수 있다. Homomorphic encryption is a mathematical algorithm that can perform arithmetic operations in an undecrypted state (with a password attached). It can be widely used in a way that can be proved by

이를 이용하여, 본 발명은 스마트 계약을 작성하는 과정에서 외부에 공개하고 싶지 아니한 정보(본 발명의 요약에 있어서의 중요 변수)를 동형암호로 암호화한다. 외부에 공개하지 않지만, 무결성은 암호문 사이에 연산한 값을 통해 검증이 가능하다. 앞서 언급하였듯이, 암호문 사이에 연산한 값에서 평문에서 연산한 값을 알아낼 수 있기 때문이다. Using this, the present invention encrypts information (an important variable in the summary of the present invention) that you do not want to be disclosed to the outside in the process of creating a smart contract with a homomorphic encryption. Although it is not disclosed to the outside, the integrity can be verified through the value calculated between the ciphertexts. This is because, as mentioned earlier, the value calculated in the plaintext can be found from the value calculated between the ciphertexts.

예컨대, 구좌 A의 잔액 10,000원이 있는 상태에서 2,000원을 잔액 0원의 구좌 B에 넘겨주면서 A에는 8,000원이 남게 되고, B에는 2,000원의 잔액이 생기는 것을 증명하고자 한다. For example, we want to prove that while there is a balance of 10,000 won in account A, and 2,000 won is transferred to account B with a balance of 0, 8,000 won remains in A and a balance of 2,000 won is generated in B.

A와 B의 초기 잔액을 각각 I(A)와 I(B), 이체액을 Y, A와 B의 거래 이후 잔액을 각각 B(A)와 B(Y)라고 하였을 때, 아래의 암호화된 산술식 (1)과 (2)가 있다고 하자. Assuming that the initial balances of A and B are I(A) and I(B), the transfer amount is Y, and the balance after the transaction of A and B is B(A) and B(Y), respectively, the encrypted arithmetic below Suppose we have equations (1) and (2).

I(A) - Y = B(A) -- (1) I(A) - Y = B(A) -- (1)

Y + I(B) = B(B) -- (2) Y + I(B) = B(B) -- (2)

최종 잔액의 무결성이 암호화된 (1)과 (2)같은 산술식에서 검증이 가능하다는 것이다. The fact that the integrity of the final balance can be verified in encrypted arithmetic expressions such as (1) and (2).

참고로, 하기의 수식들은 각종 연산에 대한 동형 암호화 절차를 보인다.For reference, the following equations show homomorphic encryption procedures for various operations.

1) 덧셈식에 대한 동형 암호화 절차:1) Homomorphic encryption procedure for addition expression:

Figure 112019056963812-pat00001
Figure 112019056963812-pat00001

2) 곱셈식에 대한 동형 암호화 절차2) Homomorphic Encryption Procedure for Multiplication Expressions

Figure 112019056963812-pat00002
Figure 112019056963812-pat00002

3) 뺄셈식에 대한 동형 암호화 절차3) Homomorphic Encryption Procedure for Subtraction Expressions

Figure 112019056963812-pat00003
Figure 112019056963812-pat00003

4) 나눗셈에 대한 동형 암호화 절차4) homomorphic encryption procedure for division

Figure 112019056963812-pat00004
Figure 112019056963812-pat00004

5) 비교 연산에 대한 동형 암호와 절차5) Homomorphic ciphers and procedures for comparison operations

Figure 112019056963812-pat00005
Figure 112019056963812-pat00005

제1분산 합의 네트워크(30)에 참여한 노드들은 스마트 계약의 유효성을 검증한다. The nodes participating in the first distributed consensus network 30 verify the validity of the smart contract.

도 6은 스마트 계약의 유효성을 검증하기 위한 제1분산 합의 네트워크의 합의 알고리즘의 개요를 보인다.6 shows an overview of the consensus algorithm of the first distributed consensus network for verifying the validity of a smart contract.

PBFT(Practical Byzantine Fault Tolerance)는 분산 시스템이 약속된 행동을 하지 않는 비잔틴 노드(Byzantine node)가 존재할 수 있는 비동기 시스템일 때 해당 분산 시스템에 참여한 모든 노드가 성공적으로 합의를 이룰 수 있도록 개발된 합의 알고리즘이다. PBFT 합의 알고리즘은 프라이머리(Primary) 혹은 리더(Leader)라 불리는 특별한 노드가 존재한다. 이 노드는 클라이언트의 요청을 다른 노드들에게 뿌려주는 역할을 한다.PBFT (Practical Byzantine Fault Tolerance) is a consensus algorithm developed so that all nodes participating in the distributed system can successfully reach consensus when the distributed system is an asynchronous system in which Byzantine nodes that do not perform the promised behavior can exist. am. In the PBFT consensus algorithm, there is a special node called a primary or a leader. This node is responsible for distributing client requests to other nodes.

합의는 다음과 같이 수행된다. The agreement is carried out as follows.

1) 리더가 클라이언트들의 요청을 수집하여 다른 노드들에 전파한다. 1) The leader collects requests from clients and propagates them to other nodes.

2) 리더의 메시지를 받은 노드들은 메시지가 리더로부터 받은 것이 맞는지 확인한 후 다시 한 번 모든 노드들에게 전파한다. 2) After receiving the message from the leader, the nodes verify that the message was received from the leader and then propagate it to all nodes once again.

3) 모든 노드는 자신이 다른 노드에서 가장 많이 받은 같은 메시지(정족수 이상의)를 선택한다.3) Every node chooses the same message (more than a quorum) that it receives the most from other nodes.

1) 2) 3)의 과정이 끝나면 모든 노드들은 정족수 이상이 동의한, 즉 합의를 이룬 같은 요청(스마트 계약)을 가지게 된다.After the process of 1) 2) 3), all nodes have the same request (smart contract) agreed upon by a quorum or more.

제1 분산 합의 네트워크에 참여한 노드들 중에서 정족수를 만족하는 노드들에 의해 스마트 계약의 유효성이 검증되면, 계약 이행 단말이 스마트 계약에 따른 계약 내용을 이행하고, 스마트 계약의 적합성 여부를 평가한다.When the validity of the smart contract is verified by the nodes that satisfy the quorum among the nodes participating in the first distributed consensus network, the contract execution terminal executes the contract contents according to the smart contract and evaluates whether the smart contract is suitable.

계약 이행 단말은 스마트 계약을 이행을 위한 조건 평가에 의해 조건에 따른 계약 이행의 적합성 여부를 평가한다. 또한, 스마트 계약에 포함된 모든 조건들이 모두 이행된 경우, 동형 암호 비교 연산에 의해 조건에 따른 계약 이행의 적합성을 판단한다. 복수의 노드들이 동형 암호 비교 연산의 복호화를 위한 제2분산 합의 네트워크를 구성하고, 정족수가 넘은 노드들이 계약 이행이 적합하게 완료된 것으로 검증하면, 해당 스마트 계약이 적합하게 완료된 것으로 처리된다. The contract fulfillment terminal evaluates the suitability of contract execution according to the conditions by evaluating the conditions for implementing the smart contract. In addition, when all conditions included in the smart contract are fulfilled, the suitability of contract execution according to the conditions is determined by the homomorphic cryptographic comparison operation. If a plurality of nodes constitute the second distributed consensus network for decrypting the homomorphic cryptographic comparison operation, and the nodes exceeding the quorum verify that the contract execution has been properly completed, the corresponding smart contract is treated as appropriately completed.

도 5에 도시된 시스템에 따르면, 동형암호를 이용하여 스마트 계약을 작성하게 됨으로써 사용자는 별도의 프라이빗(private) 블록체인 네트워크를 구축할 필요가 없이 기밀성을 확보하면서 기존 블록체인 생태계에서 기밀성과 무결성을 동시에 보장하는 스마트 계약을 수행할 수 있게 효과가 있다. According to the system shown in FIG. 5, by creating a smart contract using homomorphic encryption, the user does not need to build a separate private blockchain network, and secures confidentiality while maintaining confidentiality and integrity in the existing blockchain ecosystem. At the same time, it is effective to perform a guaranteed smart contract.

도 7은 본 발명에 따른 동형암호를 이용한 스마트 계약 수행 과정을 개략적으로 과정도이다.7 is a schematic flowchart of a smart contract execution process using homomorphic encryption according to the present invention.

도 7을 참조하면, s702과정에서 계약 당사자 단말은 스마트 계약을 작성한다. 이 때 암호화될 정보는 동형 암호 함수를 이용하여 암호화하여 바이트 코드 내부에 삽입하도록 한다. Referring to FIG. 7 , in step s702, the contract party terminal creates a smart contract. At this time, the information to be encrypted is encrypted using a homomorphic encryption function and inserted into the byte code.

예컨대, 현재 잔액 10,000원에서 2,000원을 이체하는 것이 계약 내용의 이라고 했을 때 동형암호 함수 H()를 이용하여 10,000 및 2,000 각각을 변수로 취한 결과값, 즉 H(10000)과 H(2000)의 결과값(즉, 동형 암호화된 암호문)들로 대체하고 , 스마트 계약에서는 H(10000) - H(2000)이 평문 8,000의 동형 암호값이 된다고 명시한다. 여기서, H(10000) - H(2000)이 평문 8,000의 동형 암호값이 된다고 명시하는 연산문은 본 발명의 요약에 있어서의 동형 암호 비교 연산에 해당한다. (H(10000) - H(2000) 자체는 ‘동형암호 연산’이고, ‘- H(2000) = 8000’가 ‘동형암호 비교연산’에 해당한다.)For example, when transferring 2,000 won from the current balance of 10,000 won is in the contract, the result of taking 10,000 and 2,000 as variables using the homomorphic cryptographic function H(), that is, the result of H(10000) and H(2000) It is replaced with the result value (that is, isomorphic encrypted ciphertext), and in the smart contract, it is specified that H(10000) - H(2000) is the homomorphic encryption value of 8,000 plaintext. Here, the operation statement specifying that H(10000) - H(2000) becomes the homomorphic encryption value of the plaintext 8,000 corresponds to the homomorphic encryption comparison operation in the summary of the present invention. (H(10000) - H(2000) itself is a ‘homomorphic encryption operation’, and ‘-H(2000) = 8000’ corresponds to a ‘homomorphic encryption comparison operation’.)

정족수 이상의 계약 이행 단말로부터 복호화된 결과로서 계약이 적합하게 수행된 것으로 판단되면, 계약 당사자 단말은 스마트 계약을 종료한다.If it is determined that the contract has been properly performed as a result of decryption from the contract fulfillment terminals having a quorum or more, the contract party terminal terminates the smart contract.

계약 수행 후의 암호값이 H(8000)의 값, 예컨대 Y라고 하자 Let the cryptographic value after contract execution be the value of H (8000), for example Y.

s704 과정에서 사용자는 암호화된 스마트 계약을 블록체인 네트워크에 업로드한다. In process s704, the user uploads the encrypted smart contract to the blockchain network.

s706 과정에서 블록체인 네트워크 내부의 계약 이행 단말은 해당 스마트 계약을 이행한다. In process s706, the contract execution terminal inside the blockchain network implements the corresponding smart contract.

도 8은 본 발명에 따른 스마트 계약의 수행 방법을 보이는 흐름도이다.8 is a flowchart showing a method of performing a smart contract according to the present invention.

먼저, 계약 당사자 단말이 스마트 계약을 작성한다.(s802)First, the contract party terminal creates a smart contract (s802).

계약 당사자 단말이 자연어로 작성된 스마트 계약을 바이트 코드(스마트 계약 실행문)으로 변환한다.(s804)The contract party terminal converts the smart contract written in natural language into byte code (smart contract execution statement). (s804)

바이트 코드 내부의 변수를 동형암호에 의해 암호화한다.(s806)Variables inside the bytecode are encrypted by homomorphic encryption. (s806)

스마트 계약의 유효성을 검증한다.(s808)Validate the smart contract (s808)

스마트 계약의 유효성이 검증되면, 계약 이행 단말은 검증된 스마트 계약을 이행한다.(s810)When the validity of the smart contract is verified, the contract execution terminal executes the verified smart contract (s810).

동형 암호 비교 연산이 있을 경우, 계약 이행 단말은 동형 암호 비교 연산을 수행하고, 동형 암호 비교 연산 결과를 분산 합의 네트워크를 이용하여 복호화한다.(s812, s814)If there is a homomorphic cryptographic comparison operation, the contract fulfillment terminal performs the homomorphic cryptographic comparison operation and decrypts the homomorphic cryptographic comparison operation result using a distributed consensus network (s812, s814).

계약 이행 단말은 계약 당사자 단말에 스마트 계약 이행 결과를 전달한다.(s816)The contract fulfillment terminal delivers the smart contract execution result to the contract party terminal. (s816)

정족수 이상의 동일한 결과가 선택되었다면, 계약 당사자 단말은 스마트 계약을 종료한다.(s818)If the same result of more than a quorum is selected, the contract party terminal terminates the smart contract (s818).

도 8에 있어서, 동형 암호 비교 연산은 스마트 계약의 내용이 정당한 지를 판단하기 위하여 스마트 계약에 포함된 암호문에 의해 동형 암호 비교 연산을 수행하는 과정이다. In FIG. 8 , the homomorphic cryptographic comparison operation is a process of performing the homomorphic cryptographic comparison operation by the ciphertext included in the smart contract in order to determine whether the contents of the smart contract are legitimate.

동형 암호 비교 연산은 작거나, 크거나, 작거나 같거나, 크거나 같거나, 같거나 등의 연산문에 의해 수행된다. 이러한 동형 암호 비교 연산은 동형 암호문의 수리적 적합성을 평가하기 위한 것이다. A homomorphic cryptographic comparison operation is performed by an operation statement of less than, greater than, less than, equal to, greater than or equal to, equal to, or the like. This homomorphic cipher comparison operation is to evaluate the mathematical suitability of the homomorphic ciphertext.

동형 암호 비교 연산은 암호문 간 연산을 통해 나온 값과 스마트 계약에 명시된 계약 이행 후의 값이 동일한 지를 검사한다. The homomorphic cryptographic comparison operation checks whether the value obtained through the ciphertext operation is the same as the value after contract execution specified in the smart contract.

예컨대, Z == Y, 즉 직접 암호문 간 연산을 통해서 나온 Z값과 계약서에 나온 암호문의 값 즉, H(8000)의 결과값인 Y가 서로 같은 지 동형 암호 비교 연산을 통해서 확인한다. For example, Z == Y, that is, the Z value obtained through direct ciphertext operation and the value of the ciphertext in the contract, that is, Y, the result value of H(8000), is verified through a homogeneous encryption comparison operation.

동형 암호 비교 연산의 결과 역시 암호문이 된다. The result of the homomorphic cryptographic comparison operation is also a ciphertext.

동형 암호 비교 연산의 결과값이 올바른 것(True)인지 올바르지 않은 것(False)인지는 정해진 기존 비대칭 암호 체계를 통해서 특정 서버에서 확인 가능하다. Whether the result value of the homomorphic cryptographic comparison operation is correct (True) or incorrect (False) can be checked in a specific server through the established asymmetric cryptosystem.

그러나 본 발명에서는 블록체인의 탈중앙화 성격을 유지하고자, 암호문 간의 연산 결과와 계약상 비교해야할 암호문 값 간의 비교를 주변 노드들이 수행을 하고, 비교의 결과값이 평문으로 무엇인지는 분산 합의 (Distributed Consensus)를 통해서 결정하는 방식을 취한다. 본 발명에 있어서 PBFT 방식의 알고리즘이 적용될 수 있다.However, in the present invention, in order to maintain the decentralized nature of the block chain, the neighboring nodes perform a comparison between the computation result between ciphertexts and the ciphertext value to be compared contractually, and the result of the comparison is determined in plaintext by distributed consensus (Distributed Consensus). ) to make a decision. In the present invention, a PBFT algorithm may be applied.

구체적으로, 비교 결과값이 평문으로는 무엇인지 계약 완료의 적합성을 검증하기 위한 분산 합의 네트워크에 참여하는 각 노드들이 공유한다. 각 노드들은 이웃 노드로부터 수령한 값들 중 정족수 이상의 노드들이 손을 들어준 값을 선정하고 합의를 착수한 노드(리더)에 전달하도록 한다. Specifically, what the comparison result is in plaintext is shared by each node participating in the distributed consensus network to verify the suitability of contract completion. Each node selects a value accepted by a quorum or more among the values received from neighboring nodes, and transmits the consensus to the node (leader).

합의 과정을 착수하는 노드를 리더라고 부른다. 이 리더는 정해진 순서에 따라서 선정이 된다. 선정 시 승인 역시 분산 합의를 따르고, 합의를 통해 최종 승인된 리더는 안정적으로 역할을 수행한다고 전제한다. 리더가 장애로 인하여 더 이상 가용되지 않는 경우는 다음 리더가 선정되고 분산 합의에 의해 승인된다. The node that initiates the consensus process is called the leader. This leader is selected according to a set order. When selected, approval also follows distributed consensus, and it is assumed that the leader who is finally approved through consensus performs its role stably. When a leader is no longer available due to a disability, the next leader is selected and approved by distributed consensus.

도 9는 본 발명에 따른 스마트 계약 수행 시스템의 구성을 보인다.9 shows the configuration of a smart contract execution system according to the present invention.

도 9를 참조하면, 본 발명에 따른 스마트 계약 수행 시스템은 계약 당사자 단말(20), 제1 분산 합의 네트워크(30), 제2 분산 합의 네트워크(40)를 포함한다. 계약 당사자 단말(10)은 계약코드 사상(mapping) 모듈(12)과 스마트 계약 전처리 모듈(14)을 포함한다.Referring to FIG. 9 , the smart contract execution system according to the present invention includes a contract party terminal 20 , a first distributed consensus network 30 , and a second distributed consensus network 40 . The contract party terminal 10 includes a contract code mapping module 12 and a smart contract preprocessing module 14 .

제1분산 합의 네트워크(30)는 합의 모듈(32) 및 계약 이행 모듈(20)을 포함한다.The first distributed consensus network 30 includes a consensus module 32 and a contract fulfillment module 20 .

동형 암호 비교 연산 평가용 제2 분산 합의 네트워크(40)는 복수의 노드를 포함하며, 각각의 노드는 복호화 모듈(42)을 포함한다. 제1 분산 합의 네트워크(30) 내부의 합의 모듈(32)이 수행하는 것과 같은 방식으로, 동형 암호 비교 평가를 위한 제1 분산 합의 네트워크(40) 아래의 각각의 노드들은 각자 동형 암호 비교 평가의 평가 결과를 복호화하여 동형 암호 비교 평가의 평가를 요청한 블록체인 네트워크의 노드에게 전달한다. 블록체인 네트워크의 노드는 정족수 이상의 동일한 답변을 합의 결과로 채택하게 된다.The second distributed consensus network 40 for homomorphic cryptographic comparison operation evaluation includes a plurality of nodes, and each node includes a decryption module 42 . In the same way as the consensus module 32 inside the first distributed consensus network 30 performs, each node under the first distributed consensus network 40 for homomorphic cryptographic comparison evaluation evaluates each homomorphic cryptographic comparison evaluation. The result is decrypted and delivered to the node of the blockchain network that requested the evaluation of homomorphic cryptographic comparison evaluation. Nodes in the blockchain network will adopt the same answer with more than a quorum as a result of consensus.

도 10은 본 발명에 따른 스마트 계약 수행 시스템에 의한 스마트 계약 수행 과정을 보이는 과정도이다.10 is a process diagram showing a smart contract execution process by the smart contract execution system according to the present invention.

계약 당사자 단말은 템플릿-코드 사상 모듈(template-code mapping module) 및 스마트 계약 전처리 모듈(smart contract pre-processing module)을 포함한다.The contract party terminal includes a template-code mapping module and a smart contract pre-processing module.

도 10을 참조하면, 먼저 계약 당사자 단말(10)이 원하는 계약서 템플릿을 선택한 후 스마트 계약서를 작성한다(s1002). 계약 당사자 단말(10)은 계약의 내용상 둘 이상일 수 있지만 여기서는 설명을 간략하게 하기 위해 대표적인 계약 당사자 단말만을 들어 설명한다. Referring to FIG. 10 , first, the contract party terminal 10 selects a desired contract template and then creates a smart contract (s1002). The contract party terminal 10 may be two or more in terms of the contents of the contract, but only a representative contract party terminal will be described here in order to simplify the description.

계약 당사자 단말(10)은 텍스트폼 (form) 등, UI widget으로 구성된 계약서 양식에 따라서 계약 내용을 기입한다. The contract party terminal 10 writes the contract contents according to the contract form composed of UI widgets, such as a text form.

다음으로, 계약 당사자 단말(10)은 자연어로 작성된 스마트 계약 내용을 템플릿-코드 사상 모듈(12)을 이용하여 바이트 코드로 컴파일(compile)한다(s1004). 템플릿-코드 사상 모듈(12)은 계약서 템플릿 및 코드 템플릿(미도시)을 포함한다.Next, the contract party terminal 10 compiles the smart contract content written in natural language into byte code using the template-code mapping module 12 (s1004). The template-code mapping module 12 includes a contract template and a code template (not shown).

계약 당사자 단말(10)은 계약서 템플릿을 이용하여 자연어로 작성된 스마트 계약을 정식 스마트 계약서로 변환하고, 계약서 템플릿에 해당하는 코드 탬플릿(컴파일러)을 선택 후 계약서 내용을 바이트 코드로 변환한다.The contract party terminal 10 converts a smart contract written in natural language into a formal smart contract using a contract template, selects a code template (compiler) corresponding to the contract template, and converts the contract content into byte code.

이와 같이, 계약 당사자 간 작성된 스마트 계약서가 ‘템플릿-코드 사상 모듈’을 통해 바이트 코드로 변환된다. 이 과정에서 계약서 템플릿과 이에 해당하는 미리 작성된 코드 템플릿이 일대일로 대응되어 있다면, 자동화가 가능하다.In this way, the smart contract written between the contracting parties is converted into byte code through the ‘template-code mapping module’. In this process, if the contract template and the corresponding pre-written code template are matched one-to-one, automation is possible.

작성된 코드가 블록체인 네트워크에 업로드 되기 전, 암호화하고자 하는 변수가 보이지 않도록 코드 내부에 삽입하기 위해 전 처리 과정을 통하여 암호화하고자 하는 변수를 암호화한다. 전처리 과정에서는 동형암호를 이용하여 암호화하고자 하는 변수를 암호화한다(s1006).Before the written code is uploaded to the blockchain network, the variable to be encrypted is encrypted through a pre-processing process to insert it into the code so that the variable to be encrypted is not visible. In the preprocessing process, the variable to be encrypted is encrypted using the homomorphic encryption (s1006).

그 과정은 다음과 같다.The process is as follows.

Figure 112019056963812-pat00006
Figure 112019056963812-pat00006

program 1; 전처리 과정을 거치지 않은 코드program 1; Code without preprocessing

Figure 112019056963812-pat00007
Figure 112019056963812-pat00007

program 2; 전처리 과정이 모두 수행된 코드program 2; Code with all preprocessing done

Figure 112019056963812-pat00008
Figure 112019056963812-pat00008

program 3; 전처리기 수행 코드program 3; preprocessor execution code

a) 전처리 모듈(Preprocessor, 14)은 암호화될 부분(평문)을 스마트 계약 내부에서 찾아낸다.(program 1의 라인1에 encryptFromPlain 함수가 사용됨)a) The preprocessor module (Preprocessor, 14) finds the part to be encrypted (plaintext) inside the smart contract. (The encryptFromPlain function is used in line 1 of program 1)

암호화될 평문은 문서상의 계약서로부터 ‘템플릿-코드 모듈’을 통해 자동으로 스마트 계약으로 변환된다. 변환 과정에서 미리 정해진 절차에 따라 계약서 내부의 키워드를 추출하여 미완성된 스마트 계약 템플릿에 채워 넣게 된다. 이 과정에서 미완성된 스마트 계약 템플릿에 채워질 키워드들이 전부 암호화 대상이 된다.The plaintext to be encrypted is automatically converted from the document contract into a smart contract through the ‘template-code module’. During the conversion process, keywords inside the contract are extracted according to a predetermined procedure and filled into the unfinished smart contract template. In this process, all keywords to be filled in the unfinished smart contract template are subject to encryption.

b) 전처리 모듈(14)은 a)에서 찾아낸 평문을 추출하여 program 2의 템플릿에 채워 넣는다. b) The preprocessing module 14 extracts the plaintext found in a) and fills it in the template of program 2.

c) 전처리 모듈(14)은 완성된 템플릿 코드(program 3)를 수행하여 암호문(cipher)을 저장한다.c) The preprocessing module 14 stores the cipher by executing the completed template code (program 3).

d) 스마트 계약 코드(program 1)에서 평문을 암호화 하던 부분을 c)에서 생성 및 저장된 암호문(cipher)을 불러오는 방식으로 변경한다.d) Change the plaintext encryption part in the smart contract code (program 1) to the method of calling the cipher generated and stored in c).

전처리 모듈(14)의 전처리 과정에서 기본적으로는 한 가지 동형 암호화만 사용되었다고 가정했지만 원하는 경우에는 각 암호화 변수마다 다른 암호화 기법을 적용하는 것도 가능하다. In the preprocessing of the preprocessing module 14, it is basically assumed that only one homomorphic encryption is used, but if desired, it is possible to apply a different encryption technique to each encryption variable.

다시 도 9를 참조하면, 제1분산 합의 네트워크(30)의 합의 모듈(32)에서는 스마트 계약의 유효성을 검증한다(s1008).Referring back to FIG. 9 , the consensus module 32 of the first distributed consensus network 30 verifies the validity of the smart contract (s1008).

제1분산 합의 네트워크(30)에 참여한 노드들 중에서 정족수를 만족하는 노드들에 의해 스마트 계약의 유효성이 검증되면, 계약 이행 단말(20)이 스마트 계약을 이행한다(s1008, s1010).If the validity of the smart contract is verified by the nodes satisfying the quorum among the nodes participating in the first distributed consensus network 30, the contract execution terminal 20 executes the smart contract (s1008, s1010).

도 11은 스마트 계약의 유효성을 검증하는 과정을 보이는 흐름도이다.11 is a flowchart showing a process of verifying the validity of a smart contract.

도 11을 참조하면, 계약의 유효성 검증을 위한 분산 네트워크에 참여한 노드들이 계약 당사자 단말이 업로드한 스마트 계약을 수신한다.(s1102) 계약의 유효성 검증을 위한 분산 네트워크에 참여하는 노드들은 기본적으로 블록체인 네트워크에 참여한 노드들이다. Referring to FIG. 11 , nodes participating in the distributed network for contract validation receive the smart contract uploaded by the contract party terminal (s1102). Nodes participating in the distributed network for contract validation are basically block chains. Nodes participating in the network.

노드는 수신된 스마트 계약의 전자 서명, 스마트 계약을 전달한 리더, 스마트 계약에 사상된 시퀀스 넘버를 검증한다.(s1104)The node verifies the digital signature of the received smart contract, the leader who delivered the smart contract, and the sequence number mapped to the smart contract (s1104).

여기서, 노드는 분산 합의 과정을 착수하고 합의 결과를 도출하여 요청한 이에게 전달하는 노드를 뜻한다.Here, the node refers to a node that initiates the distributed consensus process, derives the consensus result, and delivers it to the requester.

시퀀스 넘버는 블록의 헤더 정보를 조합해서 나온 스마트계약의 고유 정보이다. The sequence number is the unique information of the smart contract obtained by combining the header information of the block.

검증에 성공하면, 검증 사실을 다른 모든 블록체인 노드에 전달한다.(s1106, s1108)If the verification is successful, the verification fact is transmitted to all other blockchain nodes. (s1106, s1108)

노드는 다른 노드가 해당 거래를 검증했다는 사실을 수신한다.(s1110)The node receives the fact that other nodes have verified the transaction (s1110).

리더는 정족수 이상의 검증이 수집되었는지를 판단한다.(s1112)The leader determines whether verification of a quorum or more has been collected (s1112).

정족수 이상의 검증이 수집되면, 리더는 합의에 성공하였음을 블록체인의 계약 당사자 단말에 통지한다.(s1114)When the verification of more than a quorum is collected, the leader notifies the terminal of the contracting party of the block chain that the agreement has been successful. (s1114)

다시 도 10을 참조하면, 합의 모듈에 의해 스마트 계약의 유효성이 검증되면, 계약 이행 단말이 스마트 계약에 따른 스마트 계약을 이행한다(s1010). Referring back to FIG. 10 , when the validity of the smart contract is verified by the consensus module, the contract fulfillment terminal executes the smart contract according to the smart contract (s1010).

계약 이행 단말이 스마트 계약을 이행하는 과정에서 동형암호 비교 연산이 있으면, 제2분산 합의 네트워크에 의해 복호화한다.If there is a homomorphic encryption comparison operation in the process of the contract execution terminal implementing the smart contract, it is decrypted by the second distributed consensus network.

제2분산 합의 네트워크(40)에 참여하는 노드들은 복호화 모듈(42)을 구비한다.The nodes participating in the second distributed consensus network 40 have a decryption module 42 .

도 12는 계약 이행 단말에 의한 스마트 계약의 완료 적합성 검증 과정을 보이는 흐름도이다.12 is a flowchart illustrating a process of verifying completion suitability of a smart contract by a contract fulfillment terminal.

스마트 계약에 대한 합의가 종료되면, 계약 이행 모듈(20)은 스마트 계약의 이행을 시작하고(s1202), 동형 암호 비교 평가가 존재하는 지 즉, 동형 암호간 연산이 존재하는 지를 검사한다(s1204).When the agreement on the smart contract is terminated, the contract fulfillment module 20 starts the execution of the smart contract (s1202), and checks whether homomorphic cryptographic comparison evaluation exists, that is, homomorphic cryptographic operation exists (s1204) .

여기서, 계약 이행 모듈은 조건에 따른 계약 이행 여부를 암호문의 검증을 통해서 확인하는 모듈이다. 계약 이행 검증에 참여하는 모든 노드들에는 이 모듈이 탑재되어 있고, 이 모듈들에 프로그램된 분산 합의 프로세스에 따라서 이행이 검증이 된다 (분산 합의 알고리즘).Here, the contract fulfillment module is a module that confirms whether the contract is fulfilled according to the conditions through verification of the encrypted text. This module is loaded on all nodes participating in contract fulfillment verification, and implementation is verified according to the distributed consensus process programmed in these modules (distributed consensus algorithm).

동형암호가 존재하면, 동형암호간 연산을 수행하고(s1206), 직전에 수행한 연산이 동형 암호 비교 평가이었는지를 판단한다(s1208).If homomorphic encryption exists, the operation between homomorphic encryptions is performed (s1206), and it is determined whether the operation performed immediately before is homomorphic encryption comparison evaluation (s1208).

s1208에서 직전에 수행한 연산이 동형 암호 비교 평가이었는지를 판단하는 것은 동형암호의 연산을 수행하였을 때, 그 결과가 복호화가 필요한 비교 평가 연산인지, 복호화가 필요 없는 일반적인 산술연산(+, -, *, /)인지 판단하고자 하는 것이다. 산술연산을 수행한 경우는 제2 분산합의 네트워크를 사용할 필요가 없으므로 나머지 코드를 수행하면 되는 것 이고, 비교 연산을 수행한 경우는 암호화된 불린값을 복호화 해야 하므로 암호화된 불린값을 제2 분산합의 네트워크에 복호화 하도록 요청을 하는 과정이 필요하다.To determine whether the operation performed immediately before in s1208 was homomorphic encryption comparison evaluation, whether the result is a comparison evaluation operation requiring decryption when the homomorphic encryption operation is performed, or general arithmetic operations that do not require decryption (+, -, *, /) is what we want to determine. In the case of performing an arithmetic operation, there is no need to use the second distributed sum network, so the rest of the code is executed. A process of requesting the network to decrypt is necessary.

직전에 수행한 연산이 비교연산이었다면, 동형 암호 비교 평가를 위한 분산 네트워크와 상호 협력하여 복호화 결과를 검증한다(s1210). If the operation performed immediately before was a comparison operation, the decryption result is verified by mutual cooperation with a distributed network for homomorphic encryption comparison evaluation (s1210).

s1202(스마트 계약 이행 시작)는 이미 스마트 계약을 한 줄씩 수행하고 있음을 의미한다. 따라서 평문으로만 이루어진 코드 혹은 동형암호 산술연산(+, -, *, /)으로만 이루어진 경우, 계약 이행 모듈 혼자서 스마트 계약을 이행할 능력이 있다. 따라서 굳이 ‘나머지 코드를 수행한다’라는 표현을 할 필요가 없이 s1202단계에서 모든 계약을 이행할 수 있다. s1202 (Start Smart Contract Implementation) means that you are already executing the smart contract line by line. Therefore, in the case of only plaintext codes or homomorphic cryptographic arithmetic operations (+, -, *, /), the contract execution module alone has the ability to execute a smart contract. Therefore, all contracts can be executed in step s1202 without the need to express the expression 'execute the rest of the code'.

반면, 동형암호 비교연산이 스마트 계약 내부에 삽입된 경우 계약 이행 모듈 혼자서는 스마트 계약을 이행할 능력이 없다. 따라서 제2분산합의 네트워크를 사용해야 한다는 점을 명확히 표현하기 위해 계약 이행 모듈의 일을 잠시 멈추고, 제2 분산합의 네트워크에 비교연산을 위임한 다음 제2분산합의 네트워크의 일이 다 끝난 후 다시 계약 이행 모듈이 실행된다.On the other hand, if the homomorphic cryptographic comparison operation is inserted inside the smart contract, the contract fulfillment module alone has no ability to execute the smart contract. Therefore, in order to clearly express the need to use the second distributed agreement network, the contract fulfillment module is temporarily stopped, and the comparison operation is delegated to the second distributed agreement network. After the second distributed agreement network is finished, the contract is executed again The module is executed.

동형 암호 비교 연산은 동형 암호화된 두 암호의 값이 서로 같은지, 다른지, 큰지, 작은지 등의 여부를 비교 평가하는 연산이다. 예컨대, A < B 라는 비교 평가문이 있을 때, A가 실제로 B보다 작다면, 이 식은 부울 값으로 참값을 가지게 된다. 아니면 거짓값을 지니게 된다. 그런데, 동형 암호 비교 평가의 결과까지도 동형 암호에 의해 기밀화되므로, 이 부울값이 무엇인지 복호화를 통해서 확인해봐야 한다. Homomorphic cipher comparison operation is an operation that compares and evaluates whether the values of two isomorphic encrypted ciphers are the same, different, larger, smaller, etc. For example, when there is a comparative evaluation statement A < B, if A is actually less than B, this expression has a true value as a Boolean value. Otherwise, it will have a false value. However, since even the result of homomorphic encryption comparison evaluation is confidential by homomorphic encryption, it is necessary to check what this boolean value is through decryption.

계약 이행 모듈(20)이 탑재된 노드들은 직접 동형 암호 비교 연산 의 결과를 돌려보고 복호화 키를 통해서 실제 부울 값을 판단할 수가 있다. 동형 암호 비교 연산식의 부울 값이 무엇인지를 분산 합의 과정을 통해서 확인을 하고 이행이 제대로 되었는지 확인한다. Nodes equipped with the contract fulfillment module 20 can directly return the result of the homomorphic cryptographic comparison operation and determine the actual Boolean value through the decryption key. Check the boolean value of the homomorphic cryptographic comparison expression through the distributed consensus process and check whether the implementation is correct.

나머지 코드 수행 과정을 거치지 않는 경우는 동형암호가 쓰이지 않은 일반적인 스마트 계약의 경우이다.The case where the rest of the code execution process is not performed is the case of a general smart contract in which homomorphic encryption is not used.

동형암호가 쓰였으면서 동형 암호 비교 평가가 아닌 경우에는 조건 평가는 거치지 않지만, 나머지 코드 수행 과정은 거치게 된다. 이에 대한 것은 아래에 자세히 설명한다.If homomorphic encryption is used but not homomorphic encryption comparison evaluation, condition evaluation is not performed, but the rest of the code execution process is performed. This will be described in detail below.

비교연산이 아닌 경우는 두 가지이다.There are two cases where the comparison operation is not.

순수하게 기밀성을 유지할 목적으로 연산 없이 암호화만 진행한 경우.When encryption is performed without computation for the purpose of purely maintaining confidentiality.

산술연산(사칙연산)을 사용하는 경우.When using arithmetic operation (arithmetic operation).

위 두 경우 중 1번은 자명하므로, 2번의 경우에 대해 설명한다. Since case 1 of the above two cases is self-evident, case 2 will be described.

2번은 복호화 과정이 필요가 없기 때문에 조건 평가 과정을 수행하지 않는 것이다. 예를 들어 스마트 계약 내부에 어떠한 수들의 합계를 구하라고 명시가 되어있다면, 동형 암호 체계에 의하여 복호화 절차가 없이 합계를 구하는 것이 가능하다. 따라서 조건 연산 평가를 위한 복호화 모듈을 거칠 필요가 없다.No. 2 is that the condition evaluation process is not performed because the decoding process is not required. For example, if it is specified in the smart contract to obtain the sum of certain numbers, it is possible to obtain the sum without a decryption procedure by the homomorphic encryption system. Therefore, there is no need to go through the decoding module for conditional operation evaluation.

조건 평가 및 나머지 코드를 수행한다(s1212).Condition evaluation and the rest of the code are performed (s1212).

나머지 코드를 수행한다는 것은 도식화된 흐름도 이후의 프로그램을 수행한다는 것으로서 이행 중이던 스마트 계약을 마저 실행한다는 의미이다.Executing the rest of the code means executing the program after the schematic flowchart, and even executing the smart contract being implemented.

다시 도 10을 참조하면, 계약 당사자 단말(10)이 스마트 계약의 완료 여부를 확인한다(s1014).Referring back to FIG. 10 , the contract party terminal 10 checks whether the smart contract is completed (s1014).

도 13은 계약 당사자 단말의 스마트 계약 완료 확인 과정을 보이는 흐름도이다.13 is a flowchart illustrating a smart contract completion confirmation process of a contract party terminal.

도 13을 참조하면, 계약 당사자 단말(10)은 계약 이행 단말(20)로부터의 스마트 계약 결과의 수신을 대기한다(s1302). Referring to FIG. 13 , the contract party terminal 10 waits for reception of the smart contract result from the contract fulfillment terminal 20 ( s1302 ).

스마트 계약 결과를 수신하고(s1304), 정족수 이상의 동일한 결과가 존재하는 지를 판단한다(s1306).The smart contract result is received (s1304), and it is determined whether there is an identical result more than a quorum (s1306).

정족수 이상의 동일한 결과가 존재하면 합의를 완료하고 종료한다(s1308).If there is more than a quorum of the same result, the agreement is completed and terminated (s1308).

합의가 완료되었다는 것은 계약 내용이 이행이 제대로 잘 되었다는 것을 확인했다는 것이다.Completion of the agreement means that the contract has been properly executed.

도 14는 비교 연산 회로의 예를 보인다.14 shows an example of a comparison arithmetic circuit.

난드 게이트(NAND gate)는 유니버설 게이트(universal gate)이므로 임의의 비교연산 회로를 구성하는 것이 가능하다.Since the NAND gate is a universal gate, it is possible to configure an arbitrary comparison operation circuit.

본 명세서 및 청구범위에 사용된 용어나 단어는 통상적이거나 사전적인 의미로 한정해서 해석되어서는 아니 되며, 발명자는 그 자신의 발명을 가장 최선의 방법으로 설명하기 위해 용어의 개념을 적절하게 정의할 수 있다는 원칙에 입각하여 본 발명의 기술적 사상에 부합하는 의미와 개념으로 해석되어야만 한다.The terms or words used in the present specification and claims should not be construed as being limited to their ordinary or dictionary meanings, and the inventor may properly define the concept of the term in order to best describe his invention. It should be interpreted as meaning and concept consistent with the technical idea of the present invention based on the principle that there is.

따라서 본 명세서에 기재된 실시 예와 도면에 도시된 구성은 본 발명의 가장 바람직한 일 실시 예에 불과할 뿐이고, 본 발명의 기술적 사상을 모두 대변하는 것은 아니므로, 본 출원시점에 있어서 이들은 대체할 수 있는 다양한 균등물과 변형 예들이 있을 수 있음을 이해하여야 한다.Therefore, the embodiments described in this specification and the configurations shown in the drawings are only the most preferred embodiment of the present invention, and do not represent all of the technical spirit of the present invention. It should be understood that there may be equivalents and variations.

10...계약 당사자 단말 20...계약 이행 단말
30...제1 분산 합의 네트워크 40...제2 분산 합의 네트워크
10...Terminal of contracting party 20...Terminal of contract fulfillment
30...First Distributed Consensus Network 40...Second Distributed Consensus Network

Claims (12)

계약 당사자 단말, 스마트 계약의 유효성을 검증하기 위한 제1분산 합의 네트워크, 조건에 따른 계약 이행의 적합성을 판단하는 계약 이행 단말, 조건에 따른 계약 이행의 적합성을 검증하기 위한 제2분산 합의 네트워크를 포함하는 블록체인 네트워크 기반의 스마트 계약 수행 방법에 있어서,
상기 계약 당사자 단말이, 스마트 계약을 작성하는 과정에서 외부에 공개하고 싶지 않은 정보인 동형 암호화된 변수를 포함하는 스마트 계약을 블록체인 네트워크에 업로드하는 과정;
상기 제1분산 합의 네트워크에 참여한 노드들이 스마트 계약의 유효성을 검증하는 과정;
상기 제1분산 합의 네트워크에 참여한 노드들 중에서 정족수를 만족하는 노드들에 의해 스마트 계약의 유효성이 검증되면, 상기 계약 이행 단말이 스마트 계약의 계약 내용을 이행하는 과정; 및
상기 스마트 계약의 계약 내용에 작거나, 크거나, 작거나 같거나, 크거나 같거나, 또는 같거나의 연산문에 의해 수행되는 동형 암호 비교 연산이 있는 경우, 상기 계약 이행 단말이 제2분산 합의 네트워크에 참여한 노드들의 합의에 의해 동형 암호 비교 연산 결과를 복호화하는 과정;
계약 이행 단말이 복호화 결과를 계약 당사자 단말에 제공하는 과정; 및
정족수 이상의 계약 이행 단말이 적합한 계약 이행이 이루어진 것으로 합의된 경우, 상기 계약 당사자 단말이 스마트 계약을 종료하는 과정;을 포함하며,
상기 동형 암호 비교 연산은,
암호문 간 연산을 통해 나온 값과 상기 스마트 계약에 명시된 계약 이행 후의 값이 동일한지를 검사하는 과정을 포함하는 스마트 계약 수행 방법.
Includes a contract party terminal, a first distributed consensus network to verify the validity of a smart contract, a contract fulfillment terminal to determine the suitability of contract execution according to conditions, and a second distributed consensus network to verify the suitability of contract execution according to conditions In a method of performing a smart contract based on a blockchain network,
uploading, by the contract party terminal, a smart contract including homomorphic encrypted variables, which is information not to be disclosed to the outside in the process of creating a smart contract, to a block chain network;
a process in which nodes participating in the first distributed consensus network verify the validity of a smart contract;
when the validity of the smart contract is verified by the nodes that satisfy the quorum among the nodes participating in the first distributed consensus network, the contract execution terminal executes the contract contents of the smart contract; and
When there is a homomorphic cryptographic comparison operation performed by an operation statement of less than, greater than, less than, equal to, greater than, or equal to, in the contract content of the smart contract, the contract execution terminal performs the second distributed agreement A process of decrypting a homomorphic encryption comparison operation result by consensus of nodes participating in the network;
a process in which the contract fulfillment terminal provides a decryption result to the contract party terminal; and
When the contract fulfillment terminal with a quorum or more agrees that the appropriate contract has been performed, the contract party terminal terminates the smart contract;
The homomorphic cryptographic comparison operation is
A method of performing a smart contract, comprising the step of checking whether the value obtained through ciphertext operation is the same as the value after contract execution specified in the smart contract.
제1항에 있어서,
스마트 계약의 유효성을 검증하는 과정은 블록체인 네트워크에 참여한 노드들이 스마트 계약의 전자 서명, 스마트 계약을 전달한 리더, 스마트 계약에 사상된 시퀀스 넘버(sequence number)를 검증하는 과정;
검증한 노드 수가 정족수를 넘을 경우 해당 스마트 계약의 유효성이 검증된 것으로 처리하는 과정;
을 포함하는 것을 특징으로 하는 스마트 계약 수행 방법.
According to claim 1,
The process of verifying the validity of the smart contract is a process in which nodes participating in the blockchain network verify the electronic signature of the smart contract, the leader who delivered the smart contract, and the sequence number mapped to the smart contract;
If the number of verified nodes exceeds the quorum, the process of treating the validity of the smart contract as verified;
A method of performing a smart contract, comprising:
제1항에 있어서,
상기 복호화 과정은
상기 계약 이행 단말이 스마트 계약에 포함된 동형 암호 비교 연산을 연산하는 과정; 및
동형 암호 비교 연산 결과를 제2분산 합의 네트워크에 참여한 노드들로부터 검증받는 과정;
을 포함하는 것을 특징으로 하는 스마트 계약 수행 방법.
According to claim 1,
The decryption process is
calculating, by the contract fulfillment terminal, a homomorphic cryptographic comparison operation included in the smart contract; and
a process of verifying a homomorphic cryptographic comparison operation result from nodes participating in a second distributed consensus network;
A method of performing a smart contract, comprising:
제3항에 있어서,
제2분산 합의 네트워크에 참여하는 노드들이 동형 암호 비교 연산 결과에 해당하는 평문을 공유하고, 각 노드들은 상기 계약 이행 단말에서 제공되는 암호문을 복호하여 공유된 평문과 비교하여 일치 여부를 판단하고, 판단 결과를 이웃 노드들에 전파하고, 각 노드들은 이웃 노드들로부터 수령한 값들 중 정족수 이상의 노드들이 합의한 값을 선정하고 선정된 값을 합의를 착수한 노드(리더)에 전달하며,
상기 리더는 정족수 이상의 노드들이 합의한 값을 선정하여 합의의 결과로서 채택하여 상기 계약 이행 단말에 제공하는 것을 특징으로 하는 스마트 계약 수행 방법.
4. The method of claim 3,
Nodes participating in the second distributed consensus network share the plaintext corresponding to the homomorphic encryption comparison operation result, and each node decrypts the ciphertext provided by the contract fulfillment terminal and compares it with the shared plaintext to determine whether or not they match The result is propagated to the neighboring nodes, and each node selects the value agreed by the nodes with a quorum or more among the values received from the neighboring nodes, and delivers the selected value to the node (leader) that initiated the consensus,
The smart contract execution method, characterized in that the leader selects a value agreed upon by nodes with a quorum or more, adopts it as a result of the agreement, and provides it to the contract fulfillment terminal.
제4항에 있어서,
리더는 상기 제2분산 합의 네트워크의 분산 합의에 의해 선정되는 것을 특징으로 하는 스마트 계약 수행 방법.
5. The method of claim 4,
The smart contract execution method, characterized in that the leader is selected by the distributed consensus of the second distributed consensus network.
제5항에 있어서,
리더가 장애로 인하여 더 이상 가용되지 않는 경우는 정해진 순서에 따라 다음 리더가 선정되고 분산 합의에 의해 승인되는 것을 특징으로 하는 스마트 계약 수행 방법.
6. The method of claim 5,
When the leader is no longer available due to a failure, the next leader is selected in a predetermined order and is approved by distributed consensus.
스마트 계약을 작성하는 과정에서 외부에 공개하고 싶지 않은 정보인 동형 암호화된 변수를 포함하는 스마트 계약을 블록체인 네트워크에 업로드하는 계약 당사자 단말;
상기 블록체인 네트워크에 참여한 노드들로 이루어지며, 스마트 계약의 유효성을 검증하기 위한 제1분산 합의 네트워크;
상기 블록체인 네트워크에 참여한 노드에 의해 구현되며, 조건에 따른 계약 이행의 적합성을 판단하는 계약 이행 단말;
상기 블록체인 네트워크에 참여한 노드들로 이루어지며, 조건에 따른 계약 이행의 적합성을 검증하기 위한 제2분산 합의 네트워크를 포함하며,
상기 계약 당사자 단말은,
자연어로 작성된 스마트 계약을 바이트 코드로 변환하는 템플릿-코드 사상 모듈 및 바이트 코드 중에서 암호화할 변수를 선택하여 암호화하는 전처리 모듈을 포함하며,
상기 계약 이행 단말은,
조건에 따른 계약 이행을 판단하고, 상기 스마트 계약의 계약 내용에 작거나, 크거나, 작거나 같거나, 크거나 같거나, 또는 같거나의 연산문에 의해 수행되는 동형 암호 비교 연산이 있을 경우 상기 제2분산 합의 네트워크와의 합의에 의해 동형 암호 비교 연산 결과를 복호화하며,
상기 동형 암호 비교 연산은,
암호문 간 연산을 통해 나온 값과 상기 스마트 계약에 명시된 계약 이행 후의 값이 동일한지를 검사하는 과정을 포함하는 블록체인 기반의 스마트 계약 수행 시스템.
a contract party terminal for uploading a smart contract including homomorphic encrypted variables, which is information that is not intended to be disclosed to the outside in the process of creating a smart contract, to a block chain network;
a first distributed consensus network consisting of nodes participating in the blockchain network and for verifying the validity of a smart contract;
a contract fulfillment terminal implemented by nodes participating in the block chain network and determining suitability of contract execution according to conditions;
Consists of nodes participating in the blockchain network, and includes a second distributed consensus network to verify the suitability of contract execution according to conditions,
The contract party terminal,
It includes a template-code mapping module that converts a smart contract written in natural language into bytecode, and a preprocessing module that selects a variable to be encrypted from among the bytecode and encrypts it,
The contract fulfillment terminal,
Judging the contract execution according to the conditions, and if there is a homomorphic cryptographic comparison operation performed by an operation statement of less than, greater than, less than, equal to, greater than, equal to, or equal to, in the contract contents of the smart contract, Decrypts the homomorphic cryptographic comparison operation result by agreement with the second distributed consensus network,
The homomorphic cryptographic comparison operation is
A blockchain-based smart contract execution system including the process of checking whether the value obtained through the ciphertext operation is the same as the value after contract execution specified in the smart contract.
제7항에 있어서,
상기 제2분산 합의 네트워크에 참여하는 노드들이 동형 암호 비교 연산 결과에 해당하는 평문을 공유하고, 각 노드들은 상기 계약 이행 단말에서 제공되는 암호문을 복호하여 공유된 평문과 비교하여 일치 여부를 판단하고, 판단 결과를 이웃 노드들에 전파하고, 각 노드들은 이웃 노드들로부터 수령한 값들 중 정족수 이상의 노드들이 합의한 값을 선정하고 선정된 값을 합의를 착수한 노드(리더)에 전달하며,
상기 리더는 정족수 이상의 노드들이 합의한 값을 선정하여 합의의 결과로서 채택하여 상기 계약 이행 단말에 제공하는 것을 특징으로 하는 블록체인 기반의 스마트 계약 수행 시스템.
8. The method of claim 7,
The nodes participating in the second distributed consensus network share the plaintext corresponding to the homomorphic encryption comparison operation result, and each node decodes the ciphertext provided by the contract fulfillment terminal and compares it with the shared plaintext to determine whether it is consistent, The decision result is propagated to the neighboring nodes, and each node selects a value agreed by the nodes with a quorum or more among the values received from the neighboring nodes, and delivers the selected value to the node (leader) that initiated the consensus,
The leader selects a value agreed upon by nodes with a quorum or more, adopts it as a result of the consensus, and provides it to the contract fulfillment terminal.
제8항에 있어서,
상기 리더는 상기 제2분산 합의 네트워크의 분산 합의에 의해 선정되는 것을 특징으로 하는 블록체인 기반의 스마트 계약 수행 시스템.
9. The method of claim 8,
The blockchain-based smart contract execution system, characterized in that the leader is selected by the distributed consensus of the second distributed consensus network.
제9항에 있어서,
상기 리더가 장애로 인하여 더 이상 가용되지 않는 경우는 정해진 순서에 따라 다음 리더가 선정되고 분산 합의에 의해 승인되는 것을 특징으로 하는 블록체인 기반의 스마트 계약 수행 시스템.
10. The method of claim 9,
When the leader is no longer available due to a failure, the next leader is selected in a predetermined order and approved by distributed consensus.
제7항에 있어서,
상기 제2분산 합의 네트워크에 참여하는 노드들은 상기 계약 이행 단말로부터 수신한 암호문과 공유된 평문을 비교함에 의해 암호문을 복호화하는 복호화 모듈을 포함하는 것을 특징으로 하는 블록체인 기반의 스마트 계약 수행 시스템.
8. The method of claim 7,
Nodes participating in the second distributed consensus network include a decryption module that decrypts the encrypted text by comparing the shared plain text with the encrypted text received from the contract fulfillment terminal.
제7항에 있어서,
상기 계약 당사자 단말은 상기 계약 이행 단말로부터 정족수 이상의 합의가 있을 경우 계약이 적합하게 완료된 것으로 판단하여 스마트 계약을 종료하는 것을 특징으로 하는 블록체인 기반의 스마트 계약 수행 시스템.
8. The method of claim 7,
The block chain-based smart contract execution system, wherein the contract party terminal determines that the contract is properly completed and terminates the smart contract when there is a quorum or more agreement from the contract execution terminal.
KR1020190065522A 2019-06-03 2019-06-03 Method for performing smart contract based on block chain network and smart contract performing system therefor KR102308185B1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
KR1020190065522A KR102308185B1 (en) 2019-06-03 2019-06-03 Method for performing smart contract based on block chain network and smart contract performing system therefor

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
KR1020190065522A KR102308185B1 (en) 2019-06-03 2019-06-03 Method for performing smart contract based on block chain network and smart contract performing system therefor

Publications (2)

Publication Number Publication Date
KR20200139012A KR20200139012A (en) 2020-12-11
KR102308185B1 true KR102308185B1 (en) 2021-10-05

Family

ID=73786589

Family Applications (1)

Application Number Title Priority Date Filing Date
KR1020190065522A KR102308185B1 (en) 2019-06-03 2019-06-03 Method for performing smart contract based on block chain network and smart contract performing system therefor

Country Status (1)

Country Link
KR (1) KR102308185B1 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114580369B (en) * 2022-05-05 2022-08-26 杭州天谷信息科技有限公司 Signing method and system based on contract template
WO2024054899A1 (en) * 2022-09-07 2024-03-14 Xixventures, Llc Peer-to-peer selectable digital money system

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101727525B1 (en) * 2016-09-05 2017-04-17 주식회사 스케일체인 Block chain based distributed storage method and device thereof
KR101849917B1 (en) * 2016-10-13 2018-05-31 주식회사 코인플러그 Method for providing certificate service based on smart contract and server using the same

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101727525B1 (en) * 2016-09-05 2017-04-17 주식회사 스케일체인 Block chain based distributed storage method and device thereof
KR101849917B1 (en) * 2016-10-13 2018-05-31 주식회사 코인플러그 Method for providing certificate service based on smart contract and server using the same

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
한상우, 배민수, 황경호, "동형암호를 사용한 블록체인 기반 전자투표 시스템 개발." 한국통신학회논문지 44(1), pp.171-174(2019.01.) 1부.*

Also Published As

Publication number Publication date
KR20200139012A (en) 2020-12-11

Similar Documents

Publication Publication Date Title
US11941624B2 (en) Concurrent state machine processing using a blockchain
US20220021662A1 (en) Operating system for blockchain iot devices
US20200193292A1 (en) Auditable privacy protection deep learning platform construction method based on block chain incentive mechanism
JP7029468B2 (en) Methods and systems for secure data record distribution using blockchain
CN112232527B (en) Safe distributed federal deep learning method
Kilian Founding crytpography on oblivious transfer
JP2022095891A (en) Implementation of logic gate function using block chain
CN112631605A (en) Code compiling method, device, equipment and storage medium of federal learning model
CN111066047A (en) Implementing a blockchain based workflow
TW201928755A (en) System and method for securely sharing cryptographic material
KR20200019944A (en) System and method for hierarchical token distribution in blockchain network
KR102308185B1 (en) Method for performing smart contract based on block chain network and smart contract performing system therefor
CN111737715A (en) Decentralized electronic contract online signing method and system
CN112307513B (en) Uplink document security management method and device based on time domain consensus and electronic equipment
JP2020530956A (en) Systems and methods for communicating, storing, and processing data provided by entities on the blockchain network
CN110865793B (en) Method for generating random number based on blockchain intelligent contract
KR102494873B1 (en) Transaction execution device to implement a virtual machine based on a zero-knowledge proof circuit for general operation verification
CN114936853A (en) Chain transaction protocol and transaction authentication method based on trusted execution environment
Sweet A Decentralized Computation Platform
KR102582359B1 (en) Method and apparatus for generating block in blockchain system
Golosovskiy et al. Architecture of the Digital Distributed Platform for Medical Consiliums
CA3189405A1 (en) Talking head digital identity authentication
CN115099767A (en) Method, equipment and storage medium for carrying out project approval based on block chain

Legal Events

Date Code Title Description
E902 Notification of reason for refusal
E90F Notification of reason for final refusal
E701 Decision to grant or registration of patent right
GRNT Written decision to grant