The present disclosure relates to a computer-implemented method for enabling elliptic curve arithmetic to be performed in-script using blockchain transactions.
A blockchain refers to a form of distributed data structure, wherein a duplicate copy of the blockchain is maintained at each of a plurality of nodes in a distributed peer-to-peer (P2P) network (referred to below as a “blockchain network”) and widely publicised. The blockchain comprises a chain of blocks of data, wherein each block comprises one or more transactions. Each transaction, other than so-called “coinbase transactions”, points back to a preceding transaction in a sequence which may span one or more blocks going back to one or more coinbase transactions. Coinbase transactions are discussed further below. Transactions that are submitted to the blockchain network are included in new blocks. New blocks are created by a process often referred to as “mining”, which involves each of a plurality of the nodes competing to perform “proof-of-work”, i.e. solving a cryptographic puzzle based on a representation of a defined set of ordered and validated pending transactions waiting to be included in a new block of the blockchain. It should be noted that the blockchain may be pruned at some nodes, and the publication of blocks can be achieved through the publication of mere block headers.
The transactions in the blockchain may be used for one or more of the following purposes: to convey a digital asset (i.e. a number of digital tokens), to order a set of entries in a virtualised ledger or registry, to receive and process timestamp entries, and/or to time-order index pointers. A blockchain can also be exploited in order to layer additional functionality on top of the blockchain. For example blockchain protocols may allow for storage of additional user data or indexes to data in a transaction. There is no pre-specified limit to the maximum data capacity that can be stored within a single transaction, and therefore increasingly more complex data can be incorporated. For instance this may be used to store an electronic document in the blockchain, or audio or video data.
Nodes of the blockchain network (which are often referred to as “miners”) perform a distributed transaction registration and verification process, which will be described in more detail later. In summary, during this process a node validates transactions and inserts them into a block template for which they attempt to identify a valid proof-of-work solution. Once a valid solution is found, a new block is propagated to other nodes of the network, thus enabling each node to record the new block on the blockchain. In order to have a transaction recorded in the blockchain, a user (e.g. a blockchain client application) sends the transaction to one of the nodes of the network to be propagated. Nodes which receive the transaction may race to find a proof-of-work solution incorporating the validated transaction into a new block. Each node is configured to enforce the same node protocol, which will include one or more conditions for a transaction to be valid. Invalid transactions will not be propagated nor incorporated into blocks. Assuming the transaction is validated and thereby accepted onto the blockchain, then the transaction (including any user data) will thus remain registered and indexed at each of the nodes in the blockchain network as an immutable public record.
The node who successfully solved the proof-of-work puzzle to create the latest block is typically rewarded with a new transaction called the “coinbase transaction” which distributes an amount of the digital asset, i.e. a number of tokens. The detection and rejection of invalid transactions is enforced by the actions of competing nodes who act as agents of the network and are incentivised to report and block malfeasance. The widespread publication of information allows users to continuously audit the performance of nodes. The publication of the mere block headers allows participants to ensure the ongoing integrity of the blockchain.
In an “output-based” model (sometimes referred to as a UTXO-based model), the data structure of a given transaction comprises one or more inputs and one or more outputs. Any spendable output comprises an element specifying an amount of the digital asset that is derivable from the proceeding sequence of transactions. The spendable output is sometimes referred to as a UTXO (“unspent transaction output”). The output may further comprise a locking script specifying a condition for the future redemption of the output. A locking script is a predicate defining the conditions necessary to validate and transfer digital tokens or assets. Each input of a transaction (other than a coinbase transaction) comprises a pointer (i.e. a reference) to such an output in a preceding transaction, and may further comprise an unlocking script for unlocking the locking script of the pointed-to output. So consider a pair of transactions, call them a first and a second transaction (or “target” transaction). The first transaction comprises at least one output specifying an amount of the digital asset, and comprising a locking script defining one or more conditions of unlocking the output. The second, target transaction comprises at least one input, comprising a pointer to the output of the first transaction, and an unlocking script for unlocking the output of the first transaction.
In such a model, when the second, target transaction is sent to the blockchain network to be propagated and recorded in the blockchain, one of the criteria for validity applied at each node will be that the unlocking script meets all of the one or more conditions defined in the locking script of the first transaction. Another will be that the output of the first transaction has not already been redeemed by another, earlier valid transaction. Any node that finds the target transaction invalid according to any of these conditions will not propagate it (as a valid transaction, but possibly to register an invalid transaction) nor include it in a new block to be recorded in the blockchain.
An alternative type of transaction model is an account-based model. In this case each transaction does not define the amount to be transferred by referring back to the UTXO of a preceding transaction in a sequence of past transactions, but rather by reference to an absolute account balance. The current state of all accounts is stored by the nodes separate to the blockchain and is updated constantly.
Blockchain transactions include scripts: unlocking script and locking scripts. These scripts allow data (e.g. public keys) and functions (e.g. opcodes) to be recorded on chain, with the functions operating on the data when the scripts are executed, e.g. during transaction validation. For instance, a function may be used to hash a public key to generate a public key hash.
Elliptic curves are used in many applications such as, for example, elliptic curve cryptography (ECC), elliptic curve digital signature algorithms (ECDSA), elliptic curve Diffie-Hellman key exchanges, and so on. Some of these applications, such as ECDSA, are fundamentally linked to some blockchain protocols. For instance, most blockchain protocols use ECDSA signatures to sign transactions, which in turn rely on private and public key-pairs that are generated using elliptic curve points.
Elliptic curve arithmetic refers to performing mathematical operations on elliptic curve points, for instance, summing two elliptic curve points or multiplying an elliptic curve point by a scalar. A fundamental requirement of elliptic curve arithmetic is the ability to compute the modular inverse of an elliptic curve point, or more generally the modular inverse of an integer, such as the x-coordinate of elliptic curve point. It is recognised herein that it would be advantageous to be able to perform elliptic curve arithmetic in-script. Therefore there is a need to be able to compute the modular inverse of an integer in-script.
According to one aspect disclosed herein, there is provided a computer-implemented method for enabling elliptic curve arithmetic to be performed using blockchain transactions, wherein the method is performed by a script generator and comprises: generating a first script of a first blockchain transaction, wherein the first script comprises a modular inversion script, and wherein the modular inversion script is configured to, when executed, by a script engine: obtain a target integer and a modulus value, wherein the target integer and the modulus value are co-prime, and output a modular inverse of the target integer, wherein the modular inverse is generated by iteratively computing a first sequence of the extended Euclidean algorithm with the target integer and modulus value as inputs, and using the first sequence to compute a Bezout co-efficient of the target integer, wherein the Bezout co-efficient of the target integer is output as the modular inverse; and outputting the first script for inclusion in the first blockchain transaction.
The script generator generates a first script (e.g. a locking script) of a second transaction. The script includes at least a modular inversion script that is configured to take the modular inverse of a target integer (x) using a modulus value (n), i.e. x−1 mod n. The modular inverse is calculated as the Bezout coefficient of the target integer produced by performing at least part of the extended Euclidean algorithm. The first script is configured to compute the sequence of the extended Euclidean algorithm that computes the Bezout coefficient of the target integer. The target integer and modulus value may be included as part of the first script (e.g. the locking script), or provided as inputs by a different script (e.g. an unlocking script of a second transaction). The first transaction is recorded on the blockchain. When the first script is executed (e.g. during transaction validation), the modular inverse of the target integer is computed and output (e.g. to memory, such as a stack). The present disclosure improves the functionality of the blockchain by enabling modular inverse of an integer to be performed in script.
The modular inverse of an integer may be used as part of one or more additional arithmetic operations. For instance, the modular inversion script may be included as part of (or output data to) a point addition script which is configured to add two elliptic curve points. As another example, the modular inversion script may be used as part of a scalar multiplication script which is configured to multiply an elliptic curve point by a scalar.
One advantage of performing elliptic curve arithmetic in-script is that the calculations are immutably stored on-chain, meaning that the calculations and the results cannot be changed and that they can be verified in the future. Another advantage is that the computations, which are expensive in terms of processing power, are performed by the script engine that executes the script, rather than the script generator. The script engine is typically implemented by an entity (e.g. a blockchain node) with more computational resources than the script engine (e.g. a user).
The first script is written in a scripting language. For example, one particular blockchain protocol uses a specific language called ‘Script’ (capital S), which is a stack-based scripting language made up of predefined functions called opcodes. In such a language, a given opcode mapped to one or more of the following operations: (a) put an element on a stack, (b) retrieve an element from the stack, (c) operate on an element on the stack, and (d) remove an element from the stack. Some stack-based languages may allow for storing data on two stacks, e.g. a main stack and an alternate (alt) stack. Embodiments of the present disclosure enable elliptic curve arithmetic to be performed using the existing Script language of the blockchain, and thus maintains the security of the blockchain by avoiding the introduction of new opcodes which may increase the attack surface for an attacker.
To assist understanding of embodiments of the present disclosure and to show how such embodiments may be put into effect, reference is made, by way of example only, to the accompanying drawings in which:
Each blockchain node 104 comprises computer equipment of a peer, with different ones of the nodes 104 belonging to different peers. Each blockchain node 104 comprises processing apparatus comprising one or more processors, e.g. one or more central processing units (CPUs), accelerator processors, application specific processors and/or field programmable gate arrays (FPGAs), and other equipment such as application specific integrated circuits (ASICs). Each node also comprises memory, i.e. computer-readable storage in the form of a non-transitory computer-readable medium or media. The memory may comprise one or more memory units employing one or more memory media, e.g. a magnetic medium such as a hard disk; an electronic medium such as a solid-state drive (SSD), flash memory or EEPROM; and/or an optical medium such as an optical disk drive.
The blockchain 150 comprises a chain of blocks of data 151, wherein a respective copy of the blockchain 150 is maintained at each of a plurality of blockchain nodes 104 in the distributed or blockchain network 106. As mentioned above, maintaining a copy of the blockchain 150 does not necessarily mean storing the blockchain 150 in full. Instead, the blockchain 150 may be pruned of data so long as each blockchain node 150 stores the block header (discussed below) of each block 151. Each block 151 in the chain comprises one or more transactions 152, wherein a transaction in this context refers to a kind of data structure. The nature of the data structure will depend on the type of transaction protocol used as part of a transaction model or scheme. A given blockchain will use one particular transaction protocol throughout. In one common type of transaction protocol, the data structure of each transaction 152 comprises at least one input and at least one output. Each output specifies an amount representing a quantity of a digital asset as property, an example of which is a user 103 to whom the output is cryptographically locked (requiring a signature or other solution of that user in order to be unlocked and thereby redeemed or spent). Each input points back to the output of a preceding transaction 152, thereby linking the transactions.
Each block 151 also comprises a block pointer 155 pointing back to the previously created block 151 in the chain so as to define a sequential order to the blocks 151. Each transaction 152 (other than a coinbase transaction) comprises a pointer back to a previous transaction so as to define an order to sequences of transactions (N.B. sequences of transactions 152 are allowed to branch). The chain of blocks 151 goes all the way back to a genesis block (Gb) 153 which was the first block in the chain. One or more original transactions 152 early on in the chain 150 pointed to the genesis block 153 rather than a preceding transaction.
Each of the blockchain nodes 104 is configured to forward transactions 152 to other blockchain nodes 104, and thereby cause transactions 152 to be propagated throughout the network 106. Each blockchain node 104 is configured to create blocks 151 and to store a respective copy of the same blockchain 150 in their respective memory. Each blockchain node 104 also maintains an ordered set (or “pool”) 154 of transactions 152 waiting to be incorporated into blocks 151. The ordered pool 154 is often referred to as a “mempool”. This term herein is not intended to limit to any particular blockchain, protocol or model. It refers to the ordered set of transactions which a node 104 has accepted as valid and for which the node 104 is obliged not to accept any other transactions attempting to spend the same output.
In a given present transaction 152j, the (or each) input comprises a pointer referencing the output of a preceding transaction 152i in the sequence of transactions, specifying that this output is to be redeemed or “spent” in the present transaction 152j. Spending or redeeming does not necessarily imply transfer of a financial asset, though that is certainly one common application. More generally spending could be described as consuming the output, or assigning it to one or more outputs in another, onward transaction. In general, the preceding transaction could be any transaction in the ordered set 154 or any block 151. The preceding transaction 152i need not necessarily exist at the time the present transaction 152j is created or even sent to the network 106, though the preceding transaction 152i will need to exist and be validated in order for the present transaction to be valid. Hence “preceding” herein refers to a predecessor in a logical sequence linked by pointers, not necessarily the time of creation or sending in a temporal sequence, and hence it does not necessarily exclude that the transactions 152i, 152j be created or sent out-of-order (see discussion below on orphan transactions). The preceding transaction 152i could equally be called the antecedent or predecessor transaction.
The input of the present transaction 152j also comprises the input authorisation, for example the signature of the user 103a to whom the output of the preceding transaction 152i is locked. In turn, the output of the present transaction 152j can be cryptographically locked to a new user or entity 103b. The present transaction 152j can thus transfer the amount defined in the input of the preceding transaction 152i to the new user or entity 103b as defined in the output of the present transaction 152j. In some cases a transaction 152 may have multiple outputs to split the input amount between multiple users or entities (one of whom could be the original user or entity 103a in order to give change). In some cases a transaction can also have multiple inputs to gather together the amounts from multiple outputs of one or more preceding transactions, and redistribute to one or more outputs of the current transaction.
According to an output-based transaction protocol such as bitcoin, when a party 103, such as an individual user or an organization, wishes to enact a new transaction 152j (either manually or by an automated process employed by the party), then the enacting party sends the new transaction from its computer terminal 102 to a recipient. The enacting party or the recipient will eventually send this transaction to one or more of the blockchain nodes 104 of the network 106 (which nowadays are typically servers or data centres, but could in principle be other user terminals). It is also not excluded that the party 103 enacting the new transaction 152j could send the transaction directly to one or more of the blockchain nodes 104 and, in some examples, not to the recipient. A blockchain node 104 that receives a transaction checks whether the transaction is valid according to a blockchain node protocol which is applied at each of the blockchain nodes 104. The blockchain node protocol typically requires the blockchain node 104 to check that a cryptographic signature in the new transaction 152j matches the expected signature, which depends on the previous transaction 152i in an ordered sequence of transactions 152. In such an output-based transaction protocol, this may comprise checking that the cryptographic signature or other authorisation of the party 103 included in the input of the new transaction 152j matches a condition defined in the output of the preceding transaction 152i which the new transaction spends (or “assigns”), wherein this condition typically comprises at least checking that the cryptographic signature or other authorisation in the input of the new transaction 152j unlocks the output of the previous transaction 152i to which the input of the new transaction is linked to. The condition may be at least partially defined by a script included in the output of the preceding transaction 152i. Alternatively it could simply be fixed by the blockchain node protocol alone, or it could be due to a combination of these. Either way, if the new transaction 152j is valid, the blockchain node 104 forwards it to one or more other blockchain nodes 104 in the blockchain network 106. These other blockchain nodes 104 apply the same test according to the same blockchain node protocol, and so forward the new transaction 152j on to one or more further nodes 104, and so forth. In this way the new transaction is propagated throughout the network of blockchain nodes 104.
In an output-based model, the definition of whether a given output (e.g. UTXO) is assigned (or “spent”) is whether it has yet been validly redeemed by the input of another, onward transaction 152j according to the blockchain node protocol. Another condition for a transaction to be valid is that the output of the preceding transaction 152i which it attempts to redeem has not already been redeemed by another transaction. Again if not valid, the transaction 152j will not be propagated (unless flagged as invalid and propagated for alerting) or recorded in the blockchain 150. This guards against double-spending whereby the transactor tries to assign the output of the same transaction more than once. An account-based model on the other hand guards against double-spending by maintaining an account balance. Because again there is a defined order of transactions, the account balance has a single defined state at any one time.
In addition to validating transactions, blockchain nodes 104 also race to be the first to create blocks of transactions in a process commonly referred to as mining, which is supported by “proof-of-work”. At a blockchain node 104, new transactions are added to an ordered pool 154 of valid transactions that have not yet appeared in a block 151 recorded on the blockchain 150. The blockchain nodes then race to assemble a new valid block 151 of transactions 152 from the ordered set of transactions 154 by attempting to solve a cryptographic puzzle. Typically this comprises searching for a “nonce” value such that when the nonce is concatenated with a representation of the ordered pool of pending transactions 154 and hashed, then the output of the hash meets a predetermined condition. E.g. the predetermined condition may be that the output of the hash has a certain predefined number of leading zeros. Note that this is just one particular type of proof-of-work puzzle, and other types are not excluded. A property of a hash function is that it has an unpredictable output with respect to its input. Therefore this search can only be performed by brute force, thus consuming a substantive amount of processing resource at each blockchain node 104 that is trying to solve the puzzle.
The first blockchain node 104 to solve the puzzle announces this to the network 106, providing the solution as proof which can then be easily checked by the other blockchain nodes 104 in the network (once given the solution to a hash it is straightforward to check that it causes the output of the hash to meet the condition). The first blockchain node 104 propagates a block to a threshold consensus of other nodes that accept the block and thus enforce the protocol rules. The ordered set of transactions 154 then becomes recorded as a new block 151 in the blockchain 150 by each of the blockchain nodes 104. A block pointer 155 is also assigned to the new block 151n pointing back to the previously created block 151n-1 in the chain. The significant amount of effort, for example in the form of hash, required to create a proof-of-work solution signals the intent of the first node 104 to follow the rules of the blockchain protocol. Such rules include not accepting a transaction as valid if it spends or assigns the same output as a previously validated transaction, otherwise known as double-spending. Once created, the block 151 cannot be modified since it is recognized and maintained at each of the blockchain nodes 104 in the blockchain network 106. The block pointer 155 also imposes a sequential order to the blocks 151. Since the transactions 152 are recorded in the ordered blocks at each blockchain node 104 in a network 106, this therefore provides an immutable public ledger of the transactions.
Note that different blockchain nodes 104 racing to solve the puzzle at any given time may be doing so based on different snapshots of the pool of yet-to-be published transactions 154 at any given time, depending on when they started searching for a solution or the order in which the transactions were received. Whoever solves their respective puzzle first defines which transactions 152 are included in the next new block 151n and in which order, and the current pool 154 of unpublished transactions is updated. The blockchain nodes 104 then continue to race to create a block from the newly-defined ordered pool of unpublished transactions 154, and so forth. A protocol also exists for resolving any “fork” that may arise, which is where two blockchain nodes 104 solve their puzzle within a very short time of one another such that a conflicting view of the blockchain gets propagated between nodes 104. In short, whichever prong of the fork grows the longest becomes the definitive blockchain 150. Note this should not affect the users or agents of the network as the same transactions will appear in both forks.
According to the bitcoin blockchain (and most other blockchains) a node that successfully constructs a new block 104 is granted the ability to newly assign an additional, accepted amount of the digital asset in a new special kind of transaction which distributes an additional defined quantity of the digital asset (as opposed to an inter-agent, or inter-user transaction which transfers an amount of the digital asset from one agent or user to another). This special type of transaction is usually referred to as a “coinbase transaction”, but may also be termed an “initiation transaction” or “generation transaction”. It typically forms the first transaction of the new block 151n. The proof-of-work signals the intent of the node that constructs the new block to follow the protocol rules allowing this special transaction to be redeemed later. The blockchain protocol rules may require a maturity period, for example 100 blocks, before this special transaction may be redeemed. Often a regular (non-generation) transaction 152 will also specify an additional transaction fee in one of its outputs, to further reward the blockchain node 104 that created the block 151n in which that transaction was published. This fee is normally referred to as the “transaction fee”, and is discussed blow.
Due to the resources involved in transaction validation and publication, typically at least each of the blockchain nodes 104 takes the form of a server comprising one or more physical server units, or even whole a data centre. However in principle any given blockchain node 104 could take the form of a user terminal or a group of user terminals networked together.
The memory of each blockchain node 104 stores software configured to run on the processing apparatus of the blockchain node 104 in order to perform its respective role or roles and handle transactions 152 in accordance with the blockchain node protocol. It will be understood that any action attributed herein to a blockchain node 104 may be performed by the software run on the processing apparatus of the respective computer equipment. The node software may be implemented in one or more applications at the application layer, or a lower layer such as the operating system layer or a protocol layer, or any combination of these.
Also connected to the network 101 is the computer equipment 102 of each of a plurality of parties 103 in the role of consuming users. These users may interact with the blockchain network 106 but do not participate in validating transactions or constructing blocks. Some of these users or agents 103 may act as senders and recipients in transactions. Other users may interact with the blockchain 150 without necessarily acting as senders or recipients. For instance, some parties may act as storage entities that store a copy of the blockchain 150 (e.g. having obtained a copy of the blockchain from a blockchain node 104).
Some or all of the parties 103 may be connected as part of a different network, e.g. a network overlaid on top of the blockchain network 106. Users of the blockchain network (often referred to as “clients”) may be said to be part of a system that includes the blockchain network 106; however, these users are not blockchain nodes 104 as they do not perform the roles required of the blockchain nodes. Instead, each party 103 may interact with the blockchain network 106 and thereby utilize the blockchain 150 by connecting to (i.e. communicating with) a blockchain node 106. Two parties 103 and their respective equipment 102 are shown for illustrative purposes: a first party 103a and his/her respective computer equipment 102a, and a second party 103b and his/her respective computer equipment 102b. It will be understood that many more such parties 103 and their respective computer equipment 102 may be present and participating in the system 100, but for convenience they are not illustrated. Each party 103 may be an individual or an organization. Purely by way of illustration the first party 103a is referred to herein as Alice and the second party 103b is referred to as Bob, but it will be appreciated that this is not limiting and any reference herein to Alice or Bob may be replaced with “first party” and “second “party” respectively.
The computer equipment 102 of each party 103 comprises respective processing apparatus comprising one or more processors, e.g. one or more CPUs, GPUs, other accelerator processors, application specific processors, and/or FPGAs. The computer equipment 102 of each party 103 further comprises memory, i.e. computer-readable storage in the form of a non-transitory computer-readable medium or media. This memory may comprise one or more memory units employing one or more memory media, e.g. a magnetic medium such as hard disk; an electronic medium such as an SSD, flash memory or EEPROM; and/or an optical medium such as an optical disc drive. The memory on the computer equipment 102 of each party 103 stores software comprising a respective instance of at least one client application 105 arranged to run on the processing apparatus. It will be understood that any action attributed herein to a given party 103 may be performed using the software run on the processing apparatus of the respective computer equipment 102. The computer equipment 102 of each party 103 comprises at least one user terminal, e.g. a desktop or laptop computer, a tablet, a smartphone, or a wearable device such as a smartwatch. The computer equipment 102 of a given party 103 may also comprise one or more other networked resources, such as cloud computing resources accessed via the user terminal.
The client application 105 may be initially provided to the computer equipment 102 of any given party 103 on suitable computer-readable storage medium or media, e.g. downloaded from a server, or provided on a removable storage device such as a removable SSD, flash memory key, removable EEPROM, removable magnetic disk drive, magnetic floppy disk or tape, optical disk such as a CD or DVD ROM, or a removable optical drive, etc.
The client application 105 comprises at least a “wallet” function. This has two main functionalities. One of these is to enable the respective party 103 to create, authorise (for example sign) and send transactions 152 to one or more bitcoin nodes 104 to then be propagated throughout the network of blockchain nodes 104 and thereby included in the blockchain 150. The other is to report back to the respective party the amount of the digital asset that he or she currently owns. In an output-based system, this second functionality comprises collating the amounts defined in the outputs of the various 152 transactions scattered throughout the blockchain 150 that belong to the party in question.
Note: whilst the various client functionality may be described as being integrated into a given client application 105, this is not necessarily limiting and instead any client functionality described herein may instead be implemented in a suite of two or more distinct applications, e.g. interfacing via an API, or one being a plug-in to the other. More generally the client functionality could be implemented at the application layer or a lower layer such as the operating system, or any combination of these. The following will be described in terms of a client application 105 but it will be appreciated that this is not limiting.
The instance of the client application or software 105 on each computer equipment 102 is operatively coupled to at least one of the blockchain nodes 104 of the network 106. This enables the wallet function of the client 105 to send transactions 152 to the network 106. The client 105 is also able to contact blockchain nodes 104 in order to query the blockchain 150 for any transactions of which the respective party 103 is the recipient (or indeed inspect other parties' transactions in the blockchain 150, since in embodiments the blockchain 150 is a public facility which provides trust in transactions in part through its public visibility). The wallet function on each computer equipment 102 is configured to formulate and send transactions 152 according to a transaction protocol. As set out above, each blockchain node 104 runs software configured to validate transactions 152 according to the blockchain node protocol, and to forward transactions 152 in order to propagate them throughout the blockchain network 106. The transaction protocol and the node protocol correspond to one another, and a given transaction protocol goes with a given node protocol, together implementing a given transaction model. The same transaction protocol is used for all transactions 152 in the blockchain 150. The same node protocol is used by all the nodes 104 in the network 106.
When a given party 103, say Alice, wishes to send a new transaction 152j to be included in the blockchain 150, then she formulates the new transaction in accordance with the relevant transaction protocol (using the wallet function in her client application 105). She then sends the transaction 152 from the client application 105 to one or more blockchain nodes 104 to which she is connected. E.g. this could be the blockchain node 104 that is best connected to Alice's computer 102. When any given blockchain node 104 receives a new transaction 152j, it handles it in accordance with the blockchain node protocol and its respective role. This comprises first checking whether the newly received transaction 152j meets a certain condition for being “valid”, examples of which will be discussed in more detail shortly. In some transaction protocols, the condition for validation may be configurable on a per-transaction basis by scripts included in the transactions 152. Alternatively the condition could simply be a built-in feature of the node protocol, or be defined by a combination of the script and the node protocol.
On condition that the newly received transaction 152j passes the test for being deemed valid (i.e. on condition that it is “validated”), any blockchain node 104 that receives the transaction 152j will add the new validated transaction 152 to the ordered set of transactions 154 maintained at that blockchain node 104. Further, any blockchain node 104 that receives the transaction 152j will propagate the validated transaction 152 onward to one or more other blockchain nodes 104 in the network 106. Since each blockchain node 104 applies the same protocol, then assuming the transaction 152j is valid, this means it will soon be propagated throughout the whole network 106.
Once admitted to the ordered pool of pending transactions 154 maintained at a given blockchain node 104, that blockchain node 104 will start competing to solve the proof-of-work puzzle on the latest version of their respective pool of 154 including the new transaction 152 (recall that other blockchain nodes 104 may be trying to solve the puzzle based on a different pool of transactions 154, but whoever gets there first will define the set of transactions that are included in the latest block 151. Eventually a blockchain node 104 will solve the puzzle for a part of the ordered pool 154 which includes Alice's transaction 152j). Once the proof-of-work has been done for the pool 154 including the new transaction 152j, it immutably becomes part of one of the blocks 151 in the blockchain 150. Each transaction 152 comprises a pointer back to an earlier transaction, so the order of the transactions is also immutably recorded.
Different blockchain nodes 104 may receive different instances of a given transaction first and therefore have conflicting views of which instance is ‘valid’ before one instance is published in a new block 151, at which point all blockchain nodes 104 agree that the published instance is the only valid instance. If a blockchain node 104 accepts one instance as valid, and then discovers that a second instance has been recorded in the blockchain 150 then that blockchain node 104 must accept this and will discard (i.e. treat as invalid) the instance which it had initially accepted (i.e. the one that has not been published in a block 151).
An alternative type of transaction protocol operated by some blockchain networks may be referred to as an “account-based” protocol, as part of an account-based transaction model. In the account-based case, each transaction does not define the amount to be transferred by referring back to the UTXO of a preceding transaction in a sequence of past transactions, but rather by reference to an absolute account balance. The current state of all accounts is stored, by the nodes of that network, separate to the blockchain and is updated constantly. In such a system, transactions are ordered using a running transaction tally of the account (also called the “position”). This value is signed by the sender as part of their cryptographic signature and is hashed as part of the transaction reference calculation. In addition, an optional data field may also be signed the transaction. This data field may point back to a previous transaction, for example if the previous transaction ID is included in the data field.
In a UTXO-based model, each transaction (“Tx”) 152 comprises a data structure comprising one or more inputs 202, and one or more outputs 203. Each output 203 may comprise an unspent transaction output (UTXO), which can be used as the source for the input 202 of another new transaction (if the UTXO has not already been redeemed). The UTXO includes a value specifying an amount of a digital asset. This represents a set number of tokens on the distributed ledger. The UTXO may also contain the transaction ID of the transaction from which it came, amongst other information. The transaction data structure may also comprise a header 201, which may comprise an indicator of the size of the input field(s) 202 and output field(s) 203. The header 201 may also include an ID of the transaction. In embodiments the transaction ID is the hash of the transaction data (excluding the transaction ID itself) and stored in the header 201 of the raw transaction 152 submitted to the nodes 104.
Say Alice 103a wishes to create a transaction 152j transferring an amount of the digital asset in question to Bob 103b. In
The preceding transaction Tx0 may already have been validated and included in a block 151 of the blockchain 150 at the time when Alice creates her new transaction Tx1, or at least by the time she sends it to the network 106. It may already have been included in one of the blocks 151 at that time, or it may be still waiting in the ordered set 154 in which case it will soon be included in a new block 151. Alternatively Tx0 and Tx1 could be created and sent to the network 106 together, or Tx0 could even be sent after Tx1 if the node protocol allows for buffering “orphan” transactions. The terms “preceding” and “subsequent” as used herein in the context of the sequence of transactions refer to the order of the transactions in the sequence as defined by the transaction pointers specified in the transactions (which transaction points back to which other transaction, and so forth). They could equally be replaced with “predecessor” and “successor”, or “antecedent” and “descendant”, “parent” and “child”, or such like. It does not necessarily imply an order in which they are created, sent to the network 106, or arrive at any given blockchain node 104. Nevertheless, a subsequent transaction (the descendent transaction or “child”) which points to a preceding transaction (the antecedent transaction or “parent”) will not be validated until and unless the parent transaction is validated. A child that arrives at a blockchain node 104 before its parent is considered an orphan. It may be discarded or buffered for a certain time to wait for the parent, depending on the node protocol and/or node behaviour.
One of the one or more outputs 203 of the preceding transaction Tx0 comprises a particular UTXO, labelled here UTXO0. Each UTXO comprises a value specifying an amount of the digital asset represented by the UTXO, and a locking script which defines a condition which must be met by an unlocking script in the input 202 of a subsequent transaction in order for the subsequent transaction to be validated, and therefore for the UTXO to be successfully redeemed. Typically the locking script locks the amount to a particular party (the beneficiary of the transaction in which it is included). I.e. the locking script defines an unlocking condition, typically comprising a condition that the unlocking script in the input of the subsequent transaction comprises the cryptographic signature of the party to whom the preceding transaction is locked.
The locking script (aka scriptPubKey) is a piece of code written in the domain specific language recognized by the node protocol. A particular example of such a language is called “Script” (capital S) which is used by the blockchain network. The locking script specifies what information is required to spend a transaction output 203, for example the requirement of Alice's signature. Unlocking scripts appear in the outputs of transactions. The unlocking script (aka scriptSig) is a piece of code written the domain specific language that provides the information required to satisfy the locking script criteria. For example, it may contain Bob's signature. Unlocking scripts appear in the input 202 of transactions.
So in the example illustrated, UTXO0 in the output 203 of Tx0 comprises a locking script [Checksig PA] which requires a signature Sig PA of Alice in order for UTXO0 to be redeemed (strictly, in order for a subsequent transaction attempting to redeem UTXO0 to be valid). [Checksig PA] contains a representation (i.e. a hash) of the public key PA from a public-private key pair of Alice. The input 202 of Tx1 comprises a pointer pointing back to Tx1 (e.g. by means of its transaction ID, TxID0, which in embodiments is the hash of the whole transaction Tx0). The input 202 of Tx1 comprises an index identifying UTXO0 within Tx0, to identify it amongst any other possible outputs of Tx0. The input 202 of Tx/further comprises an unlocking script <Sig PA> which comprises a cryptographic signature of Alice, created by Alice applying her private key from the key pair to a predefined portion of data (sometimes called the “message” in cryptography). The data (or “message”) that needs to be signed by Alice to provide a valid signature may be defined by the locking script, or by the node protocol, or by a combination of these.
When the new transaction Tx1 arrives at a blockchain node 104, the node applies the node protocol. This comprises running the locking script and unlocking script together to check whether the unlocking script meets the condition defined in the locking script (where this condition may comprise one or more criteria). In embodiments this involves concatenating the two scripts:
where “∥” represents a concatenation and “< . . . >” means place the data on the stack, and “[ . . . ]” is a function comprised by the locking script (in this example a stack-based language). Equivalently the scripts may be run one after the other, with a common stack, rather than concatenating the scripts. Either way, when run together, the scripts use the public key PA of Alice, as included in the locking script in the output of Tx0, to authenticate that the unlocking script in the input of Tx1 contains the signature of Alice signing the expected portion of data. The expected portion of data itself (the “message”) also needs to be included in order to perform this authentication. In embodiments the signed data comprises the whole of Tx1 (so a separate element does not need to be included specifying the signed portion of data in the clear, as it is already inherently present).
The details of authentication by public-private cryptography will be familiar to a person skilled in the art. Basically, if Alice has signed a message using her private key, then given Alice's public key and the message in the clear, another entity such as a node 104 is able to authenticate that the message must have been signed by Alice. Signing typically comprises hashing the message, signing the hash, and tagging this onto the message as a signature, thus enabling any holder of the public key to authenticate the signature. Note therefore that any reference herein to signing a particular piece of data or part of a transaction, or such like, can in embodiments mean signing a hash of that piece of data or part of the transaction.
If the unlocking script in Tx1 meets the one or more conditions specified in the locking script of Tx0 (so in the example shown, if Alice's signature is provided in Tx1 and authenticated), then the blockchain node 104 deems Tx1 valid. This means that the blockchain node 104 will add Tx1 to the ordered pool of pending transactions 154. The blockchain node 104 will also forward the transaction Tx1 to one or more other blockchain nodes 104 in the network 106, so that it will be propagated throughout the network 106. Once Tx1 has been validated and included in the blockchain 150, this defines UTXO0 from Tx0 as spent. Note that Tx1 can only be valid if it spends an unspent transaction output 203. If it attempts to spend an output that has already been spent by another transaction 152, then Tx1 will be invalid even if all the other conditions are met. Hence the blockchain node 104 also needs to check whether the referenced UTXO in the preceding transaction Tx0 is already spent (i.e. whether it has already formed a valid input to another valid transaction). This is one reason why it is important for the blockchain 150 to impose a defined order on the transactions 152. In practice a given blockchain node 104 may maintain a separate database marking which UTXOs 203 in which transactions 152 have been spent, but ultimately what defines whether a UTXO has been spent is whether it has already formed a valid input to another valid transaction in the blockchain 150.
If the total amount specified in all the outputs 203 of a given transaction 152 is greater than the total amount pointed to by all its inputs 202, this is another basis for invalidity in most transaction models. Therefore such transactions will not be propagated nor included in a block 151.
Note that in UTXO-based transaction models, a given UTXO needs to be spent as a whole. It cannot “leave behind” a fraction of the amount defined in the UTXO as spent while another fraction is spent. However the amount from the UTXO can be split between multiple outputs of the next transaction. E.g. the amount defined in UTXO0 in Tx0 can be split between multiple UTXOs in Tx1. Hence if Alice does not want to give Bob all of the amount defined in UTXO0, she can use the remainder to give herself change in a second output of Tx1, or pay another party.
In practice Alice will also usually need to include a fee for the bitcoin node 104 that successfully includes her transaction 104 in a block 151. If Alice does not include such a fee, Tx0 may be rejected by the blockchain nodes 104, and hence although technically valid, may not be propagated and included in the blockchain 150 (the node protocol does not force blockchain nodes 104 to accept transactions 152 if they don't want). In some protocols, the transaction fee does not require its own separate output 203 (i.e. does not need a separate UTXO). Instead any difference between the total amount pointed to by the input(s) 202 and the total amount of specified in the output(s) 203 of a given transaction 152 is automatically given to the blockchain node 104 publishing the transaction. E.g. say a pointer to UTXO0 is the only input to Tx1, and Tx1 has only one output UTXO1. If the amount of the digital asset specified in UTXO0 is greater than the amount specified in UTXO1, then the difference may be assigned (or spent) by the node 104 that wins the proof-of-work race to create the block containing UTXO1. Alternatively or additionally however, it is not necessarily excluded that a transaction fee could be specified explicitly in its own one of the UTXOs 203 of the transaction 152.
Alice and Bob's digital assets consist of the UTXOs locked to them in any transactions 152 anywhere in the blockchain 150. Hence typically, the assets of a given party 103 are scattered throughout the UTXOs of various transactions 152 throughout the blockchain 150.
There is no one number stored anywhere in the blockchain 150 that defines the total balance of a given party 103. It is the role of the wallet function in the client application 105 to collate together the values of all the various UTXOs which are locked to the respective party and have not yet been spent in another onward transaction. It can do this by querying the copy of the blockchain 150 as stored at any of the bitcoin nodes 104.
Note that the script code is often represented schematically (i.e. not using the exact language). For example, one may use operation codes (opcodes) to represent a particular function. “OP_. . . ” refers to a particular opcode of the Script language. As an example, OP_RETURN is an opcode of the Script language that when preceded by OP_FALSE at the beginning of a locking script creates an unspendable output of a transaction that can store data within the transaction, and thereby record the data immutably in the blockchain 150. E.g. the data could comprise a document which it is desired to store in the blockchain.
Typically an input of a transaction contains a digital signature corresponding to a public key PA. In embodiments this is based on the ECDSA using the elliptic curve secp256k1. A digital signature signs a particular piece of data. In some embodiments, for a given transaction the signature will sign part of the transaction input, and some or all of the transaction outputs. The particular parts of the outputs it signs depends on the SIGHASH flag. The SIGHASH flag is usually a 4-byte code included at the end of a signature to select which outputs are signed (and thus fixed at the time of signing).
The locking script is sometimes called “scriptPubKey” referring to the fact that it typically comprises the public key of the party to whom the respective transaction is locked. The unlocking script is sometimes called “scriptSig” referring to the fact that it typically supplies the corresponding signature. However, more generally it is not essential in all applications of a blockchain 150 that the condition for a UTXO to be redeemed comprises authenticating a signature. More generally the scripting language could be used to define any one or more conditions. Hence the more general terms “locking script” and “unlocking script” may be preferred.
As shown in
The side channel 107 may be established via the same packet-switched network 101 as the blockchain network 106. Alternatively or additionally, the side channel 301 may be established via a different network such as a mobile cellular network, or a local area network such as a local wireless network, or even a direct wired or wireless link between Alice and Bob's devices 102a, 102b. Generally, the side channel 107 as referred to anywhere herein may comprise any one or more links via one or more networking technologies or communication media for exchanging data “off-chain”, i.e. separately from the blockchain network 106. Where more than one link is used, then the bundle or collection of off-chain links as a whole may be referred to as the side channel 107. Note therefore that if it is said that Alice and Bob exchange certain pieces of information or data, or such like, over the side channel 107, then this does not necessarily imply all these pieces of data have to be send over exactly the same link or even the same type of network.
The script engine 452 thus has the locking script of Txj and the unlocking script from the corresponding input of Txj. For example, transactions labelled Tx0 and Tx1 are illustrated in
By running the scripts together, the script engine 452 determines whether or not the unlocking script meets the one or more criteria defined in the locking script—i.e. does it “unlock” the output in which the locking script is included? The script engine 452 returns a result of this determination to the protocol engine 451. If the script engine 452 determines that the unlocking script does meet the one or more criteria specified in the corresponding locking script, then it returns the result “true”. Otherwise it returns the result “false”.
In an output-based model, the result “true” from the script engine 452 is one of the conditions for validity of the transaction. Typically there are also one or more further, protocol-level conditions evaluated by the protocol engine 451 that must be met as well; such as that the total amount of digital asset specified in the output(s) of Txj does not exceed the total amount pointed to by its inputs, and that the pointed-to output of Txi has not already been spent by another valid transaction. The protocol engine 451 evaluates the result from the script engine 452 together with the one or more protocol-level conditions, and only if they are all true does it validate the transaction Txj. The protocol engine 451 outputs an indication of whether the transaction is valid to the application-level decision engine 454. Only on condition that Txj is indeed validated, the decision engine 454 may select to control both of the consensus module 455C and the propagation module 455P to perform their respective blockchain-related function in respect of Txj. This comprises the consensus module 455C adding Tx1 to the node's respective ordered set of transactions 154 for incorporating in a block 151, and the propagation module 455P forwarding Txj to another blockchain node 104 in the network 106. Optionally, in embodiments the application-level decision engine 454 may apply one or more additional conditions before triggering either or both of these functions. E.g. the decision engine may only select to publish the transaction on condition that the transaction is both valid and leaves enough of a transaction fee.
Note also that the terms “true” and “false” herein do not necessarily limit to returning a result represented in the form of only a single binary digit (bit), though that is certainly one possible implementation. More generally, “true” can refer to any state indicative of a successful or affirmative outcome, and “false” can refer to any state indicative of an unsuccessful or non-affirmative outcome. For instance in an account-based model, a result of “true” could be indicated by a combination of an implicit, protocol-level validation of a signature and an additional affirmative output of a smart contract (the overall result being deemed to signal true if both individual outcomes are true).
Continuing with the example of
The first script comprises a modular inversion script. The modular inversion script is configured to generate the modular inverse of a target integer using a modulus value that is co-prime with the target integer. The target integer and the modulus value are supplied to the modular inversion script as inputs. In some examples, the inputs are included in the first script, i.e. the same script as the modular inversion script. In other examples, the inputs are included in a second script of a second blockchain transaction. For instance, the second script may be or form part of an unlocking script of the second transaction. The second transaction may be generated and submitted to the blockchain network 106 by Bob 103b, as shown in
In embodiments, the modular inversion script is configured to generate the modular inverse of the target integer by executing at least part of the extended Euclidean algorithm. The extended Euclidean algorithm (eGCD) computes the greatest common divisor (GCD) of two integers n, x and the coefficients y, m of the Bezout identity:
If n and x are coprime, then the Bezout coefficient y is the modular inverse of x modulus n. The algorithm sets r0:=n, s0:=1, t0:=0, and r1:=x, s1:=0, t1:=1 and computes three sequences ri, si, ti iteratively as follows:
The iteration stops when rk+1=0. By defining egcd(x,n):=(rk,sk,tk), the GCD is rk and the Bezout coefficients of n and x are sk, tk respectively.
The modular inversion script is configured to compute a first sequence (ti+1) of the extended Euclidean algorithm based on the target integer (x) and the modulus value (n), and to compute the Bezout coefficient (y) of the target integer (x) based on the computed first sequence (ti+1). The modular inversion script is further configured to output the Bezout coefficient (y) of the target integer (x) as the modular inverse (x−1) of the target integer. For instance, the modular inverse may be output to a stack-based memory 453. Additionally or alternatively, the modular inverse may be output to be used by a different script of the first script, as discussed below.
The modular inversion script may be configured to compute a second sequence (ri+1) of the extended Euclidean algorithm based on the target integer (x) and the modulus value (n), and to use the second sequence to compute the GCD of the target index and the modulus value. Starting from initial values in the first and second sequences, the modular inversion script is configured to iteratively compute each next value in the first sequence ti+1 and in the second sequence ri+1 until a respective value of the second sequence is equal to the GCD. The corresponding value in the first sequence is output as the Bezout coefficient of the target integer.
In these examples, the modular inversion script may initialize (i.e. include as hardcoded values) the values of t1: =1, t0:=0, r0:=n, r1:=x.
The modular inversion script may comprise a series of sub-scripts, each configured to generate a respective next value in the first and second sequences. The series of sub-scripts act as a loop inside the modular inversion script. An upper bound of the number of sub-scripts in the series may be determined as
wherein κ is the number of bits in the modulus value and Φ is the golden ratio.
This upper bound is derived as follows. Let FN+1 be the (N+1)-th Fibonacci number such that x≥FN+1. It is known that the number of iterations to compute egcd(a,b) is at most N. Noting that n>x≥FN+1≥ΦN−1, where
is the golden ratio, we have that
In other words, for a κ-bit modulus n, the number of iterations N to compute modular inverses of any x∈n* is upper bounded by
The following box shows an example modular inversion script [egcd mod invert] configured to compute and output the modular inverse of a target integer <x> for a modulus value <n>. The example scripts shown herein are written in the Script scripting language, as used by, for example the Bitcoin blockchain. It should be appreciated that the described embodiments are not limited to any specific scripting language, and that Script is used merely be way of example. Other suitable scripting languages may be used. egcd mod invert] may also be referred to as [modular invert] herein.
As shown, the modular inversion script may be configured to implement an unwrapped loop—some scripting languages do not allow for loops. The number of steps of the loop is given by the bound specified above. Each step implements a first (IF) branch and a second (ELSE) branch. The first branch is the “working” branch. It computes each next value in the first and second sequences, i.e. the sequence that eventually reveals the Bezout co-efficient and the sequence that eventually reveals the GCD. When the GCD is revealed, the ELSE branch (the “idle” branch) is accessed in which the script remains idle until all steps of the unwrapped loop are executed. In other words, ion the ELSE branch, the script essentially remains idle and does not contribute to the computation of the modular inverse. At the end of the script execution, the Bezout coefficient to be output, e.g. to the stack.
The critical sequence is the first (ti) sequence. It is not necessary to compute the si sequence. The example script above receives as arguments x∈n* and n and computes t2, . . . tk+1. The sequence ri (that eventually gives away the GCD) is used to decide when the modular inverse has been obtained, and when to branch in the script. When rk:=gcd (n,x) is reached, the script accesses the OP_ELSE branch—the idle branch. After termination, it leaves the modular inverse tk≡x−1 mod n on top of the stack.
Each iteration (i.e. repeat of the specified opcodes) takes twenty bytes. Adding the bytes for initialization (six) and finalization (seventeen) gives a script of size:
The modular inversion script may be used to compute the modular inverse of an integer as part of performing an addition of two elliptic curve points.
Let p be an odd prime and a, b∈p such that 4a3−27b2≠0. A Weierstrass elliptic curve is the set Ea,b,p:={(x,y)∈
p: y2=x3+ax+b}∪{Ø}. For any two points P,Q∈Ea,b,p the group law (addition) is defined as follows:
The inverse of an affine point P:=(x,y) is defined as −P:=(x,−y). All operations above are over p.
The costliest operation in point addition is computing modular inverses. In terms of size, it is even more costly in script because a loop must be unwrapped.
The first script may comprise a point addition script configured to obtain a first elliptic curve point (P) and a second elliptic curve point (Q) and a modulus value (p). In script, the elliptic curve points P and Q may be represented as (x1,y1) and (x2,y2) respectively. The point addition script is configured to output an addition (P+Q) of the first and second points. The addition (P+Q) is referred to herein as a first target point. In some examples, the first and/or second elliptic curve points may be obtained from the second script of the second transaction. When computing the first target point, the point addition script is configured to compute the lambda value λ. As shown above, λ is based on a numerator and a denominator value. The numerator and denominator are calculated in script. The point addition script is then configured to compute the inverse of the denominator, and multiply the inverse of the denominator by the numerator so as to compute λ. In other words, the target integer and modulus value input to the modular inversion script is the computed denominator and p, respectively. The computed λ is then used by the point addition script to compute the first target point according to equation 4.
The point addition script is configured to calculate the numerator and denominator according to equations 4a and 4b above, depending on whether the first and second points are equal or not. The point addition script may be configured to determine, in script, whether the first and second points are equal. This means that the script for computing A only needs to be included once as part of the point addition script. In turn, this means that the modular inversion script only needs to be included once as part of the point addition script.
The point addition script may also be configured to determine whether either of the first and second points are equal to the identity element (Ø), and only compute λ if neither of the first and second points are equal to the identity element (Ø).
The following box shows an example point addition script [Add points] configured to compute and output the addition of two elliptic curve points.
The script [Add points] assumes a stack initialized with its five top elements to y2,x2,y1,x1, p from bottom to top—the coordinates of the summand points P, Q and the modulus p. After completion, the script pops out P, Q and p, and pushes to the stack the coordinates y+,x+ (in this order) of P+Q. The script is defined so that during the generation of λ it calls the invert subroutine just once, instead of calling it (twice) in the branched statements (4a) and (4b).
More precisely, if
mod p, the subroutine script [Compute λ]—see below calculates the appropriate numerator N and denominator D (over the integers) in branches (4a) and (4b). In the joint branch (4) we modular invert D, and finalize the computation of λ and P+Q. After completion, the script pushes to the stack scalar λ on top of the coordinates of P and Q.
The script [Add points from precomputed λ]—see below—is used to calculate P+Q. It assumes a stack initialized with its six top elements to y2,x2,y1,x1,λ, p, from bottom to top. After completion, it pushes to the stack the coordinates y+,x+ of the added point P+Q on top of the coordinates of P and Q and consumes λ, p.
Adding two points is dominated by the complexity of a modular inversion. Specifically, the script contains 37 opcodes plus subroutines:
The following box shows an example script [Compute λ] configured to compute and output λ based on a numerator, a denominator and a modulus value. This example script utilizes the modular inversion script.
The following box shows an example script [Add points with precomputed λ] configured to compute and output a target point based on a first and second point and a pre-computed value of λ.
The first script may comprise a point subtraction script configured to subtract one elliptic curve point from another. In some examples, the point subtraction script may comprise the point addition script.
The point subtraction script is configured to obtain a third elliptic curve point and a modulus value. The point subtraction script is configured to negate the third elliptic curve point using the modulus value, and to output the result to the point addition script as the first or second elliptic curve point. That is, the point subtraction script negates an elliptic curve point, which is then added to another elliptic curve point by the point addition script.
The following box shows an example negate point script [Negate point] that may be used by the point subtraction script to negate an elliptic curve point.
This operation finds the inverse of a point. It is implemented for Weierstrass curves, wherein the negation of point P=(x,y) is defined as −P:=(x,−y mod p). The negate points script consumes the point and pushes its negation. It assumes a stack with point coordinates reduced mod p (least positive residues), which allows to use OP_MOD. It takes seven bytes to negate a point
Subtracting two points may be performed using the [Negate point] and [Add points] scripts, already discussed. The resulting complexity is the sum of the complexities of the two scripts:
The modular inversion script may be used to compute the modular inverse of an integer as part of performing a doubling of an elliptic curve point. Point doubling is defined above in equation 4b.
The first script may include a point doubling script is configured to obtain a fourth elliptic curve point (P) and a modulus value (p). In script, the elliptic curve point P may be represented as (x1,y1). The point doubling script is configured to output a doubling (2P) of the elliptic curve point. The doubling (2P) is referred to herein as a second target point. Note that in general the labels “first”, “second”, “third”, and so on are used as arbitrary labels and do not necessarily imply an order or the presence of any other values unless the context requires otherwise. For instance, the second target point may be computed without having to compute the first target point. Similarly, “first” and “second” and so on may be used as labels for the same or different values or other types of data. For instance, the “first” and “third” elliptic curve points may be the same points.
In some examples, the elliptic curve point to be doubled may be obtained from the second script of the second transaction.
The point doubling script may be configured to compute a second lambda value in a similar way as described above for the point addition script. That is, a numerator and denominator are calculated (e.g. using equation 4b),the inverse of the denominator is calculated using the modular inversion script, and the numerator is then multiplied with the inverse of the denominator to generate λ. The point doubling script is then configured to compute the second target point using the third elliptic curve point (P) and λ.
The following box shows an example point doubling script [Double points] configured to compute and output the doubling of an elliptic curve point. It takes a point and the modulus and pushes its doubling, consuming the arguments.
Doubling a point is dominated by the modular inverse. However, constants are slightly smaller than adding two points with [Add points]. Specifically:
The first script may comprise a first multiplication-by-scalar (MBS) script configured to multiply a fifth elliptic curve point (P) by a scalar (k). Again, note that “fifth” is used here merely as a convenient label. The first MBS script is configured to obtain the fifth elliptic curve point, the scalar value and a modulus value. The scalar value is expressed in binary, or is converted to binary in script. The first MBS script is configured to use the double-and-add algorithm to calculate UP, referred to herein as a third target elliptic curve point.
To calculate kP the double-and-add algorithm computes iteratively the doublings
and adds Di to the result point R if and only if the i-th bit of scalar k is set.
More specifically, the first MBS script comprises a series of sub-scripts to be executed in turn. Each sub-script is associated with a respective index and comprises an instance of the point doubling script (e.g. [Double point]). Recall that the point doubling script and utilises the modular inversion script.
A first one of the sub-scripts in the series is configured to double the fifth elliptic curve point, i.e. to calculate D1:=2P. This is referred to as a first intermediate result. A next one of the sub-scripts in the series is configured to double the first intermediate result, i.e. to calculate D2:=D1+D1=22P. This is referred to as a second intermediate result. The process repeats one or more times. In general, each sub-script is configured to generate a respective intermediate result by doubling a previous value, wherein the previous value is either the fifth elliptic curve point (P) or a previous intermediate result (Di−1).
The first MBS script is configured to calculate kP by summing the intermediate results generated by the sub-scripts whose respective index is associated with a corresponding bit of the scalar k that is set, i.e. equal to one. In other words, if the ith bit is set, the ith intermediate result generated by the ith sub-script is added to a result value. The result value may be initialised as an empty array and updated by adding each of the relevant intermediate results.
The following box shows an example first MBS script [Multiply by scalar via double—and—add] configured to compute and output the scalar multiplication of an elliptic curve point. It takes a point, a scalar and a modulus, and pushes the resulting scalar multiplication.
The [Multiply by scalar via double—and—add] uses as a subroutine the script shown in the following box, which for points R and D (the doubling) over an elliptic curve and a scalar k updates R with either itself or with R+D, based on the i-th bit value of the scalar k.
After execution of the subroutine, the top of the stack is either P (bit not set) or P+D (bit set). It leaves the scalar as the third-to-top element of the stack.
We now count the number of bytes to do a scalar multiplication using double-and-add.
There are two factors here, the size n of the scalar k and the size K of the modulus p of the base field (in secp256k1 both are 256-bit long). The script has 9n opcodes plus subroutines:
The first script may comprise a second multiplication-by-scalar (MBS) script configured to multiply a sixth elliptic curve point (P) by a scalar (k). Again, note that “sixth” is used here merely as a convenient label. The second MBS script is different to the first MBS script. That is, the first and second MBS scripts are different types of scripts, configured to perform different functions. The second MBS script is configured to a predefined elliptic curve point by the scalar using a modulus value. The scalar value is expressed in binary, or is converted to binary in script. Like the first MBS script, the second MBS script is also configured to use the double-and-add algorithm to calculate kP, referred to herein as a fourth target elliptic curve point. However in this case the doublings Di are pre-calculated, rather than calculated in-script.
The second MBS script comprises a series of sub-scripts to be executed in turn. Each sub-script is associated with a respective index and comprises an instance of the point addition script (e.g. [Add points]). Each sub-script comprises a respective pre-calculated doubling of the sixth elliptic curve point. That is, the first sub-script comprises a first doubling D1:=2P, the second sub-script comprises a second doubling D2:=D1+D1=22P, and so on. Each sub-script is configured to use the point addition script to add the respective doubling to a result if the corresponding bit of the scalar is set, i.e. equal to one. In other words, if the ith bit is set, the ith sub-script is configured to add the ith doubling Di to a result value. The result value may be initialised as an empty array and updated by adding each of the relevant doublings.
The following box shows an example second MBS script [Multiply P by scalar] configured to compute and output the scalar multiplication of an elliptic curve point. It takes a scalar and a modulus, and pushes the resulting scalar multiplication.
Compared with the double and add script shown above, it saves the doublings, yielding:
This section shows a plurality of scripts that may be included as part of the first script. It will be appreciated that these scripts are merely examples and that it is within the gambit of the skilled person to, given the present disclosure, develop an equivalent script that performs an equivalent function. The same applies to the example scripts presented above.
Let (bκ−1, . . . , b0) be the big-endian bit-array representation of a κ-bit integer λ=Σi=0κ−1bi·2i. Let =┌κ/8┐ be the byte length of λ. One can test whether the i-th bit bi of Δ is set to one) or not with bitwise operations:
The following box shows an example script [Is bit set] configured to take as arguments the target bit and the scalar. The first line pushes integer 1 as an -byte array in big-endian (needed for the bitwise OP_AND); since OP_NUM2BIN converts to numbers in little-endian, we attach bit one to the right end of a (
−1)-long zero-array directly. The second line sets only the i-th bit of the pushed 1. The third line leaves the top of the stack with a number res that is either 2′ (bit is set, bi=1) or 0 (bit is not set, bi=0). Jumping ahead, this can be interpreted as a boolean to branch in an OP_IF statement.
It follows an execution showing the state of the stack after each line. The notation is a byte array of length
representing integer n in big-endian.
The size of script [Is bit set] is nine bytes regardless of the size of λ.
It is sometimes beneficial to be able to duplicate two points P:=(x1,y1) and Q:=(x2,Y2). The following example script does that. It takes two bytes to duplicate a pair of points.
Two points of an elliptic curve are equal if and only if their coordinates are the same. A script implementing this logic is given in the following box. It consumes the coordinates of the points and pushes one to the stack if the points are equal, else it pushes zero. The script assumes a stack with point coordinates already reduced mod p. It takes five bytes to check if two points are equal.
Let E be the empty array. We represent the identity element of a Weierstrass curve with Ø:=(128,ε)=(0x80,ε), where ε denotes the empty array. In some examples, the script engine interprets integer 128 as the positive zero. Therefore, this choice ensures the identity element is not part of the set of affine points of the curve: zero coordinates in the script engine are given by 0x00 instead of 0x80.
Testing if a given point is Ø can be done more efficiently than point equality. It is enough to check whether the first coordinate matches 0x80 as byte array. See script [Is identity element] below. It assumes the coordinates are reduced mod p, i.e. they are in [0,p). It consumes the point and pushes one if the point is the identity element. Else, pushes zero. It takes three bytes to check if a point is the identity element of the curve.
The opcode OP_MOD is implemented in the script engine with the remainder operator %. Integer division in C truncates the integer towards zero, and therefore % may output negative numbers. Thus, we have that x=x,n OP_MOD for −n<x<n. In other words, the output range of OP_MOD is not a residue system. For example:
−2=−5,3OP_MOD.
Modular reduction may be implemented using the example script shown in the following box. Concretely, the range output of the script is the least residue system {0,1, . . . , n−1}. For example 1=−5, 3 [Reduce mod].
The script assumes the top of the stack is x, n and outputs x mod n∈[0,n), consuming the arguments. Under the hood (i.e., in combination with the script engine OP_MOD implementation) it computes (x % p+p) % p. It takes ten bytes to reduce an integer modulo p.
6.6. Loading the Modulus from the Alt Stack
To avoid hard-coding the modulus in many high-level scripts, the following script may be defined that maintains it in the alt stack. It assumes that the modulus has been already moved to the alt stack.
The size of a scalar multiplication for an arbitrary point P (unknown when creating the script) can be greatly improved assuming we know the logarithm of P in a known basis G.
Suppose P=xG for a fixed G. Then kP=(xk)G. Thus, we just have to compute y=xy and run a fixed-point script passing scalar y as argument. The example script shown in the following box implements this. Note that x:=logG P is passed as parameter. The script outputs yP. The size of the script exceeds by just three bytes the size of the underlying fixed-point script.
EC arithmetic in script as described above can be used to redeem UTXOs. Some example use cases are provided below.
It is possible for a party to spend a UTXO if they know an opening m, r of a Pedersen commitment C=xG+rP specified in the locking script. Generators G and H are known. With a hiding commitment it is possible to commit to messages m from a small set. For example, m could be a bit, or a string from a small public set. This may be useful in a Hash Time Locked Contract (HTLC) when we want the commitment scheme to hide the committed value.
In one embodiment, a script may be provided which comprises two instances of the second multiply-by-scalar (MBS) script, set out in section 5.6 above, and one instance of the point addition script described in section 5.2. The script also comprises a commitment point.
The script is configured to implement the MBS script to multiply H by the scalar r to calculate a first elliptical rH, where r is provided in the unlocking script. The script is configured to run a second instance of the second MBS script to multiply G by the scalar m to calculate a second elliptical curve point mG. The script is configured to run the point addition script to calculate the sum of rH and mG, and thus calculate a candidate commitment point C*. Finally, the script is configured to verify that the calculated candidate commitment point is equal to the commitment point of the script.
The following box shows an example script [Open Pedersen commitment C] configured to compute and output a candidate commitment point on m and r.
UTXO can be spent only if an opening to a commitment is known. The commitment C and the generators G,H are hardcoded in the locking script. The opening (m,r) is given in the unlocking script. Note that the committed message m can be a single bit.
The script has size:
Where the curve is instantiated over a κ-bit base field p. In secp256k1, this yields a script of roughly 1.5 MB.
Using a private key puzzle, funds can only be spent if the signing key s corresponding to public key P:=s·G is revealed.
Private key puzzles can be implemented exposing the ECDSA ephemeral key, resulting in extremely light locking scripts of just a few opcodes.
This approach requires the private key to be re-generated off-chain using the contents of the unlocking script. EC arithmetic can be used to envision locking scripts that impose further constraints on the signing key (the solution of the puzzle).
This has applications to contingent payment of goods. As an example, we apply it to outsourcing vanity addresses without off-chain calculations nor off-chain communication. Indeed, a buyer with keypair (sbuyer, Pbuyer) can publish a transaction whose locking script enforces the following three conditions on an ECDSA keypair (s,P) solution given in the unlocking script:
Any party that spends this transaction gives away the signing key s, and therefore the buyer can derive the signing key sbuyer+s of the vanity address.
A script may be provided which comprises a predetermined public key and a predetermined address, an instance of the second MBS, and an instance of the point addition script.
The script is configured to obtain, from an unlocking script of a subsequent transaction, a private key and a candidate address. The script is further configured to input the private key into the instance of the second MBS script to generate a candidate public key. It is then verified in script that the generated candidate public key is equal to the predetermined candidate key, for example using the [Are equal points] script. The script is further configured to input the candidate public key and the predetermined public key into the instance of the point addition script to generate a candidate elliptical curve point, and hash the generated candidate elliptical curve point to generate a candidate address. The script is configured to verify that the candidate address matches the predetermined address, or that a part of the candidate address matches a part of the predetermined address.
Over secp256k1, the locking script is roughly 700 KB.
In this case a transaction is redeemed with the knowledge of a plaintext m and a decryption key sk that decrypts to a fixed ciphertext C. The locking scripts contains C and implements the decryption algorithm.
ElGamal can be used, however it will be apricated that any group-based encryption scheme would work. Given an ElGamal ciphertext C=(C0,C1) over an elliptic curve, specified in the locking script. The locking script decrypts C to m*:=C1−skC0 and checks if m=m*. This is again implemented with EC arithmetic: using fixed-point scalar multiplication and point subtraction.
Other variants or use cases of the disclosed techniques may become apparent to the person skilled in the art once given the disclosure herein. The scope of the disclosure is not limited by the described embodiments but only by the accompanying claims.
For instance, some embodiments above have been described in terms of a bitcoin network 106, bitcoin blockchain 150 and bitcoin nodes 104. However it will be appreciated that the bitcoin blockchain is one particular example of a blockchain 150 and the above description may apply generally to any blockchain. That is, the present invention is in by no way limited to the bitcoin blockchain. More generally, any reference above to bitcoin network 106, bitcoin blockchain 150 and bitcoin nodes 104 may be replaced with reference to a blockchain network 106, blockchain 150 and blockchain node 104 respectively. The blockchain, blockchain network and/or blockchain nodes may share some or all of the described properties of the bitcoin blockchain 150, bitcoin network 106 and bitcoin nodes 104 as described above.
In preferred embodiments of the invention, the blockchain network 106 is the bitcoin network and bitcoin nodes 104 perform at least all of the described functions of creating, publishing, propagating and storing blocks 151 of the blockchain 150. It is not excluded that there may be other network entities (or network elements) that only perform one or some but not all of these functions. That is, a network entity may perform the function of propagating and/or storing blocks without creating and publishing blocks (recall that these entities are not considered nodes of the preferred bitcoin network 106).
In other embodiments of the invention, the blockchain network 106 may not be the bitcoin network. In these embodiments, it is not excluded that a node may perform at least one or some but not all of the functions of creating, publishing, propagating and storing blocks 151 of the blockchain 150. For instance, on those other blockchain networks a “node” may be used to refer to a network entity that is configured to create and publish blocks 151 but not store and/or propagate those blocks 151 to other nodes.
Even more generally, any reference to the term “bitcoin node” 104 above may be replaced with the term “network entity” or “network element”, wherein such an entity/element is configured to perform some or all of the roles of creating, publishing, propagating and storing blocks. The functions of such a network entity/element may be implemented in hardware in the same way described above with reference to a blockchain node 104.
It will be appreciated that the above embodiments have been described by way of example only. More generally there may be provided a method, apparatus or program in accordance with any one or more of the following Statements.
Statement 1. A computer-implemented method for enabling elliptic curve arithmetic to be performed using blockchain transactions, wherein the method is performed by a script generator and comprises: generating a first script of a first blockchain transaction, wherein the first script comprises a modular inversion script, and wherein the modular inversion script is configured to, when executed, by a script engine: obtain a target integer and a modulus value, wherein the target integer and the modulus value are co-prime, and output a modular inverse of the target integer, wherein the modular inverse is generated by iteratively computing a first sequence of the extended Euclidean algorithm with the target integer and modulus value as inputs, and using the first sequence to compute a Bezout co-efficient of the target integer, wherein the Bezout co-efficient of the target integer is output as the modular inverse; and outputting the first script for inclusion in the first blockchain transaction.
Statement 2. The method of statement 1, wherein modular inversion script may be configured to iteratively compute a second sequence of the extended Euclidean algorithm and use the second sequence to compute a greatest common divisor (GCD) of the target index and the modulus value, and wherein the modular inversion script comprises a series of sub-scripts to be executed in turn, each sub-script being configured to compute a respective value in the second sequence and a corresponding respective value in the first sequence, and wherein the modular inversion script is configured to execute the sub-scripts in sequence until the respective value in the second sequence is equal to the GCD, wherein the respective value in the first sequence corresponding to the respective value in the second sequence equal to the GCD is output as the Bezout co-efficient of the target integer.
Statement 3. The method of statement 2, wherein the modular inversion script may be configured to implement an unwrapped loop, wherein each respective sub-script implements a respective step of the unwrapped loop and comprises a respective first branch and a respective second branch, wherein the respective first branch is configured to compute the next respective value of the first sequence and the next respective value of the second sequence, and wherein the respective first branch of a first number of sub-scripts is executed until a respective sub-script computes the GCD as the next respective value of the sequence, upon which the respective second branch of each remaining sub-scripts is executed, wherein execution of the respective second branch of each remaining sub-script does not contribute to the computation of the Bezout co-efficient.
Statement 4. The method of statement 2 or statement 3, wherein the number of sub-scripts may be predetermined and corresponds to an upper bound equal to
wherein κ is the number of bits in the modulus value and Φ is the golden ratio.
Statement 5. The method of any preceding statement, wherein the method may comprise: including the first script in the first blockchain transaction; and submitting the first blockchain transaction to one or more blockchain nodes and/or one or more blockchain users.
Statement 6. The method of any preceding statement, wherein outputting the first script may comprise sending the first script to one or more blockchain users.
Statement 7. The method of any preceding statement, wherein the first script may comprise a point addition script configured to: obtain a first elliptic curve point, a second elliptic curve point, and the modulus value; and output a first target elliptic curve point by performing elliptic curve addition of the first and second elliptic curve points, wherein the point addition script comprises the modular inversion script, and wherein performing said elliptic curve addition may comprise: computing a first lambda value used to compute a respective x-coordinate and a respective y-coordinate of the first target elliptic curve point, wherein computing the first lambda value comprises computing a first numerator value and a first denominator value, and wherein the point addition script is configured to cause the modular inversion script to be executed with the first denominator value set as the target integer in order to generate a modular inverse of the first denominator value, and wherein the first lambda value is computed by multiplying the first numerator value by the modular inverse of the first denominator value.
Statement 8. The method of statement 7, wherein the point addition script may comprise a first branch configured to generate the first numerator value and the second numerator value if the first and second elliptic curve points are equal, and a second branch configured to generate the first numerator value and the second numerator value if the first and second elliptic curve points are not equal, and wherein the modular inversion script is executed after either the first branch or the second branch is executed, such that the modular version script is included a single time as part of the point addition script.
Statement 9. The method of statement 7 or statement 8, wherein the first script may comprise a point subtraction script configured to: obtain a third elliptic curve point and the modulus value; output the second elliptic curve point to the point addition script, wherein the second elliptic curve point is generated by computing a modulus of the third elliptic curve point using the modulus value and negating the result.
Statement 10. The method of any preceding statement, wherein the first script may comprise a point doubling script configured to: obtain a fourth elliptic curve point and the modulus value; and output a second target elliptic curve point by doubling the fourth elliptic curve point, wherein the point doubling script comprises the modular inversion script, and wherein performing said doubling of the fourth elliptic curve point comprises: computing a second lambda value used to compute a respective x-coordinate and a respective y-coordinate of the second target elliptic curve point, wherein computing the second lambda value comprises computing a second numerator value and a second denominator value, and wherein the point doubling script is configured to cause the modular inversion script to be executed with the second denominator value set as the target integer in order to generate a modular inverse of the second denominator value, and wherein the lambda value is computed by multiplying the second numerator value by the modular inverse of the second denominator value.
Statement 11. The method of statement 10, wherein the first script may comprise a first multiplication-by-scalar (MBS) script configured to: obtain a fifth elliptic curve point, the modulus value and a first scalar value, wherein the first scalar value is expressed in binary, each respective bit of the binary representation being associated with a respective index; output a third target elliptic curve point by multiplying the fifth elliptic curve point by the scalar value using a double-and-add algorithm, wherein the first MBS script comprises a series of sub-scripts to be executed in turn, each sub-script being associated with a respective index and comprising an instance of the point doubling script, wherein a first one of the sub-scripts is configured to use the point doubling script to double the fifth elliptic curve point and output a respective intermediate result, wherein each successive sub-script in the series is configured to use the point doubling script to double the respective intermediate result output by the previous sub-script in the series, and wherein the first MBS script is configured to generate the third target elliptic curve point by adding together the respective intermediate results generated by the respective sub-scripts having respective indexes corresponding to the same respective indexes of the respective bits of the binary representation of the first scalar value that are set as one.
Statement 12. The method of statement 7 or any claim dependent thereon, wherein the first script may comprise a second multiplication-by-scalar (MBS) script configured to: obtain a second scalar value, wherein the second scalar value is expressed in binary, each respective bit of the binary representation being associated with a respective index i; and output a fourth target elliptic curve point by multiplying a respective fifth elliptic curve point by the second scalar value, wherein the second MBS script comprises a series of sub-scripts to be executed in turn, each sub-script being associated with a respective index i and comprising an instance of the point addition script, each sub-script comprising a respective elliptic curve point corresponding to the respective fifth elliptic curve point raised to 2i, and wherein the second MBS script is configured to generate the fourth target elliptic curve point by adding together the respective elliptic curve points belonging to the respective sub-scripts having respective indexes corresponding to the same respective indexes of the respective bits of the binary representation of the second scalar value that are set as one.
Statement 13. The method of any preceding statement, wherein the first script may comprise a set-bit determination script configured to determine whether each respective bit of the binary representation of a given scalar is set as one by, for each respective bit: outputting one as a -byte array in big-endian, where
is a byte length of the scalar; setting the respective bit of the
-byte array as one; and comparing the respective bit of the scalar and the respective bit of the
-byte array, wherein the respective bit is determined to be set as one if the respective bit of the scalar matches the respective bit of the
-byte array.
Statement 14. The method of any preceding statement, wherein the first script may comprise a modular reduction script configured to: obtain a respective integer, x, and a respective modulus value, p, and output a modular reduction of the respective integer by computing (x % p+p) % p, where % is the remainder operator.
Statement 15. The method of statement 12 or any statement dependent thereon, wherein the first script may comprise a commitment point, two respective instances of the second MBS script and a respective instance of the point addition script, and wherein first script may be configured to: obtain a first candidate scalar and a second candidate scalar, the first and second candidate scalars being included in an unlocking script of a second blockchain transaction; input the first candidate scalar to a first respective instance of the second MBS script to generate a first candidate elliptic curve point; input the second candidate scalar to a second respective instance of the second MBS script to generate a second candidate elliptic curve point; input the first candidate elliptic curve point and the second candidate elliptic curve point to the respective instance of the point addition script to generate a candidate commitment point; and verify that the candidate commitment point is equal to the commitment point.
Statement 16. The method of statement 12 or any statement dependent thereon, wherein the first script may comprise a predetermined public key and a predetermined address, and wherein the first script may be configured to: obtain a private key and a candidate address, the private key and the candidate address being included in an unlocking script of a second blockchain transaction; input the private key into the second MBS to generate a candidate public key, wherein the respective fifth elliptic curve point of the second MBS is a public key generator point; verify that the candidate public key is equal to the predetermined public key; input the candidate public key and the predetermined public key to an instance of the point addition script to generate a candidate elliptic curve point; hash the candidate elliptic curve point with one or more hash functions to generate a candidate address; and verify that the candidate address matches the predetermined address, or that a part of the candidate address matches a part of the predetermined address.
Statement 17. A computer-implemented method for performing elliptic curve arithmetic using blockchain transactions, wherein the method is performed by a script engine and comprises: obtaining a first blockchain transaction, wherein the first blockchain transaction comprises a first script, wherein the first script comprises a modular inversion script, and wherein the modular inversion script is configured to, when executed, by a script engine: obtain a target integer and a modulus value, wherein the target integer and the modulus value are co-prime, and output a modular inverse of the target integer, wherein the modular inverse is generated by iteratively computing a first sequence of the extended Euclidean algorithm with the target integer and modulus value as inputs, and using the first sequence to compute a Bezout co-efficient of the target integer, wherein the Bezout co-efficient of the target integer is output as the modular inverse; obtaining a second blockchain transaction, wherein the second blockchain transaction comprises a second script, wherein the second script comprises the target integer and the modulus value; and executing the first script together with the second script to generate the modular inverse of the target integer.
Statement 18. The method of any preceding statement, wherein the modulus value is a prime number.
Statement 19. Computer equipment comprising: memory comprising one or more memory units; and processing apparatus comprising one or more processing units, wherein the memory stores code arranged to run on the processing apparatus, the code being configured s0 as when on the processing apparatus to perform the method of any of statements 1 to 18.
Statement 20. A computer program embodied on computer-readable storage and configured s0 as, when run on one or more processors, to perform the method of any of statements 1 to 18.
Number | Date | Country | Kind |
---|---|---|---|
2200993.0 | Jan 2022 | GB | national |
This application is the U.S. National Stage of International Application No. PCT/EP2023/050089 filed on Jan. 3, 2023, which claims the benefit of United Kingdom Patent Application No. 2200993.0, filed on Jan. 26, 2022, the contents of which are incorporated herein by reference in their entireties.
Filing Document | Filing Date | Country | Kind |
---|---|---|---|
PCT/EP2023/050089 | 1/3/2023 | WO |