# US 2023/0057419 A1 · System and method for compiling high-level language code into a script executable on a blockchain platform

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2023/0057419 A1
- Document ID: US20230057419A1
- Status: Published application
- Kind: A1
- Application number: 17/887,445
- Filed: 2022-08-13
- Published: 2023-02-23
- Earliest claimed: 2017-07-07
- Assignees: nChain Licensing AG
- Applicants: nChain Licensing AG
- Inventors: Craig Steven WRIGHT; Stephane SAVANAH
- Web page: https://patentgrep.com/patent/US20230057419A1

## CPC

- H04L 9/0618: {Block ciphers, i.e. encrypting groups of characters of a plain text message using fixed encryption transformation}
- G06F 8/31: {Programming languages or programming paradigms}
- G06F 8/41: Compilation
- G06F 8/433: {Dependency analysis; Data or control flow analysis}
- G06F 8/443: {Optimisation}
- G06F 8/452: {Loops}
- G06F 8/51: Source to source
- H04L 9/0637: {Modes of operation, e.g. cipher block chaining [CBC], electronic codebook [ECB] or Galois/counter mode [GCM]}
- H04L 9/0643: {Hash functions, e.g. MD5, SHA, HMAC or f9 MAC}
- H04L 9/3247: {involving digital signatures}
- H04L 9/3297: {involving time stamps, e.g. generation of time stamps}
- H04L 9/50: {using hash chains, e.g. blockchains or hash trees}
- H04L 63/1458: {Denial of Service}
- H04L 2209/56: Financial cryptography, e.g. electronic payment or e-cash
- H04L: TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION (arrangements common to telegraphic and telephonic communication H04M)
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A computer-implemented method (and corresponding system) is provided, that enables or facilitates the execution of a portion of source code, written in a high-level language (HLL), on a blockchain platform. The method and system can include a blockchain compiler, arranged to convert a portion of high-level source code into a form that can be used with a blockchain platform. This may be the Bitcoin blockchain or an alternative. The method can include: receiving the portion of source code as input; and generating an output script comprising a plurality of op_codes. The op_codes are a subset of op_codes that are native to a functionally-restricted, blockchain scripting language. The outputted script is arranged and/or generated such that, when executed, the script provides, at least in part, the functionality specified in the source code. The blockchain scripting language is restricted such that it does not natively support complex control-flow constructs or recursion via jump-based loops or other recursive programming constructs. The step of generating the output script may comprise the unrolling at least one looping construct provided in the source code. The method may further comprise providing or using an interpreter or virtual machine arranged to convert the output script into a form that is executable on a blockchain platform.

## Claims

### Claim 1

A computer-implemented method comprising steps:
receiving a portion of source code as input, wherein the portion of source code is written in a high-level language (HLL) that specifies a functionality; and
generating 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 source code.

### Claim 2 (depends on 1)

The computer-implemented method according to claim 1, and comprising the step of
providing or using a compiler arranged to perform the steps of claim 1.

### Claim 3 (depends on 1)

The computer-implemented method according to claim 1, wherein the output script is generated by performing a static compilation.

### Claim 4 (depends on 1)

The computer-implemented method according to claim 1, wherein:
the functionally-restricted blockchain scripting language is restricted such that the functionally-restricted blockchain scripting language does not natively support complex control-flow constructs, recursion, and/or jump-based loops.

### Claim 5 (depends on 1)

The computer-implemented method of claim 1, wherein the step of generating the output script comprises:
unrolling at least one looping construct provided in the portion of source code.

### Claim 6 (depends on 1)

The computer-implemented method of claim 1, and further comprising the step of:
providing or using an interpreter or virtual machine arranged to convert the output script into a form that is executable on a blockchain platform.

### Claim 7 (depends on 1)

The computer-implemented method of claim 1, and further comprising the step of:
optimising the output script at least once to provide a more efficient or reduced version of the output script.

### Claim 8 (depends on 1)

The computer-implemented method of claim 1, wherein the step of generating the output script comprises derivative free optimisation.

### Claim 9 (depends on 2)

The computer-implemented method of claim 2, wherein:
the compiler forms part of a software development kit (SDK).

### Claim 10 (depends on 1)

The computer-implemented method of claim 1, wherein:
the portion of source code is arranged to implement a smart contract.

### Claim 11 (depends on 1)

The computer-implemented method of claim 1, wherein:
the HLL comprises at least one primitive or construct which can be translated directly into one or more primitives native to the functionally-restricted blockchain scripting language.

### Claim 12 (depends on 1)

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

### Claim 13 (depends on 1)

The computer-implemented method of claim 1, wherein:
the HLL comprises a primitive arranged to push a number of inputs to the portion of source code onto a stack used for memory allocation by the functionally-restricted blockchain scripting language.

### Claim 14 (depends on 1)

The computer-implemented method of claim 1, wherein the HLL comprises at least one of the following primitives or operators or a functional equivalent of at least one of the following primitives or operators:
Initiate;
Declare;
Increment;
IF;
While;
Populate;
Monus;
Reset;
Rawscript;
Abort;
Retrieve; and
Hash, hash 160, or another hash operation or a variation thereof.

### Claim 15

A computer-implemented method comprising the step of using static compilation to translate a portion of source code into a blockchain-compatible script, wherein the blockchain-compatible script is functionally-restricted, and wherein the static compilation comprises the step of loop unrolling.

### Claim 16 (depends on 1)

A computer-implemented system comprising one or more processors and memory that stores computer-executable instructions that, as a result of execution, cause the one or more processors to implement the steps of claim 1.

### Claim 17 (depends on 16)

A computer-implemented system according to claim 16, and comprising a compiler arranged to:
receive a portion of source code as input, the portion of the source code being written in a high-level language (HLL) and specifying a functionality; and
generate an output script comprising a plurality of op_codes selected from a functionally-restricted blockchain scripting language such that, when executed, the output script provides, at least in part, the functionality specified in the source code.

### Claim 18 (depends on 16)

The computer-implemented system according to claim 16, and comprising a software development kit (SDK).
