IP Library Granted Patent US 12,316,740
Granted Patent B2
US 12,316,740 · App. 18/521,958 · Granted May 27, 2025

System and method for compiling high-level language code into a script executable on a blockchain platform

Inventors: Craig Steven Wright (London, GB); Stephane Savanah (London, GB)
Assignee: NCHAIN LICENSING AG
H04L9/0618G06F8/31G06F8/41G06F8/433G06F8/443G06F8/452G06F8/51H04L9/0637H04L9/0643H04L9/3247H04L9/3297H04L9/50H04L2209/56
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 12,316,740
App. No.
18/521,958
Granted
May 27, 2025
Kind
B2
Abstract

A computer-implemented method and system are provided that provides functionality of a portion of source code, written in a high-level language (HLL), on a blockchain platform. The method and system comprise the steps of receiving a portion of source code as input, wherein the portion of source code is written in a high-level language, HLL; and generating an output script comprising a plurality of op_codes selected from and/or native to a blockchain scripting language such that, when executed, the output script provides, at least in part, a functionality specified in the portion of source code, the blockchain scripting language restricted from supporting recursive programming constructs.

Claims (26)

1. A computer-implemented method comprising:

receiving a portion of a source code as input, wherein the portion of the source code is written in a high-level language (HLL) that specifies a functionality;

generating or receiving an output script comprising a plurality of op_codes selected from and/or native to a functionally-restricted blockchain scripting language such that, when executed, the output script provides, at least in part, a functionality specified in the portion of the source code, wherein the functionally-restricted blockchain scripting language is restricted from supporting recursive programming constructs; and

executing the output script, wherein the functionally-restricted blockchain scripting language is stack-based and during execution of the output script, one or more op_code commands that test a condition evaluate as a TRUE or FALSE result and place the TRUE or FALSE result on top of a stack used by the functionally-restricted blockchain scripting language.

2. The computer-implemented method of claim 1 , wherein the output script is generated, wherein generating the output script comprises unrolling a looping construct provided in the portion of the source code, and wherein the looping construct comprises a block of code, a condition, and a maximum number of iterations.

3. The computer-implemented method of claim 2 , wherein the looping construct is a WHILE loop.

4. The computer-implemented method of claim 2 , wherein unrolling the looping construct comprises replicating in the output script, a number of times equal to the maximum number of iterations, one or more op_code commands that test the condition followed by a sequence of op_codes that represent a functionality of the block of code embedded within an OP_IF/OP_ENDIF pair.

5. The computer-implemented method of claim 4 , wherein execution of an OP_IF statement will selectively execute a replicated block of code when the TRUE result is on top of the stack used by the functionally-restricted blockchain scripting language, such that when the FALSE result is on top of the stack used by the functionally-restricted blockchain scripting language, the execution of the OP_IF statement bypasses the execution of the replicated block of code.

6. The computer-implemented method of claim 2 , wherein the maximum number of iterations is defined by a parameter specified in the looping construct.

7. The computer-implemented method of claim 1 , wherein the functionally-restricted blockchain scripting language does not natively support complex control- flow constructs, recursion, and jump-based loops.

8. The computer-implemented method of claim 1 , wherein the HLL comprises one or more primitives arranged to perform an operation on the stack used by the functionally- restricted blockchain scripting language.

9. The computer-implemented method of claim 1 , wherein generating the output script is performed by a compiler.

10. The computer-implemented method of claim 1 , further comprising translating, by an interpreter, the output script into machine-executable code.

11. A computer-implemented system comprising one or more processors and a memory that stores computer-executable instructions that, as a result of execution by the one or more processors, cause the one or more processors to:

receive a portion of a source code as input, wherein the portion of the source code is written in a high-level language (HLL) that specifies a functionality;

generate or receive an output script comprising a plurality of op_codes selected from and/or native to a functionally-restricted blockchain scripting language such that, when executed, the output script provides, at least in part, a functionality specified in the portion of the source code, wherein the functionally-restricted blockchain scripting language is restricted from supporting recursive programming constructs; and

execute the output script, wherein the functionally-restricted blockchain scripting language is stack-based and during execution of the output script, one or more op_code commands that test a condition evaluate as a TRUE or FALSE result and place the TRUE or FALSE result on top of a stack used by the functionally-restricted blockchain scripting language.

12. The computer-implemented system of claim 11 , further comprising a compiler arranged to:

receive the portion of the source code as input, wherein the portion of the source code is written in a high-level language (HLL) that specifies a functionality;

generate or receive the output script comprising a plurality of op_codes selected from and/or native to a functionally-restricted blockchain scripting language such that, when executed, the output script provides, at least in part, the functionality specified in the portion of the source code, wherein the functionally-restricted blockchain scripting language is restricted from supporting recursive programming constructs,

wherein the output script is generated, wherein the step of generating the output script comprises unrolling a looping construct provided in the portion of the source code, and wherein the looping construct comprises a block of code, a condition, and a maximum number of iterations, and

wherein unrolling the looping construct comprises replicating in the output script, a number of times equal to the maximum number of iterations, one or more op_code commands that test the condition followed by a sequence of op_codes that represent a functionality of the block of code embedded within an OP_IF/OP_ENDIF pair; and

execute the output script, wherein the functionally-restricted blockchain scripting language is stack-based and during execution of the output script, one or more op_code commands that test a condition evaluate as a TRUE or FALSE result and place the TRUE or FALSE result on top of a stack used by the functionally-restricted blockchain scripting language.

13. The computer-implemented system of claim 12 , further comprising a software development kit.

14. The computer-implemented system of claim 12 ,

wherein execution of an OP_IF statement will selectively execute a replicated block of code when the TRUE result is on top of the stack used by the functionally-restricted blockchain scripting language, such that when the FALSE result is on top of the stack used by the functionally-restricted blockchain scripting language, the execution of the OP_IF statement bypasses the execution of the replicated block of code.

Assignments (4)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Dec 3, 2023
From: WRIGHT, CRAIG; SAVANAH, STEPHANE
To: NCHAIN HOLDINGS LTD.
Reel/Frame 065742/0466 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Dec 3, 2023
From: WRIGHT, CRAIG; SAVANAH, STEPHANE
To: NCHAIN HOLDINGS LTD.
Reel/Frame 065742/0473 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Dec 3, 2023
From: WRIGHT, CRAIG; SAVANAH, STEPHANE
To: NCHAIN HOLDINGS LTD.
Reel/Frame 065742/0508 →
CHANGE OF NAME Recorded Dec 3, 2023
From: NCHAIN HOLDINGS LTD
To: NCHAIN LICENSING AG
Reel/Frame 065749/0220 →
Priority Claims (6)
GB 1710967 · Jul 7, 2017 · national
GB 1710971 · Jul 7, 2017 · national
GB 1710974 · Jul 7, 2017 · national
WO PCT/IB2017/054110 · Jul 7, 2017 · international
WO PCT/IB2017/054113 · Jul 7, 2017 · international
WO PCT/IB2017/054114 · Jul 7, 2017 · international
Continuity (3)
Continuation 17887445 · Aug 13, 2022
Continuation 16629295
Related Publication 20240168735A1 · May 23, 2024
References Cited (91)
US 5761652A · Wu et al. · 1998 [cited by applicant]
US 6760905B1 · Hostetter et al. · 2004 [cited by applicant]
US 9569206B1 · Dawson et al. · 2017 [cited by applicant]
US 10050779B2 · Alness et al. · 2018 [cited by applicant]
US 10871948B1 · Dowling · 2020 [cited by applicant]
US 11307835B2 · Wright et al. · 2022 [cited by applicant]
US 20030005404A1 · Bowyer et al. · 2003 [cited by applicant]
US 20040015916A1 · Click et al. · 2004 [cited by applicant]
US 20140068576A1 · Pendap et al. · 2014 [cited by applicant]
US 20150007167A1 · Mody et al. · 2015 [cited by applicant]
US 20150074655A1 · de Lima Ottoni et al. · 2015 [cited by applicant]
US 20150149978A1 · Kim · 2015 [cited by applicant]
US 20160274998A1 · Coyle et al. · 2016 [cited by applicant]
US 20160330034A1 · Back et al. · 2016 [cited by applicant]
US 20170287090A1 · Hunn et al. · 2017 [cited by applicant]
US 20170300403A1 · Ramraz · 2017 [cited by applicant]
US 20170300627A1 · Giordano et al. · 2017 [cited by applicant]
US 20180293157A1 · Dougherty et al. · 2018 [cited by applicant]
US 20180314938A1 · Andoni et al. · 2018 [cited by applicant]
US 20190116024A1 · Wright et al. · 2019 [cited by applicant]
CN 106598549A · 2017 [cited by applicant]
CN 106598579A · 2017 [cited by applicant]
JP S61182138A · 1986 [cited by applicant]
JP 2006107339A · 2006 [cited by applicant]
JP 2018533103A · 2018 [cited by applicant]
WO 2017024071A1 · 2017 [cited by applicant]
WO 2017027407A1 · 2017 [cited by applicant]
WO 2017145006A1 · 2017 [cited by applicant]
WO 2017187398A1 · 2017 [cited by applicant]
Willis et al., “TX Script—History,” GitHub, Jun. 27, 2016, https://github.com/Kefkius/txsc/commits/master/doc/txscript.asciidoc, 2 pages. [cited by applicant]
Willis et al., “TX Script,” GitHub, Jun. 27, 2016, https://github.com/Kefkius/txsc, 3 pages. [cited by applicant]
Zyskind, “Efficient secure computation enabled by blockchain technology,” Doctoral dissertation, Massachusetts Institute of Technology, Jun. 2016, https://pdfs.semanticscholar.org/5b54/7a7f2e47af79429d9467701538434d8e6b… [cited by applicant]
github.com, “EVM OPCODE Gas Costs”, https://github.com/djrtwo/evm-opcode-gas-costs, Apr. 12, 2017, 2 pages. [cited by applicant]
Robinson, Dan, “Ivy: A Declarative Predicate Language for Smart Contracts” BPASE 2017, Stanford University, Jan. 26, 2017, 6 pages. [cited by applicant]
Allison, “Jeff Garzik's Bloq runs smart contracts like an ‘Ethereum plug-in for Bitcoin,’” International Business Times, May 25, 2016, https://www.ibtimes.co.uk/jeff-garziks-bloq-runs-smart-contracts-like-ethereum-plug-… [cited by applicant]
Anonymous: “Announcing Ivy Playground—Chain”, May 18, 2017, 15 pages. [cited by applicant]
Anonymous: “Part 1: Transaction Basics Crypto Tokens”, Jun. 6, 2017, https:/web.archive.org/web/2017060202729/https://klmoney.wordspress.com/bitcoin-dissecting-transactions-part1, 16 pages. [cited by applicant]
Anonymous: “Part 2: Building a Transaction By Hand, Crypto Tokens”, Jun. 7, 2017, 18 pages. [cited by applicant]
Antonopoulos, “Mastering Bitcoin—Unlocking Digital Cryptocurrencies,” O'Reilly Media, Inc., Dec. 20, 2014, 282 pages. [cited by applicant]
Bedford, “How to code with Google Blockly,” Tech Advisor, Jun. 12, 2014, https://web.archive.org/web/20170626164055/https://www.techadvisor.co.uk/how-to/software/how-code-with-google-blockly-3524675, 6 pages. [cited by applicant]
Bhargavan et al., “Formal Verification of Smart Contracts,” Proceedings of the 2016 ACM Workshop on Programming Languages and Analysis for Security, Oct. 24, 2016, https://antoine.delignat-lavaud.fr/doc/plas16.pdf, 6 pa… [cited by applicant]
bitcoininvestor.com, “All-Star Panel: Ed Moy, Joseph VaughnPerling, Trace Mayer, Nick Szabo, Dr. Craig Wright,” YouTube, https://youtu.be/LdvQTwjVmrE, Bitcoin Investor Conference, Oct. 29, 2015 [retrieved Dec. 12, 2018]… [cited by applicant]
Ceejep et al., “Rfp-8: Higher Level Language Compiling To Transaction Script,” Dec. 14, 2015, https://forum.decred.org/threads/rfp-8-higher-level-language-compiling-totransaction-script.3665/, 7 pages. [cited by applicant]
Chain, “Announcing Ivy Playground,” Medium, May 17, 2017, https://web.archive.org/web/20170518000630/https://blog.chain.com/announcing-ivy-playground-395364675d0a, 12 pages. [cited by applicant]
Chen et al., “Under-Optimized Smart Contracts Devour Your Money,” IEEE 24th International Conference on Software Analysis, Evolution and Reengineering (SANER), Feburary 20, 2017, https://arxiv.org/pdf/1703.03994.pdf, 5 … [cited by applicant]
Costill, “Bitcoin Scripting and How It Can Be Improved,” Due, https://due.com/blog/bitcoin-scripting-and-how-it-can-be-improved/, Mar. 25, 2016, 16 pages. [cited by applicant]
Curiosity Driven, “Bitcoin contracts compiler,” Sep. 6, 2014, https://github.com/curiosity-driven/bitcoin-contracts-compiler, 2 pages. [cited by applicant]
Curiosity Driven, “Bitcoin contracts,” Apr. 8, 2016, https://curiosity-driven.org/bitcoin-contracts, 10 pages. [cited by applicant]
Curiosity Driven, “Superscript compiler,” Sep. 6, 2014, https://github.com/curiosity-driven/bitcoin-contracts-compiler/commits/master, 1 page. [cited by applicant]
De Rosa, “A developer-oriented series about Bitcoin—Section 10: The Bitcoin Script language (pt. 1) and Section 11: The Bitcoin Script language (pt. 2),” May 25, 2015, https://davidederosa.com/basic-blockchain-programmi… [cited by applicant]
Etherscan, “ByteCode to Opcode Disassembler,” Etherscan, the Ethereum Block Explorer, Aug. 2015, https://etherscan.io/address/0xafdacfee6395bc1e480a900943f1803f854bc20e, 3 pages. [cited by applicant]
Etherscan, “Contract Address—Transaction Example,” Etherscan, the Etheruem Block Explorer, Oct. 20, 2016, 3 pages. [cited by applicant]
Etherscan, “Contract Address,” Etherscan, the Etheruem Block Explorer, copyright 2017, https://etherscan.io/address/0x5a4964bb5fdd3ce646bb6aa020704f7d4db79302, 4 pages. [cited by applicant]
Exab et al., “Understanding the risk of BU (bitcoin unlimited),” Reddit, Feb. 22, 20217, https://www.reddit.com/r/Bitcoin/comments/5vo5wi/understanding_the_risk_of_bu_bitcoin_unlimited/, 27 pages. [cited by applicant]
FMLFPL111 et al., “It's there a solution to the scaling problem?,” Reddit, Jan. 25, 2017, https://www.reddit.com/r/Monero/comments/5q3fcf/its_there_a_solution_to_the_scaling_problem/, 14 pages. [cited by applicant]
Frontier, “State Machine,” Gitbooks, Mar. 15, 2017, https://ethereum.gitbooks.io/frontierguide/content/opcodes, _costs,_and_gas.html, 1 page. [cited by applicant]
Gitbook, “Ethereum Frontier Guide,” Gitbook (Legacy), Feb. 4, 2016, 293 pages. [cited by applicant]
International Search Report and Written Opinion mailed Aug. 30, 2018, Patent Application No. PCT/IB2018/054970, 13 pages. [cited by applicant]
International Search Report and Written Opinion mailed Aug. 30, 2018, Patent Application No. PCT/IB2018/054971, 12 pages. [cited by applicant]
International Search Report and Written Opinion mailed Mar. 23, 2018, Patent Application No. PCT/IB2017/054110, 13 pages. [cited by applicant]
International Search Report and Written Opinion mailed Mar. 23, 2018, Patent Application No. PCT/IB2017/054113, 13 pages. [cited by applicant]
International Search Report and Written Opinion mailed Mar. 23, 2018, Patent Application No. PCT/IB2017/054114, 14 pages. [cited by applicant]
International Search Report and Written Opinion mailed Sep. 3, 2018, Patent Application No. PCT/IB2018/054969, 13 pages. [cited by applicant]
Klmoney, “Part 1: Transaction Basics,” Jun. 6, 2017, Wordpress, https://web.archive.org/web/20170606202729/ https://klmoney.wordpress.com/bitcoin-dissecting-transactions-part-1/, 9 pages. [cited by applicant]
Klmoney, “Part 2: Building a Transaction By Hand,” Wordpress, Jun. 7, 2017, https://web.archive.org/web/20170607015517/https://klmoney.wordpress.com/bitcoin-dissecting-transactions-part-2-building-a-transaction-by-hand/… [cited by applicant]
Kosba et al., “Hawk: The Blockchain Model of Cryptography and Privacy-Preserving Smart Contracts,” IEEE Symposium on Security and Privacy, May 22, 2016, 31 pages. [cited by applicant]
Le Calvez, “A look at Bitcoin non-standard outputs,” Medium, Nov. 8, 2015 [retrieved Feb. 28, 2017], https://medium.com/@alcio/a-look-at-bitcoin-non-standard-outputs-c97f65cccbb6#.3fw5ur52k, 6 pages. [cited by applicant]
Lerner, “RSK Rootstock Platform Bitcoin powered Smart Contracts White Paper version 9,” Nov. 19, 2015, https://uploads.strikinglycdn.com/files/90847694-70f0-4668-ba7fdd0c6b0b00a1/RootstockWhitePaperv9-Overview.pdf, 24 p… [cited by applicant]
Morgenstern, “Forth's Stacks,” Forth.org, Nov. 14, 2016, https://web.archive.org/web/20161114030625/ http://www.forth.org/svfig/Len/softstak.htm, 3 pages. [cited by applicant]
Nakamoto, “Bitcoin: A Peer-to-Peer Electronic Cash System,” Bitcoin, Oct. 31, 2008, https://bitcoin.org/bitcoin.pdf, 9 pages. [cited by applicant]
Rensylvain et al., “Any truth to haveing turing complete programming worked into bitcoin via an OP code?,” Reddit, Dec. 13, 2015, https://www.reddit.com/r/Bitcoin/comments/3wpkd0/any_truth_to_haveing_turing_complete_pro… [cited by applicant]
Rios et al., “Derivative-free optimization: a review of algorithms and comparison of software implementations,” Journal of Global Optimization 56(3):1247-93, Jul. 12, 2012. [cited by applicant]
Robinson, “Ivy: A Declarative Predicate Language for Smart Contracts,” Chain, https://cyber.stanford.edu/sites/default/files/danrobinson.pdf, Jan. 2017, 30 pages. [cited by applicant]
Sarchar et al., “[Announce] Whitepaper for Bitstorage—a peer to peer, cloud storage network,” Bitcoin Forum, Nov. 27, 2013, https://bitcointalk.org/index.php?topic=348868.0, 10 pages. [cited by applicant]
Satoshi et al., “Connection Limits,” Bitcoin Forum, Aug. 9, 2010, https://bitcointalk.org/index.php?topic=741.0; prev_next=prev, 2 pages. [cited by applicant]
Solidity in Depth, “Expressions and Control Structures” Input Parameters and Output Parameters, Jul. 3, 2017, https://docs.huihoo.com/ethereum/solidity/control-structures.html, 10 pages. [cited by applicant]
Stevenroose et al., “IRC Chat Log Feb. 9, 2016,” Bitcoin Wizards, Feb. 9, 2016, https://irclog.whitequark.org/bitcoin-wizards/2016-02-09, pages. [cited by applicant]
Tekknolagi et al., “How to implement LOOP in a FORTH-like language interpreter written in C,” Stack Overflow, Aug. 4, 2011, https://web.archive.org/web/20150531001644/https://stackoverflow.com/questions/6949434/how-to-i… [cited by applicant]
UK Commercial Search Report mailed Nov. 17, 2017, Patent Application No. GB1710974.5, 9 pages. [cited by applicant]
UK IPO Search Report mailed Dec. 21, 2017, Patent Application No. GB1710967.9, 9 pages. [cited by applicant]
UK IPO Search Report mailed Dec. 21, 2017, Patent Application No. GB1710971.1, 9 pages. [cited by applicant]
UK IPO Search Report mailed Dec. 21, 2017, Patent Application No. GB1710974.5, 9 pages. [cited by applicant]
Wikipedia, “Proof of space,” Wikipedia the Free Encyclopedia, Jul. 11, 2017, https://en.wikipedia.org/w/index.php?title=Proof-of-space&oldid=790069182, 5 pages. [cited by applicant]
Willis et al., “TX Script—Documentation,” GitHub, Jun. 27, 2016, https://github.com/Kefkius/txsc/blob/master/doc/txscript.asciidoc, 8 pages. [cited by applicant]
Simon Thompson, Pablo Lamela Seijas et al., “Scripting smart contracts for distributed ledger technology”, Cryptology ePrint Archive [online], Feb. 10, 2017 [Date of search: Feb. 14, 2025], on the Internet <https://epri… [cited by applicant]
Yoshiharu Akabane et al., “Blockchain—Mechanism and Theory,” Ric Telecom. co.jp, Oct. 28, 2016, 1st edition, ISBN:978-4-86594-040-4, pp. 218-222. [cited by applicant]
Akihiro Toriyabe et al., “Full-Fledged Introduction to Smart Contracts”, GijutsuHyoron Co., Ltd., Mar. 1, 2017, 1st edition, ISBN:978-4-7741-8746-4, p. 128. [cited by applicant]
Andrychowicz, Marcin et al., “Modeling Bitcoin Contracts by Timed Automata,” (2014), 23 pages. [cited by applicant]
“The Bitcoin Script language (pt. 1)”, Davide De Rosa, [online], May 25, 2015 [Date of search: Feb. 14, 2025], on the Internet <https://davidederosa.com/basic-blockchainprogramming/bitcoin-script-language-part-one/>, pp… [cited by applicant]
“The Bitcoin Script language (pt. 2)”, Davide De Rosa, [online], May 25, 2015 [Date of search: Feb. 14, 2025], on the Internet <https://davidederosa.com/basic-blockchainprogramming/bitcoin-script-language-part-two/>, pp… [cited by applicant]
Solidity 0.4.5 Release Announcement, [online], Nov. 21, 2016 [Date of search: Feb. 14, 2025], on the Internet <https://soliditylang.org/blog/2016/11/21/solidity-0.4.5-release-announcement/>, pp. 1-2. [cited by applicant]