diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000..6f6192f810 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "examples"] + path = examples + url = https://github.com/ProvableHQ/leo-examples diff --git a/examples b/examples new file mode 160000 index 0000000000..b742a2f93b --- /dev/null +++ b/examples @@ -0,0 +1 @@ +Subproject commit b742a2f93b7ec6b4f23f52cbe25333b9a7f1d7ca diff --git a/examples/README.md b/examples/README.md deleted file mode 100644 index 375b786211..0000000000 --- a/examples/README.md +++ /dev/null @@ -1,26 +0,0 @@ -# Leo Examples - -This directory includes the following Leo code including: - -1. Hello World -> Basic Sum of two u32 -2. Groups -> Basic operations over groups -3. Core -> Core functions over a field type -4. Bubblesort -> Sorting algorithms over a tuple -5. Message -> Initialization of a struct -6. Token -> Record example - -along with many more. - -## Run Guide - -To run each program, run: -```bash -leo run main -``` - -## Execute Guide - -To execute each program call, run: -```bash -leo execute main -``` diff --git a/examples/auction/.env b/examples/auction/.env deleted file mode 100644 index 75bc722f06..0000000000 --- a/examples/auction/.env +++ /dev/null @@ -1,4 +0,0 @@ - -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH -ENDPOINT=http://localhost:3030 diff --git a/examples/auction/.gitignore b/examples/auction/.gitignore deleted file mode 100644 index 750b56f237..0000000000 --- a/examples/auction/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -outputs/ -*.avm -*.prover -*.verifier \ No newline at end of file diff --git a/examples/auction/README.md b/examples/auction/README.md deleted file mode 100644 index 4bb7b3bc98..0000000000 --- a/examples/auction/README.md +++ /dev/null @@ -1,57 +0,0 @@ - - -[//]: # (workshop/auction) - -A first-price sealed-bid auction in Leo. - -## Summary - -A first-price sealed-bid auction (or blind auction) is a type of auction in which each participant submits a bid without knowing the bids of the other participants. -The bidder with the highest bid wins the auction. - -In this model, there are two parties: the auctioneer and the bidders. -- **Bidder**: A participant in the auction. -- **Auctioneer**: The party responsible for conducting the auction. - -We make the following assumptions about the auction: -- The auctioneer is honest. That is, the auctioneer will resolve **all** bids in the order they are received. The auctioneer will not tamper with the bids. -- There is no limit to the number of bids. -- The auctioneer knows the identity of all bidders, but bidders do not necessarily know the identity of other bidders. - -Under this model, we require that: -- Bidders do not learn any information about the value of other bids. - -### Auction Flow -The auction is conducted in a series of stages. -- **Bidding**: In the bidding stage, bidders submit bids to the auctioneer. They do so by invoking the `place_bid` function. -- **Resolution**: In the resolution stage, the auctioneer resolves the bids in the order they were received. The auctioneer does so by invoking the `resolve` function. The resolution process produces a single winning bid. -- **Finishing**: In this stage, the auctioneer finishes the auction by invoking the `finish` function. This function returns the winning bid to the bidder, which the bidder can then use to claim the item. - - -## Language Features and Concepts -- `record` declarations -- `assert_eq` -- record ownership - -## Running the Program - -Leo provides users with a command line interface for compiling and running Leo programs. - -### Configuring Accounts -The `.env` file contains a private key. -This is the account that will be used to sign transactions and is checked for record ownership. -When executing programs as different parties, be sure to set the `PRIVATE_KEY` field in `.env` to the appropriate values. -See `./run.sh` for an example of how to run the program as different parties. - - -The [Aleo SDK](https://github.com/ProvableHQ/leo/tree/mainnet) provides an interface for generating new accounts. -To generate a new account, navigate to [provable.tools](https://provable.tools). - - -### Providing inputs via the command line. -```bash -leo run ... -``` -See `./run.sh` for an example. - - diff --git a/examples/auction/build/main.aleo b/examples/auction/build/main.aleo deleted file mode 100644 index 23f114074b..0000000000 --- a/examples/auction/build/main.aleo +++ /dev/null @@ -1,35 +0,0 @@ -program auction.aleo; - -record Bid: - owner as address.private; - bidder as address.private; - amount as u64.private; - is_winner as boolean.private; - - -function place_bid: - input r0 as address.private; - input r1 as u64.private; - assert.eq self.caller r0; - cast aleo1ashyu96tjwe63u0gtnnv8z5lhapdu4l5pjsl2kha7fv7hvz2eqxs5dz0rg r0 r1 false into r2 as Bid.record; - output r2 as Bid.record; - - -function resolve: - input r0 as Bid.record; - input r1 as Bid.record; - assert.eq self.caller aleo1ashyu96tjwe63u0gtnnv8z5lhapdu4l5pjsl2kha7fv7hvz2eqxs5dz0rg; - gte r0.amount r1.amount into r2; - ternary r2 r0.owner r1.owner into r3; - ternary r2 r0.bidder r1.bidder into r4; - ternary r2 r0.amount r1.amount into r5; - ternary r2 r0.is_winner r1.is_winner into r6; - cast r3 r4 r5 r6 into r7 as Bid.record; - output r7 as Bid.record; - - -function finish: - input r0 as Bid.record; - assert.eq self.caller aleo1ashyu96tjwe63u0gtnnv8z5lhapdu4l5pjsl2kha7fv7hvz2eqxs5dz0rg; - cast r0.bidder r0.bidder r0.amount true into r1 as Bid.record; - output r1 as Bid.record; diff --git a/examples/auction/build/program.json b/examples/auction/build/program.json deleted file mode 100644 index 86302fc7f2..0000000000 --- a/examples/auction/build/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "auction.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/auction/leo.lock b/examples/auction/leo.lock deleted file mode 100644 index c4293b3b9f..0000000000 --- a/examples/auction/leo.lock +++ /dev/null @@ -1 +0,0 @@ -package = [] diff --git a/examples/auction/program.json b/examples/auction/program.json deleted file mode 100644 index 86302fc7f2..0000000000 --- a/examples/auction/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "auction.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/auction/run.sh b/examples/auction/run.sh deleted file mode 100755 index 82182c5aa1..0000000000 --- a/examples/auction/run.sh +++ /dev/null @@ -1,154 +0,0 @@ -#!/bin/bash -# First check that Leo is installed. -if ! command -v leo &> /dev/null -then - echo "leo is not installed." - exit -fi - -# The private key and address of the first bidder. -# Swap these into program.json, when running transactions as the first bidder. -# NETWORK=testnet -# PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH - -# The private key and address of the second bidder. -# Swap these into program.json, when running transactions as the second bidder. -# NETWORK=testnet -# PRIVATE_KEY=APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh - - -# The private key and address of the auctioneer. -# Swap these into program.json, when running transactions as the auctioneer. -# NETWORK=testnet -# PRIVATE_KEY=APrivateKey1zkp2GUmKbVsuc1NSj28pa1WTQuZaK5f1DQJAT6vPcHyWokG - - -echo " -############################################################################### -######## ######## -######## STEP 0: Initialize a new 2-party auction ######## -######## ######## -######## ------------------------------- ######## -######## | OPEN | A | B | ######## -######## ------------------------------- ######## -######## | Bid | | | ######## -######## ------------------------------- ######## -######## ######## -############################################################################### -" -# Swap in the private key and address of the first bidder to .env. -echo " -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH -ENDPOINT=http://localhost:3030 -" > .env - -# Have the first bidder place a bid of 10. -echo " -############################################################################### -######## ######## -######## STEP 1: The first bidder places a bid of 10 ######## -######## ######## -######## ------------------------------- ######## -######## | OPEN | A | B | ######## -######## ------------------------------- ######## -######## | Bid | 10 | | ######## -######## ------------------------------- ######## -######## ######## -############################################################################### -" -leo run place_bid aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px 10u64 || exit - -# Swap in the private key and address of the second bidder to .env. -echo " -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh -ENDPOINT=http://localhost:3030 -" > .env - -# Have the second bidder place a bid of 90. -echo " -############################################################################### -######## ######## -######## STEP 2: The second bidder places a bid of 90 ######## -######## ######## -######## ------------------------------- ######## -######## | OPEN | A | B | ######## -######## ------------------------------- ######## -######## | Bid | 10 | 90 | ######## -######## ------------------------------- ######## -######## ######## -############################################################################### -" -leo run place_bid aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t 90u64 || exit - -# Swap in the private key and address of the auctioneer to .env. -echo " -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp2GUmKbVsuc1NSj28pa1WTQuZaK5f1DQJAT6vPcHyWokG -ENDPOINT=http://localhost:3030 -" > .env - -# Have the auctioneer select the winning bid. -echo " -############################################################################### -######## ######## -######## STEP 3: The auctioneer selects the winning bidder ######## -######## ######## -######## ------------------------------- ######## -######## | OPEN | A | → B ← | ######## -######## ------------------------------- ######## -######## | Bid | 10 | → 90 ← | ######## -######## ------------------------------- ######## -######## ######## -############################################################################### -" -leo run resolve "{ - owner: aleo1ashyu96tjwe63u0gtnnv8z5lhapdu4l5pjsl2kha7fv7hvz2eqxs5dz0rg.private, - bidder: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - amount: 10u64.private, - is_winner: false.private, - _nonce: 4668394794828730542675887906815309351994017139223602571716627453741502624516group.public - }" "{ - owner: aleo1ashyu96tjwe63u0gtnnv8z5lhapdu4l5pjsl2kha7fv7hvz2eqxs5dz0rg.private, - bidder: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - amount: 90u64.private, - is_winner: false.private, - _nonce: 5952811863753971450641238938606857357746712138665944763541786901326522216736group.public - }" || exit - -# Have the auctioneer finish the auction. -echo " -############################################################################### -######## ######## -######## STEP 4: The auctioneer completes the auction. ######## -######## ######## -######## ------------------------------- ######## -######## | CLOSE | A | → B ← | ######## -######## ------------------------------- ######## -######## | Bid | 10 | → 90 ← | ######## -######## ------------------------------- ######## -######## ######## -############################################################################### -" -leo run finish "{ - owner: aleo1ashyu96tjwe63u0gtnnv8z5lhapdu4l5pjsl2kha7fv7hvz2eqxs5dz0rg.private, - bidder: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - amount: 90u64.private, - is_winner: false.private, - _nonce: 5952811863753971450641238938606857357746712138665944763541786901326522216736group.public - }" || exit - - -# Restore the .env file to its original state. -echo " -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH -ENDPOINT=http://localhost:3030 -" > .env - - - - - - diff --git a/examples/auction/src/main.leo b/examples/auction/src/main.leo deleted file mode 100644 index 09389b2fae..0000000000 --- a/examples/auction/src/main.leo +++ /dev/null @@ -1,66 +0,0 @@ -program auction.aleo { - // A bid in an auction. - // - `owner` : The address of the account that owns the record associated with this bid. - // This is separate from the address of the account that placed the bid. - // - `bidder` : The address of the account that placed the bid. - // - `amount` : The amount of the bid. - // - `is_winner` : Whether the bid is the winning bid. - record Bid { - owner: address, - bidder: address, - amount: u64, - is_winner: bool, - } - - // Returns a new bid. - // - `bidder` : The address of the account that placed the bid. - // - `amount` : The amount of the bid. - // Requires that `bidder` matches the function caller. - // The owner of the record is set to the entity responsible for running the auction (auction runner). - // The address of the auction runner is aleo1ashyu96tjwe63u0gtnnv8z5lhapdu4l5pjsl2kha7fv7hvz2eqxs5dz0rg. - transition place_bid(bidder: address, amount: u64) -> Bid { - // Ensure the caller is the auction bidder. - assert_eq(self.caller, bidder); - // Return a new 'Bid' record for the auction bidder. - return Bid { - owner: aleo1ashyu96tjwe63u0gtnnv8z5lhapdu4l5pjsl2kha7fv7hvz2eqxs5dz0rg, - bidder: bidder, - amount: amount, - is_winner: false, - }; - } - - // Returns the winning bid. - // - `first` : The first bid. - // - `second` : The second bid. - // Requires that the function caller is the auction runner. - // Assumes that the function is invoked only after the bidding period has ended. - // In the event of a tie, the first bid is selected. - transition resolve(first: Bid, second: Bid) -> Bid { - // Ensure the caller is the auctioneer. - assert_eq(self.caller, aleo1ashyu96tjwe63u0gtnnv8z5lhapdu4l5pjsl2kha7fv7hvz2eqxs5dz0rg); - // Resolve the winner of the auction. - if (first.amount >= second.amount) { - return first; - } else { - return second; - } - } - - // Returns ownership of the bid to bidder. - // - `bid` : The winning bid. - // Requires that the function caller is the auction runner. - // Assumes that the function is invoked only after all bids have been resolved. - transition finish(bid: Bid) -> Bid { - // Ensure the caller is the auctioneer. - assert_eq(self.caller, aleo1ashyu96tjwe63u0gtnnv8z5lhapdu4l5pjsl2kha7fv7hvz2eqxs5dz0rg); - // Return 'is_winner' as 'true' in the winning 'Bid'. - return Bid { - owner: bid.bidder, - bidder: bid.bidder, - amount: bid.amount, - is_winner: true, - }; - } -} - diff --git a/examples/basic_bank/.env b/examples/basic_bank/.env deleted file mode 100644 index 75bc722f06..0000000000 --- a/examples/basic_bank/.env +++ /dev/null @@ -1,4 +0,0 @@ - -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH -ENDPOINT=http://localhost:3030 diff --git a/examples/basic_bank/.gitignore b/examples/basic_bank/.gitignore deleted file mode 100644 index 750b56f237..0000000000 --- a/examples/basic_bank/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -outputs/ -*.avm -*.prover -*.verifier \ No newline at end of file diff --git a/examples/basic_bank/README.md b/examples/basic_bank/README.md deleted file mode 100644 index f9ade17e37..0000000000 --- a/examples/basic_bank/README.md +++ /dev/null @@ -1,55 +0,0 @@ - - -[//]: # (workshop/basic_bank) - -A simple-interest yielding bank account in Leo. - -## Summary - -This program implements a bank that issues tokens to users and allows users to deposit tokens to accrue simple interest on their deposits. - -### User Flow -1. The bank issues users tokens via the `issue` function. -2. A user deposits tokens via the `deposit` function. -3. Upon a user's request to withdraw, the bank calculates the appropriate amount of compound interest and pays the user the principal and interest via the `withdraw` function. - -Note that the program can be easily extended to include additional features such as a `transfer` function, which would allow users to transfer tokens to other users. - -## Bugs - -You may have already guessed that this program has a few bugs. We list some of them below: -- `withdraw` can only be invoked by the bank. A malicious bank could lock users' tokens by not invoking `withdraw`. -- `withdraw` fails if the sum of the interest and principal is greater than the user's balance. -- Users can increase their principal by depositing tokens multiple times, including immediately before withdrawal. -- Integer division rounds down; if the calculated interest is too small, then it will be rounded down to zero. - -Can you find any others? - -## Language Features and Concepts -- `record` declarations -- `assert_eq` -- core functions, e.g. `BHP256::hash_to_field` -- record ownership -- loops and bounded iteration -- mappings -- `async`/`await` - -## Running the Program - -Leo provides users with a command line interface for compiling and running Leo programs. - -### Configuring Accounts -The `.env` file contains a private key. -This is the account that will be used to sign transactions and is checked for record ownership. -When executing programs as different parties, be sure to set the `PRIVATE_KEY` field in `.env` to the appropriate values. -See `./run.sh` for an example of how to run the program as different parties. - - -The [Aleo SDK](https://github.com/ProvableHQ/leo/tree/mainnet) provides an interface for generating new accounts. -To generate a new account, navigate to [provable.tools](https://provable.tools). - -### Providing inputs via the command line. -```bash -leo run ... -``` -See `./run.sh` for an example. diff --git a/examples/basic_bank/build/main.aleo b/examples/basic_bank/build/main.aleo deleted file mode 100644 index 73965d8697..0000000000 --- a/examples/basic_bank/build/main.aleo +++ /dev/null @@ -1,567 +0,0 @@ -program basic_bank.aleo; - -record Token: - owner as address.private; - amount as u64.private; - - -mapping balances: - key as field.public; - value as u64.public; - -function issue: - input r0 as address.private; - input r1 as u64.private; - assert.eq self.caller aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px; - cast r0 r1 into r2 as Token.record; - output r2 as Token.record; - - - -function deposit: - input r0 as Token.record; - input r1 as u64.private; - sub r0.amount r1 into r2; - cast r0.owner r2 into r3 as Token.record; - hash.bhp256 r0.owner into r4 as field; - async deposit r4 r1 into r5; - output r3 as Token.record; - output r5 as basic_bank.aleo/deposit.future; - -finalize deposit: - input r0 as field.public; - input r1 as u64.public; - get.or_use balances[r0] 0u64 into r2; - add r2 r1 into r3; - set r3 into balances[r0]; - - - -closure calculate_interest: - input r0 as u64; - input r1 as u64; - input r2 as u64; - lt 0u64 r2 into r3; - mul r0 r1 into r4; - div r4 10000u64 into r5; - add r0 r5 into r6; - ternary r3 r6 r0 into r7; - lt 1u64 r2 into r8; - mul r7 r1 into r9; - div r9 10000u64 into r10; - add r7 r10 into r11; - ternary r8 r11 r7 into r12; - lt 2u64 r2 into r13; - mul r12 r1 into r14; - div r14 10000u64 into r15; - add r12 r15 into r16; - ternary r13 r16 r12 into r17; - lt 3u64 r2 into r18; - mul r17 r1 into r19; - div r19 10000u64 into r20; - add r17 r20 into r21; - ternary r18 r21 r17 into r22; - lt 4u64 r2 into r23; - mul r22 r1 into r24; - div r24 10000u64 into r25; - add r22 r25 into r26; - ternary r23 r26 r22 into r27; - lt 5u64 r2 into r28; - mul r27 r1 into r29; - div r29 10000u64 into r30; - add r27 r30 into r31; - ternary r28 r31 r27 into r32; - lt 6u64 r2 into r33; - mul r32 r1 into r34; - div r34 10000u64 into r35; - add r32 r35 into r36; - ternary r33 r36 r32 into r37; - lt 7u64 r2 into r38; - mul r37 r1 into r39; - div r39 10000u64 into r40; - add r37 r40 into r41; - ternary r38 r41 r37 into r42; - lt 8u64 r2 into r43; - mul r42 r1 into r44; - div r44 10000u64 into r45; - add r42 r45 into r46; - ternary r43 r46 r42 into r47; - lt 9u64 r2 into r48; - mul r47 r1 into r49; - div r49 10000u64 into r50; - add r47 r50 into r51; - ternary r48 r51 r47 into r52; - lt 10u64 r2 into r53; - mul r52 r1 into r54; - div r54 10000u64 into r55; - add r52 r55 into r56; - ternary r53 r56 r52 into r57; - lt 11u64 r2 into r58; - mul r57 r1 into r59; - div r59 10000u64 into r60; - add r57 r60 into r61; - ternary r58 r61 r57 into r62; - lt 12u64 r2 into r63; - mul r62 r1 into r64; - div r64 10000u64 into r65; - add r62 r65 into r66; - ternary r63 r66 r62 into r67; - lt 13u64 r2 into r68; - mul r67 r1 into r69; - div r69 10000u64 into r70; - add r67 r70 into r71; - ternary r68 r71 r67 into r72; - lt 14u64 r2 into r73; - mul r72 r1 into r74; - div r74 10000u64 into r75; - add r72 r75 into r76; - ternary r73 r76 r72 into r77; - lt 15u64 r2 into r78; - mul r77 r1 into r79; - div r79 10000u64 into r80; - add r77 r80 into r81; - ternary r78 r81 r77 into r82; - lt 16u64 r2 into r83; - mul r82 r1 into r84; - div r84 10000u64 into r85; - add r82 r85 into r86; - ternary r83 r86 r82 into r87; - lt 17u64 r2 into r88; - mul r87 r1 into r89; - div r89 10000u64 into r90; - add r87 r90 into r91; - ternary r88 r91 r87 into r92; - lt 18u64 r2 into r93; - mul r92 r1 into r94; - div r94 10000u64 into r95; - add r92 r95 into r96; - ternary r93 r96 r92 into r97; - lt 19u64 r2 into r98; - mul r97 r1 into r99; - div r99 10000u64 into r100; - add r97 r100 into r101; - ternary r98 r101 r97 into r102; - lt 20u64 r2 into r103; - mul r102 r1 into r104; - div r104 10000u64 into r105; - add r102 r105 into r106; - ternary r103 r106 r102 into r107; - lt 21u64 r2 into r108; - mul r107 r1 into r109; - div r109 10000u64 into r110; - add r107 r110 into r111; - ternary r108 r111 r107 into r112; - lt 22u64 r2 into r113; - mul r112 r1 into r114; - div r114 10000u64 into r115; - add r112 r115 into r116; - ternary r113 r116 r112 into r117; - lt 23u64 r2 into r118; - mul r117 r1 into r119; - div r119 10000u64 into r120; - add r117 r120 into r121; - ternary r118 r121 r117 into r122; - lt 24u64 r2 into r123; - mul r122 r1 into r124; - div r124 10000u64 into r125; - add r122 r125 into r126; - ternary r123 r126 r122 into r127; - lt 25u64 r2 into r128; - mul r127 r1 into r129; - div r129 10000u64 into r130; - add r127 r130 into r131; - ternary r128 r131 r127 into r132; - lt 26u64 r2 into r133; - mul r132 r1 into r134; - div r134 10000u64 into r135; - add r132 r135 into r136; - ternary r133 r136 r132 into r137; - lt 27u64 r2 into r138; - mul r137 r1 into r139; - div r139 10000u64 into r140; - add r137 r140 into r141; - ternary r138 r141 r137 into r142; - lt 28u64 r2 into r143; - mul r142 r1 into r144; - div r144 10000u64 into r145; - add r142 r145 into r146; - ternary r143 r146 r142 into r147; - lt 29u64 r2 into r148; - mul r147 r1 into r149; - div r149 10000u64 into r150; - add r147 r150 into r151; - ternary r148 r151 r147 into r152; - lt 30u64 r2 into r153; - mul r152 r1 into r154; - div r154 10000u64 into r155; - add r152 r155 into r156; - ternary r153 r156 r152 into r157; - lt 31u64 r2 into r158; - mul r157 r1 into r159; - div r159 10000u64 into r160; - add r157 r160 into r161; - ternary r158 r161 r157 into r162; - lt 32u64 r2 into r163; - mul r162 r1 into r164; - div r164 10000u64 into r165; - add r162 r165 into r166; - ternary r163 r166 r162 into r167; - lt 33u64 r2 into r168; - mul r167 r1 into r169; - div r169 10000u64 into r170; - add r167 r170 into r171; - ternary r168 r171 r167 into r172; - lt 34u64 r2 into r173; - mul r172 r1 into r174; - div r174 10000u64 into r175; - add r172 r175 into r176; - ternary r173 r176 r172 into r177; - lt 35u64 r2 into r178; - mul r177 r1 into r179; - div r179 10000u64 into r180; - add r177 r180 into r181; - ternary r178 r181 r177 into r182; - lt 36u64 r2 into r183; - mul r182 r1 into r184; - div r184 10000u64 into r185; - add r182 r185 into r186; - ternary r183 r186 r182 into r187; - lt 37u64 r2 into r188; - mul r187 r1 into r189; - div r189 10000u64 into r190; - add r187 r190 into r191; - ternary r188 r191 r187 into r192; - lt 38u64 r2 into r193; - mul r192 r1 into r194; - div r194 10000u64 into r195; - add r192 r195 into r196; - ternary r193 r196 r192 into r197; - lt 39u64 r2 into r198; - mul r197 r1 into r199; - div r199 10000u64 into r200; - add r197 r200 into r201; - ternary r198 r201 r197 into r202; - lt 40u64 r2 into r203; - mul r202 r1 into r204; - div r204 10000u64 into r205; - add r202 r205 into r206; - ternary r203 r206 r202 into r207; - lt 41u64 r2 into r208; - mul r207 r1 into r209; - div r209 10000u64 into r210; - add r207 r210 into r211; - ternary r208 r211 r207 into r212; - lt 42u64 r2 into r213; - mul r212 r1 into r214; - div r214 10000u64 into r215; - add r212 r215 into r216; - ternary r213 r216 r212 into r217; - lt 43u64 r2 into r218; - mul r217 r1 into r219; - div r219 10000u64 into r220; - add r217 r220 into r221; - ternary r218 r221 r217 into r222; - lt 44u64 r2 into r223; - mul r222 r1 into r224; - div r224 10000u64 into r225; - add r222 r225 into r226; - ternary r223 r226 r222 into r227; - lt 45u64 r2 into r228; - mul r227 r1 into r229; - div r229 10000u64 into r230; - add r227 r230 into r231; - ternary r228 r231 r227 into r232; - lt 46u64 r2 into r233; - mul r232 r1 into r234; - div r234 10000u64 into r235; - add r232 r235 into r236; - ternary r233 r236 r232 into r237; - lt 47u64 r2 into r238; - mul r237 r1 into r239; - div r239 10000u64 into r240; - add r237 r240 into r241; - ternary r238 r241 r237 into r242; - lt 48u64 r2 into r243; - mul r242 r1 into r244; - div r244 10000u64 into r245; - add r242 r245 into r246; - ternary r243 r246 r242 into r247; - lt 49u64 r2 into r248; - mul r247 r1 into r249; - div r249 10000u64 into r250; - add r247 r250 into r251; - ternary r248 r251 r247 into r252; - lt 50u64 r2 into r253; - mul r252 r1 into r254; - div r254 10000u64 into r255; - add r252 r255 into r256; - ternary r253 r256 r252 into r257; - lt 51u64 r2 into r258; - mul r257 r1 into r259; - div r259 10000u64 into r260; - add r257 r260 into r261; - ternary r258 r261 r257 into r262; - lt 52u64 r2 into r263; - mul r262 r1 into r264; - div r264 10000u64 into r265; - add r262 r265 into r266; - ternary r263 r266 r262 into r267; - lt 53u64 r2 into r268; - mul r267 r1 into r269; - div r269 10000u64 into r270; - add r267 r270 into r271; - ternary r268 r271 r267 into r272; - lt 54u64 r2 into r273; - mul r272 r1 into r274; - div r274 10000u64 into r275; - add r272 r275 into r276; - ternary r273 r276 r272 into r277; - lt 55u64 r2 into r278; - mul r277 r1 into r279; - div r279 10000u64 into r280; - add r277 r280 into r281; - ternary r278 r281 r277 into r282; - lt 56u64 r2 into r283; - mul r282 r1 into r284; - div r284 10000u64 into r285; - add r282 r285 into r286; - ternary r283 r286 r282 into r287; - lt 57u64 r2 into r288; - mul r287 r1 into r289; - div r289 10000u64 into r290; - add r287 r290 into r291; - ternary r288 r291 r287 into r292; - lt 58u64 r2 into r293; - mul r292 r1 into r294; - div r294 10000u64 into r295; - add r292 r295 into r296; - ternary r293 r296 r292 into r297; - lt 59u64 r2 into r298; - mul r297 r1 into r299; - div r299 10000u64 into r300; - add r297 r300 into r301; - ternary r298 r301 r297 into r302; - lt 60u64 r2 into r303; - mul r302 r1 into r304; - div r304 10000u64 into r305; - add r302 r305 into r306; - ternary r303 r306 r302 into r307; - lt 61u64 r2 into r308; - mul r307 r1 into r309; - div r309 10000u64 into r310; - add r307 r310 into r311; - ternary r308 r311 r307 into r312; - lt 62u64 r2 into r313; - mul r312 r1 into r314; - div r314 10000u64 into r315; - add r312 r315 into r316; - ternary r313 r316 r312 into r317; - lt 63u64 r2 into r318; - mul r317 r1 into r319; - div r319 10000u64 into r320; - add r317 r320 into r321; - ternary r318 r321 r317 into r322; - lt 64u64 r2 into r323; - mul r322 r1 into r324; - div r324 10000u64 into r325; - add r322 r325 into r326; - ternary r323 r326 r322 into r327; - lt 65u64 r2 into r328; - mul r327 r1 into r329; - div r329 10000u64 into r330; - add r327 r330 into r331; - ternary r328 r331 r327 into r332; - lt 66u64 r2 into r333; - mul r332 r1 into r334; - div r334 10000u64 into r335; - add r332 r335 into r336; - ternary r333 r336 r332 into r337; - lt 67u64 r2 into r338; - mul r337 r1 into r339; - div r339 10000u64 into r340; - add r337 r340 into r341; - ternary r338 r341 r337 into r342; - lt 68u64 r2 into r343; - mul r342 r1 into r344; - div r344 10000u64 into r345; - add r342 r345 into r346; - ternary r343 r346 r342 into r347; - lt 69u64 r2 into r348; - mul r347 r1 into r349; - div r349 10000u64 into r350; - add r347 r350 into r351; - ternary r348 r351 r347 into r352; - lt 70u64 r2 into r353; - mul r352 r1 into r354; - div r354 10000u64 into r355; - add r352 r355 into r356; - ternary r353 r356 r352 into r357; - lt 71u64 r2 into r358; - mul r357 r1 into r359; - div r359 10000u64 into r360; - add r357 r360 into r361; - ternary r358 r361 r357 into r362; - lt 72u64 r2 into r363; - mul r362 r1 into r364; - div r364 10000u64 into r365; - add r362 r365 into r366; - ternary r363 r366 r362 into r367; - lt 73u64 r2 into r368; - mul r367 r1 into r369; - div r369 10000u64 into r370; - add r367 r370 into r371; - ternary r368 r371 r367 into r372; - lt 74u64 r2 into r373; - mul r372 r1 into r374; - div r374 10000u64 into r375; - add r372 r375 into r376; - ternary r373 r376 r372 into r377; - lt 75u64 r2 into r378; - mul r377 r1 into r379; - div r379 10000u64 into r380; - add r377 r380 into r381; - ternary r378 r381 r377 into r382; - lt 76u64 r2 into r383; - mul r382 r1 into r384; - div r384 10000u64 into r385; - add r382 r385 into r386; - ternary r383 r386 r382 into r387; - lt 77u64 r2 into r388; - mul r387 r1 into r389; - div r389 10000u64 into r390; - add r387 r390 into r391; - ternary r388 r391 r387 into r392; - lt 78u64 r2 into r393; - mul r392 r1 into r394; - div r394 10000u64 into r395; - add r392 r395 into r396; - ternary r393 r396 r392 into r397; - lt 79u64 r2 into r398; - mul r397 r1 into r399; - div r399 10000u64 into r400; - add r397 r400 into r401; - ternary r398 r401 r397 into r402; - lt 80u64 r2 into r403; - mul r402 r1 into r404; - div r404 10000u64 into r405; - add r402 r405 into r406; - ternary r403 r406 r402 into r407; - lt 81u64 r2 into r408; - mul r407 r1 into r409; - div r409 10000u64 into r410; - add r407 r410 into r411; - ternary r408 r411 r407 into r412; - lt 82u64 r2 into r413; - mul r412 r1 into r414; - div r414 10000u64 into r415; - add r412 r415 into r416; - ternary r413 r416 r412 into r417; - lt 83u64 r2 into r418; - mul r417 r1 into r419; - div r419 10000u64 into r420; - add r417 r420 into r421; - ternary r418 r421 r417 into r422; - lt 84u64 r2 into r423; - mul r422 r1 into r424; - div r424 10000u64 into r425; - add r422 r425 into r426; - ternary r423 r426 r422 into r427; - lt 85u64 r2 into r428; - mul r427 r1 into r429; - div r429 10000u64 into r430; - add r427 r430 into r431; - ternary r428 r431 r427 into r432; - lt 86u64 r2 into r433; - mul r432 r1 into r434; - div r434 10000u64 into r435; - add r432 r435 into r436; - ternary r433 r436 r432 into r437; - lt 87u64 r2 into r438; - mul r437 r1 into r439; - div r439 10000u64 into r440; - add r437 r440 into r441; - ternary r438 r441 r437 into r442; - lt 88u64 r2 into r443; - mul r442 r1 into r444; - div r444 10000u64 into r445; - add r442 r445 into r446; - ternary r443 r446 r442 into r447; - lt 89u64 r2 into r448; - mul r447 r1 into r449; - div r449 10000u64 into r450; - add r447 r450 into r451; - ternary r448 r451 r447 into r452; - lt 90u64 r2 into r453; - mul r452 r1 into r454; - div r454 10000u64 into r455; - add r452 r455 into r456; - ternary r453 r456 r452 into r457; - lt 91u64 r2 into r458; - mul r457 r1 into r459; - div r459 10000u64 into r460; - add r457 r460 into r461; - ternary r458 r461 r457 into r462; - lt 92u64 r2 into r463; - mul r462 r1 into r464; - div r464 10000u64 into r465; - add r462 r465 into r466; - ternary r463 r466 r462 into r467; - lt 93u64 r2 into r468; - mul r467 r1 into r469; - div r469 10000u64 into r470; - add r467 r470 into r471; - ternary r468 r471 r467 into r472; - lt 94u64 r2 into r473; - mul r472 r1 into r474; - div r474 10000u64 into r475; - add r472 r475 into r476; - ternary r473 r476 r472 into r477; - lt 95u64 r2 into r478; - mul r477 r1 into r479; - div r479 10000u64 into r480; - add r477 r480 into r481; - ternary r478 r481 r477 into r482; - lt 96u64 r2 into r483; - mul r482 r1 into r484; - div r484 10000u64 into r485; - add r482 r485 into r486; - ternary r483 r486 r482 into r487; - lt 97u64 r2 into r488; - mul r487 r1 into r489; - div r489 10000u64 into r490; - add r487 r490 into r491; - ternary r488 r491 r487 into r492; - lt 98u64 r2 into r493; - mul r492 r1 into r494; - div r494 10000u64 into r495; - add r492 r495 into r496; - ternary r493 r496 r492 into r497; - lt 99u64 r2 into r498; - mul r497 r1 into r499; - div r499 10000u64 into r500; - add r497 r500 into r501; - ternary r498 r501 r497 into r502; - output r502 as u64; - - - -function withdraw: - input r0 as address.private; - input r1 as u64.private; - input r2 as u64.private; - input r3 as u64.private; - assert.eq self.caller aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px; - hash.bhp256 r0 into r4 as field; - call calculate_interest r1 r2 r3 into r5; - cast r0 r5 into r6 as Token.record; - async withdraw r4 r1 into r7; - output r6 as Token.record; - output r7 as basic_bank.aleo/withdraw.future; - -finalize withdraw: - input r0 as field.public; - input r1 as u64.public; - get.or_use balances[r0] 0u64 into r2; - sub r2 r1 into r3; - set r3 into balances[r0]; - diff --git a/examples/basic_bank/build/program.json b/examples/basic_bank/build/program.json deleted file mode 100644 index 13c1bc036f..0000000000 --- a/examples/basic_bank/build/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "basic_bank.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/basic_bank/leo.lock b/examples/basic_bank/leo.lock deleted file mode 100644 index c4293b3b9f..0000000000 --- a/examples/basic_bank/leo.lock +++ /dev/null @@ -1 +0,0 @@ -package = [] diff --git a/examples/basic_bank/program.json b/examples/basic_bank/program.json deleted file mode 100644 index 13c1bc036f..0000000000 --- a/examples/basic_bank/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "basic_bank.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/basic_bank/run.sh b/examples/basic_bank/run.sh deleted file mode 100755 index 3dd99286c9..0000000000 --- a/examples/basic_bank/run.sh +++ /dev/null @@ -1,214 +0,0 @@ -#!/bin/bash -# First check that Leo is installed. -if ! command -v leo &> /dev/null -then - echo "leo is not installed." - exit -fi - -# The private key and address of the bank. -# Swap these into program.json, when running transactions as the bank. -# NETWORK=testnet -# PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH - -# The private key and address of the user. -# Swap these into program.json, when running transactions as the user. -# NETWORK=testnet -# PRIVATE_KEY=APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh - -# Swap in the private key and address of the bank to .env. -echo " -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH -ENDPOINT=http://localhost:3030 -" > .env - -# Have the bank issue 100 tokens to the user. -echo " -############################################################################### -######## ######## -######## STEP 1: Initialize 100 tokens for aleo1s3ws5...em2u4t ######## -######## ######## -######## ----------------------------------------- ######## -######## | ACTION | AMOUNT | ######## -######## ----------------------------------------- ######## -######## ----------------------------------------- ######## -######## | Issuing | 100 | ######## -######## ----------------------------------------- ######## -######## | Depositing | 0 | ######## -######## ----------------------------------------- ######## -######## | Withdrawing | 0 | ######## -######## ----------------------------------------- ######## -######## ######## -######## ----------------------------------------- ######## -######## | WALLET | aleo1s3ws5...em2u4t | ######## -######## ----------------------------------------- ######## -######## ----------------------------------------- ######## -######## | Balance | 100 | ######## -######## ----------------------------------------- ######## -######## ######## -######## ----------------------------------------- ######## -######## | BANK | aleo1rhgdu...vzp9px | ######## -######## ----------------------------------------- ######## -######## ----------------------------------------- ######## -######## | Balance | 0 | ######## -######## ----------------------------------------- ######## -######## | Periods | 0 | ######## -######## ----------------------------------------- ######## -######## | Interest Rate | 12.34% | ######## -######## ----------------------------------------- ######## -######## ######## -######## ----------------------------------------- ######## -######## | TOTAL BALANCE | 100 | ######## -######## ----------------------------------------- ######## -######## ######## -############################################################################### -" -leo run issue aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t 100u64 || exit - - -# Swap in the private key and address of the user to .env. -echo " -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh -ENDPOINT=http://localhost:3030 -" > .env - -# Have the user deposit 50 tokens into the bank. -echo " -############################################################################### -######## ######## -######## STEP 2: aleo1s3ws5...em2u4t deposits 50 tokens ######## -######## ######## -######## ----------------------------------------- ######## -######## | ACTION | AMOUNT | ######## -######## ----------------------------------------- ######## -######## ----------------------------------------- ######## -######## | Issuing | 0 | ######## -######## ----------------------------------------- ######## -######## | Depositing | 50 | ######## -######## ----------------------------------------- ######## -######## | Withdrawing | 0 | ######## -######## ----------------------------------------- ######## -######## ######## -######## ----------------------------------------- ######## -######## | WALLET | aleo1s3ws5...em2u4t | ######## -######## ----------------------------------------- ######## -######## ----------------------------------------- ######## -######## | Balance | 50 | ######## -######## ----------------------------------------- ######## -######## ######## -######## ----------------------------------------- ######## -######## | BANK | aleo1rhgdu...vzp9px | ######## -######## ----------------------------------------- ######## -######## ----------------------------------------- ######## -######## | Balance | 50 | ######## -######## ----------------------------------------- ######## -######## | Periods | 0 | ######## -######## ----------------------------------------- ######## -######## | Interest Rate | 12.34% | ######## -######## ----------------------------------------- ######## -######## ######## -######## ----------------------------------------- ######## -######## | TOTAL BALANCE | 100 | ######## -######## ----------------------------------------- ######## -######## ######## -############################################################################### -" -leo run deposit "{ - owner: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - amount: 100u64.private, - _nonce: 4668394794828730542675887906815309351994017139223602571716627453741502624516group.public -}" 50u64 || exit - -echo " -############################################################################### -######## ######## -######## STEP 3: Wait 15 periods ######## -######## ######## -######## ----------------------------------------- ######## -######## | ACTION | AMOUNT | ######## -######## ----------------------------------------- ######## -######## ----------------------------------------- ######## -######## | Issuing | 0 | ######## -######## ----------------------------------------- ######## -######## | Depositing | 0 | ######## -######## ----------------------------------------- ######## -######## | Withdrawing | 0 | ######## -######## ----------------------------------------- ######## -######## ######## -######## ----------------------------------------- ######## -######## | WALLET | aleo1s3ws5...em2u4t | ######## -######## ----------------------------------------- ######## -######## ----------------------------------------- ######## -######## | Balance | 50 | ######## -######## ----------------------------------------- ######## -######## ######## -######## ----------------------------------------- ######## -######## | BANK | aleo1rhgdu...vzp9px | ######## -######## ----------------------------------------- ######## -######## ----------------------------------------- ######## -######## | Balance | 266 | ######## -######## ----------------------------------------- ######## -######## | Periods | 15 | ######## -######## ----------------------------------------- ######## -######## | Interest Rate | 12.34% | ######## -######## ----------------------------------------- ######## -######## ######## -######## ----------------------------------------- ######## -######## | TOTAL BALANCE | 316 | ######## -######## ----------------------------------------- ######## -######## ######## -############################################################################### -" - -# Swap in the private key and address of the bank to .env. -echo " -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH -ENDPOINT=http://localhost:3030 -" > .env - -# Have the bank withdraw all of the user's tokens with compound interest over 15 periods at 12.34%. -echo " -############################################################################### -######## ######## -######## STEP 4: Withdraw tokens of aleo1s3ws5...em2u4t w/ interest ######## -######## ######## -######## ----------------------------------------- ######## -######## | ACTION | AMOUNT | ######## -######## ----------------------------------------- ######## -######## ----------------------------------------- ######## -######## | Issuing | 0 | ######## -######## ----------------------------------------- ######## -######## | Depositing | 0 | ######## -######## ----------------------------------------- ######## -######## | Withdrawing | 266 | ######## -######## ----------------------------------------- ######## -######## ######## -######## ----------------------------------------- ######## -######## | WALLET | aleo1s3ws5...em2u4t | ######## -######## ----------------------------------------- ######## -######## ----------------------------------------- ######## -######## | Balance | 316 | ######## -######## ----------------------------------------- ######## -######## ######## -######## ----------------------------------------- ######## -######## | BANK | aleo1rhgdu...vzp9px | ######## -######## ----------------------------------------- ######## -######## ----------------------------------------- ######## -######## | Balance | 0 | ######## -######## ----------------------------------------- ######## -######## | Periods | 15 | ######## -######## ----------------------------------------- ######## -######## | Interest Rate | 12.34% | ######## -######## ----------------------------------------- ######## -######## ######## -######## ----------------------------------------- ######## -######## | TOTAL BALANCE | 316 | ######## -######## ----------------------------------------- ######## -######## ######## -############################################################################### -" -leo run withdraw aleo1t0uer3jgtsgmx5tq6x6f9ecu8tr57rzzfnc2dgmcqldceal0ls9qf6st7a 50u64 1234u64 15u64 || exit - diff --git a/examples/basic_bank/src/main.leo b/examples/basic_bank/src/main.leo deleted file mode 100644 index 83c540f206..0000000000 --- a/examples/basic_bank/src/main.leo +++ /dev/null @@ -1,96 +0,0 @@ -program basic_bank.aleo { - // A token, issued by a bank. - // - 'owner' : The address of the account that owns the record associated with this token. - // - 'amount' : The amount of tokens owned by the account. - record Token { - owner: address, - amount: u64, - } - - // An on-chain mapping, storing the amount of tokens owned by each account - // The account is stored as a hash to preserve user privacy. - mapping balances: field => u64; - - // Returns a new Token. - // - `owner` : The address of the account to issue the token to. - // - `amount`: The amount of tokens to issue. - // Requires that the function caller is the bank. - // The bank's address is aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px. - transition issue(owner: address, amount: u64) -> Token { - assert_eq(self.caller, aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px); - return Token { - owner: owner, - amount: amount, - }; - } - - // Deposits some amount of money into the bank. - // Returns a new Token with the remaining amount of money. - // - `token` : A record containing tokens to deposit. - // - `amount`: The amount of tokens to deposit. - async transition deposit(token: Token, amount: u64) -> (Token, Future) { - let difference: u64 = token.amount - amount; - - let remaining: Token = Token { - owner: token.owner, - amount: difference, - }; - - // Compute the hash of the token owner. - let hash: field = BHP256::hash_to_field(token.owner); - - return (remaining, finalize_deposit(hash, amount)); - } - - // Updates on-chain state by the amount of tokens deposited. - // - `hash` : The hash of the token owner. - // - `amount`: The amount of tokens that were deposited. - async function finalize_deposit(hash: field, amount: u64) { - let current_amount: u64 = Mapping::get_or_use(balances, hash, 0u64); - Mapping::set(balances, hash, current_amount + amount); - } - - // Returns a new Token containing the amount of money withdrawn. - // - `recipient`: The address of the account to withdraw the tokens to. - // - `amount` : The amount of tokens to withdraw. - // - `rate` : The compound interest rate. - // - `periods` : The number of periods to compound the interest over. - // Requires that the function caller is the bank. - async transition withdraw(recipient: address, amount: u64, rate: u64, periods: u64) -> (Token, Future) { - assert_eq(self.caller, aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px); - let hash: field = BHP256::hash_to_field(recipient); - - let total: u64 = calculate_interest(amount, rate, periods); - - let token: Token = Token { - owner: recipient, - amount: total, - }; - - return (token, finalize_withdraw(hash, amount)); - } - - // Updates on-chain state by the amount of tokens withdrawn. - // - `hash` : The hash of the token owner. - // - `amount`: The amount of tokens that were withdrawn. - async function finalize_withdraw(hash: field, amount: u64) { - let current_amount: u64 = Mapping::get_or_use(balances, hash, 0u64); - Mapping::set(balances, hash, current_amount - amount); - } - - // Returns the total amount of tokens after compounding interest. - // - `principal`: The amount of tokens to compound interest over. - // - `rate` : The compound interest rate. - // - `periods` : The number of periods to compound the interest over. - function calculate_interest(principal: u64, rate: u64, periods: u64) -> u64 { - let amount: u64 = principal; - - for i:u64 in 0u64..100u64 { - if i < periods { - amount += (amount * rate) / 10000u64; - } - } - - return amount; - } -} diff --git a/examples/battleship/.env b/examples/battleship/.env deleted file mode 100644 index 13b856d7da..0000000000 --- a/examples/battleship/.env +++ /dev/null @@ -1,5 +0,0 @@ - -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh -ENDPOINT=http://localhost:3030 - diff --git a/examples/battleship/.gitignore b/examples/battleship/.gitignore deleted file mode 100644 index 3aceddb0d8..0000000000 --- a/examples/battleship/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -outputs/ -*.avm -*.prover -*.verifier diff --git a/examples/battleship/README.md b/examples/battleship/README.md deleted file mode 100644 index a81086d943..0000000000 --- a/examples/battleship/README.md +++ /dev/null @@ -1,910 +0,0 @@ - - -[//]: # (workshop/battleship) - -- [Summary](#summary) -- [Build](#how-to-build) -- [Run](#how-to-run) - - [1. Initializing the Players](#1-initializing-the-players) - - [2: Player 1 Places Ships On The Board](#2-player-1-places-ships-on-the-board) - - [3: Player 1 Passes The Board To Player 2](#3-player-1-passes-the-board-to-player-2) - - [4: Player 2 Places Ships On The Board](#4-player-2-places-ships-on-the-board) - - [5: Passing The Board Back To Player 1](#5-passing-the-board-back-to-player-1) - - [6: Player 1 Takes The 1st Turn](#6-player-1-takes-the-1st-turn) - - [7: Player 2 Takes The 2nd Turn](#7-player-2-takes-the-2nd-turn) - - [8: Player 1 Takes The 3rd Turn](#8-player-1-takes-the-3rd-turn) - - [9: Player 2 Takes The 4th Turn](#9-player-2-takes-the-4th-turn) - - [10. Who Wins?](#10-who-wins) - - [Graphical Representation](#graphical-representation) -- [ZK Battleship Privacy](#zk-battleship-privacy) -- [Modeling the Boards and Ships](#modeling-the-board-and-ships) -- [Validating a Single Ship](#validating-a-single-ship-at-a-time) -- [Validating all Ships](#validating-all-ships-together-in-a-single-board) -- [Sequencing Game State](#ensure-that-players-and-boards-cannot-swap-mid-game) -- [Preventing Double Moves](#ensure-that-each-player-can-only-move-once-before-the-next-player-can-move) -- [Ensuring Valid Moves](#enforce-constraints-on-valid-moves-and-force-the-player-to-give-their-opponent-information-about-their-opponents-previous-move-in-order-to-continue-playing) -- [Winning](#winning-the-game) - -# Summary -Battleship is a game where two players lay their ships into secret configurations on their respective 8x8 grids, -and then take turns firing upon each other's board. -The game ends when one player has sunk all of the other player's ships. - -This application was translated into Leo from the [zk-battleship](https://github.com/demox-labs/zk-battleship) example written by the Aleo community - show them some love! - -## How to Build - -To compile this Leo program, run: -```bash -leo run -``` - -## How to Run -
Commands and Playing the Game - -### 1. Initializing the Players -In order to play battleship, there must be two players with two boards. -Players will be represented by their Aleo address. -You can use the provided player accounts or [generate your own](https://aleohq.github.io/aleo/). -```markdown -Player 1: - Private Key APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH - View Key AViewKey1fSyEPXxfPFVgjL6qcM9izWRGrhSHKXyN3c64BNsAjnA6 - Address aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px - -Player 2: - Private Key APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh - View Key AViewKey1hh6dvSEgeMdfseP4hfdbNYjX4grETwCuTbKnCftkpMwE - Address aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t -``` - -Save the keys and addresses. Set the `program.json` private key and address to one of the newly created aleo accounts. We'll refer to this address as Player 1, and the other address as Player 2. - -```json -{ - "program": "battleship.aleo", - "version": "0.0.0", - "description": "Play ZK Battleship", - "development": { - "private_key": "APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH", - "view_key": "AViewKey1fSyEPXxfPFVgjL6qcM9izWRGrhSHKXyN3c64BNsAjnA6", - "address": "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px" - }, - "license": "MIT" -} -``` - -### 2. Player 1 Places Ships on the Board -Now, we need to make a board as Player 1. -See the [modeling the boards and ships](#modeling-the-board-and-ships) section for information on valid ship bitstrings and placements on the board. -For this example, we will be using sample valid inputs. -Initialize a new board as Player 1 with valid ship inputs and Player 2's address: `leo run initialize_board ship_5_bitstring ship_4_bitstring ship_3_bitstring ship_2_bitstring player_2_address` - -**Run** -``` -leo run initialize_board 34084860461056u64 551911718912u64 7u64 1157425104234217472u64 aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t -``` -**Output** -```bash -➡️ Output - - • { - owner: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - hits_and_misses: 0u64.private, - played_tiles: 0u64.private, - ships: 1157459741006397447u64.private, - player_1: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - player_2: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - game_started: false.private, - _nonce: 3887646704618532506963887075433683846689834495661101507703164090915348189037group.public -} - -✅ Executed 'battleship.aleo/initialize_board' -``` - -The output is a `board_state` record owned by Player 1. -Notice that the `game_started` flag is false, and that the composite ship configuration `ships` -1157459741006397447u64, as a binary bitstring, is `0001000000010000000111111000000010000000100000001000000000000111`, -which laid out in columns and rows is: -``` -0 0 0 1 0 0 0 0 -0 0 0 1 0 0 0 0 -0 0 0 1 1 1 1 1 -1 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 -0 0 0 0 0 1 1 1 -``` - -### 3: Player 1 Passes The Board To Player 2 -Now, we can offer a battleship game to player 2. Run `leo run offer_battleship 'board_state.record'` with the record you just created: -**Run** -``` -leo run offer_battleship '{ - owner: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - hits_and_misses: 0u64.private, - played_tiles: 0u64.private, - ships: 1157459741006397447u64.private, - player_1: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - player_2: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - game_started: false.private, - _nonce: 3887646704618532506963887075433683846689834495661101507703164090915348189037group.public -}' -``` - -**Output** -```bash -➡️ Outputs - - • { - owner: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - hits_and_misses: 0u64.private, - played_tiles: 0u64.private, - ships: 1157459741006397447u64.private, - player_1: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - player_2: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - game_started: true.private, - _nonce: 6563064852163330630334088854834332804417910882908622526775624018226782316843group.public -} - • { - owner: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - incoming_fire_coordinate: 0u64.private, - player_1: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - player_2: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - prev_hit_or_miss: 0u64.private, - _nonce: 4374626042494973146987320062571809401151262172766172816829659487584978644457group.public -} - -✅ Executed 'battleship.aleo/offer_battleship' -``` - -The first output record is the updated `board_state` record. -Notice the `game_started` flag is now true. -This board cannot be used to offer any other battleship games or accept any battleship game offers. -Player 1 would need to initialize a new board and use that instead. -The second output record is a dummy `move` record -- -there are no fire coordinates included to play on Player 2's board, -and no information about any previous Player 2 moves (Player 2 has not made any moves yet). -This `move` record is owned by Player 2, who must use that in combination with their own `board_state` record to accept the game. Let's do that now. - -### 4: Player 2 Places Ships On The Board -We must run the program as Player 2 now, so switch the `program.json` file to use Player 2's keys: -```json -{ - "program": "battleship.aleo", - "version": "0.0.0", - "description": "Play ZK Battleship", - "development": { - "private_key": "APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh", - "view_key": "AViewKey1hh6dvSEgeMdfseP4hfdbNYjX4grETwCuTbKnCftkpMwE", - "address": "aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t" - }, - "license": "MIT" -} -``` - -We'll create a new and different board for Player 2, and make sure to include Player 1's address as the opponent: -**Run** -```bash -leo run initialize_board 31u64 2207646875648u64 224u64 9042383626829824u64 aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px -``` - -**Output** -```bash -➡️ Output - - • { - owner: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - hits_and_misses: 0u64.private, - played_tiles: 0u64.private, - ships: 9044591273705727u64.private, - player_1: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - player_2: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - game_started: false.private, - _nonce: 1549419609469324182591325047490602235361156298832591378925133482196483208807group.public -} - -✅ Executed 'battleship.aleo/initialize_board' -``` - -Note, the output ships here is 9044591273705727u64, which in a bitstring is: -``` -0 0 1 0 0 0 0 0 -0 0 1 0 0 0 1 0 -0 0 0 0 0 0 1 0 -0 0 0 0 0 0 1 0 -0 0 0 0 0 0 1 0 -0 0 0 0 0 0 0 0 -1 1 1 1 1 1 1 1 -``` - -### 5: Passing The Board Back To Player 1 -Now, we can accept Player 1's offer. Run `leo run start_battleship 'board_state.record' 'move.record'`: -**Run** -```bash -leo run start_battleship '{ - owner: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - hits_and_misses: 0u64.private, - played_tiles: 0u64.private, - ships: 9044591273705727u64.private, - player_1: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - player_2: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - game_started: false.private, - _nonce: 1549419609469324182591325047490602235361156298832591378925133482196483208807group.public -}' '{ - owner: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - incoming_fire_coordinate: 0u64.private, - player_1: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - player_2: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - prev_hit_or_miss: 0u64.private, - _nonce: 4374626042494973146987320062571809401151262172766172816829659487584978644457group.public -}' -``` - -**Outputs** -```bash -➡️ Outputs - - • { - owner: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - hits_and_misses: 0u64.private, - played_tiles: 0u64.private, - ships: 9044591273705727u64.private, - player_1: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - player_2: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - game_started: true.private, - _nonce: 6222383571142756260765569201308836492199048237638652378826141459336360362251group.public -} - • { - owner: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - incoming_fire_coordinate: 0u64.private, - player_1: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - player_2: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - prev_hit_or_miss: 0u64.private, - _nonce: 3742551407126138397717446975757978589064777004441277005584760115236217735495group.public -} - -✅ Executed 'battleship.aleo/start_battleship' -``` - -Notice the outputs here are similar to `offer_battleship`. -A dummy `move` record is owned by Player 1, and Player 2 gets a `board_state` record with the `game_started` flag updated. -However, now that Player 1 has a `move` record and a started board, they can begin to play. - -### 6: Player 1 Takes The 1st Turn -**Switch** `program.json`'s keys back to Player 1's. -Player 1 now makes the first real move: `leo run play 'board_state.record' 'move.record' fire_coordinate` - -**Run** -```bash -leo run play '{ - owner: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - hits_and_misses: 0u64.private, - played_tiles: 0u64.private, - ships: 1157459741006397447u64.private, - player_1: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - player_2: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - game_started: true.private, - _nonce: 6563064852163330630334088854834332804417910882908622526775624018226782316843group.public -}' '{ - owner: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - incoming_fire_coordinate: 0u64.private, - player_1: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - player_2: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - prev_hit_or_miss: 0u64.private, - _nonce: 3742551407126138397717446975757978589064777004441277005584760115236217735495group.public -}' 1u64 -``` -**Outputs** -```bash -➡️ Outputs - - • { - owner: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - hits_and_misses: 0u64.private, - played_tiles: 1u64.private, - ships: 1157459741006397447u64.private, - player_1: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - player_2: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - game_started: true.private, - _nonce: 1474170213684980843727833284550698461565286563122422722760769547002894080093group.public -} - • { - owner: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - incoming_fire_coordinate: 1u64.private, - player_1: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - player_2: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - prev_hit_or_miss: 0u64.private, - _nonce: 5481529266389297320813092061136936339861329677911328036818179854958874588416group.public -} - -✅ Executed 'battleship.aleo/play' -``` - -Player 1 has an updated `board_state` record -- they have a new `played_tiles` bitstring, -which corresponds to the fire coordinate they just sent to Player 2. -You can see that the `incoming_fire_coordinate` in the `move` record owned by Player 2 matches exactly the input given by Player 1. -Player 2 can now play this move tile and respond with a fire coordinate of their own, -and they will also let Player 1 know whether their fire coordinate hit or miss Player 2's ships. - -### 7: Player 2 Takes The 2nd Turn -**Switch** `program.json` to Player 2's keys. Player 2 makes their move: - -**Run** -```bash -leo run play '{ - owner: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - hits_and_misses: 0u64.private, - played_tiles: 0u64.private, - ships: 9044591273705727u64.private, - player_1: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - player_2: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - game_started: true.private, - _nonce: 6222383571142756260765569201308836492199048237638652378826141459336360362251group.public -}' '{ - owner: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - incoming_fire_coordinate: 1u64.private, - player_1: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - player_2: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - prev_hit_or_miss: 0u64.private, - _nonce: 5481529266389297320813092061136936339861329677911328036818179854958874588416group.public -}' 2048u64 - -``` - -**Outputs** -```bash -➡️ Outputs - - • { - owner: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - hits_and_misses: 0u64.private, - played_tiles: 2048u64.private, - ships: 9044591273705727u64.private, - player_1: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - player_2: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - game_started: true.private, - _nonce: 5254963165391133332409074172682159033621708071536429341861038147524454777097group.public -} - • { - owner: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - incoming_fire_coordinate: 2048u64.private, - player_1: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - player_2: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - prev_hit_or_miss: 1u64.private, - _nonce: 5851606198769770675504009323414373017067582072428989801313256693053765675198group.public -} - -✅ Executed 'battleship.aleo/play' -``` - -Player 2 now has an updated `board_state` record which includes their newly updated `played_tiles`, -only containing the fire coordinate they just sent to Player 1. -Player 1 now owns a new `move` record which includes the `prev_hits_and_misses` component. -This contains only the result of Player 1's previous fire coordinate they had sent to Player 2. -It will always be a single coordinate on the 8x8 grid if it's a hit. A miss is 0u64 (8x8 grid of 0s), -whereas a hit is the u64 equivalent of their previous fire coordinate in bitstring form. -If you check Player 2's ships configuration, you'll note their entire bottom row is covered by two ships, -so sample valid hits on the bottom row would be: 1u64, 2u64, 4u64, 8u64, 16u64, 32u64, 64u64, and 128u64. -Since Player 1's first fire coordinate (1u64) was a hit, the `prev_hits_and_misses` component is also 1u64. - -Player 1's next move will consume this `move` record, which will update Player 1's board with the hit-or-miss, -as well as figure out the result of Player 2's fire coordinate. -Now that Player 1 has some `played_tiles`, they can no longer choose an already-played fire coordinate. -For example, running `aleo run play 'board_state.record' 'move.record' 1u64` will fail, because 1u64 has already been played. - -### 8: Player 1 Takes The 3rd Turn -**Switch** `program.json` to use Player 1's keys. - -**Run** -```bash -leo run play '{ - owner: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - hits_and_misses: 0u64.private, - played_tiles: 1u64.private, - ships: 1157459741006397447u64.private, - player_1: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - player_2: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - game_started: true.private, - _nonce: 1474170213684980843727833284550698461565286563122422722760769547002894080093group.public -}' '{ - owner: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - incoming_fire_coordinate: 2048u64.private, - player_1: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - player_2: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - prev_hit_or_miss: 1u64.private, - _nonce: 5851606198769770675504009323414373017067582072428989801313256693053765675198group.public -}' 2u64 -``` - -**Outputs** -```bash -➡️ Outputs - - • { - owner: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - hits_and_misses: 1u64.private, - played_tiles: 3u64.private, - ships: 1157459741006397447u64.private, - player_1: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - player_2: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - game_started: true.private, - _nonce: 853278652528988609827041334083853520436225751739504321439524466875699631772group.public -} - • { - owner: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - incoming_fire_coordinate: 2u64.private, - player_1: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - player_2: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - prev_hit_or_miss: 0u64.private, - _nonce: 710336412388939616658264778971886770861024495941253598683184288448156545822group.public -} - -✅ Executed 'battleship.aleo/play' -``` - -As before, both a `board_state` record and `move` record are created. -The `board_state` record now contains 3u64 as the `played_tiles`, which looks like this in bitstring form: -``` -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 1 1 -``` - -The `board_state` record `hits_and_misses` component has also been updated with the result of their previous move. The new `move` record owned by Player 2 now contains information about whether Player 2's previous move was a hit or miss, as well as Player 1's new fire coordinate. - -### 9: Player 2 Takes The 4th Turn -**Switch** `program.json`'s keys to Player 2. Player 2 makes their next move: - -**Run** -```bash -leo run play '{ - owner: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - hits_and_misses: 0u64.private, - played_tiles: 2048u64.private, - ships: 9044591273705727u64.private, - player_1: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - player_2: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - game_started: true.private, - _nonce: 5254963165391133332409074172682159033621708071536429341861038147524454777097group.public -}' '{ - owner: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - incoming_fire_coordinate: 2u64.private, - player_1: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - player_2: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - prev_hit_or_miss: 0u64.private, - _nonce: 710336412388939616658264778971886770861024495941253598683184288448156545822group.public -}' 4u64 -``` - -**Outputs** -```bash -➡️ Outputs - - • { - owner: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - hits_and_misses: 0u64.private, - played_tiles: 2052u64.private, - ships: 9044591273705727u64.private, - player_1: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - player_2: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - game_started: true.private, - _nonce: 1145182747531998766752104305052328886102707397061849372000385383229513301534group.public -} - • { - owner: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - incoming_fire_coordinate: 4u64.private, - player_1: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - player_2: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - prev_hit_or_miss: 2u64.private, - _nonce: 5958326936461495382488152485080596366937963499216527548334225566230682598418group.public -} - -✅ Executed 'battleship.aleo/play' -``` - -### 10. Who Wins? -Play continues back and forth between Player 1 and Player 2. -When one player has a total of 14 flipped bits in their `hits_and_misses` component on their `board_state` record, -they have won the game. - -### Graphical Representation - -The following diagram depicts the records and transitions in a game. - -![diagram](./diagram.png) - -
- -## ZK Battleship Privacy - -How can we ensure that the ship configurations of each player remains secret, -while being able to trustlessly and fairly play with their opponent? -By taking advantage of selective privacy powered by zero-knowledge proofs on Aleo. - -Broadly speaking, we can follow this general strategy: - -1. Create mathematical rules for placing the ships on the board, to ensure that neither player can cheat by stacking all their ships in one place, moving them off the board, or laying them across each other. - -2. Ensure that the players and boards that begin a game cannot be swapped out. - -3. Ensure that each player can only move once before the next player can move. - -4. Enforce constraints on valid moves, and force the player to give their opponent information about their opponent's previous move in order to continue playing. - -## Modeling the board and ships - -Most battleship representations in programs use a 64-character string or an array of arrays (8 arrays of 8 elements each) to model the board state. Unfortunately, Leo doesn't represent strings well yet. Luckily for us, Leo has the unsigned 64-bit integer type, `u64`. To represent every space on a battleship board, from top left to bottom right, we can use each bit in a `u64`. For example, an empty board would be: -0u64 = -``` -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -``` - -Battleship is played with 4 different ship types -- a ship of length 5, length 4, length 3, and length 2. Some versions of battleship have an extra length 3 ship or another extra ship type; however, we will stick to the most basic version for this project. In order to be a valid ship placement, a ship must be placed vertically or horizontally (not diagonally). On a physical board, a ship cannot break across rows or intersect with another ship, but ships are allowed to touch one another. - -Similar to how we represent a board with a `u64` bitstring, we can represent a ship horizontally as a bitstring. We "flip" the bits to represent a ship: -| Length | Bitstring | u64 | -| ------ | --------- | --- | -| 5 | 11111 | 31u64| -| 4 | 1111 | 15u64| -| 3 | 111 | 7u64 | -| 2 | 11 | 3u64 | - -We can also represent a ship vertically as a bitstring. To show this, we need 7 "unflipped" bits (zeroes) in between the flipped bits so that the bits are adjacent vertically. -| Length | Bitstring | u64 | -| --- | --- | --- | -| 5 | 1 00000001 00000001 00000001 00000001 | 4311810305u64 | -| 4 | 1 00000001 00000001 00000001 | 16843009u64 | -| 3 | 1 00000001 00000001 | 65793u64 | -| 2 | 1 00000001 | 257u64 | - -With a board model and ship bitstring models, we can now place ships on a board. - -
Examples of valid board configurations: - -17870284429256033024u64 -``` -1 1 1 1 1 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 1 -0 0 0 0 0 0 0 1 -1 1 1 1 0 0 0 1 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 1 1 -0 0 0 0 0 0 0 0 -``` - -16383u64 -``` -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -``` - -2157505700798988545u64 -``` -0 0 0 1 1 1 0 1 -1 1 1 1 0 0 0 1 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 1 -0 0 0 0 0 0 0 1 -0 0 0 0 0 0 0 1 -0 0 0 0 0 0 0 1 -0 0 0 0 0 0 0 1 -``` - -
- -
Examples of invalid board configurations: - -Ships overlapping the bottom ship: -67503903u64 -``` -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 1 0 0 -0 0 0 0 0 1 1 0 -0 0 0 0 0 1 1 1 -0 0 0 1 1 1 1 1 -``` - -Diagonal ships: -9242549787790754436u64 -``` -1 0 0 0 0 0 0 0 -0 1 0 0 0 1 0 0 -0 0 1 0 0 0 1 0 -0 0 0 1 0 0 0 0 -0 0 0 1 1 0 0 0 -0 0 1 0 0 0 0 1 -0 1 0 0 0 0 1 0 -1 0 0 0 0 1 0 0 -``` - -Ships splitting across rows and columns: -1297811850814034450u64 -``` -0 0 0 1 0 0 1 0 -0 0 0 0 0 0 1 0 -1 1 0 0 0 0 0 1 -0 0 0 0 0 0 0 0 -1 0 0 1 0 0 0 1 -0 0 0 1 0 0 0 0 -0 0 0 1 0 0 1 0 -0 0 0 1 0 0 1 0 -``` -
- -Given these rules, our strategy will be to validate each individual ship bitstring placement on a board, and then, if all the ships are valid, compose all the positions onto a board and validate that the board with all ships are valid. If each individual ship's position is valid, then all the ships together should be valid unless any overlapping occurs. - -## Validating a single ship at a time - -To follow along with the code, all verification of ship bitstrings is done in `verify.leo`. We know a ship is valid if all these conditions are met: -If horizontal: -1. The correct number of bits is flipped (a ship of length 5 should not have 6 flipped bits) -2. All the bits are adjacent to each other. -3. The bits do not split a row. - -If vertical: -1. The correct number of bits is flipped. -2. All the bits are adjacent to each other, vertically. This means that each flipped bit should be separated by exactly 7 unflipped bits. -3. The bits do not split a column. - -If a ship is valid vertically or horizontally, then we know the ship is valid. We just need to check the bit count, check the adjacency of those bits, and make sure those bits do not split a row/column. However, we can't loop through the bit string to count bits, or to make sure those bits don't break across columns. We'll need to turn to special bitwise operations and hacks. - -
Bit Counting - -See the `bitcount` function to follow along with the code. 50 years ago, MIT AI Laboratory published HAKMEM, which was a series of tricks and hacks to speed up processing for bitwise operations. https://w3.pppl.gov/~hammett/work/2009/AIM-239-ocr.pdf We turned to HAKMEM 169 for bit counting inspiration, although we've tweaked our implementation to be (hopefully) easier to understand. Before diving into details, let's build some intuition. - -Let a,b,c,d be either 0 or 1. Given a polynomial 8a + 4b + 2c + d, how do we find the summation of a + b + c + d? -If we subtract subsets of this polynomial, we'll be left with the summation. -Step 1: 8a + 4b + 2c + d -Step 2: -4a - 2b - c -Step 3: -2a - b -Step 4: - a -Step 5: = a + b + c + d -This polynomial is basically a bitwise representation of a number, so given a 4 bit number, e.g. 1011 or 13u64, we can follow these instructions to get the bit count. Step 2 is just subtracting the starting number but shifted to the right once (equivalent to dividing by 2). Step 3 shifts the starting number to the right twice and is subtracted, and Step 4 shifts thrice and is subtracted. Put another way: Start with a 4-digit binary number A, and do `A - (A >> 1) - (A >> 2) - (A >> 3) = B`. -Step 1: 1101 = 13u64 -Step 2: -0110 = 6u64 -Step 3: -0011 = 3u64 -Step 4: -0001 = 1u64 -Step 5: =0011 = 3u64 - -To make this process work for any bit-length number, where the sum of the bits is left in groups of 4 bits, we'll need to use some bit masking, so that the sum of one group of 4 does not interfere with the next group of 4. -With a larger starting number, like 1111 0001 0111 0110, we will need the following bit maskings: -``` -For A >> 1, we'll use 0111 0111 0111 .... (in u64, this is 8608480567731124087u64) -For A >> 2, we'll use 0011 0011 0011 .... (in u64, this is 3689348814741910323u64) -For A >> 3, we'll use 0001 0001 0001 .... (in u64, this is 1229782938247303441u64) -``` - -For example, finding the sums of groups of 4 with a 16-bit number we'll call A to yield the bit sum number B: -``` -A: 1111 0001 0111 0110 -A>>1: 0111 1000 1011 1011 -A>>2: 0011 1100 0101 1101 -A>>3: 0001 1110 0010 1110 - -A>>1: 0111 1000 1011 1011 - & 0111 0111 0111 0111: - 0111 0000 0011 0011 - -A>>2: 0011 1100 0101 1101 - & 0011 0011 0011 0011: - 0011 0000 0001 0001 - -A>>3: 0001 1110 0010 1110 - & 0001 0001 0001 0001: - 0001 0000 0000 0000 - -A - (A>>1 & 0111....) - (A>>2 & 0011....) - (A>>3 & 0001....): -B: 0100 0001 0011 0010 - 4 1 3 2 -``` - -The next step is to combine the summation of each of those 4-bit groups into sums of 8-bit groups. To do this, we'll use another bit trick. We will shift this number B to the right by 4 (B >> 4), and add that back to B. Then, we'll apply a bit masking of 0000 1111 0000 1111 .... (in u64, this is 1085102592571150095u64) to yield the sums of bits in groups of 8, a number we'll call C. -``` -B: 0100 0001 0011 0010 -B>>4: 0000 0100 0001 0011 - 0100 0101 0100 0101 - 4 5 4 5 - -apply the bit mask - 0000 1111 0000 1111 - -C: 0000 0101 0000 0101 - 0 5 0 5 -``` - -At this point, we've gone from a bit sum in groups of 4 to bit sums in groups of 8. That's great, but ultimately we want the total sum of bits in the original binary number. The final bit trick is to modulo C by 255. This is 2^8 - 1. For a bit of intuition, consider the number 1 0000 0001. If we take 1 0000 0001 mod 256, we're left with 1. If we take 1 0000 0001 mod 255, we're left with 2. Modding by 255 gives us the amount of bits _beyond_ the first 255 numbers, as 255 is the largest number that can be represented with 8 bits. - -A full summary of abbreviated steps to get the bit count, starting with a 64-bit integer A (closely following the `bitcount` function in the `verify.leo` code): -``` -let A = unsigned 64-bit integer -let B = A - (A>>1 & 8608480567731124087u64) - (A>>2 & 3689348814741910323u64) - (A>>3 & 1229782938247303441u64) -let C = (B - B>>4) & 1085102592571150095u64 -bit count = C mod 255u64 -``` - -
- -
Adjacency Check - -Given a ship's placement on the board and its bitstring representation (horizontally or vertically), we can determine if the bits are adjacent. Follow the `adjacency_check` function in `verify.leo`. Given the ship of length 2, we know its horizontal bitstring is 11 (3u64) and its vertical bitstring is 100000001 (257u64). If on the board, the ship starts at the bottom right corner, its horizontal ship placement string would be: -3u64 -``` -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 1 1 -``` - -Vertical ship placement: -257u64 -``` -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 1 -0 0 0 0 0 0 0 1 -``` - -If we move the ship to the left one column: -Horizontal 6u64 -``` -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 1 1 0 -``` - -Vertical 514u64 -``` -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 1 0 -0 0 0 0 0 0 1 0 -``` - -If we move the ship up one row: -Horizontal 768u64 -``` -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 1 1 -0 0 0 0 0 0 0 0 -``` - -Vertical 65792u64 -``` -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 1 -0 0 0 0 0 0 0 1 -0 0 0 0 0 0 0 0 -``` - -We can make the observation that the original bitstring is always shifted by an integer amount to get to a new valid position on the board. Therefore, if we take the ship placement bitstring and divide by the ship bitstring (either horizontal or vertical), as long as the remaining number is a power of 2 (2^0, 2^1, 2^2, 2^3...), we know the ship's bits are adjacent. - -To ensure that the remaining number is a power of 2, we can use a bit trick. See the bit trick for ensuring a bitstring is a power of 2 section. - -In the code, you'll notice one extra step. Dividing a ship placement bitstring by a ship bitstring representation could result in 0, and then subtracting by 1 will result in an underflow. In that case, we know the ship placement is not valid, so we can set a number which is guaranteed to not be a power of 2. -
- -
Splitting a row or column -Follow the `horizontal_check` function in `verify.leo` to follow the code. Assume all the bits are adjacent (see the adjacency check section). The column case is trivial. We can be certain that if a ship bitstring splits columns, the division of that ship placement bitstring by its ship bitstring representation will not yield a power of 2, and it would have failed the adjacency check. - -The horizontal case must be checked because a split row bitstring could still contain a ship with adjacent bits. To make this check easier, we will condense the `64` bitstring into an 8-bit bitstring by taking it modulo 255. If we assume that a bitstring is not splitting a row, then taking the ship placement bitstring modulo 255 will yield an 8-bit valid bitstring. If the original ship placement bitstring is not valid, then we will have an invalid 8-bit bitstring. E.g.: -``` -1 1 1 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -``` -mod 255 = 11100000 (valid) - -``` -0 0 0 0 0 0 0 1 -1 1 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 -``` -mod 255 = 11000001 (invalid) - -How do we know the 8 bit bitstring is valid or not? We can simply do an adjacency check, as before. - -
- -
Ensuring a bitstring is a power of 2 - -Any power of 2 will have a single bit flipped. If we subtract 1 from that number, it will result in a complementary bitstring that, bitwise-ANDed with the original, will always result in 0. - -E.g. -``` -8: 1000 -8-1: 0111 -8&7: 0000 == 0 - -7: 0111 -7-1: 0110 -7&6: 0110 != 0 -``` - -
- -## Validating all ships together in a single board - -Give individual valid ship position bitstrings, we can combine all these together into a single board using bitwise OR operators. See the `create_board` function in `verify.leo` to follow the code. Once all ships are on the board, we can count the total number of bits, which should be 14 exactly for a ship of length 5, 4, 3, and 2. - -## Ensure that players and boards cannot swap mid-game - -Board states are represented with the board state record. Each board has a flag indicating whether a game has been started with the board. This flag is set when offering a battleship game to an opponent, or accepting a battleship game from an opponent. Move records are created only in 3 ways: -1. Offering a battleship game creates a dummy move record that sets the two players to the addresses set in the board state record. -2. Accepting a battleship game consumes the first dummy move record and checks that the move record contains the same two players as the board of the player accepting the game. Then, a new dummy move record is created and keeps the same two players. -2. A move record must be consumed in order to play and create the next move record. There's a check to ensure the players in the move record matches the players in the board, and the players in the next move record are automatically set. - -The only way moves _not_ matching a board can be combined is if the players begin multiple games with each other. As long as one player is honest and only accepts a single game with a particular opponent, only one set of moves can be played on one board between them. - -## Ensure that each player can only move once before the next player can move - -A move record must be consumed in order to create the next move record. The owner of the move record changes with each play. Player A must spend a move record in order to create a move record containing their fire coordinate, and that move record will be owned by Player B. Player B must spend that move record in order to create the next move record, which will belong to Player A. - -## Enforce constraints on valid moves, and force the player to give their opponent information about their opponent's previous move in order to continue playing - -A valid move for a player is a fire coordinate that has only one flipped bit in a u64. We can make sure only one bit is flipped with the powers of 2 bit trick. That single bit must be a coordinate that has not been played by that player before, which we check in `board.leo/update_played_tiles`. - -In order to give their next move to their opponent, a player must call the `main.leo/play` function, which checks the opponent's fire coordinate on the current player's board. The move record being created is updated with whether that fire coordinate was a hit or a miss for the opponent. - -## Winning the game - -Right now, the way to check when a game has been won is to count the number of hits on your `hits_and_misses` component on your `board_state` record. Once you have 14 hits, you've won the game. diff --git a/examples/battleship/board/.gitignore b/examples/battleship/board/.gitignore deleted file mode 100644 index f721f7f6f4..0000000000 --- a/examples/battleship/board/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -.env -*.avm -*.prover -*.verifier -outputs/ diff --git a/examples/battleship/board/README.md b/examples/battleship/board/README.md deleted file mode 100644 index d7d689efbc..0000000000 --- a/examples/battleship/board/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# board.aleo - -## Build Guide - -To compile this Aleo program, run: -```bash -snarkvm build -``` - -To execute this Aleo program, run: -```bash -snarkvm run hello -``` diff --git a/examples/battleship/board/build/main.aleo b/examples/battleship/board/build/main.aleo deleted file mode 100644 index fac2e70af8..0000000000 --- a/examples/battleship/board/build/main.aleo +++ /dev/null @@ -1,46 +0,0 @@ -program board.aleo; - -record board_state: - owner as address.private; - hits_and_misses as u64.private; - played_tiles as u64.private; - ships as u64.private; - player_1 as address.private; - player_2 as address.private; - game_started as boolean.private; - - -function new_board_state: - input r0 as u64.private; - input r1 as address.private; - cast self.caller 0u64 0u64 r0 self.caller r1 false into r2 as board_state.record; - output r2 as board_state.record; - - -function start_board: - input r0 as board_state.record; - not r0.game_started into r1; - assert.eq r1 true; - cast r0.owner r0.hits_and_misses r0.played_tiles r0.ships r0.player_1 r0.player_2 true into r2 as board_state.record; - output r2 as board_state.record; - - -function update_played_tiles: - input r0 as board_state.record; - input r1 as u64.private; - sub r1 1u64 into r2; - and r1 r2 into r3; - assert.eq r3 0u64; - and r1 r0.played_tiles into r4; - assert.eq r4 0u64; - or r0.played_tiles r1 into r5; - cast r0.owner r0.hits_and_misses r5 r0.ships r0.player_1 r0.player_2 r0.game_started into r6 as board_state.record; - output r6 as board_state.record; - - -function update_hits_and_misses: - input r0 as board_state.record; - input r1 as u64.private; - or r0.hits_and_misses r1 into r2; - cast r0.owner r2 r0.played_tiles r0.ships r0.player_1 r0.player_2 r0.game_started into r3 as board_state.record; - output r3 as board_state.record; diff --git a/examples/battleship/board/build/program.json b/examples/battleship/board/build/program.json deleted file mode 100644 index b140f09fcc..0000000000 --- a/examples/battleship/board/build/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "board.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/battleship/board/inputs/board.in b/examples/battleship/board/inputs/board.in deleted file mode 100644 index d414604f3e..0000000000 --- a/examples/battleship/board/inputs/board.in +++ /dev/null @@ -1,4 +0,0 @@ -// The program input for board/src/main.leo -[main] -public a: u32 = 1u32; -b: u32 = 2u32; diff --git a/examples/battleship/board/leo.lock b/examples/battleship/board/leo.lock deleted file mode 100644 index c4293b3b9f..0000000000 --- a/examples/battleship/board/leo.lock +++ /dev/null @@ -1 +0,0 @@ -package = [] diff --git a/examples/battleship/board/program.json b/examples/battleship/board/program.json deleted file mode 100644 index b140f09fcc..0000000000 --- a/examples/battleship/board/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "board.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/battleship/board/src/main.leo b/examples/battleship/board/src/main.leo deleted file mode 100644 index 70f82cde13..0000000000 --- a/examples/battleship/board/src/main.leo +++ /dev/null @@ -1,110 +0,0 @@ -program board.aleo { - // Battleship boards are represented by 8x8 squares. - // A u64 is all that is required to represent a hit or a miss on a single board. - // Starting from the top row, left to right, a hit is 1 and a miss is 0. - // A first move resulting in a hit in row 1, column 3 would be: - // 00100000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 - // A second u64 is needed to represent which squares have been played, with 1s being played squares and 0s being - // unplayed squares. - record board_state { - owner: address, - // The hits and misses registered on the opponent's board. - hits_and_misses: u64, - // The squares that have been played on the opponent's board. - played_tiles: u64, - // The ship bitstring representing all ship positions on your own board - ships: u64, - player_1: address, - player_2: address, - game_started: bool, - } - - // Returns a new board_state. - transition new_board_state( - ships: u64, - opponent: address, - ) -> board_state { - return board_state { - owner: self.caller, - hits_and_misses: 0u64, - played_tiles: 0u64, - ships, - player_1: self.caller, - player_2: opponent, - game_started: false, - }; - } - - // Returns a new board state that has been started. - // Fails if this board has been started before. - transition start_board( - // The record of the board to start. A board can only be started once. - board: board_state, - ) -> board_state { - // Ensure this board hasn't been used to start a game before. - assert(!board.game_started); - - return board_state { - owner: board.owner, - hits_and_misses: board.hits_and_misses, - played_tiles: board.played_tiles, - ships: board.ships, - player_1: board.player_1, - player_2: board.player_2, - game_started: true, - }; - } - - // Returns a new board state record that includes all the played tiles. - // Fails if r1 has been played before. - transition update_played_tiles( - // The record of the board to update. - board: board_state, - // The u64 equivalent of a bitstring fire coordinate to send to the opponent. - shoot: u64, - ) -> board_state { - // Need to make sure r1 is a valid move. Only one bit of r1 should be flipped. - let flip_bit: u64 = shoot - 1u64; - // bitwise and operation - let check_move: u64 = shoot & flip_bit; - assert_eq(check_move, 0u64); - - // Need to make sure r1 is a valid move given the played_tiles. no bits should overlap. - let check_tiles: u64 = shoot & board.played_tiles; - assert_eq(check_tiles, 0u64); - - // Update played tiles. - let played_tiles: u64 = board.played_tiles | shoot; - - return board_state { - owner: board.owner, - hits_and_misses: board.hits_and_misses, - played_tiles, - ships: board.ships, - player_1: board.player_1, - player_2: board.player_2, - game_started: board.game_started, - }; - } - - // Returns a new board state record that includes all the hits and misses. - transition update_hits_and_misses( - // The record of the board to update. - board: board_state, - // The u64 equivalent of a bitstring of whether this player's previous move was a hit or miss. - hit_or_miss: u64, - ) -> board_state { - // Update hits and misses. - let hits_and_misses: u64 = board.hits_and_misses | hit_or_miss; - - return board_state { - owner: board.owner, - hits_and_misses, - played_tiles: board.played_tiles, - ships: board.ships, - player_1: board.player_1, - player_2: board.player_2, - game_started: board.game_started, - }; - } -} diff --git a/examples/battleship/build/imports/board.aleo b/examples/battleship/build/imports/board.aleo deleted file mode 100644 index fac2e70af8..0000000000 --- a/examples/battleship/build/imports/board.aleo +++ /dev/null @@ -1,46 +0,0 @@ -program board.aleo; - -record board_state: - owner as address.private; - hits_and_misses as u64.private; - played_tiles as u64.private; - ships as u64.private; - player_1 as address.private; - player_2 as address.private; - game_started as boolean.private; - - -function new_board_state: - input r0 as u64.private; - input r1 as address.private; - cast self.caller 0u64 0u64 r0 self.caller r1 false into r2 as board_state.record; - output r2 as board_state.record; - - -function start_board: - input r0 as board_state.record; - not r0.game_started into r1; - assert.eq r1 true; - cast r0.owner r0.hits_and_misses r0.played_tiles r0.ships r0.player_1 r0.player_2 true into r2 as board_state.record; - output r2 as board_state.record; - - -function update_played_tiles: - input r0 as board_state.record; - input r1 as u64.private; - sub r1 1u64 into r2; - and r1 r2 into r3; - assert.eq r3 0u64; - and r1 r0.played_tiles into r4; - assert.eq r4 0u64; - or r0.played_tiles r1 into r5; - cast r0.owner r0.hits_and_misses r5 r0.ships r0.player_1 r0.player_2 r0.game_started into r6 as board_state.record; - output r6 as board_state.record; - - -function update_hits_and_misses: - input r0 as board_state.record; - input r1 as u64.private; - or r0.hits_and_misses r1 into r2; - cast r0.owner r2 r0.played_tiles r0.ships r0.player_1 r0.player_2 r0.game_started into r3 as board_state.record; - output r3 as board_state.record; diff --git a/examples/battleship/build/imports/move.aleo b/examples/battleship/build/imports/move.aleo deleted file mode 100644 index ed5247d932..0000000000 --- a/examples/battleship/build/imports/move.aleo +++ /dev/null @@ -1,24 +0,0 @@ -program move.aleo; - -record move: - owner as address.private; - incoming_fire_coordinate as u64.private; - player_1 as address.private; - player_2 as address.private; - prev_hit_or_miss as u64.private; - - -function create_move: - input r0 as move.record; - input r1 as u64.private; - input r2 as u64.private; - is.eq r0.player_1 r0.owner into r3; - ternary r3 r0.player_2 r0.player_1 into r4; - cast r4 r1 r0.player_2 r0.player_1 r2 into r5 as move.record; - output r5 as move.record; - - -function start_game: - input r0 as address.private; - cast r0 0u64 self.caller r0 0u64 into r1 as move.record; - output r1 as move.record; diff --git a/examples/battleship/build/imports/verify.aleo b/examples/battleship/build/imports/verify.aleo deleted file mode 100644 index 804dcf2a0e..0000000000 --- a/examples/battleship/build/imports/verify.aleo +++ /dev/null @@ -1,73 +0,0 @@ -program verify.aleo; - - - -closure bitcount: - input r0 as u64; - div r0 2u64 into r1; - div r0 4u64 into r2; - div r0 8u64 into r3; - and r1 8608480567731124087u64 into r4; - and r2 3689348814741910323u64 into r5; - and r3 1229782938247303441u64 into r6; - sub r0 r4 into r7; - sub r7 r5 into r8; - sub r8 r6 into r9; - div r9 16u64 into r10; - add r9 r10 into r11; - and r11 1085102592571150095u64 into r12; - rem r12 255u64 into r13; - output r13 as u64; - - -closure adjacency_check: - input r0 as u64; - input r1 as u64; - div r0 r1 into r2; - is.eq r2 0u64 into r3; - ternary r3 3u64 r2 into r4; - sub r4 1u64 into r5; - and r5 r4 into r6; - is.eq r6 0u64 into r7; - output r7 as boolean; - - -closure horizontal_check: - input r0 as u64; - input r1 as u64; - rem r0 255u64 into r2; - div r2 r1 into r3; - is.eq r3 0u64 into r4; - ternary r4 3u64 r3 into r5; - sub r5 1u64 into r6; - and r6 r5 into r7; - is.eq r7 0u64 into r8; - output r8 as boolean; - - -function validate_ship: - input r0 as u64.private; - input r1 as u64.private; - input r2 as u64.private; - input r3 as u64.private; - call bitcount r0 into r4; - assert.eq r4 r1; - call adjacency_check r0 r2 into r5; - call horizontal_check r0 r2 into r6; - and r5 r6 into r7; - call adjacency_check r0 r3 into r8; - or r7 r8 into r9; - output r9 as boolean.private; - - -function create_board: - input r0 as u64.private; - input r1 as u64.private; - input r2 as u64.private; - input r3 as u64.private; - or r0 r1 into r4; - or r4 r2 into r5; - or r5 r3 into r6; - call bitcount r6 into r7; - assert.eq r7 14u64; - output r6 as u64.private; diff --git a/examples/battleship/build/main.aleo b/examples/battleship/build/main.aleo deleted file mode 100644 index 5fe36f9fe6..0000000000 --- a/examples/battleship/build/main.aleo +++ /dev/null @@ -1,59 +0,0 @@ -import board.aleo; -import move.aleo; -import verify.aleo; -program battleship.aleo; - - - - -function initialize_board: - input r0 as u64.private; - input r1 as u64.private; - input r2 as u64.private; - input r3 as u64.private; - input r4 as address.private; - call verify.aleo/validate_ship r0 5u64 31u64 4311810305u64 into r5; - assert.eq r5 true; - call verify.aleo/validate_ship r1 4u64 15u64 16843009u64 into r6; - assert.eq r6 true; - call verify.aleo/validate_ship r2 3u64 7u64 65793u64 into r7; - assert.eq r7 true; - call verify.aleo/validate_ship r3 2u64 3u64 257u64 into r8; - assert.eq r8 true; - call verify.aleo/create_board r0 r1 r2 r3 into r9; - call board.aleo/new_board_state r9 r4 into r10; - output r10 as board.aleo/board_state.record; - - -function offer_battleship: - input r0 as board.aleo/board_state.record; - call board.aleo/start_board r0 into r1; - call move.aleo/start_game r0.player_2 into r2; - output r1 as board.aleo/board_state.record; - output r2 as move.aleo/move.record; - - -function start_battleship: - input r0 as board.aleo/board_state.record; - input r1 as move.aleo/move.record; - assert.eq r0.player_1 r1.player_2; - assert.eq r0.player_2 r1.player_1; - call board.aleo/start_board r0 into r2; - call move.aleo/start_game r0.player_2 into r3; - output r2 as board.aleo/board_state.record; - output r3 as move.aleo/move.record; - - -function play: - input r0 as board.aleo/board_state.record; - input r1 as move.aleo/move.record; - input r2 as u64.private; - assert.eq r0.game_started true; - assert.eq r0.player_1 r1.player_2; - assert.eq r0.player_2 r1.player_1; - call board.aleo/update_played_tiles r0 r2 into r3; - call board.aleo/update_hits_and_misses r3 r1.prev_hit_or_miss into r4; - and r1.incoming_fire_coordinate r0.ships into r5; - call move.aleo/create_move r1 r2 r5 into r6; - output r4 as board.aleo/board_state.record; - output r6 as move.aleo/move.record; diff --git a/examples/battleship/build/program.json b/examples/battleship/build/program.json deleted file mode 100644 index fe5a3d5e74..0000000000 --- a/examples/battleship/build/program.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "program": "battleship.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT", - "dependencies" : [ - { - "name": "board.aleo", - "location": "local", - "path": "board" - }, - { - "name": "move.aleo", - "location": "local", - "path": "move" - }, - { - "name": "verify.aleo", - "location": "local", - "path": "verify" - } - ] -} diff --git a/examples/battleship/diagram.png b/examples/battleship/diagram.png deleted file mode 100644 index bb16a920e2..0000000000 Binary files a/examples/battleship/diagram.png and /dev/null differ diff --git a/examples/battleship/move/.gitignore b/examples/battleship/move/.gitignore deleted file mode 100644 index f721f7f6f4..0000000000 --- a/examples/battleship/move/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -.env -*.avm -*.prover -*.verifier -outputs/ diff --git a/examples/battleship/move/README.md b/examples/battleship/move/README.md deleted file mode 100644 index a8beca6049..0000000000 --- a/examples/battleship/move/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# move.aleo - -## Build Guide - -To compile this Aleo program, run: -```bash -snarkvm build -``` - -To execute this Aleo program, run: -```bash -snarkvm run hello -``` diff --git a/examples/battleship/move/build/main.aleo b/examples/battleship/move/build/main.aleo deleted file mode 100644 index ed5247d932..0000000000 --- a/examples/battleship/move/build/main.aleo +++ /dev/null @@ -1,24 +0,0 @@ -program move.aleo; - -record move: - owner as address.private; - incoming_fire_coordinate as u64.private; - player_1 as address.private; - player_2 as address.private; - prev_hit_or_miss as u64.private; - - -function create_move: - input r0 as move.record; - input r1 as u64.private; - input r2 as u64.private; - is.eq r0.player_1 r0.owner into r3; - ternary r3 r0.player_2 r0.player_1 into r4; - cast r4 r1 r0.player_2 r0.player_1 r2 into r5 as move.record; - output r5 as move.record; - - -function start_game: - input r0 as address.private; - cast r0 0u64 self.caller r0 0u64 into r1 as move.record; - output r1 as move.record; diff --git a/examples/battleship/move/build/program.json b/examples/battleship/move/build/program.json deleted file mode 100644 index b8acf29858..0000000000 --- a/examples/battleship/move/build/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "move.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/battleship/move/inputs/move.in b/examples/battleship/move/inputs/move.in deleted file mode 100644 index d632154504..0000000000 --- a/examples/battleship/move/inputs/move.in +++ /dev/null @@ -1,4 +0,0 @@ -// The program input for move/src/main.leo -[main] -public a: u32 = 1u32; -b: u32 = 2u32; diff --git a/examples/battleship/move/leo.lock b/examples/battleship/move/leo.lock deleted file mode 100644 index c4293b3b9f..0000000000 --- a/examples/battleship/move/leo.lock +++ /dev/null @@ -1 +0,0 @@ -package = [] diff --git a/examples/battleship/move/program.json b/examples/battleship/move/program.json deleted file mode 100644 index b8acf29858..0000000000 --- a/examples/battleship/move/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "move.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/battleship/move/src/main.leo b/examples/battleship/move/src/main.leo deleted file mode 100644 index f9676435d0..0000000000 --- a/examples/battleship/move/src/main.leo +++ /dev/null @@ -1,46 +0,0 @@ -program move.aleo { - record move { - owner: address, - incoming_fire_coordinate: u64, - player_1: address, - player_2: address, - // One flipped bit indicates a hit. No flipped bits indicates a miss. - prev_hit_or_miss: u64, - } - - // Returns new move record owned by the opponent. - transition create_move( - // The move record created by the opponent. - move_record: move, - // The u64 representation of incoming_fire_coordinate, the bitstring fire coordinate to send to the opponent. - incoming_fire_coordinate: u64, - // The u64 representation of prev_hit_or_miss, this player's previous fire coordinate as a hit or miss. - prev_hit_or_miss: u64, - ) -> move { - // A new move record should be created and owned by the opponent. - let one_is_owner: bool = move_record.player_1 == move_record.owner; - let opponent: address = one_is_owner ? move_record.player_2 : move_record.player_1; - - return move { - owner: opponent, - incoming_fire_coordinate, - player_1: move_record.player_2, - player_2: move_record.player_1, - prev_hit_or_miss, - }; - } - - // Returns the move record owned by the opponent. - // Note, this move record contains dummy fire coordinates and previous hit or miss. - transition start_game(player_2: address) -> move { - return move { - owner: player_2, - incoming_fire_coordinate: 0u64, - player_1: self.caller, - player_2: player_2, - prev_hit_or_miss: 0u64, - }; - } -} - - diff --git a/examples/battleship/program.json b/examples/battleship/program.json deleted file mode 100644 index fe5a3d5e74..0000000000 --- a/examples/battleship/program.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "program": "battleship.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT", - "dependencies" : [ - { - "name": "board.aleo", - "location": "local", - "path": "board" - }, - { - "name": "move.aleo", - "location": "local", - "path": "move" - }, - { - "name": "verify.aleo", - "location": "local", - "path": "verify" - } - ] -} diff --git a/examples/battleship/run.sh b/examples/battleship/run.sh deleted file mode 100755 index f3998e574b..0000000000 --- a/examples/battleship/run.sh +++ /dev/null @@ -1,260 +0,0 @@ -#!/bin/bash -# First check that Leo is installed. -if ! command -v leo &> /dev/null -then - echo "leo is not installed." - exit -fi -# Follow along in the README.md for a detailed explanation of each step. - -# 1: Initializing Player 1 -echo " -############################################################################### -######## ######## -######## STEP 1: Initializing Player 1 ######## -######## ######## -############################################################################### -" - -echo " -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH -ENDPOINT=http://localhost:3030 -" > .env - -echo "✅ Successfully initialized Player 1." - -# 2: Player 1 Places Ships On The Board -echo " -############################################################################### -######## ######## -######## STEP 2: Player 1 Places Ships On The Board ######## -######## ######## -############################################################################### -" -leo run initialize_board 34084860461056u64 551911718912u64 7u64 1157425104234217472u64 aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px || exit - -echo " -✅ Successfully initialized Player 1's board." - -# 3: Player 1 Passes The Board To Player 2 -echo " -############################################################################### -######## ######## -######## STEP 3: Player 1 Passes The Board To Player 2 ######## -######## ######## -############################################################################### -" -leo run offer_battleship '{ - owner: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - hits_and_misses: 0u64.private, - played_tiles: 0u64.private, - ships: 1157459741006397447u64.private, - player_1: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - player_2: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - game_started: false.private, - _nonce: 3887646704618532506963887075433683846689834495661101507703164090915348189037group.public -}' || exit -echo " -✅ Successfully passed the board to Player 2." - -# 4: Player 2 Places Ships On The Board -echo " -############################################################################### -######## ######## -######## STEP 4: Player 2 Places Ships On The Board ######## -######## ######## -############################################################################### -" - -echo " -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh -ENDPOINT=http://localhost:3030 -" > .env - -leo run initialize_board 31u64 2207646875648u64 224u64 9042383626829824u64 aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t || exit - -echo " -✅ Successfully initialized Player 2's board." - -# 5: Passing The Board Back To Player 1 -echo " -############################################################################### -######## ######## -######## STEP 5: Passing The Board Back To Player 1 ######## -######## ######## -############################################################################### - -" -leo run start_battleship '{ - owner: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - hits_and_misses: 0u64.private, - played_tiles: 0u64.private, - ships: 9044591273705727u64.private, - player_1: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - player_2: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - game_started: false.private, - _nonce: 1549419609469324182591325047490602235361156298832591378925133482196483208807group.public -}' '{ - owner: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - incoming_fire_coordinate: 0u64.private, - player_1: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - player_2: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - prev_hit_or_miss: 0u64.private, - _nonce: 4374626042494973146987320062571809401151262172766172816829659487584978644457group.public -}' || exit -echo " -✅ Successfully passed the board back to Player 1." - -# 6: Player 1 Takes The 1st Turn -echo " -############################################################################### -######## ######## -######## STEP 6: Player 1 Takes The 1st Turn ######## -######## ######## -############################################################################### -" - -echo " -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH -ENDPOINT=http://localhost:3030 -" > .env - -leo run play '{ - owner: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - hits_and_misses: 0u64.private, - played_tiles: 0u64.private, - ships: 1157459741006397447u64.private, - player_1: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - player_2: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - game_started: true.private, - _nonce: 6563064852163330630334088854834332804417910882908622526775624018226782316843group.public -}' '{ - owner: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - incoming_fire_coordinate: 0u64.private, - player_1: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - player_2: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - prev_hit_or_miss: 0u64.private, - _nonce: 3742551407126138397717446975757978589064777004441277005584760115236217735495group.public -}' 1u64 || exit - -echo " -✅ Successfully executed Player 1's turn." - -# 7: Player 2 Takes The 2nd Turn -echo " -############################################################################### -######## ######## -######## STEP 7: Player 2 Takes The 2nd Turn ######## -######## ######## -############################################################################### -" - -echo " -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh -ENDPOINT=http://localhost:3030 -" > .env - -leo run play '{ - owner: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - hits_and_misses: 0u64.private, - played_tiles: 0u64.private, - ships: 9044591273705727u64.private, - player_1: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - player_2: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - game_started: true.private, - _nonce: 6222383571142756260765569201308836492199048237638652378826141459336360362251group.public -}' '{ - owner: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - incoming_fire_coordinate: 1u64.private, - player_1: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - player_2: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - prev_hit_or_miss: 0u64.private, - _nonce: 5481529266389297320813092061136936339861329677911328036818179854958874588416group.public -}' 2048u64 || exit - -echo " -✅ Successfully executed Player 2's turn." - -# 8: Player 1 Takes The 3rd Turn -echo " -############################################################################### -######## ######## -######## STEP 8: Player 1 Takes The 3rd Turn ######## -######## ######## -############################################################################### -" - -echo " -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH -ENDPOINT=http://localhost:3030 -" > .env - -leo run play '{ - owner: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - hits_and_misses: 0u64.private, - played_tiles: 1u64.private, - ships: 1157459741006397447u64.private, - player_1: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - player_2: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - game_started: true.private, - _nonce: 1474170213684980843727833284550698461565286563122422722760769547002894080093group.public -}' '{ - owner: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - incoming_fire_coordinate: 2048u64.private, - player_1: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - player_2: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - prev_hit_or_miss: 1u64.private, - _nonce: 5851606198769770675504009323414373017067582072428989801313256693053765675198group.public -}' 2u64 || exit - -echo " -✅ Successfully executed Player 1's turn." - -# 9: Player 2 Takes The 4th Turn -echo " -############################################################################### -######## ######## -######## STEP 9: Player 2 Takes The 4th Turn ######## -######## ######## -############################################################################### -" - -echo " -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh -ENDPOINT=http://localhost:3030 -" > .env - -leo run play '{ - owner: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - hits_and_misses: 0u64.private, - played_tiles: 2048u64.private, - ships: 9044591273705727u64.private, - player_1: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - player_2: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - game_started: true.private, - _nonce: 5254963165391133332409074172682159033621708071536429341861038147524454777097group.public -}' '{ - owner: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - incoming_fire_coordinate: 2u64.private, - player_1: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - player_2: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - prev_hit_or_miss: 0u64.private, - _nonce: 710336412388939616658264778971886770861024495941253598683184288448156545822group.public -}' 4u64 || exit - -echo " -✅ Successfully executed Player 2's turn." - - -# Restore the .env file to its original state -echo " -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH -ENDPOINT=http://localhost:3030 -" > .env diff --git a/examples/battleship/src/main.leo b/examples/battleship/src/main.leo deleted file mode 100644 index d6ffe01e7f..0000000000 --- a/examples/battleship/src/main.leo +++ /dev/null @@ -1,105 +0,0 @@ -import board.aleo; -import move.aleo; -import verify.aleo; - -// The 'battleship.aleo' program. -program battleship.aleo { - // Returns a new record representing a new game of battleship. - transition initialize_board( - // The u64 representation of a carrier's placement in an 8x8 grid. Length = 5. - carrier: u64, - // The u64 representation of a battleship's placement in an 8x8 grid. Length = 4. - battleship: u64, - // The u64 representation of a cruiser's placement in an 8x8 grid. Length = 3. - cruiser: u64, - // The u64 representation of a destroyer's placement in an 8x8 grid. Length = 2. - destroyer: u64, - // The address of the opponent. - player: address, - ) -> board.aleo/board_state { - // Verify that each individual ship placement bitstring is valid. - let valid_carrier: bool = verify.aleo/validate_ship(carrier, 5u64, 31u64, 4311810305u64); - assert(valid_carrier); - - let valid_battleship: bool = verify.aleo/validate_ship(battleship, 4u64, 15u64, 16843009u64); - assert(valid_battleship); - - let valid_cruiser: bool = verify.aleo/validate_ship(cruiser, 3u64, 7u64, 65793u64); - assert(valid_cruiser); - - let valid_destroyer: bool = verify.aleo/validate_ship(destroyer, 2u64, 3u64, 257u64); - assert(valid_destroyer); - - // Create the board with all the ship placements combined. - let board: u64 = verify.aleo/create_board(carrier, battleship, cruiser, destroyer); - - // Initialize the board state record. - let state: board.aleo/board_state = board.aleo/new_board_state(board, player); - - return state; - } - - // Returns an updated board state record that has been started. This board cannot be used to start any other games. - // Returns a dummy move record owned by the opponent. - // This function commits a given board to a game with an opponent and creates the initial dummy move. - transition offer_battleship( - // The board record to start a game with. - board: board.aleo/board_state, - ) -> (board.aleo/board_state, move.aleo/move) { - let state: board.aleo/board_state = board.aleo/start_board(board); - let dummy: move.aleo/move = move.aleo/start_game(board.player_2); - - return (state, dummy); - } - - // Returns updated board_state that has been started and can no longer be used to join or start new games. - // Returns dummy move record owned by the opponent. - transition start_battleship( - // The board record to play the game with. - board: board.aleo/board_state, - // The move record to play to begin the game. This should be the dummy move record created from offer_battleship. - move_start: move.aleo/move, - ) -> (board.aleo/board_state, move.aleo/move) { - // Validate that the move players and board players match each other. - assert_eq(board.player_1, move_start.player_2); - assert_eq(board.player_2, move_start.player_1); - - let state: board.aleo/board_state = board.aleo/start_board(board); - let dummy: move.aleo/move = move.aleo/start_game(board.player_2); - - return (state, dummy); - } - - // Returns updated board record. - // Returns new move record owned by opponent. - transition play( - // The board record to update. - board: board.aleo/board_state, - // The incoming move from the opponent. - move_incoming: move.aleo/move, - // The u64 equivalent of the bitwise representation of the next coordinate to play on the opponent's board. - shoot: u64, - ) -> (board.aleo/board_state, move.aleo/move) { - // Verify the board has been started. This prevents players from starting a game and then creating - // a brand new board to play with. - assert(board.game_started); - - // Validate that the move players and board players match each other. - assert_eq(board.player_1, move_incoming.player_2); - assert_eq(board.player_2, move_incoming.player_1); - - // Play coordinate on own board. Will fail if not a valid move. - let hit_or_miss: board.aleo/board_state = board.aleo/update_played_tiles(board, shoot); - - // Update own board with result of last shot. - let next_board: board.aleo/board_state = board.aleo/update_hits_and_misses(hit_or_miss, move_incoming.prev_hit_or_miss); - - // Assess whether incoming fire coordinate is a hit. - let is_hit: u64 = move_incoming.incoming_fire_coordinate & board.ships; - - let next_move: move.aleo/move = move.aleo/create_move(move_incoming, shoot, is_hit); - - return (next_board, next_move); - } -} - diff --git a/examples/battleship/verify/.gitignore b/examples/battleship/verify/.gitignore deleted file mode 100644 index f721f7f6f4..0000000000 --- a/examples/battleship/verify/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -.env -*.avm -*.prover -*.verifier -outputs/ diff --git a/examples/battleship/verify/README.md b/examples/battleship/verify/README.md deleted file mode 100644 index f5f2c6731e..0000000000 --- a/examples/battleship/verify/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# verify.aleo - -## Build Guide - -To compile this Aleo program, run: -```bash -snarkvm build -``` - -To execute this Aleo program, run: -```bash -snarkvm run hello -``` diff --git a/examples/battleship/verify/build/main.aleo b/examples/battleship/verify/build/main.aleo deleted file mode 100644 index 804dcf2a0e..0000000000 --- a/examples/battleship/verify/build/main.aleo +++ /dev/null @@ -1,73 +0,0 @@ -program verify.aleo; - - - -closure bitcount: - input r0 as u64; - div r0 2u64 into r1; - div r0 4u64 into r2; - div r0 8u64 into r3; - and r1 8608480567731124087u64 into r4; - and r2 3689348814741910323u64 into r5; - and r3 1229782938247303441u64 into r6; - sub r0 r4 into r7; - sub r7 r5 into r8; - sub r8 r6 into r9; - div r9 16u64 into r10; - add r9 r10 into r11; - and r11 1085102592571150095u64 into r12; - rem r12 255u64 into r13; - output r13 as u64; - - -closure adjacency_check: - input r0 as u64; - input r1 as u64; - div r0 r1 into r2; - is.eq r2 0u64 into r3; - ternary r3 3u64 r2 into r4; - sub r4 1u64 into r5; - and r5 r4 into r6; - is.eq r6 0u64 into r7; - output r7 as boolean; - - -closure horizontal_check: - input r0 as u64; - input r1 as u64; - rem r0 255u64 into r2; - div r2 r1 into r3; - is.eq r3 0u64 into r4; - ternary r4 3u64 r3 into r5; - sub r5 1u64 into r6; - and r6 r5 into r7; - is.eq r7 0u64 into r8; - output r8 as boolean; - - -function validate_ship: - input r0 as u64.private; - input r1 as u64.private; - input r2 as u64.private; - input r3 as u64.private; - call bitcount r0 into r4; - assert.eq r4 r1; - call adjacency_check r0 r2 into r5; - call horizontal_check r0 r2 into r6; - and r5 r6 into r7; - call adjacency_check r0 r3 into r8; - or r7 r8 into r9; - output r9 as boolean.private; - - -function create_board: - input r0 as u64.private; - input r1 as u64.private; - input r2 as u64.private; - input r3 as u64.private; - or r0 r1 into r4; - or r4 r2 into r5; - or r5 r3 into r6; - call bitcount r6 into r7; - assert.eq r7 14u64; - output r6 as u64.private; diff --git a/examples/battleship/verify/build/program.json b/examples/battleship/verify/build/program.json deleted file mode 100644 index b9b28db270..0000000000 --- a/examples/battleship/verify/build/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "verify.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/battleship/verify/inputs/verify.in b/examples/battleship/verify/inputs/verify.in deleted file mode 100644 index 0321a565c0..0000000000 --- a/examples/battleship/verify/inputs/verify.in +++ /dev/null @@ -1,4 +0,0 @@ -// The program input for verify/src/main.leo -[main] -public a: u32 = 1u32; -b: u32 = 2u32; diff --git a/examples/battleship/verify/leo.lock b/examples/battleship/verify/leo.lock deleted file mode 100644 index c4293b3b9f..0000000000 --- a/examples/battleship/verify/leo.lock +++ /dev/null @@ -1 +0,0 @@ -package = [] diff --git a/examples/battleship/verify/program.json b/examples/battleship/verify/program.json deleted file mode 100644 index b9b28db270..0000000000 --- a/examples/battleship/verify/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "verify.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/battleship/verify/src/main.leo b/examples/battleship/verify/src/main.leo deleted file mode 100644 index 336176bc39..0000000000 --- a/examples/battleship/verify/src/main.leo +++ /dev/null @@ -1,125 +0,0 @@ -program verify.aleo { - // Returns the number of flipped bits. - // E.g. 17870283321406128128u64, in binary 11111000 00000000 00000000 00000000 00000000 00000000 00000000 00000000, - // returns 5u64; - function bitcount(bits: u64) -> u64 { - let r1: u64 = bits / 2u64; - let r2: u64 = bits / 4u64; - let r3: u64 = bits / 8u64; - - let r4: u64 = r1 & 8608480567731124087u64; - let r5: u64 = r2 & 3689348814741910323u64; - let r6: u64 = r3 & 1229782938247303441u64; - - let r7: u64 = bits - r4 - r5 - r6; - - let r8: u64 = r7 / 16u64; - let r9: u64 = r7 + r8; - let r10: u64 = r9 & 1085102592571150095u64; - let r11: u64 = r10 % 255u64; - - return r11; - } - - // Returns boolean of whether all the flipped bits in location are "adjacent". Horizontally, this means all flipped bits are - // directly next to each other (111). Vertically, this means all flipped bits are separated by 7 unflipped bits - // (10000000100000001). - function adjacency_check( - // The u64 representation of a ship's placement in an 8x8 grid. - ship: u64, - // The u64 representation of a ship's bitstring, either horizontally or vertically. - // E.g. a ship of length 3's bit string horizontally would be: 000111 = 7u64. Vertically, the bit string would be: - // 10000000100000001 = 65793u64. - orientation: u64, - ) -> bool { - // This may result in 0. - let division: u64 = ship / orientation; - - // subtracting 1 from 0 will cause an underflow, so we should check for this edge case. - let is_eq: bool = division == 0u64; - - // if the above division resulted in 0, we know the adjacency check should return false. - // Setting to r4 to 3 (11) will guarantee failure here. - let ternary: u64 = is_eq ? 3u64 : division; - let subtraction: u64 = ternary - 1u64; - let and: u64 = subtraction & ternary; - - let bits_are_adjacent: bool = and == 0u64; - - return bits_are_adjacent; - } - - // Returns boolean of whether adjacent flipped bits don't split a row of size 8. - // E.g. 111000000 has adjacent flipped bits but splits a row: 00000001 11000000 - function horizontal_check( - // The u64 representation of a ship's placement in an 8x8 grid. - ship: u64, - // The u64 representation of a ship's bitstring horizontally. - horizontal: u64, - ) -> bool { - let remainder: u64 = ship % 255u64; - // This may result in 0. - let division: u64 = remainder / horizontal; - - // Subtracting 1 from 0 will cause an underflow. - let is_eq: bool = division == 0u64; - - // Setting to 3 will guarantee failure. - let ternary: u64 = is_eq ? 3u64 : division; - let subtraction: u64 = ternary - 1u64; - let and: u64 = subtraction & ternary; - - let bits_split_row: bool = and == 0u64; - - return bits_split_row; - } - - // Returns `true` if the ship placement is valid. - transition validate_ship( - // The u64 representation of a ship's placement in an 8x8 grid. - ship: u64, - // The length of the placed ship. - length: u64, - // The u64 equivalent of a ship's horizontal bitstring representation. - horizontal: u64, - // The u64 equivalent of a ship's vertical bitstring representation. - vertical: u64, - ) -> bool { - // Check bitcount -- all other validations depend on the bitcount being correct. - let num_bits: u64 = bitcount(ship); - assert_eq(num_bits, length); - - // Check horizontal bits of ship. - let is_adjacent: bool = adjacency_check(ship, horizontal); // True if bits are adjacent horizontally. - let is_horizontal: bool = horizontal_check(ship, horizontal); // True if those horizontal bits are not split across rows. - let valid_horizontal: bool = is_adjacent && is_horizontal; // True if bits are adjacent horizontally and not split across rows. - - // Check vertical bits of ship. - let valid_vertical: bool = adjacency_check(ship, vertical); // True if bits are adjacent vertically. - - let ship_is_valid: bool = valid_horizontal || valid_vertical; // Ship is valid if it is vertically or horizontally valid. - - return ship_is_valid; - } - - // Returns the u64 representation of all the ships' placements in an 8x8 grid. This function will fail - // if any of the ship placements overlap each other. - transition create_board( - // The u64 representation of a carrier's placement in an 8x8 grid. Length = 5. - carrier: u64, - // The u64 representation of a battleship's placement in an 8x8 grid. Length = 4. - battleship: u64, - // The u64 representation of a cruiser's placement in an 8x8 grid. Length = 3. - cruiser: u64, - // The u64 representation of a destroyer's placement in an 8x8 grid. Length = 2. - destroyer: u64, - ) -> u64 { - // Bitwise combine the ship placements together - let ships: u64 = carrier | battleship | cruiser | destroyer; - - let num_bits: u64 = bitcount(ships); - assert_eq(num_bits, 14u64); // Given 4 individually-valid ships, a valid combination should yield exactly 14 flipped bits. - - return ships; - } -} diff --git a/examples/bubblesort/.env b/examples/bubblesort/.env deleted file mode 100644 index ab204ee457..0000000000 --- a/examples/bubblesort/.env +++ /dev/null @@ -1,3 +0,0 @@ -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH -ENDPOINT=http://localhost:3030 diff --git a/examples/bubblesort/.gitignore b/examples/bubblesort/.gitignore deleted file mode 100644 index 74befa5ec9..0000000000 --- a/examples/bubblesort/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -outputs/ -*.prover -*.verifier \ No newline at end of file diff --git a/examples/bubblesort/README.md b/examples/bubblesort/README.md deleted file mode 100644 index 9fcbfbdde3..0000000000 --- a/examples/bubblesort/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# bubblesort - -## Run Guide - -To run this program, run: -```bash -leo run bubble_sort -``` - -## Execute Guide - -To execute this program, run: -```bash -leo execute bubble_sort -``` - -## Overview - -This example shows how to sort an array. - -It takes the input data from inputs/bubblesort.in diff --git a/examples/bubblesort/build/build/main.avm b/examples/bubblesort/build/build/main.avm deleted file mode 100644 index 8f1492528d..0000000000 Binary files a/examples/bubblesort/build/build/main.avm and /dev/null differ diff --git a/examples/bubblesort/build/main.aleo b/examples/bubblesort/build/main.aleo deleted file mode 100644 index 7e05ffaa2b..0000000000 --- a/examples/bubblesort/build/main.aleo +++ /dev/null @@ -1,105 +0,0 @@ -program bubblesort.aleo; - - - -function bubble_sort: - input r0 as u32.private; - input r1 as u32.private; - input r2 as u32.private; - input r3 as u32.private; - input r4 as u32.private; - input r5 as u32.private; - input r6 as u32.private; - input r7 as u32.private; - lt r1 r0 into r8; - ternary r8 r1 r0 into r9; - ternary r8 r0 r1 into r10; - lt r2 r10 into r11; - ternary r11 r2 r10 into r12; - ternary r11 r10 r2 into r13; - lt r3 r13 into r14; - ternary r14 r3 r13 into r15; - ternary r14 r13 r3 into r16; - lt r4 r16 into r17; - ternary r17 r4 r16 into r18; - ternary r17 r16 r4 into r19; - lt r5 r19 into r20; - ternary r20 r5 r19 into r21; - ternary r20 r19 r5 into r22; - lt r6 r22 into r23; - ternary r23 r6 r22 into r24; - ternary r23 r22 r6 into r25; - lt r7 r25 into r26; - ternary r26 r7 r25 into r27; - ternary r26 r25 r7 into r28; - lt r12 r9 into r29; - ternary r29 r12 r9 into r30; - ternary r29 r9 r12 into r31; - lt r15 r31 into r32; - ternary r32 r15 r31 into r33; - ternary r32 r31 r15 into r34; - lt r18 r34 into r35; - ternary r35 r18 r34 into r36; - ternary r35 r34 r18 into r37; - lt r21 r37 into r38; - ternary r38 r21 r37 into r39; - ternary r38 r37 r21 into r40; - lt r24 r40 into r41; - ternary r41 r24 r40 into r42; - ternary r41 r40 r24 into r43; - lt r27 r43 into r44; - ternary r44 r27 r43 into r45; - ternary r44 r43 r27 into r46; - lt r33 r30 into r47; - ternary r47 r33 r30 into r48; - ternary r47 r30 r33 into r49; - lt r36 r49 into r50; - ternary r50 r36 r49 into r51; - ternary r50 r49 r36 into r52; - lt r39 r52 into r53; - ternary r53 r39 r52 into r54; - ternary r53 r52 r39 into r55; - lt r42 r55 into r56; - ternary r56 r42 r55 into r57; - ternary r56 r55 r42 into r58; - lt r45 r58 into r59; - ternary r59 r45 r58 into r60; - ternary r59 r58 r45 into r61; - lt r51 r48 into r62; - ternary r62 r51 r48 into r63; - ternary r62 r48 r51 into r64; - lt r54 r64 into r65; - ternary r65 r54 r64 into r66; - ternary r65 r64 r54 into r67; - lt r57 r67 into r68; - ternary r68 r57 r67 into r69; - ternary r68 r67 r57 into r70; - lt r60 r70 into r71; - ternary r71 r60 r70 into r72; - ternary r71 r70 r60 into r73; - lt r66 r63 into r74; - ternary r74 r66 r63 into r75; - ternary r74 r63 r66 into r76; - lt r69 r76 into r77; - ternary r77 r69 r76 into r78; - ternary r77 r76 r69 into r79; - lt r72 r79 into r80; - ternary r80 r72 r79 into r81; - ternary r80 r79 r72 into r82; - lt r78 r75 into r83; - ternary r83 r78 r75 into r84; - ternary r83 r75 r78 into r85; - lt r81 r85 into r86; - ternary r86 r81 r85 into r87; - ternary r86 r85 r81 into r88; - lt r87 r84 into r89; - ternary r89 r87 r84 into r90; - ternary r89 r84 r87 into r91; - output r90 as u32.private; - output r91 as u32.private; - output r88 as u32.private; - output r82 as u32.private; - output r73 as u32.private; - output r61 as u32.private; - output r46 as u32.private; - output r28 as u32.private; diff --git a/examples/bubblesort/build/program.json b/examples/bubblesort/build/program.json deleted file mode 100644 index 6c04aa95ba..0000000000 --- a/examples/bubblesort/build/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "bubblesort.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} \ No newline at end of file diff --git a/examples/bubblesort/inputs/bubblesort.in b/examples/bubblesort/inputs/bubblesort.in deleted file mode 100644 index d0152c0bdd..0000000000 --- a/examples/bubblesort/inputs/bubblesort.in +++ /dev/null @@ -1 +0,0 @@ -13u32 2u32 4u32 3u32 5u32 10u32 7u32 1u32 diff --git a/examples/bubblesort/leo.lock b/examples/bubblesort/leo.lock deleted file mode 100644 index c4293b3b9f..0000000000 --- a/examples/bubblesort/leo.lock +++ /dev/null @@ -1 +0,0 @@ -package = [] diff --git a/examples/bubblesort/program.json b/examples/bubblesort/program.json deleted file mode 100644 index 6c04aa95ba..0000000000 --- a/examples/bubblesort/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "bubblesort.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} \ No newline at end of file diff --git a/examples/bubblesort/src/main.leo b/examples/bubblesort/src/main.leo deleted file mode 100644 index 05ca264c7f..0000000000 --- a/examples/bubblesort/src/main.leo +++ /dev/null @@ -1,287 +0,0 @@ -program bubblesort.aleo { - // Executes the bubble sorting algorithm. - // The original algorithm is given below. - // - // for i in 0..7 { - // for j in 0..7-i { - // // Move the smaller elements forward - // if arr[j+1] < arr[j] { - // // Swap the elements at indexes ‘j‘ and ‘j+1‘ - // let swap = arr[j]; - // arr[j] = arr[j+1]; - // arr[j+1] = swap; - // } - // } - // } - // - // Note that the implementation below uses tuples instead of arrays. - // The implementation also manually unrolls the loop. - - transition bubble_sort( - arr0: u32, - arr1: u32, - arr2: u32, - arr3: u32, - arr4: u32, - arr5: u32, - arr6: u32, - arr7: u32, - ) -> (u32, u32, u32, u32, u32, u32, u32, u32) { - - // Unroll the loops. - - // (i, j) = (0, 0). - // Move the smaller elements forward. - if arr1 < arr0 { - // Swap the elements at indexes ‘j‘ and ‘j+1‘ - let temp: u32 = arr0; - arr0 = arr1; - arr1 = temp; - } - - // (i, j) = (0, 1). - // Move the smaller elements forward. - if arr2 < arr1 { - // Swap the elements at indexes ‘j‘ and ‘j+1‘ - let temp: u32 = arr1; - arr1 = arr2; - arr2 = temp; - } - - // (i, j) = (0, 2). - // Move the smaller elements forward. - if arr3 < arr2 { - // Swap the elements at indexes ‘j‘ and ‘j+1‘ - let temp: u32 = arr2; - arr2 = arr3; - arr3 = temp; - } - - // (i, j) = (0, 3). - // Move the smaller elements forward. - if arr4 < arr3 { - // Swap the elements at indexes ‘j‘ and ‘j+1‘ - let temp: u32 = arr3; - arr3 = arr4; - arr4 = temp; - } - - // (i, j) = (0, 4). - // Move the smaller elements forward. - if arr5 < arr4 { - // Swap the elements at indexes ‘j‘ and ‘j+1‘ - let temp: u32 = arr4; - arr4 = arr5; - arr5 = temp; - } - - // (i, j) = (0, 5). - // Move the smaller elements forward. - if arr6 < arr5 { - // Swap the elements at indexes ‘j‘ and ‘j+1‘ - let temp: u32 = arr5; - arr5 = arr6; - arr6 = temp; - } - - // (i, j) = (0, 6). - // Move the smaller elements forward. - if arr7 < arr6 { - // Swap the elements at indexes ‘j‘ and ‘j+1‘ - let temp: u32 = arr6; - arr6 = arr7; - arr7 = temp; - } - - // (i, j) = (1, 0). - // Move the smaller elements forward. - if arr1 < arr0 { - // Swap the elements at indexes ‘j‘ and ‘j+1‘ - let temp: u32 = arr0; - arr0 = arr1; - arr1 = temp; - } - - // (i, j) = (1, 1). - // Move the smaller elements forward. - if arr2 < arr1 { - // Swap the elements at indexes ‘j‘ and ‘j+1‘ - let temp: u32 = arr1; - arr1 = arr2; - arr2 = temp; - } - - // (i, j) = (1, 2). - // Move the smaller elements forward. - if arr3 < arr2 { - // Swap the elements at indexes ‘j‘ and ‘j+1‘ - let temp: u32 = arr2; - arr2 = arr3; - arr3 = temp; - } - - // (i, j) = (1, 3). - // Move the smaller elements forward. - if arr4 < arr3 { - // Swap the elements at indexes ‘j‘ and ‘j+1‘ - let temp: u32 = arr3; - arr3 = arr4; - arr4 = temp; - } - - // (i, j) = (1, 4). - // Move the smaller elements forward. - if arr5 < arr4 { - // Swap the elements at indexes ‘j‘ and ‘j+1‘ - let temp: u32 = arr4; - arr4 = arr5; - arr5 = temp; - } - - // (i, j) = (1, 5). - // Move the smaller elements forward. - if arr6 < arr5 { - // Swap the elements at indexes ‘j‘ and ‘j+1‘ - let temp: u32 = arr5; - arr5 = arr6; - arr6 = temp; - } - - // (i, j) = (2, 0). - // Move the smaller elements forward. - if arr1 < arr0 { - // Swap the elements at indexes ‘j‘ and ‘j+1‘ - let temp: u32 = arr0; - arr0 = arr1; - arr1 = temp; - } - - // (i, j) = (2, 1). - // Move the smaller elements forward. - if arr2 < arr1 { - // Swap the elements at indexes ‘j‘ and ‘j+1‘ - let temp: u32 = arr1; - arr1 = arr2; - arr2 = temp; - } - - // (i, j) = (2, 2). - // Move the smaller elements forward. - if arr3 < arr2 { - // Swap the elements at indexes ‘j‘ and ‘j+1‘ - let temp: u32 = arr2; - arr2 = arr3; - arr3 = temp; - } - - // (i, j) = (2, 3). - // Move the smaller elements forward. - if arr4 < arr3 { - // Swap the elements at indexes ‘j‘ and ‘j+1‘ - let temp: u32 = arr3; - arr3 = arr4; - arr4 = temp; - } - - // (i, j) = (2, 4). - // Move the smaller elements forward. - if arr5 < arr4 { - // Swap the elements at indexes ‘j‘ and ‘j+1‘ - let temp: u32 = arr4; - arr4 = arr5; - arr5 = temp; - } - - // (i, j) = (3, 0). - // Move the smaller elements forward. - if arr1 < arr0 { - // Swap the elements at indexes ‘j‘ and ‘j+1‘ - let temp: u32 = arr0; - arr0 = arr1; - arr1 = temp; - } - - // (i, j) = (3, 1). - // Move the smaller elements forward. - if arr2 < arr1 { - // Swap the elements at indexes ‘j‘ and ‘j+1‘ - let temp: u32 = arr1; - arr1 = arr2; - arr2 = temp; - } - - // (i, j) = (3, 2). - // Move the smaller elements forward. - if arr3 < arr2 { - // Swap the elements at indexes ‘j‘ and ‘j+1‘ - let temp: u32 = arr2; - arr2 = arr3; - arr3 = temp; - } - - // (i, j) = (3, 3). - // Move the smaller elements forward. - if arr4 < arr3 { - // Swap the elements at indexes ‘j‘ and ‘j+1‘ - let temp: u32 = arr3; - arr3 = arr4; - arr4 = temp; - } - - // (i, j) = (4, 0). - // Move the smaller elements forward. - if arr1 < arr0 { - // Swap the elements at indexes ‘j‘ and ‘j+1‘ - let temp: u32 = arr0; - arr0 = arr1; - arr1 = temp; - } - - // (i, j) = (4, 1). - // Move the smaller elements forward. - if arr2 < arr1 { - // Swap the elements at indexes ‘j‘ and ‘j+1‘ - let temp: u32 = arr1; - arr1 = arr2; - arr2 = temp; - } - - // (i, j) = (4, 2). - // Move the smaller elements forward. - if arr3 < arr2 { - // Swap the elements at indexes ‘j‘ and ‘j+1‘ - let temp: u32 = arr2; - arr2 = arr3; - arr3 = temp; - } - - // (i, j) = (5, 0). - // Move the smaller elements forward. - if arr1 < arr0 { - // Swap the elements at indexes ‘j‘ and ‘j+1‘ - let temp: u32 = arr0; - arr0 = arr1; - arr1 = temp; - } - - // (i, j) = (5, 1). - // Move the smaller elements forward. - if arr2 < arr1 { - // Swap the elements at indexes ‘j‘ and ‘j+1‘ - let temp: u32 = arr1; - arr1 = arr2; - arr2 = temp; - } - - // (i, j) = (6, 0). - // Move the smaller elements forward. - if arr1 < arr0 { - // Swap the elements at indexes ‘j‘ and ‘j+1‘ - let temp: u32 = arr0; - arr0 = arr1; - arr1 = temp; - } - - return (arr0, arr1, arr2, arr3, arr4, arr5, arr6, arr7); - } -} diff --git a/examples/core/.env b/examples/core/.env deleted file mode 100644 index ab204ee457..0000000000 --- a/examples/core/.env +++ /dev/null @@ -1,3 +0,0 @@ -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH -ENDPOINT=http://localhost:3030 diff --git a/examples/core/.gitignore b/examples/core/.gitignore deleted file mode 100644 index 750b56f237..0000000000 --- a/examples/core/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -outputs/ -*.avm -*.prover -*.verifier \ No newline at end of file diff --git a/examples/core/README.md b/examples/core/README.md deleted file mode 100644 index 4053adb7d6..0000000000 --- a/examples/core/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Leo core functions - -## Run Guide - -To run this program, run: -```bash -leo run main -``` - -## Execute Guide - -To execute this program, run: -```bash -leo execute main -``` diff --git a/examples/core/build/main.aleo b/examples/core/build/main.aleo deleted file mode 100644 index c7c63279b5..0000000000 --- a/examples/core/build/main.aleo +++ /dev/null @@ -1,10 +0,0 @@ -program core.aleo; - - - -function main: - input r0 as field.private; - hash.bhp256 r0 into r1 as field; - hash.psd2 r1 into r2 as field; - commit.bhp256 r2 1scalar into r3 as field; - output r3 as field.private; diff --git a/examples/core/build/program.json b/examples/core/build/program.json deleted file mode 100644 index 228340bc22..0000000000 --- a/examples/core/build/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "core.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/core/inputs/core.in b/examples/core/inputs/core.in deleted file mode 100644 index 336793ee4e..0000000000 --- a/examples/core/inputs/core.in +++ /dev/null @@ -1,2 +0,0 @@ -1field - diff --git a/examples/core/leo.lock b/examples/core/leo.lock deleted file mode 100644 index c4293b3b9f..0000000000 --- a/examples/core/leo.lock +++ /dev/null @@ -1 +0,0 @@ -package = [] diff --git a/examples/core/program.json b/examples/core/program.json deleted file mode 100644 index 228340bc22..0000000000 --- a/examples/core/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "core.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/core/src/main.leo b/examples/core/src/main.leo deleted file mode 100644 index d1f21de0f3..0000000000 --- a/examples/core/src/main.leo +++ /dev/null @@ -1,13 +0,0 @@ -program core.aleo { - // This function takes as input a field `a` and calls several core functions. - // Core functions are built-in to the Leo language and call handwritten, optimized circuits in the AVM. - // To call a core function, use the correct capitalized identifier followed by two colons - // and then the function name. Example: `Pedersen64::hash_to_field()`. - transition main(a: field) -> field { - let b: field = BHP256::hash_to_field(a); - let c: field = Poseidon2::hash_to_field(b); - let d: field = BHP256::commit_to_field(c, 1scalar); - return d; - } -} - diff --git a/examples/fibonacci/.env b/examples/fibonacci/.env deleted file mode 100644 index ab204ee457..0000000000 --- a/examples/fibonacci/.env +++ /dev/null @@ -1,3 +0,0 @@ -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH -ENDPOINT=http://localhost:3030 diff --git a/examples/fibonacci/.gitignore b/examples/fibonacci/.gitignore deleted file mode 100644 index 750b56f237..0000000000 --- a/examples/fibonacci/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -outputs/ -*.avm -*.prover -*.verifier \ No newline at end of file diff --git a/examples/fibonacci/README.md b/examples/fibonacci/README.md deleted file mode 100644 index 04e07a7320..0000000000 --- a/examples/fibonacci/README.md +++ /dev/null @@ -1,20 +0,0 @@ -# fibonacci.aleo - -## Run Guide - -To run this program, run: -```bash -leo run fibonacci -``` - -## Execute Guide - -To execute this program, run: -```bash -leo execute fibonacci -``` - -## Overview -This example shows how to calculate Fibonacci number using the [fast-doubling method](https://math.stackexchange.com/questions/1124590/need-help-understanding-fibonacci-fast-doubling-proof). - -It takes the input data from `inputs/fibonacci.in` diff --git a/examples/fibonacci/inputs/fibonacci.in b/examples/fibonacci/inputs/fibonacci.in deleted file mode 100644 index 9ba1528650..0000000000 --- a/examples/fibonacci/inputs/fibonacci.in +++ /dev/null @@ -1 +0,0 @@ -63u8 diff --git a/examples/fibonacci/program.json b/examples/fibonacci/program.json deleted file mode 100644 index 8c56cc42ac..0000000000 --- a/examples/fibonacci/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "fibonacci.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/fibonacci/src/main.leo b/examples/fibonacci/src/main.leo deleted file mode 100644 index 0ada6a1217..0000000000 --- a/examples/fibonacci/src/main.leo +++ /dev/null @@ -1,48 +0,0 @@ -program fibonacci.aleo { - // This calculates the n-th fibonacci number (up to 64th) - transition fibonacci(public n: u8) -> u128 { - assert(n <= 64u8); - - let f0: u128 = 0u128; - let f1: u128 = 1u128; - let c: u8 = 0u8; - - let z: u8 = reverse_bits(n); - - for i:u8 in 0u8..8u8 { - if n > 0u8 { - let f2i1: u128 = f1 * f1 + f0 * f0; - let f2i: u128 = f0 * (2u128 * f1 - f0); - if z & 1u8.shl(c) == 0u8 { - f0 = f2i; - f1 = f2i1; - } else { - f0 = f2i1; - f1 = f2i + f2i1; - } - c = c + 1u8; - n = n >> 1u8; - } - } - - return f0; - } - - function reverse_bits(n: u8) -> u8 { - let reverse: u8 = 0u8; - - for i:u8 in 0u8..8u8 { - if n > 0u8 { - reverse = reverse << 1u8; - - if n & 1u8 == 1u8 { - reverse ^= 1u8; - } - - n = n >> 1u8; - } - } - - return reverse; - } -} diff --git a/examples/groups/.env b/examples/groups/.env deleted file mode 100644 index ab204ee457..0000000000 --- a/examples/groups/.env +++ /dev/null @@ -1,3 +0,0 @@ -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH -ENDPOINT=http://localhost:3030 diff --git a/examples/groups/.gitignore b/examples/groups/.gitignore deleted file mode 100644 index 750b56f237..0000000000 --- a/examples/groups/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -outputs/ -*.avm -*.prover -*.verifier \ No newline at end of file diff --git a/examples/groups/README.md b/examples/groups/README.md deleted file mode 100644 index 814d675dab..0000000000 --- a/examples/groups/README.md +++ /dev/null @@ -1,38 +0,0 @@ -# Leo group operations. - -## Run Guide - -To run this program, run: -```bash -leo run main -``` - -## Execute Guide - -To execute this program, run: -```bash -leo execute main -``` - -## Overview - -This example shows how to do basic operations over groups. - -It takes the input data from inputs/groups.in - - -## Documentation Group Element - -The set of affine points on the elliptic curve passed into the Leo compiler forms a group. -A subset of those points, defined by a chosen generator point, forms a subgroup of the group. -Leo supports the set of points in this subgroup as a primitive data type. -Group elements are special since their values can be defined as coordinate pairs ```(x, y)group```. -The `group` type keyword group must be used when specifying a pair of group coordinates since implicit syntax would collide with normal tuple `(a, b)` values. - -``` -let a = 0group; // the zero of the group - -let b = group::GEN; // the group generator - -let c = (0, 1)group; // coordinate notation -``` diff --git a/examples/groups/build/main.aleo b/examples/groups/build/main.aleo deleted file mode 100644 index d81be156ba..0000000000 --- a/examples/groups/build/main.aleo +++ /dev/null @@ -1,12 +0,0 @@ -program groups.aleo; - - - -function main: - input r0 as group.private; - double r0 into r1; - neg r1 into r2; - mul r0 2scalar into r3; - add r3 r2 into r4; - add r4 group::GEN into r5; - output r5 as group.private; diff --git a/examples/groups/build/program.json b/examples/groups/build/program.json deleted file mode 100644 index 800606f89a..0000000000 --- a/examples/groups/build/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "groups.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/groups/inputs/groups.in b/examples/groups/inputs/groups.in deleted file mode 100644 index 8fd3c23e6d..0000000000 --- a/examples/groups/inputs/groups.in +++ /dev/null @@ -1 +0,0 @@ -1817767092074430972953743941103352519057913259183777531581123188265134806220group diff --git a/examples/groups/leo.lock b/examples/groups/leo.lock deleted file mode 100644 index c4293b3b9f..0000000000 --- a/examples/groups/leo.lock +++ /dev/null @@ -1 +0,0 @@ -package = [] diff --git a/examples/groups/program.json b/examples/groups/program.json deleted file mode 100644 index 800606f89a..0000000000 --- a/examples/groups/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "groups.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/groups/src/main.leo b/examples/groups/src/main.leo deleted file mode 100644 index 02b277108a..0000000000 --- a/examples/groups/src/main.leo +++ /dev/null @@ -1,19 +0,0 @@ -program groups.aleo { - // This function takes a group coordinate as input `a` and performs several operations which should output the `0group`. - // Note that the operations can be called as associated functions on the `a` variable. - - transition main(a: group) -> group { - // unary - let b: group = a.double(); // 2a - let c: group = b.neg(); // -2a - - // binary - let d: group = (a * 2scalar).add(c); - - // generator - let e: group = group::GEN; - - return d + e; - } -} - diff --git a/examples/hackers-delight/README.md b/examples/hackers-delight/README.md deleted file mode 100644 index 7fba7d0439..0000000000 --- a/examples/hackers-delight/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Hacker's Delight - -This directory contains a number of algorithms for counting trailing zeros as described in "Hacker's Delight, 2nd edition" by Henry S. Warren. diff --git a/examples/hackers-delight/ntzdebruijn/.env b/examples/hackers-delight/ntzdebruijn/.env deleted file mode 100644 index ab204ee457..0000000000 --- a/examples/hackers-delight/ntzdebruijn/.env +++ /dev/null @@ -1,3 +0,0 @@ -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH -ENDPOINT=http://localhost:3030 diff --git a/examples/hackers-delight/ntzdebruijn/.gitignore b/examples/hackers-delight/ntzdebruijn/.gitignore deleted file mode 100644 index 750b56f237..0000000000 --- a/examples/hackers-delight/ntzdebruijn/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -outputs/ -*.avm -*.prover -*.verifier \ No newline at end of file diff --git a/examples/hackers-delight/ntzdebruijn/README.md b/examples/hackers-delight/ntzdebruijn/README.md deleted file mode 100644 index b147b3bf3b..0000000000 --- a/examples/hackers-delight/ntzdebruijn/README.md +++ /dev/null @@ -1,36 +0,0 @@ -# src/ntzdebruijn.leo - -## Build Guide - -To compile and run this Leo program, run: -```bash -leo run -``` - -## The Algorithm - -This algorithm is detailed in "Hacker's Delight, 2nd edition" -by Henry S. Warren, section 5-4, figure 5-26. Here is a summary. - -After handling the all-zeros case, -we isolate the rightmost `1` bit in the 32-bit input by -using the C idiom `x & (-x)`. In Leo, the `-x` is -written as `0u32.sub_wrapped(x)`. - -A constant was discovered with the property that when it was multiplied -by 1, 2, 4, ... 2**31, the 32 values all had different high 5-bit patterns. -This constant is `0x04D7651F`. - -In the algorithm, the 5 high bits are used as an index into the table -`{0, 1, 2, 24, 3, 19, ...}`. The table's values were chosen so that -they gave the correct number of trailing zeros for the inputs. - -For example, if the isolated bit has 4 trailing zeros, the number is 2**4. -The high 5 bits of `2**4 * 0x04D7651F` are `01001` which is 9. The table -value at index 9 is therefore 4. - -This algorithm was proposed by Danny Dubé in the comp.compression.research newsgroup: -https://groups.google.com/g/comp.compression.research/c/x0NaZ3CJ6O4/m/PfGuchA7o60J - -A description of de Bruijn cycles and their use for bit indexing can be seen -here: http://supertech.csail.mit.edu/papers/debruijn.pdf diff --git a/examples/hackers-delight/ntzdebruijn/build/main.aleo b/examples/hackers-delight/ntzdebruijn/build/main.aleo deleted file mode 100644 index 99d0722fdc..0000000000 --- a/examples/hackers-delight/ntzdebruijn/build/main.aleo +++ /dev/null @@ -1,1075 +0,0 @@ -program ntzdebruijn.aleo; - - - -closure deBruijnTableLookup: - input r0 as u32; - is.eq r0 0u32 into r1; - is.eq r0 1u32 into r2; - is.eq r0 2u32 into r3; - is.eq r0 3u32 into r4; - is.eq r0 4u32 into r5; - is.eq r0 5u32 into r6; - is.eq r0 6u32 into r7; - is.eq r0 7u32 into r8; - is.eq r0 8u32 into r9; - is.eq r0 9u32 into r10; - is.eq r0 10u32 into r11; - is.eq r0 11u32 into r12; - is.eq r0 12u32 into r13; - is.eq r0 13u32 into r14; - is.eq r0 14u32 into r15; - is.eq r0 15u32 into r16; - is.eq r0 16u32 into r17; - is.eq r0 17u32 into r18; - is.eq r0 18u32 into r19; - is.eq r0 19u32 into r20; - is.eq r0 20u32 into r21; - is.eq r0 21u32 into r22; - is.eq r0 22u32 into r23; - is.eq r0 23u32 into r24; - is.eq r0 24u32 into r25; - is.eq r0 25u32 into r26; - is.eq r0 26u32 into r27; - is.eq r0 27u32 into r28; - is.eq r0 28u32 into r29; - is.eq r0 29u32 into r30; - is.eq r0 30u32 into r31; - is.eq r0 31u32 into r32; - not r1 into r33; - not r2 into r34; - and r33 r34 into r35; - not r3 into r36; - and r35 r36 into r37; - not r4 into r38; - and r37 r38 into r39; - not r5 into r40; - and r39 r40 into r41; - not r6 into r42; - and r41 r42 into r43; - not r7 into r44; - and r43 r44 into r45; - not r8 into r46; - and r45 r46 into r47; - not r9 into r48; - and r47 r48 into r49; - not r10 into r50; - and r49 r50 into r51; - not r11 into r52; - and r51 r52 into r53; - not r12 into r54; - and r53 r54 into r55; - not r13 into r56; - and r55 r56 into r57; - not r14 into r58; - and r57 r58 into r59; - not r15 into r60; - and r59 r60 into r61; - not r16 into r62; - and r61 r62 into r63; - not r17 into r64; - and r63 r64 into r65; - not r18 into r66; - and r65 r66 into r67; - not r19 into r68; - and r67 r68 into r69; - not r20 into r70; - and r69 r70 into r71; - not r21 into r72; - and r71 r72 into r73; - not r22 into r74; - and r73 r74 into r75; - not r23 into r76; - and r75 r76 into r77; - not r24 into r78; - and r77 r78 into r79; - not r25 into r80; - and r79 r80 into r81; - not r26 into r82; - and r81 r82 into r83; - not r27 into r84; - and r83 r84 into r85; - not r28 into r86; - and r85 r86 into r87; - not r29 into r88; - and r87 r88 into r89; - not r30 into r90; - and r89 r90 into r91; - not r31 into r92; - and r91 r92 into r93; - and r93 r32 into r94; - ternary r94 27u8 0u8 into r95; - not r1 into r96; - not r2 into r97; - and r96 r97 into r98; - not r3 into r99; - and r98 r99 into r100; - not r4 into r101; - and r100 r101 into r102; - not r5 into r103; - and r102 r103 into r104; - not r6 into r105; - and r104 r105 into r106; - not r7 into r107; - and r106 r107 into r108; - not r8 into r109; - and r108 r109 into r110; - not r9 into r111; - and r110 r111 into r112; - not r10 into r113; - and r112 r113 into r114; - not r11 into r115; - and r114 r115 into r116; - not r12 into r117; - and r116 r117 into r118; - not r13 into r119; - and r118 r119 into r120; - not r14 into r121; - and r120 r121 into r122; - not r15 into r123; - and r122 r123 into r124; - not r16 into r125; - and r124 r125 into r126; - not r17 into r127; - and r126 r127 into r128; - not r18 into r129; - and r128 r129 into r130; - not r19 into r131; - and r130 r131 into r132; - not r20 into r133; - and r132 r133 into r134; - not r21 into r135; - and r134 r135 into r136; - not r22 into r137; - and r136 r137 into r138; - not r23 into r139; - and r138 r139 into r140; - not r24 into r141; - and r140 r141 into r142; - not r25 into r143; - and r142 r143 into r144; - not r26 into r145; - and r144 r145 into r146; - not r27 into r147; - and r146 r147 into r148; - not r28 into r149; - and r148 r149 into r150; - not r29 into r151; - and r150 r151 into r152; - not r30 into r153; - and r152 r153 into r154; - and r154 r31 into r155; - ternary r155 28u8 r95 into r156; - not r1 into r157; - not r2 into r158; - and r157 r158 into r159; - not r3 into r160; - and r159 r160 into r161; - not r4 into r162; - and r161 r162 into r163; - not r5 into r164; - and r163 r164 into r165; - not r6 into r166; - and r165 r166 into r167; - not r7 into r168; - and r167 r168 into r169; - not r8 into r170; - and r169 r170 into r171; - not r9 into r172; - and r171 r172 into r173; - not r10 into r174; - and r173 r174 into r175; - not r11 into r176; - and r175 r176 into r177; - not r12 into r178; - and r177 r178 into r179; - not r13 into r180; - and r179 r180 into r181; - not r14 into r182; - and r181 r182 into r183; - not r15 into r184; - and r183 r184 into r185; - not r16 into r186; - and r185 r186 into r187; - not r17 into r188; - and r187 r188 into r189; - not r18 into r190; - and r189 r190 into r191; - not r19 into r192; - and r191 r192 into r193; - not r20 into r194; - and r193 r194 into r195; - not r21 into r196; - and r195 r196 into r197; - not r22 into r198; - and r197 r198 into r199; - not r23 into r200; - and r199 r200 into r201; - not r24 into r202; - and r201 r202 into r203; - not r25 into r204; - and r203 r204 into r205; - not r26 into r206; - and r205 r206 into r207; - not r27 into r208; - and r207 r208 into r209; - not r28 into r210; - and r209 r210 into r211; - not r29 into r212; - and r211 r212 into r213; - and r213 r30 into r214; - ternary r214 13u8 r156 into r215; - not r1 into r216; - not r2 into r217; - and r216 r217 into r218; - not r3 into r219; - and r218 r219 into r220; - not r4 into r221; - and r220 r221 into r222; - not r5 into r223; - and r222 r223 into r224; - not r6 into r225; - and r224 r225 into r226; - not r7 into r227; - and r226 r227 into r228; - not r8 into r229; - and r228 r229 into r230; - not r9 into r231; - and r230 r231 into r232; - not r10 into r233; - and r232 r233 into r234; - not r11 into r235; - and r234 r235 into r236; - not r12 into r237; - and r236 r237 into r238; - not r13 into r239; - and r238 r239 into r240; - not r14 into r241; - and r240 r241 into r242; - not r15 into r243; - and r242 r243 into r244; - not r16 into r245; - and r244 r245 into r246; - not r17 into r247; - and r246 r247 into r248; - not r18 into r249; - and r248 r249 into r250; - not r19 into r251; - and r250 r251 into r252; - not r20 into r253; - and r252 r253 into r254; - not r21 into r255; - and r254 r255 into r256; - not r22 into r257; - and r256 r257 into r258; - not r23 into r259; - and r258 r259 into r260; - not r24 into r261; - and r260 r261 into r262; - not r25 into r263; - and r262 r263 into r264; - not r26 into r265; - and r264 r265 into r266; - not r27 into r267; - and r266 r267 into r268; - not r28 into r269; - and r268 r269 into r270; - and r270 r29 into r271; - ternary r271 29u8 r215 into r272; - not r1 into r273; - not r2 into r274; - and r273 r274 into r275; - not r3 into r276; - and r275 r276 into r277; - not r4 into r278; - and r277 r278 into r279; - not r5 into r280; - and r279 r280 into r281; - not r6 into r282; - and r281 r282 into r283; - not r7 into r284; - and r283 r284 into r285; - not r8 into r286; - and r285 r286 into r287; - not r9 into r288; - and r287 r288 into r289; - not r10 into r290; - and r289 r290 into r291; - not r11 into r292; - and r291 r292 into r293; - not r12 into r294; - and r293 r294 into r295; - not r13 into r296; - and r295 r296 into r297; - not r14 into r298; - and r297 r298 into r299; - not r15 into r300; - and r299 r300 into r301; - not r16 into r302; - and r301 r302 into r303; - not r17 into r304; - and r303 r304 into r305; - not r18 into r306; - and r305 r306 into r307; - not r19 into r308; - and r307 r308 into r309; - not r20 into r310; - and r309 r310 into r311; - not r21 into r312; - and r311 r312 into r313; - not r22 into r314; - and r313 r314 into r315; - not r23 into r316; - and r315 r316 into r317; - not r24 into r318; - and r317 r318 into r319; - not r25 into r320; - and r319 r320 into r321; - not r26 into r322; - and r321 r322 into r323; - not r27 into r324; - and r323 r324 into r325; - and r325 r28 into r326; - ternary r326 14u8 r272 into r327; - not r1 into r328; - not r2 into r329; - and r328 r329 into r330; - not r3 into r331; - and r330 r331 into r332; - not r4 into r333; - and r332 r333 into r334; - not r5 into r335; - and r334 r335 into r336; - not r6 into r337; - and r336 r337 into r338; - not r7 into r339; - and r338 r339 into r340; - not r8 into r341; - and r340 r341 into r342; - not r9 into r343; - and r342 r343 into r344; - not r10 into r345; - and r344 r345 into r346; - not r11 into r347; - and r346 r347 into r348; - not r12 into r349; - and r348 r349 into r350; - not r13 into r351; - and r350 r351 into r352; - not r14 into r353; - and r352 r353 into r354; - not r15 into r355; - and r354 r355 into r356; - not r16 into r357; - and r356 r357 into r358; - not r17 into r359; - and r358 r359 into r360; - not r18 into r361; - and r360 r361 into r362; - not r19 into r363; - and r362 r363 into r364; - not r20 into r365; - and r364 r365 into r366; - not r21 into r367; - and r366 r367 into r368; - not r22 into r369; - and r368 r369 into r370; - not r23 into r371; - and r370 r371 into r372; - not r24 into r373; - and r372 r373 into r374; - not r25 into r375; - and r374 r375 into r376; - not r26 into r377; - and r376 r377 into r378; - and r378 r27 into r379; - ternary r379 8u8 r327 into r380; - not r1 into r381; - not r2 into r382; - and r381 r382 into r383; - not r3 into r384; - and r383 r384 into r385; - not r4 into r386; - and r385 r386 into r387; - not r5 into r388; - and r387 r388 into r389; - not r6 into r390; - and r389 r390 into r391; - not r7 into r392; - and r391 r392 into r393; - not r8 into r394; - and r393 r394 into r395; - not r9 into r396; - and r395 r396 into r397; - not r10 into r398; - and r397 r398 into r399; - not r11 into r400; - and r399 r400 into r401; - not r12 into r402; - and r401 r402 into r403; - not r13 into r404; - and r403 r404 into r405; - not r14 into r406; - and r405 r406 into r407; - not r15 into r408; - and r407 r408 into r409; - not r16 into r410; - and r409 r410 into r411; - not r17 into r412; - and r411 r412 into r413; - not r18 into r414; - and r413 r414 into r415; - not r19 into r416; - and r415 r416 into r417; - not r20 into r418; - and r417 r418 into r419; - not r21 into r420; - and r419 r420 into r421; - not r22 into r422; - and r421 r422 into r423; - not r23 into r424; - and r423 r424 into r425; - not r24 into r426; - and r425 r426 into r427; - not r25 into r428; - and r427 r428 into r429; - and r429 r26 into r430; - ternary r430 17u8 r380 into r431; - not r1 into r432; - not r2 into r433; - and r432 r433 into r434; - not r3 into r435; - and r434 r435 into r436; - not r4 into r437; - and r436 r437 into r438; - not r5 into r439; - and r438 r439 into r440; - not r6 into r441; - and r440 r441 into r442; - not r7 into r443; - and r442 r443 into r444; - not r8 into r445; - and r444 r445 into r446; - not r9 into r447; - and r446 r447 into r448; - not r10 into r449; - and r448 r449 into r450; - not r11 into r451; - and r450 r451 into r452; - not r12 into r453; - and r452 r453 into r454; - not r13 into r455; - and r454 r455 into r456; - not r14 into r457; - and r456 r457 into r458; - not r15 into r459; - and r458 r459 into r460; - not r16 into r461; - and r460 r461 into r462; - not r17 into r463; - and r462 r463 into r464; - not r18 into r465; - and r464 r465 into r466; - not r19 into r467; - and r466 r467 into r468; - not r20 into r469; - and r468 r469 into r470; - not r21 into r471; - and r470 r471 into r472; - not r22 into r473; - and r472 r473 into r474; - not r23 into r475; - and r474 r475 into r476; - not r24 into r477; - and r476 r477 into r478; - and r478 r25 into r479; - ternary r479 30u8 r431 into r480; - not r1 into r481; - not r2 into r482; - and r481 r482 into r483; - not r3 into r484; - and r483 r484 into r485; - not r4 into r486; - and r485 r486 into r487; - not r5 into r488; - and r487 r488 into r489; - not r6 into r490; - and r489 r490 into r491; - not r7 into r492; - and r491 r492 into r493; - not r8 into r494; - and r493 r494 into r495; - not r9 into r496; - and r495 r496 into r497; - not r10 into r498; - and r497 r498 into r499; - not r11 into r500; - and r499 r500 into r501; - not r12 into r502; - and r501 r502 into r503; - not r13 into r504; - and r503 r504 into r505; - not r14 into r506; - and r505 r506 into r507; - not r15 into r508; - and r507 r508 into r509; - not r16 into r510; - and r509 r510 into r511; - not r17 into r512; - and r511 r512 into r513; - not r18 into r514; - and r513 r514 into r515; - not r19 into r516; - and r515 r516 into r517; - not r20 into r518; - and r517 r518 into r519; - not r21 into r520; - and r519 r520 into r521; - not r22 into r522; - and r521 r522 into r523; - not r23 into r524; - and r523 r524 into r525; - and r525 r24 into r526; - ternary r526 11u8 r480 into r527; - not r1 into r528; - not r2 into r529; - and r528 r529 into r530; - not r3 into r531; - and r530 r531 into r532; - not r4 into r533; - and r532 r533 into r534; - not r5 into r535; - and r534 r535 into r536; - not r6 into r537; - and r536 r537 into r538; - not r7 into r539; - and r538 r539 into r540; - not r8 into r541; - and r540 r541 into r542; - not r9 into r543; - and r542 r543 into r544; - not r10 into r545; - and r544 r545 into r546; - not r11 into r547; - and r546 r547 into r548; - not r12 into r549; - and r548 r549 into r550; - not r13 into r551; - and r550 r551 into r552; - not r14 into r553; - and r552 r553 into r554; - not r15 into r555; - and r554 r555 into r556; - not r16 into r557; - and r556 r557 into r558; - not r17 into r559; - and r558 r559 into r560; - not r18 into r561; - and r560 r561 into r562; - not r19 into r563; - and r562 r563 into r564; - not r20 into r565; - and r564 r565 into r566; - not r21 into r567; - and r566 r567 into r568; - not r22 into r569; - and r568 r569 into r570; - and r570 r23 into r571; - ternary r571 15u8 r527 into r572; - not r1 into r573; - not r2 into r574; - and r573 r574 into r575; - not r3 into r576; - and r575 r576 into r577; - not r4 into r578; - and r577 r578 into r579; - not r5 into r580; - and r579 r580 into r581; - not r6 into r582; - and r581 r582 into r583; - not r7 into r584; - and r583 r584 into r585; - not r8 into r586; - and r585 r586 into r587; - not r9 into r588; - and r587 r588 into r589; - not r10 into r590; - and r589 r590 into r591; - not r11 into r592; - and r591 r592 into r593; - not r12 into r594; - and r593 r594 into r595; - not r13 into r596; - and r595 r596 into r597; - not r14 into r598; - and r597 r598 into r599; - not r15 into r600; - and r599 r600 into r601; - not r16 into r602; - and r601 r602 into r603; - not r17 into r604; - and r603 r604 into r605; - not r18 into r606; - and r605 r606 into r607; - not r19 into r608; - and r607 r608 into r609; - not r20 into r610; - and r609 r610 into r611; - not r21 into r612; - and r611 r612 into r613; - and r613 r22 into r614; - ternary r614 9u8 r572 into r615; - not r1 into r616; - not r2 into r617; - and r616 r617 into r618; - not r3 into r619; - and r618 r619 into r620; - not r4 into r621; - and r620 r621 into r622; - not r5 into r623; - and r622 r623 into r624; - not r6 into r625; - and r624 r625 into r626; - not r7 into r627; - and r626 r627 into r628; - not r8 into r629; - and r628 r629 into r630; - not r9 into r631; - and r630 r631 into r632; - not r10 into r633; - and r632 r633 into r634; - not r11 into r635; - and r634 r635 into r636; - not r12 into r637; - and r636 r637 into r638; - not r13 into r639; - and r638 r639 into r640; - not r14 into r641; - and r640 r641 into r642; - not r15 into r643; - and r642 r643 into r644; - not r16 into r645; - and r644 r645 into r646; - not r17 into r647; - and r646 r647 into r648; - not r18 into r649; - and r648 r649 into r650; - not r19 into r651; - and r650 r651 into r652; - not r20 into r653; - and r652 r653 into r654; - and r654 r21 into r655; - ternary r655 21u8 r615 into r656; - not r1 into r657; - not r2 into r658; - and r657 r658 into r659; - not r3 into r660; - and r659 r660 into r661; - not r4 into r662; - and r661 r662 into r663; - not r5 into r664; - and r663 r664 into r665; - not r6 into r666; - and r665 r666 into r667; - not r7 into r668; - and r667 r668 into r669; - not r8 into r670; - and r669 r670 into r671; - not r9 into r672; - and r671 r672 into r673; - not r10 into r674; - and r673 r674 into r675; - not r11 into r676; - and r675 r676 into r677; - not r12 into r678; - and r677 r678 into r679; - not r13 into r680; - and r679 r680 into r681; - not r14 into r682; - and r681 r682 into r683; - not r15 into r684; - and r683 r684 into r685; - not r16 into r686; - and r685 r686 into r687; - not r17 into r688; - and r687 r688 into r689; - not r18 into r690; - and r689 r690 into r691; - not r19 into r692; - and r691 r692 into r693; - and r693 r20 into r694; - ternary r694 5u8 r656 into r695; - not r1 into r696; - not r2 into r697; - and r696 r697 into r698; - not r3 into r699; - and r698 r699 into r700; - not r4 into r701; - and r700 r701 into r702; - not r5 into r703; - and r702 r703 into r704; - not r6 into r705; - and r704 r705 into r706; - not r7 into r707; - and r706 r707 into r708; - not r8 into r709; - and r708 r709 into r710; - not r9 into r711; - and r710 r711 into r712; - not r10 into r713; - and r712 r713 into r714; - not r11 into r715; - and r714 r715 into r716; - not r12 into r717; - and r716 r717 into r718; - not r13 into r719; - and r718 r719 into r720; - not r14 into r721; - and r720 r721 into r722; - not r15 into r723; - and r722 r723 into r724; - not r16 into r725; - and r724 r725 into r726; - not r17 into r727; - and r726 r727 into r728; - not r18 into r729; - and r728 r729 into r730; - and r730 r19 into r731; - ternary r731 18u8 r695 into r732; - not r1 into r733; - not r2 into r734; - and r733 r734 into r735; - not r3 into r736; - and r735 r736 into r737; - not r4 into r738; - and r737 r738 into r739; - not r5 into r740; - and r739 r740 into r741; - not r6 into r742; - and r741 r742 into r743; - not r7 into r744; - and r743 r744 into r745; - not r8 into r746; - and r745 r746 into r747; - not r9 into r748; - and r747 r748 into r749; - not r10 into r750; - and r749 r750 into r751; - not r11 into r752; - and r751 r752 into r753; - not r12 into r754; - and r753 r754 into r755; - not r13 into r756; - and r755 r756 into r757; - not r14 into r758; - and r757 r758 into r759; - not r15 into r760; - and r759 r760 into r761; - not r16 into r762; - and r761 r762 into r763; - not r17 into r764; - and r763 r764 into r765; - and r765 r18 into r766; - ternary r766 23u8 r732 into r767; - not r1 into r768; - not r2 into r769; - and r768 r769 into r770; - not r3 into r771; - and r770 r771 into r772; - not r4 into r773; - and r772 r773 into r774; - not r5 into r775; - and r774 r775 into r776; - not r6 into r777; - and r776 r777 into r778; - not r7 into r779; - and r778 r779 into r780; - not r8 into r781; - and r780 r781 into r782; - not r9 into r783; - and r782 r783 into r784; - not r10 into r785; - and r784 r785 into r786; - not r11 into r787; - and r786 r787 into r788; - not r12 into r789; - and r788 r789 into r790; - not r13 into r791; - and r790 r791 into r792; - not r14 into r793; - and r792 r793 into r794; - not r15 into r795; - and r794 r795 into r796; - not r16 into r797; - and r796 r797 into r798; - and r798 r17 into r799; - ternary r799 31u8 r767 into r800; - not r1 into r801; - not r2 into r802; - and r801 r802 into r803; - not r3 into r804; - and r803 r804 into r805; - not r4 into r806; - and r805 r806 into r807; - not r5 into r808; - and r807 r808 into r809; - not r6 into r810; - and r809 r810 into r811; - not r7 into r812; - and r811 r812 into r813; - not r8 into r814; - and r813 r814 into r815; - not r9 into r816; - and r815 r816 into r817; - not r10 into r818; - and r817 r818 into r819; - not r11 into r820; - and r819 r820 into r821; - not r12 into r822; - and r821 r822 into r823; - not r13 into r824; - and r823 r824 into r825; - not r14 into r826; - and r825 r826 into r827; - not r15 into r828; - and r827 r828 into r829; - and r829 r16 into r830; - ternary r830 26u8 r800 into r831; - not r1 into r832; - not r2 into r833; - and r832 r833 into r834; - not r3 into r835; - and r834 r835 into r836; - not r4 into r837; - and r836 r837 into r838; - not r5 into r839; - and r838 r839 into r840; - not r6 into r841; - and r840 r841 into r842; - not r7 into r843; - and r842 r843 into r844; - not r8 into r845; - and r844 r845 into r846; - not r9 into r847; - and r846 r847 into r848; - not r10 into r849; - and r848 r849 into r850; - not r11 into r851; - and r850 r851 into r852; - not r12 into r853; - and r852 r853 into r854; - not r13 into r855; - and r854 r855 into r856; - not r14 into r857; - and r856 r857 into r858; - and r858 r15 into r859; - ternary r859 12u8 r831 into r860; - not r1 into r861; - not r2 into r862; - and r861 r862 into r863; - not r3 into r864; - and r863 r864 into r865; - not r4 into r866; - and r865 r866 into r867; - not r5 into r868; - and r867 r868 into r869; - not r6 into r870; - and r869 r870 into r871; - not r7 into r872; - and r871 r872 into r873; - not r8 into r874; - and r873 r874 into r875; - not r9 into r876; - and r875 r876 into r877; - not r10 into r878; - and r877 r878 into r879; - not r11 into r880; - and r879 r880 into r881; - not r12 into r882; - and r881 r882 into r883; - not r13 into r884; - and r883 r884 into r885; - and r885 r14 into r886; - ternary r886 7u8 r860 into r887; - not r1 into r888; - not r2 into r889; - and r888 r889 into r890; - not r3 into r891; - and r890 r891 into r892; - not r4 into r893; - and r892 r893 into r894; - not r5 into r895; - and r894 r895 into r896; - not r6 into r897; - and r896 r897 into r898; - not r7 into r899; - and r898 r899 into r900; - not r8 into r901; - and r900 r901 into r902; - not r9 into r903; - and r902 r903 into r904; - not r10 into r905; - and r904 r905 into r906; - not r11 into r907; - and r906 r907 into r908; - not r12 into r909; - and r908 r909 into r910; - and r910 r13 into r911; - ternary r911 16u8 r887 into r912; - not r1 into r913; - not r2 into r914; - and r913 r914 into r915; - not r3 into r916; - and r915 r916 into r917; - not r4 into r918; - and r917 r918 into r919; - not r5 into r920; - and r919 r920 into r921; - not r6 into r922; - and r921 r922 into r923; - not r7 into r924; - and r923 r924 into r925; - not r8 into r926; - and r925 r926 into r927; - not r9 into r928; - and r927 r928 into r929; - not r10 into r930; - and r929 r930 into r931; - not r11 into r932; - and r931 r932 into r933; - and r933 r12 into r934; - ternary r934 10u8 r912 into r935; - not r1 into r936; - not r2 into r937; - and r936 r937 into r938; - not r3 into r939; - and r938 r939 into r940; - not r4 into r941; - and r940 r941 into r942; - not r5 into r943; - and r942 r943 into r944; - not r6 into r945; - and r944 r945 into r946; - not r7 into r947; - and r946 r947 into r948; - not r8 into r949; - and r948 r949 into r950; - not r9 into r951; - and r950 r951 into r952; - not r10 into r953; - and r952 r953 into r954; - and r954 r11 into r955; - ternary r955 20u8 r935 into r956; - not r1 into r957; - not r2 into r958; - and r957 r958 into r959; - not r3 into r960; - and r959 r960 into r961; - not r4 into r962; - and r961 r962 into r963; - not r5 into r964; - and r963 r964 into r965; - not r6 into r966; - and r965 r966 into r967; - not r7 into r968; - and r967 r968 into r969; - not r8 into r970; - and r969 r970 into r971; - not r9 into r972; - and r971 r972 into r973; - and r973 r10 into r974; - ternary r974 4u8 r956 into r975; - not r1 into r976; - not r2 into r977; - and r976 r977 into r978; - not r3 into r979; - and r978 r979 into r980; - not r4 into r981; - and r980 r981 into r982; - not r5 into r983; - and r982 r983 into r984; - not r6 into r985; - and r984 r985 into r986; - not r7 into r987; - and r986 r987 into r988; - not r8 into r989; - and r988 r989 into r990; - and r990 r9 into r991; - ternary r991 22u8 r975 into r992; - not r1 into r993; - not r2 into r994; - and r993 r994 into r995; - not r3 into r996; - and r995 r996 into r997; - not r4 into r998; - and r997 r998 into r999; - not r5 into r1000; - and r999 r1000 into r1001; - not r6 into r1002; - and r1001 r1002 into r1003; - not r7 into r1004; - and r1003 r1004 into r1005; - and r1005 r8 into r1006; - ternary r1006 25u8 r992 into r1007; - not r1 into r1008; - not r2 into r1009; - and r1008 r1009 into r1010; - not r3 into r1011; - and r1010 r1011 into r1012; - not r4 into r1013; - and r1012 r1013 into r1014; - not r5 into r1015; - and r1014 r1015 into r1016; - not r6 into r1017; - and r1016 r1017 into r1018; - and r1018 r7 into r1019; - ternary r1019 6u8 r1007 into r1020; - not r1 into r1021; - not r2 into r1022; - and r1021 r1022 into r1023; - not r3 into r1024; - and r1023 r1024 into r1025; - not r4 into r1026; - and r1025 r1026 into r1027; - not r5 into r1028; - and r1027 r1028 into r1029; - and r1029 r6 into r1030; - ternary r1030 19u8 r1020 into r1031; - not r1 into r1032; - not r2 into r1033; - and r1032 r1033 into r1034; - not r3 into r1035; - and r1034 r1035 into r1036; - not r4 into r1037; - and r1036 r1037 into r1038; - and r1038 r5 into r1039; - ternary r1039 3u8 r1031 into r1040; - not r1 into r1041; - not r2 into r1042; - and r1041 r1042 into r1043; - not r3 into r1044; - and r1043 r1044 into r1045; - and r1045 r4 into r1046; - ternary r1046 24u8 r1040 into r1047; - not r1 into r1048; - not r2 into r1049; - and r1048 r1049 into r1050; - and r1050 r3 into r1051; - ternary r1051 2u8 r1047 into r1052; - not r1 into r1053; - and r1053 r2 into r1054; - ternary r1054 1u8 r1052 into r1055; - ternary r1 0u8 r1055 into r1056; - output r1056 as u8; - - -function main: - input r0 as u32.public; - is.eq r0 0u32 into r1; - sub.w 0u32 r0 into r2; - and r0 r2 into r3; - mul.w r3 81224991u32 into r4; - shr r4 27u8 into r5; - call deBruijnTableLookup r5 into r6; - ternary r1 32u8 r6 into r7; - output r7 as u8.private; diff --git a/examples/hackers-delight/ntzdebruijn/build/program.json b/examples/hackers-delight/ntzdebruijn/build/program.json deleted file mode 100644 index 796eeafef9..0000000000 --- a/examples/hackers-delight/ntzdebruijn/build/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "ntzdebruijn.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/hackers-delight/ntzdebruijn/inputs/ntzdebruijn.in b/examples/hackers-delight/ntzdebruijn/inputs/ntzdebruijn.in deleted file mode 100644 index b140da3eb3..0000000000 --- a/examples/hackers-delight/ntzdebruijn/inputs/ntzdebruijn.in +++ /dev/null @@ -1 +0,0 @@ -2147483648u32 diff --git a/examples/hackers-delight/ntzdebruijn/leo.lock b/examples/hackers-delight/ntzdebruijn/leo.lock deleted file mode 100644 index c4293b3b9f..0000000000 --- a/examples/hackers-delight/ntzdebruijn/leo.lock +++ /dev/null @@ -1 +0,0 @@ -package = [] diff --git a/examples/hackers-delight/ntzdebruijn/program.json b/examples/hackers-delight/ntzdebruijn/program.json deleted file mode 100644 index 796eeafef9..0000000000 --- a/examples/hackers-delight/ntzdebruijn/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "ntzdebruijn.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/hackers-delight/ntzdebruijn/src/main.leo b/examples/hackers-delight/ntzdebruijn/src/main.leo deleted file mode 100644 index 4b7a748940..0000000000 --- a/examples/hackers-delight/ntzdebruijn/src/main.leo +++ /dev/null @@ -1,54 +0,0 @@ -program ntzdebruijn.aleo { - // The 'ntzdebruijn' main function. - // From Hacker's Delight 2nd ed. figure 5-26 - transition main(public x: u32) -> u8 { - if x == 0u32 {return 32u8;} - // 0x04D7651F = 81224991 - x = (x & 0u32.sub_wrapped(x)).mul_wrapped(81224991u32); - let i: u32 = x >> 27u8; - return deBruijnTableLookup(i); - } - - // { 0, 1, 2,24, 3,19, 6,25, 22, 4,20,10,16, 7,12,26, - // 31,23,18, 5,21, 9,15,11, 30,17, 8,14,29,13,28,27}; - - function deBruijnTableLookup(i: u32) -> u8 { - - if i == 0u32 {return 0u8;} else - if i == 1u32 {return 1u8;} else - if i == 2u32 {return 2u8;} else - if i == 3u32 {return 24u8;} else - if i == 4u32 {return 3u8;} else - if i == 5u32 {return 19u8;} else - if i == 6u32 {return 6u8;} else - if i == 7u32 {return 25u8;} else - - if i == 8u32 {return 22u8;} else - if i == 9u32 {return 4u8;} else - if i == 10u32 {return 20u8;} else - if i == 11u32 {return 10u8;} else - if i == 12u32 {return 16u8;} else - if i == 13u32 {return 7u8;} else - if i == 14u32 {return 12u8;} else - if i == 15u32 {return 26u8;} else - - if i == 16u32 {return 31u8;} else - if i == 17u32 {return 23u8;} else - if i == 18u32 {return 18u8;} else - if i == 19u32 {return 5u8;} else - if i == 20u32 {return 21u8;} else - if i == 21u32 {return 9u8;} else - if i == 22u32 {return 15u8;} else - if i == 23u32 {return 11u8;} else - - if i == 24u32 {return 30u8;} else - if i == 25u32 {return 17u8;} else - if i == 26u32 {return 8u8;} else - if i == 27u32 {return 14u8;} else - if i == 28u32 {return 29u8;} else - if i == 29u32 {return 13u8;} else - if i == 30u32 {return 28u8;} else - if i == 31u32 {return 27u8;} else - {return 0u8;} // unused - } -} diff --git a/examples/hackers-delight/ntzgaudet/.env b/examples/hackers-delight/ntzgaudet/.env deleted file mode 100644 index ab204ee457..0000000000 --- a/examples/hackers-delight/ntzgaudet/.env +++ /dev/null @@ -1,3 +0,0 @@ -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH -ENDPOINT=http://localhost:3030 diff --git a/examples/hackers-delight/ntzgaudet/.gitignore b/examples/hackers-delight/ntzgaudet/.gitignore deleted file mode 100644 index 750b56f237..0000000000 --- a/examples/hackers-delight/ntzgaudet/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -outputs/ -*.avm -*.prover -*.verifier \ No newline at end of file diff --git a/examples/hackers-delight/ntzgaudet/README.md b/examples/hackers-delight/ntzgaudet/README.md deleted file mode 100644 index cf7f2c2438..0000000000 --- a/examples/hackers-delight/ntzgaudet/README.md +++ /dev/null @@ -1,32 +0,0 @@ -# src/ntzgaudet.leo - -## Build Guide - -To compile and run this Leo program, run: -```bash -leo run -``` - -## The Algorithm - -This algorithm is described in "Hacker's Delight, 2nd edition" by Henry -S. Warren, section 5-4, section 5-24, as interesting due to being branch-free, -not using table lookups, and having parallelism. It is attributed to Dean Gaudet -in private communication to Henry S. Warren. - -First we isolate the rightmost `1` bit in the 32-bit input by -using the C idiom `x & (-x)`. In Leo, the `-x` is -written as `0u32.sub_wrapped(x)`. The result is stored in `y`. - -Then we compute six intermediate variables that count different numbers -of trailing zeros. The first variable, `bz`, just counts 1 if `y` is completely zero. - -To get the other five variables, we do binary search in parallel, using 5 masks, -each looking at a different symmetric pattern of 16 bits. For example, `b4` counts 16 if -the low 16 bits are zero and counts zero otherwise. Then `b3` uses a mask `y & -0x00FF00FF` to count eight 0-bits if the result is zero and zero 0-bits -otherwise. The masks for `b2`, `b1`, and `b0` can count four, two, and -one 0-bits similarly. - -The variables `bz, b4, .., b0` are all independent, and their values are added up -for the result. diff --git a/examples/hackers-delight/ntzgaudet/build/main.aleo b/examples/hackers-delight/ntzgaudet/build/main.aleo deleted file mode 100644 index 5d48412823..0000000000 --- a/examples/hackers-delight/ntzgaudet/build/main.aleo +++ /dev/null @@ -1,31 +0,0 @@ -program ntzgaudet.aleo; - - - -function main: - input r0 as u32.public; - sub.w 0u32 r0 into r1; - and r0 r1 into r2; - is.neq r2 0u32 into r3; - ternary r3 0u8 1u8 into r4; - and r2 65535u32 into r5; - is.neq r5 0u32 into r6; - ternary r6 0u8 16u8 into r7; - and r2 16711935u32 into r8; - is.neq r8 0u32 into r9; - ternary r9 0u8 8u8 into r10; - and r2 252645135u32 into r11; - is.neq r11 0u32 into r12; - ternary r12 0u8 4u8 into r13; - and r2 858993459u32 into r14; - is.neq r14 0u32 into r15; - ternary r15 0u8 2u8 into r16; - and r2 1431655765u32 into r17; - is.neq r17 0u32 into r18; - ternary r18 0u8 1u8 into r19; - add r4 r7 into r20; - add r20 r10 into r21; - add r21 r13 into r22; - add r22 r16 into r23; - add r23 r19 into r24; - output r24 as u8.private; diff --git a/examples/hackers-delight/ntzgaudet/build/program.json b/examples/hackers-delight/ntzgaudet/build/program.json deleted file mode 100644 index 505dd22947..0000000000 --- a/examples/hackers-delight/ntzgaudet/build/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "ntzgaudet.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/hackers-delight/ntzgaudet/inputs/ntzgaudet.in b/examples/hackers-delight/ntzgaudet/inputs/ntzgaudet.in deleted file mode 100644 index b140da3eb3..0000000000 --- a/examples/hackers-delight/ntzgaudet/inputs/ntzgaudet.in +++ /dev/null @@ -1 +0,0 @@ -2147483648u32 diff --git a/examples/hackers-delight/ntzgaudet/leo.lock b/examples/hackers-delight/ntzgaudet/leo.lock deleted file mode 100644 index c4293b3b9f..0000000000 --- a/examples/hackers-delight/ntzgaudet/leo.lock +++ /dev/null @@ -1 +0,0 @@ -package = [] diff --git a/examples/hackers-delight/ntzgaudet/program.json b/examples/hackers-delight/ntzgaudet/program.json deleted file mode 100644 index 505dd22947..0000000000 --- a/examples/hackers-delight/ntzgaudet/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "ntzgaudet.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/hackers-delight/ntzgaudet/src/main.leo b/examples/hackers-delight/ntzgaudet/src/main.leo deleted file mode 100644 index d8171aa4df..0000000000 --- a/examples/hackers-delight/ntzgaudet/src/main.leo +++ /dev/null @@ -1,19 +0,0 @@ -program ntzgaudet.aleo { - // The 'ntzgaudet' main function. - // From Hacker's Delight 2nd ed. figure 5-24 - transition main(public x: u32) -> u8 { - let y: u32 = x & 0u32.sub_wrapped(x); // Isolate rightmost 1-bit - let bz: u8 = (y != 0u32) ? 0u8 : 1u8; - // 0x0000FFFF = 65535 - let b4: u8 = (y & 65535u32 != 0u32) ? 0u8 : 16u8; - // 0x00FF00FF = 16711935 - let b3: u8 = (y & 16711935u32 != 0u32) ? 0u8 : 8u8; - // 0x0F0F0F0F = 252645135 - let b2: u8 = (y & 252645135u32 != 0u32) ? 0u8 : 4u8; - // 0x33333333 = 858993459 - let b1: u8 = (y & 858993459u32 != 0u32) ? 0u8 : 2u8; - // 0x55555555 = 1431655765 - let b0: u8 = (y & 1431655765u32 != 0u32) ? 0u8 : 1u8; - return bz + b4 + b3 + b2 + b1 + b0; - } -} diff --git a/examples/hackers-delight/ntzloops/.env b/examples/hackers-delight/ntzloops/.env deleted file mode 100644 index ab204ee457..0000000000 --- a/examples/hackers-delight/ntzloops/.env +++ /dev/null @@ -1,3 +0,0 @@ -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH -ENDPOINT=http://localhost:3030 diff --git a/examples/hackers-delight/ntzloops/.gitignore b/examples/hackers-delight/ntzloops/.gitignore deleted file mode 100644 index 750b56f237..0000000000 --- a/examples/hackers-delight/ntzloops/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -outputs/ -*.avm -*.prover -*.verifier \ No newline at end of file diff --git a/examples/hackers-delight/ntzloops/README.md b/examples/hackers-delight/ntzloops/README.md deleted file mode 100644 index dace1ddf94..0000000000 --- a/examples/hackers-delight/ntzloops/README.md +++ /dev/null @@ -1,31 +0,0 @@ -# src/ntzloops.leo - -## Build Guide - -To compile and run this Leo program, run: -```bash -leo run -``` - -## The Algorithm - -This algorithm is described in "Hacker's Delight, 2nd edition" -by Henry S. Warren, section 5-4, figure 5-23, as a simple loop -for counting number of trailing zeros that is fast (on traditional architectures) -when the number of trailing zeros is small. In that same figure, in the end-of-line -comments, there is code for an analogous simple loop that is fast when the number -of trailing zeros is large. - -We start out by using the C idiom `~x & (x - 1)` to create a word with 1-bits -at the positions of the trailing zeros in `x` and 0-bits elsewhere. -If there are no trailing zeros in `x`, the formula returns zero. This idiom is -expressed in Leo as `!x & x.sub_wrapped(1u32);`. - -Then we simply count the 1-bits by right shifting until `x` is zero and -counting the number of shifts using the variable `n`. - -To get the effect of a while loop in Leo, one must use a `for` loop with the -enough iterations to accommodate all possible inputs, and then check the -while condition within the for loop. Once the condition is false, the -loop continues until finished but the `if` statement inside the loop prevents -any further operations. diff --git a/examples/hackers-delight/ntzloops/build/main.aleo b/examples/hackers-delight/ntzloops/build/main.aleo deleted file mode 100644 index 70a377e564..0000000000 --- a/examples/hackers-delight/ntzloops/build/main.aleo +++ /dev/null @@ -1,170 +0,0 @@ -program ntzloops.aleo; - - - -function main: - input r0 as u32.public; - not r0 into r1; - sub.w r0 1u32 into r2; - and r1 r2 into r3; - is.neq r3 0u32 into r4; - add 0u8 1u8 into r5; - shr r3 1u8 into r6; - ternary r4 r5 0u8 into r7; - ternary r4 r6 r3 into r8; - is.neq r8 0u32 into r9; - add r7 1u8 into r10; - shr r8 1u8 into r11; - ternary r9 r10 r7 into r12; - ternary r9 r11 r8 into r13; - is.neq r13 0u32 into r14; - add r12 1u8 into r15; - shr r13 1u8 into r16; - ternary r14 r15 r12 into r17; - ternary r14 r16 r13 into r18; - is.neq r18 0u32 into r19; - add r17 1u8 into r20; - shr r18 1u8 into r21; - ternary r19 r20 r17 into r22; - ternary r19 r21 r18 into r23; - is.neq r23 0u32 into r24; - add r22 1u8 into r25; - shr r23 1u8 into r26; - ternary r24 r25 r22 into r27; - ternary r24 r26 r23 into r28; - is.neq r28 0u32 into r29; - add r27 1u8 into r30; - shr r28 1u8 into r31; - ternary r29 r30 r27 into r32; - ternary r29 r31 r28 into r33; - is.neq r33 0u32 into r34; - add r32 1u8 into r35; - shr r33 1u8 into r36; - ternary r34 r35 r32 into r37; - ternary r34 r36 r33 into r38; - is.neq r38 0u32 into r39; - add r37 1u8 into r40; - shr r38 1u8 into r41; - ternary r39 r40 r37 into r42; - ternary r39 r41 r38 into r43; - is.neq r43 0u32 into r44; - add r42 1u8 into r45; - shr r43 1u8 into r46; - ternary r44 r45 r42 into r47; - ternary r44 r46 r43 into r48; - is.neq r48 0u32 into r49; - add r47 1u8 into r50; - shr r48 1u8 into r51; - ternary r49 r50 r47 into r52; - ternary r49 r51 r48 into r53; - is.neq r53 0u32 into r54; - add r52 1u8 into r55; - shr r53 1u8 into r56; - ternary r54 r55 r52 into r57; - ternary r54 r56 r53 into r58; - is.neq r58 0u32 into r59; - add r57 1u8 into r60; - shr r58 1u8 into r61; - ternary r59 r60 r57 into r62; - ternary r59 r61 r58 into r63; - is.neq r63 0u32 into r64; - add r62 1u8 into r65; - shr r63 1u8 into r66; - ternary r64 r65 r62 into r67; - ternary r64 r66 r63 into r68; - is.neq r68 0u32 into r69; - add r67 1u8 into r70; - shr r68 1u8 into r71; - ternary r69 r70 r67 into r72; - ternary r69 r71 r68 into r73; - is.neq r73 0u32 into r74; - add r72 1u8 into r75; - shr r73 1u8 into r76; - ternary r74 r75 r72 into r77; - ternary r74 r76 r73 into r78; - is.neq r78 0u32 into r79; - add r77 1u8 into r80; - shr r78 1u8 into r81; - ternary r79 r80 r77 into r82; - ternary r79 r81 r78 into r83; - is.neq r83 0u32 into r84; - add r82 1u8 into r85; - shr r83 1u8 into r86; - ternary r84 r85 r82 into r87; - ternary r84 r86 r83 into r88; - is.neq r88 0u32 into r89; - add r87 1u8 into r90; - shr r88 1u8 into r91; - ternary r89 r90 r87 into r92; - ternary r89 r91 r88 into r93; - is.neq r93 0u32 into r94; - add r92 1u8 into r95; - shr r93 1u8 into r96; - ternary r94 r95 r92 into r97; - ternary r94 r96 r93 into r98; - is.neq r98 0u32 into r99; - add r97 1u8 into r100; - shr r98 1u8 into r101; - ternary r99 r100 r97 into r102; - ternary r99 r101 r98 into r103; - is.neq r103 0u32 into r104; - add r102 1u8 into r105; - shr r103 1u8 into r106; - ternary r104 r105 r102 into r107; - ternary r104 r106 r103 into r108; - is.neq r108 0u32 into r109; - add r107 1u8 into r110; - shr r108 1u8 into r111; - ternary r109 r110 r107 into r112; - ternary r109 r111 r108 into r113; - is.neq r113 0u32 into r114; - add r112 1u8 into r115; - shr r113 1u8 into r116; - ternary r114 r115 r112 into r117; - ternary r114 r116 r113 into r118; - is.neq r118 0u32 into r119; - add r117 1u8 into r120; - shr r118 1u8 into r121; - ternary r119 r120 r117 into r122; - ternary r119 r121 r118 into r123; - is.neq r123 0u32 into r124; - add r122 1u8 into r125; - shr r123 1u8 into r126; - ternary r124 r125 r122 into r127; - ternary r124 r126 r123 into r128; - is.neq r128 0u32 into r129; - add r127 1u8 into r130; - shr r128 1u8 into r131; - ternary r129 r130 r127 into r132; - ternary r129 r131 r128 into r133; - is.neq r133 0u32 into r134; - add r132 1u8 into r135; - shr r133 1u8 into r136; - ternary r134 r135 r132 into r137; - ternary r134 r136 r133 into r138; - is.neq r138 0u32 into r139; - add r137 1u8 into r140; - shr r138 1u8 into r141; - ternary r139 r140 r137 into r142; - ternary r139 r141 r138 into r143; - is.neq r143 0u32 into r144; - add r142 1u8 into r145; - shr r143 1u8 into r146; - ternary r144 r145 r142 into r147; - ternary r144 r146 r143 into r148; - is.neq r148 0u32 into r149; - add r147 1u8 into r150; - shr r148 1u8 into r151; - ternary r149 r150 r147 into r152; - ternary r149 r151 r148 into r153; - is.neq r153 0u32 into r154; - add r152 1u8 into r155; - shr r153 1u8 into r156; - ternary r154 r155 r152 into r157; - ternary r154 r156 r153 into r158; - is.neq r158 0u32 into r159; - add r157 1u8 into r160; - shr r158 1u8 into r161; - ternary r159 r160 r157 into r162; - ternary r159 r161 r158 into r163; - output r162 as u8.private; diff --git a/examples/hackers-delight/ntzloops/build/program.json b/examples/hackers-delight/ntzloops/build/program.json deleted file mode 100644 index 056efb4693..0000000000 --- a/examples/hackers-delight/ntzloops/build/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "ntzloops.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/hackers-delight/ntzloops/inputs/ntzloops.in b/examples/hackers-delight/ntzloops/inputs/ntzloops.in deleted file mode 100644 index b140da3eb3..0000000000 --- a/examples/hackers-delight/ntzloops/inputs/ntzloops.in +++ /dev/null @@ -1 +0,0 @@ -2147483648u32 diff --git a/examples/hackers-delight/ntzloops/leo.lock b/examples/hackers-delight/ntzloops/leo.lock deleted file mode 100644 index c4293b3b9f..0000000000 --- a/examples/hackers-delight/ntzloops/leo.lock +++ /dev/null @@ -1 +0,0 @@ -package = [] diff --git a/examples/hackers-delight/ntzloops/program.json b/examples/hackers-delight/ntzloops/program.json deleted file mode 100644 index 056efb4693..0000000000 --- a/examples/hackers-delight/ntzloops/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "ntzloops.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/hackers-delight/ntzloops/src/main.leo b/examples/hackers-delight/ntzloops/src/main.leo deleted file mode 100644 index abd28774c4..0000000000 --- a/examples/hackers-delight/ntzloops/src/main.leo +++ /dev/null @@ -1,15 +0,0 @@ -program ntzloops.aleo { - // The 'ntzloops' main function. - // From Hacker's Delight 2nd ed. figure 5-23 - transition main(public x: u32) -> u8 { - x = !x & x.sub_wrapped(1u32); - let n: u8 = 0u8; - for i:u8 in 0u8..32u8 { - if x != 0u32 { - n += 1u8; - x = x >> 1u8; - } - } - return n; - } -} diff --git a/examples/hackers-delight/ntzmasks/.env b/examples/hackers-delight/ntzmasks/.env deleted file mode 100644 index ab204ee457..0000000000 --- a/examples/hackers-delight/ntzmasks/.env +++ /dev/null @@ -1,3 +0,0 @@ -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH -ENDPOINT=http://localhost:3030 diff --git a/examples/hackers-delight/ntzmasks/.gitignore b/examples/hackers-delight/ntzmasks/.gitignore deleted file mode 100644 index 750b56f237..0000000000 --- a/examples/hackers-delight/ntzmasks/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -outputs/ -*.avm -*.prover -*.verifier \ No newline at end of file diff --git a/examples/hackers-delight/ntzmasks/README.md b/examples/hackers-delight/ntzmasks/README.md deleted file mode 100644 index 2987cda3ea..0000000000 --- a/examples/hackers-delight/ntzmasks/README.md +++ /dev/null @@ -1,44 +0,0 @@ -# src/ntzmasks.leo - -## Build Guide - -To compile and run this Leo program, run: -```bash -leo run -``` - -## The Algorithm - -This algorithm is mentioned in "Hacker's Delight, 2nd edition" -by Henry S. Warren, section 5-4, figure 5-20. - -It starts out by handling the all-zeros case. -Then `n` is initialized to `1` for the sole reason of saving an instruction at the end. -This means during the main body `n` is one more than the number -of trailing zeros so far detected. - -The main body does a simple binary search of the 32-bit input for the -rightmost `1` bit. The first check looks at the 16 bits -of the right half (low order) bits. The condition -``` -((x & 65535u32) == 0u32) -``` -is true if the lower 16 bits are zero, in which case there -are at least 16 trailing zeros, added to `n`, -and `x` is shifted down by 16 bits to get ready for the next check. -If the first condition was false, we know -there is a `1` bit in the lower 16, so -we do not add anything to `n` and we do not shift `x`. - -The second condition checks the lower 8 bits of the new `x`, -which are either the 17-to-24 lowest bits or the 8 lowest bits, -depending on whether the first statement shifted by 16 or not, -respectively. If the second condition is true, we add -8 to the number of trailing zeros found so far, and shift right -by 8 bits. If the second condition is false, we go on to -the third condition. - -This search is repeated two more times, accumulating the number -of trailing zeros (plus one). The final return either keeps -the extra `1` bit by returning `n` if the final rightmost bit is 0, -or subtracts it from `n` if the final rightmost bit is `1`. diff --git a/examples/hackers-delight/ntzmasks/build/main.aleo b/examples/hackers-delight/ntzmasks/build/main.aleo deleted file mode 100644 index 26e4c6b07d..0000000000 --- a/examples/hackers-delight/ntzmasks/build/main.aleo +++ /dev/null @@ -1,37 +0,0 @@ -program ntzmasks.aleo; - - - -function main: - input r0 as u32.public; - is.eq r0 0u32 into r1; - and r0 65535u32 into r2; - is.eq r2 0u32 into r3; - add 1u8 16u8 into r4; - shr r0 16u8 into r5; - ternary r3 r4 1u8 into r6; - ternary r3 r5 r0 into r7; - and r7 255u32 into r8; - is.eq r8 0u32 into r9; - add r6 8u8 into r10; - shr r7 8u8 into r11; - ternary r9 r10 r6 into r12; - ternary r9 r11 r7 into r13; - and r13 15u32 into r14; - is.eq r14 0u32 into r15; - add r12 4u8 into r16; - shr r13 4u8 into r17; - ternary r15 r16 r12 into r18; - ternary r15 r17 r13 into r19; - and r19 3u32 into r20; - is.eq r20 0u32 into r21; - add r18 2u8 into r22; - shr r19 2u8 into r23; - ternary r21 r22 r18 into r24; - ternary r21 r23 r19 into r25; - and r25 1u32 into r26; - is.eq r26 1u32 into r27; - sub r24 1u8 into r28; - ternary r27 r28 r24 into r29; - ternary r1 32u8 r29 into r30; - output r30 as u8.private; diff --git a/examples/hackers-delight/ntzmasks/build/program.json b/examples/hackers-delight/ntzmasks/build/program.json deleted file mode 100644 index 2a9855a387..0000000000 --- a/examples/hackers-delight/ntzmasks/build/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "ntzmasks.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/hackers-delight/ntzmasks/inputs/ntzmasks.in b/examples/hackers-delight/ntzmasks/inputs/ntzmasks.in deleted file mode 100644 index 8a4354d07d..0000000000 --- a/examples/hackers-delight/ntzmasks/inputs/ntzmasks.in +++ /dev/null @@ -1 +0,0 @@ -1073741824u32 diff --git a/examples/hackers-delight/ntzmasks/leo.lock b/examples/hackers-delight/ntzmasks/leo.lock deleted file mode 100644 index c4293b3b9f..0000000000 --- a/examples/hackers-delight/ntzmasks/leo.lock +++ /dev/null @@ -1 +0,0 @@ -package = [] diff --git a/examples/hackers-delight/ntzmasks/program.json b/examples/hackers-delight/ntzmasks/program.json deleted file mode 100644 index 2a9855a387..0000000000 --- a/examples/hackers-delight/ntzmasks/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "ntzmasks.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/hackers-delight/ntzmasks/src/main.leo b/examples/hackers-delight/ntzmasks/src/main.leo deleted file mode 100644 index 16dc4122c9..0000000000 --- a/examples/hackers-delight/ntzmasks/src/main.leo +++ /dev/null @@ -1,17 +0,0 @@ -program ntzmasks.aleo { - // The 'ntzmasks' main function. - // From Hacker's Delight 2nd ed. figure 5-20 - transition main(public x: u32) -> u8 { - if (x == 0u32) {return 32u8;} - let n: u8 = 1u8; - // x >>= 16u8 wasn't working, and I don't want to use - // to u32 as a shift operand, so I do x = x >> 16u8 - if ((x & 65535u32) == 0u32) {n += 16u8; x = x >> 16u8;} - if ((x & 255u32) == 0u32) {n += 8u8; x = x >> 8u8;} - if ((x & 15u32) == 0u32) {n += 4u8; x = x >> 4u8;} - if ((x & 3u32) == 0u32) {n += 2u8; x = x >> 2u8;} - // can't do `return n - (x & 1u32);` because no typecasts, so: - if ((x & 1u32) == 1u32) {n -= 1u8;} - return n; - } -} diff --git a/examples/hackers-delight/ntzreisers/.env b/examples/hackers-delight/ntzreisers/.env deleted file mode 100644 index ab204ee457..0000000000 --- a/examples/hackers-delight/ntzreisers/.env +++ /dev/null @@ -1,3 +0,0 @@ -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH -ENDPOINT=http://localhost:3030 diff --git a/examples/hackers-delight/ntzreisers/.gitignore b/examples/hackers-delight/ntzreisers/.gitignore deleted file mode 100644 index 750b56f237..0000000000 --- a/examples/hackers-delight/ntzreisers/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -outputs/ -*.avm -*.prover -*.verifier \ No newline at end of file diff --git a/examples/hackers-delight/ntzreisers/README.md b/examples/hackers-delight/ntzreisers/README.md deleted file mode 100644 index 54af2b5d5d..0000000000 --- a/examples/hackers-delight/ntzreisers/README.md +++ /dev/null @@ -1,29 +0,0 @@ -# src/ntzreisers.leo - -## Build Guide - -To compile and run this Leo program, run: -```bash -leo run -``` - -## The Algorithm - -This algorithm is detailed in "Hacker's Delight, 2nd edition" -by Henry S. Warren, section 5-4, figure 5-27. - -First we isolate the rightmost `1` bit in the 32-bit input by -using the C idiom `x & (-x)`. In Leo, the `-x` is -written as `0u32.sub_wrapped(x)`. - -The smallest constant was found that has the property that when it was used to -divide the 33 arguments 0, 1, 2, ..., 2**31, the remainder is different for -each argument. This constant is 37. - -In the algorithm, the remainder is used as an index into a table of size 37, -with 4 entries unused. The table's values were chosen so that they give the -correct number of trailing zeros for the inputs. - -This algorithm was proposed by John Reiser in the comp.arch.arithmetic newsgroup -on December 11, 1998: -https://groups.google.com/g/comp.arch.arithmetic/c/yBt-QHRVEGE/m/QcQ75P6tmJ4J diff --git a/examples/hackers-delight/ntzreisers/build/main.aleo b/examples/hackers-delight/ntzreisers/build/main.aleo deleted file mode 100644 index e49ab7597d..0000000000 --- a/examples/hackers-delight/ntzreisers/build/main.aleo +++ /dev/null @@ -1,1422 +0,0 @@ -program ntzreisers.aleo; - - - -closure reisersTableLookup: - input r0 as u32; - is.eq r0 0u32 into r1; - is.eq r0 1u32 into r2; - is.eq r0 2u32 into r3; - is.eq r0 3u32 into r4; - is.eq r0 4u32 into r5; - is.eq r0 5u32 into r6; - is.eq r0 6u32 into r7; - is.eq r0 7u32 into r8; - is.eq r0 8u32 into r9; - is.eq r0 9u32 into r10; - is.eq r0 10u32 into r11; - is.eq r0 11u32 into r12; - is.eq r0 12u32 into r13; - is.eq r0 13u32 into r14; - is.eq r0 14u32 into r15; - is.eq r0 15u32 into r16; - is.eq r0 16u32 into r17; - is.eq r0 17u32 into r18; - is.eq r0 18u32 into r19; - is.eq r0 19u32 into r20; - is.eq r0 20u32 into r21; - is.eq r0 21u32 into r22; - is.eq r0 22u32 into r23; - is.eq r0 23u32 into r24; - is.eq r0 24u32 into r25; - is.eq r0 25u32 into r26; - is.eq r0 26u32 into r27; - is.eq r0 27u32 into r28; - is.eq r0 28u32 into r29; - is.eq r0 29u32 into r30; - is.eq r0 30u32 into r31; - is.eq r0 31u32 into r32; - is.eq r0 32u32 into r33; - is.eq r0 33u32 into r34; - is.eq r0 34u32 into r35; - is.eq r0 35u32 into r36; - is.eq r0 36u32 into r37; - not r1 into r38; - not r2 into r39; - and r38 r39 into r40; - not r3 into r41; - and r40 r41 into r42; - not r4 into r43; - and r42 r43 into r44; - not r5 into r45; - and r44 r45 into r46; - not r6 into r47; - and r46 r47 into r48; - not r7 into r49; - and r48 r49 into r50; - not r8 into r51; - and r50 r51 into r52; - not r9 into r53; - and r52 r53 into r54; - not r10 into r55; - and r54 r55 into r56; - not r11 into r57; - and r56 r57 into r58; - not r12 into r59; - and r58 r59 into r60; - not r13 into r61; - and r60 r61 into r62; - not r14 into r63; - and r62 r63 into r64; - not r15 into r65; - and r64 r65 into r66; - not r16 into r67; - and r66 r67 into r68; - not r17 into r69; - and r68 r69 into r70; - not r18 into r71; - and r70 r71 into r72; - not r19 into r73; - and r72 r73 into r74; - not r20 into r75; - and r74 r75 into r76; - not r21 into r77; - and r76 r77 into r78; - not r22 into r79; - and r78 r79 into r80; - not r23 into r81; - and r80 r81 into r82; - not r24 into r83; - and r82 r83 into r84; - not r25 into r85; - and r84 r85 into r86; - not r26 into r87; - and r86 r87 into r88; - not r27 into r89; - and r88 r89 into r90; - not r28 into r91; - and r90 r91 into r92; - not r29 into r93; - and r92 r93 into r94; - not r30 into r95; - and r94 r95 into r96; - not r31 into r97; - and r96 r97 into r98; - not r32 into r99; - and r98 r99 into r100; - not r33 into r101; - and r100 r101 into r102; - not r34 into r103; - and r102 r103 into r104; - not r35 into r105; - and r104 r105 into r106; - not r36 into r107; - and r106 r107 into r108; - and r108 r37 into r109; - ternary r109 18u8 0u8 into r110; - not r1 into r111; - not r2 into r112; - and r111 r112 into r113; - not r3 into r114; - and r113 r114 into r115; - not r4 into r116; - and r115 r116 into r117; - not r5 into r118; - and r117 r118 into r119; - not r6 into r120; - and r119 r120 into r121; - not r7 into r122; - and r121 r122 into r123; - not r8 into r124; - and r123 r124 into r125; - not r9 into r126; - and r125 r126 into r127; - not r10 into r128; - and r127 r128 into r129; - not r11 into r130; - and r129 r130 into r131; - not r12 into r132; - and r131 r132 into r133; - not r13 into r134; - and r133 r134 into r135; - not r14 into r136; - and r135 r136 into r137; - not r15 into r138; - and r137 r138 into r139; - not r16 into r140; - and r139 r140 into r141; - not r17 into r142; - and r141 r142 into r143; - not r18 into r144; - and r143 r144 into r145; - not r19 into r146; - and r145 r146 into r147; - not r20 into r148; - and r147 r148 into r149; - not r21 into r150; - and r149 r150 into r151; - not r22 into r152; - and r151 r152 into r153; - not r23 into r154; - and r153 r154 into r155; - not r24 into r156; - and r155 r156 into r157; - not r25 into r158; - and r157 r158 into r159; - not r26 into r160; - and r159 r160 into r161; - not r27 into r162; - and r161 r162 into r163; - not r28 into r164; - and r163 r164 into r165; - not r29 into r166; - and r165 r166 into r167; - not r30 into r168; - and r167 r168 into r169; - not r31 into r170; - and r169 r170 into r171; - not r32 into r172; - and r171 r172 into r173; - not r33 into r174; - and r173 r174 into r175; - not r34 into r176; - and r175 r176 into r177; - not r35 into r178; - and r177 r178 into r179; - and r179 r36 into r180; - ternary r180 19u8 r110 into r181; - not r1 into r182; - not r2 into r183; - and r182 r183 into r184; - not r3 into r185; - and r184 r185 into r186; - not r4 into r187; - and r186 r187 into r188; - not r5 into r189; - and r188 r189 into r190; - not r6 into r191; - and r190 r191 into r192; - not r7 into r193; - and r192 r193 into r194; - not r8 into r195; - and r194 r195 into r196; - not r9 into r197; - and r196 r197 into r198; - not r10 into r199; - and r198 r199 into r200; - not r11 into r201; - and r200 r201 into r202; - not r12 into r203; - and r202 r203 into r204; - not r13 into r205; - and r204 r205 into r206; - not r14 into r207; - and r206 r207 into r208; - not r15 into r209; - and r208 r209 into r210; - not r16 into r211; - and r210 r211 into r212; - not r17 into r213; - and r212 r213 into r214; - not r18 into r215; - and r214 r215 into r216; - not r19 into r217; - and r216 r217 into r218; - not r20 into r219; - and r218 r219 into r220; - not r21 into r221; - and r220 r221 into r222; - not r22 into r223; - and r222 r223 into r224; - not r23 into r225; - and r224 r225 into r226; - not r24 into r227; - and r226 r227 into r228; - not r25 into r229; - and r228 r229 into r230; - not r26 into r231; - and r230 r231 into r232; - not r27 into r233; - and r232 r233 into r234; - not r28 into r235; - and r234 r235 into r236; - not r29 into r237; - and r236 r237 into r238; - not r30 into r239; - and r238 r239 into r240; - not r31 into r241; - and r240 r241 into r242; - not r32 into r243; - and r242 r243 into r244; - not r33 into r245; - and r244 r245 into r246; - not r34 into r247; - and r246 r247 into r248; - and r248 r35 into r249; - ternary r249 8u8 r181 into r250; - not r1 into r251; - not r2 into r252; - and r251 r252 into r253; - not r3 into r254; - and r253 r254 into r255; - not r4 into r256; - and r255 r256 into r257; - not r5 into r258; - and r257 r258 into r259; - not r6 into r260; - and r259 r260 into r261; - not r7 into r262; - and r261 r262 into r263; - not r8 into r264; - and r263 r264 into r265; - not r9 into r266; - and r265 r266 into r267; - not r10 into r268; - and r267 r268 into r269; - not r11 into r270; - and r269 r270 into r271; - not r12 into r272; - and r271 r272 into r273; - not r13 into r274; - and r273 r274 into r275; - not r14 into r276; - and r275 r276 into r277; - not r15 into r278; - and r277 r278 into r279; - not r16 into r280; - and r279 r280 into r281; - not r17 into r282; - and r281 r282 into r283; - not r18 into r284; - and r283 r284 into r285; - not r19 into r286; - and r285 r286 into r287; - not r20 into r288; - and r287 r288 into r289; - not r21 into r290; - and r289 r290 into r291; - not r22 into r292; - and r291 r292 into r293; - not r23 into r294; - and r293 r294 into r295; - not r24 into r296; - and r295 r296 into r297; - not r25 into r298; - and r297 r298 into r299; - not r26 into r300; - and r299 r300 into r301; - not r27 into r302; - and r301 r302 into r303; - not r28 into r304; - and r303 r304 into r305; - not r29 into r306; - and r305 r306 into r307; - not r30 into r308; - and r307 r308 into r309; - not r31 into r310; - and r309 r310 into r311; - not r32 into r312; - and r311 r312 into r313; - not r33 into r314; - and r313 r314 into r315; - and r315 r34 into r316; - ternary r316 20u8 r250 into r317; - not r1 into r318; - not r2 into r319; - and r318 r319 into r320; - not r3 into r321; - and r320 r321 into r322; - not r4 into r323; - and r322 r323 into r324; - not r5 into r325; - and r324 r325 into r326; - not r6 into r327; - and r326 r327 into r328; - not r7 into r329; - and r328 r329 into r330; - not r8 into r331; - and r330 r331 into r332; - not r9 into r333; - and r332 r333 into r334; - not r10 into r335; - and r334 r335 into r336; - not r11 into r337; - and r336 r337 into r338; - not r12 into r339; - and r338 r339 into r340; - not r13 into r341; - and r340 r341 into r342; - not r14 into r343; - and r342 r343 into r344; - not r15 into r345; - and r344 r345 into r346; - not r16 into r347; - and r346 r347 into r348; - not r17 into r349; - and r348 r349 into r350; - not r18 into r351; - and r350 r351 into r352; - not r19 into r353; - and r352 r353 into r354; - not r20 into r355; - and r354 r355 into r356; - not r21 into r357; - and r356 r357 into r358; - not r22 into r359; - and r358 r359 into r360; - not r23 into r361; - and r360 r361 into r362; - not r24 into r363; - and r362 r363 into r364; - not r25 into r365; - and r364 r365 into r366; - not r26 into r367; - and r366 r367 into r368; - not r27 into r369; - and r368 r369 into r370; - not r28 into r371; - and r370 r371 into r372; - not r29 into r373; - and r372 r373 into r374; - not r30 into r375; - and r374 r375 into r376; - not r31 into r377; - and r376 r377 into r378; - not r32 into r379; - and r378 r379 into r380; - and r380 r33 into r381; - ternary r381 5u8 r317 into r382; - not r1 into r383; - not r2 into r384; - and r383 r384 into r385; - not r3 into r386; - and r385 r386 into r387; - not r4 into r388; - and r387 r388 into r389; - not r5 into r390; - and r389 r390 into r391; - not r6 into r392; - and r391 r392 into r393; - not r7 into r394; - and r393 r394 into r395; - not r8 into r396; - and r395 r396 into r397; - not r9 into r398; - and r397 r398 into r399; - not r10 into r400; - and r399 r400 into r401; - not r11 into r402; - and r401 r402 into r403; - not r12 into r404; - and r403 r404 into r405; - not r13 into r406; - and r405 r406 into r407; - not r14 into r408; - and r407 r408 into r409; - not r15 into r410; - and r409 r410 into r411; - not r16 into r412; - and r411 r412 into r413; - not r17 into r414; - and r413 r414 into r415; - not r18 into r416; - and r415 r416 into r417; - not r19 into r418; - and r417 r418 into r419; - not r20 into r420; - and r419 r420 into r421; - not r21 into r422; - and r421 r422 into r423; - not r22 into r424; - and r423 r424 into r425; - not r23 into r426; - and r425 r426 into r427; - not r24 into r428; - and r427 r428 into r429; - not r25 into r430; - and r429 r430 into r431; - not r26 into r432; - and r431 r432 into r433; - not r27 into r434; - and r433 r434 into r435; - not r28 into r436; - and r435 r436 into r437; - not r29 into r438; - and r437 r438 into r439; - not r30 into r440; - and r439 r440 into r441; - not r31 into r442; - and r441 r442 into r443; - and r443 r32 into r444; - ternary r444 9u8 r382 into r445; - not r1 into r446; - not r2 into r447; - and r446 r447 into r448; - not r3 into r449; - and r448 r449 into r450; - not r4 into r451; - and r450 r451 into r452; - not r5 into r453; - and r452 r453 into r454; - not r6 into r455; - and r454 r455 into r456; - not r7 into r457; - and r456 r457 into r458; - not r8 into r459; - and r458 r459 into r460; - not r9 into r461; - and r460 r461 into r462; - not r10 into r463; - and r462 r463 into r464; - not r11 into r465; - and r464 r465 into r466; - not r12 into r467; - and r466 r467 into r468; - not r13 into r469; - and r468 r469 into r470; - not r14 into r471; - and r470 r471 into r472; - not r15 into r473; - and r472 r473 into r474; - not r16 into r475; - and r474 r475 into r476; - not r17 into r477; - and r476 r477 into r478; - not r18 into r479; - and r478 r479 into r480; - not r19 into r481; - and r480 r481 into r482; - not r20 into r483; - and r482 r483 into r484; - not r21 into r485; - and r484 r485 into r486; - not r22 into r487; - and r486 r487 into r488; - not r23 into r489; - and r488 r489 into r490; - not r24 into r491; - and r490 r491 into r492; - not r25 into r493; - and r492 r493 into r494; - not r26 into r495; - and r494 r495 into r496; - not r27 into r497; - and r496 r497 into r498; - not r28 into r499; - and r498 r499 into r500; - not r29 into r501; - and r500 r501 into r502; - not r30 into r503; - and r502 r503 into r504; - and r504 r31 into r505; - ternary r505 14u8 r445 into r506; - not r1 into r507; - not r2 into r508; - and r507 r508 into r509; - not r3 into r510; - and r509 r510 into r511; - not r4 into r512; - and r511 r512 into r513; - not r5 into r514; - and r513 r514 into r515; - not r6 into r516; - and r515 r516 into r517; - not r7 into r518; - and r517 r518 into r519; - not r8 into r520; - and r519 r520 into r521; - not r9 into r522; - and r521 r522 into r523; - not r10 into r524; - and r523 r524 into r525; - not r11 into r526; - and r525 r526 into r527; - not r12 into r528; - and r527 r528 into r529; - not r13 into r530; - and r529 r530 into r531; - not r14 into r532; - and r531 r532 into r533; - not r15 into r534; - and r533 r534 into r535; - not r16 into r536; - and r535 r536 into r537; - not r17 into r538; - and r537 r538 into r539; - not r18 into r540; - and r539 r540 into r541; - not r19 into r542; - and r541 r542 into r543; - not r20 into r544; - and r543 r544 into r545; - not r21 into r546; - and r545 r546 into r547; - not r22 into r548; - and r547 r548 into r549; - not r23 into r550; - and r549 r550 into r551; - not r24 into r552; - and r551 r552 into r553; - not r25 into r554; - and r553 r554 into r555; - not r26 into r556; - and r555 r556 into r557; - not r27 into r558; - and r557 r558 into r559; - not r28 into r560; - and r559 r560 into r561; - not r29 into r562; - and r561 r562 into r563; - and r563 r30 into r564; - ternary r564 21u8 r506 into r565; - not r1 into r566; - not r2 into r567; - and r566 r567 into r568; - not r3 into r569; - and r568 r569 into r570; - not r4 into r571; - and r570 r571 into r572; - not r5 into r573; - and r572 r573 into r574; - not r6 into r575; - and r574 r575 into r576; - not r7 into r577; - and r576 r577 into r578; - not r8 into r579; - and r578 r579 into r580; - not r9 into r581; - and r580 r581 into r582; - not r10 into r583; - and r582 r583 into r584; - not r11 into r585; - and r584 r585 into r586; - not r12 into r587; - and r586 r587 into r588; - not r13 into r589; - and r588 r589 into r590; - not r14 into r591; - and r590 r591 into r592; - not r15 into r593; - and r592 r593 into r594; - not r16 into r595; - and r594 r595 into r596; - not r17 into r597; - and r596 r597 into r598; - not r18 into r599; - and r598 r599 into r600; - not r19 into r601; - and r600 r601 into r602; - not r20 into r603; - and r602 r603 into r604; - not r21 into r605; - and r604 r605 into r606; - not r22 into r607; - and r606 r607 into r608; - not r23 into r609; - and r608 r609 into r610; - not r24 into r611; - and r610 r611 into r612; - not r25 into r613; - and r612 r613 into r614; - not r26 into r615; - and r614 r615 into r616; - not r27 into r617; - and r616 r617 into r618; - not r28 into r619; - and r618 r619 into r620; - and r620 r29 into r621; - ternary r621 0u8 r565 into r622; - not r1 into r623; - not r2 into r624; - and r623 r624 into r625; - not r3 into r626; - and r625 r626 into r627; - not r4 into r628; - and r627 r628 into r629; - not r5 into r630; - and r629 r630 into r631; - not r6 into r632; - and r631 r632 into r633; - not r7 into r634; - and r633 r634 into r635; - not r8 into r636; - and r635 r636 into r637; - not r9 into r638; - and r637 r638 into r639; - not r10 into r640; - and r639 r640 into r641; - not r11 into r642; - and r641 r642 into r643; - not r12 into r644; - and r643 r644 into r645; - not r13 into r646; - and r645 r646 into r647; - not r14 into r648; - and r647 r648 into r649; - not r15 into r650; - and r649 r650 into r651; - not r16 into r652; - and r651 r652 into r653; - not r17 into r654; - and r653 r654 into r655; - not r18 into r656; - and r655 r656 into r657; - not r19 into r658; - and r657 r658 into r659; - not r20 into r660; - and r659 r660 into r661; - not r21 into r662; - and r661 r662 into r663; - not r22 into r664; - and r663 r664 into r665; - not r23 into r666; - and r665 r666 into r667; - not r24 into r668; - and r667 r668 into r669; - not r25 into r670; - and r669 r670 into r671; - not r26 into r672; - and r671 r672 into r673; - not r27 into r674; - and r673 r674 into r675; - and r675 r28 into r676; - ternary r676 6u8 r622 into r677; - not r1 into r678; - not r2 into r679; - and r678 r679 into r680; - not r3 into r681; - and r680 r681 into r682; - not r4 into r683; - and r682 r683 into r684; - not r5 into r685; - and r684 r685 into r686; - not r6 into r687; - and r686 r687 into r688; - not r7 into r689; - and r688 r689 into r690; - not r8 into r691; - and r690 r691 into r692; - not r9 into r693; - and r692 r693 into r694; - not r10 into r695; - and r694 r695 into r696; - not r11 into r697; - and r696 r697 into r698; - not r12 into r699; - and r698 r699 into r700; - not r13 into r701; - and r700 r701 into r702; - not r14 into r703; - and r702 r703 into r704; - not r15 into r705; - and r704 r705 into r706; - not r16 into r707; - and r706 r707 into r708; - not r17 into r709; - and r708 r709 into r710; - not r18 into r711; - and r710 r711 into r712; - not r19 into r713; - and r712 r713 into r714; - not r20 into r715; - and r714 r715 into r716; - not r21 into r717; - and r716 r717 into r718; - not r22 into r719; - and r718 r719 into r720; - not r23 into r721; - and r720 r721 into r722; - not r24 into r723; - and r722 r723 into r724; - not r25 into r725; - and r724 r725 into r726; - not r26 into r727; - and r726 r727 into r728; - and r728 r27 into r729; - ternary r729 12u8 r677 into r730; - not r1 into r731; - not r2 into r732; - and r731 r732 into r733; - not r3 into r734; - and r733 r734 into r735; - not r4 into r736; - and r735 r736 into r737; - not r5 into r738; - and r737 r738 into r739; - not r6 into r740; - and r739 r740 into r741; - not r7 into r742; - and r741 r742 into r743; - not r8 into r744; - and r743 r744 into r745; - not r9 into r746; - and r745 r746 into r747; - not r10 into r748; - and r747 r748 into r749; - not r11 into r750; - and r749 r750 into r751; - not r12 into r752; - and r751 r752 into r753; - not r13 into r754; - and r753 r754 into r755; - not r14 into r756; - and r755 r756 into r757; - not r15 into r758; - and r757 r758 into r759; - not r16 into r760; - and r759 r760 into r761; - not r17 into r762; - and r761 r762 into r763; - not r18 into r764; - and r763 r764 into r765; - not r19 into r766; - and r765 r766 into r767; - not r20 into r768; - and r767 r768 into r769; - not r21 into r770; - and r769 r770 into r771; - not r22 into r772; - and r771 r772 into r773; - not r23 into r774; - and r773 r774 into r775; - not r24 into r776; - and r775 r776 into r777; - not r25 into r778; - and r777 r778 into r779; - and r779 r26 into r780; - ternary r780 10u8 r730 into r781; - not r1 into r782; - not r2 into r783; - and r782 r783 into r784; - not r3 into r785; - and r784 r785 into r786; - not r4 into r787; - and r786 r787 into r788; - not r5 into r789; - and r788 r789 into r790; - not r6 into r791; - and r790 r791 into r792; - not r7 into r793; - and r792 r793 into r794; - not r8 into r795; - and r794 r795 into r796; - not r9 into r797; - and r796 r797 into r798; - not r10 into r799; - and r798 r799 into r800; - not r11 into r801; - and r800 r801 into r802; - not r12 into r803; - and r802 r803 into r804; - not r13 into r805; - and r804 r805 into r806; - not r14 into r807; - and r806 r807 into r808; - not r15 into r809; - and r808 r809 into r810; - not r16 into r811; - and r810 r811 into r812; - not r17 into r813; - and r812 r813 into r814; - not r18 into r815; - and r814 r815 into r816; - not r19 into r817; - and r816 r817 into r818; - not r20 into r819; - and r818 r819 into r820; - not r21 into r821; - and r820 r821 into r822; - not r22 into r823; - and r822 r823 into r824; - not r23 into r825; - and r824 r825 into r826; - not r24 into r827; - and r826 r827 into r828; - and r828 r25 into r829; - ternary r829 29u8 r781 into r830; - not r1 into r831; - not r2 into r832; - and r831 r832 into r833; - not r3 into r834; - and r833 r834 into r835; - not r4 into r836; - and r835 r836 into r837; - not r5 into r838; - and r837 r838 into r839; - not r6 into r840; - and r839 r840 into r841; - not r7 into r842; - and r841 r842 into r843; - not r8 into r844; - and r843 r844 into r845; - not r9 into r846; - and r845 r846 into r847; - not r10 into r848; - and r847 r848 into r849; - not r11 into r850; - and r849 r850 into r851; - not r12 into r852; - and r851 r852 into r853; - not r13 into r854; - and r853 r854 into r855; - not r14 into r856; - and r855 r856 into r857; - not r15 into r858; - and r857 r858 into r859; - not r16 into r860; - and r859 r860 into r861; - not r17 into r862; - and r861 r862 into r863; - not r18 into r864; - and r863 r864 into r865; - not r19 into r866; - and r865 r866 into r867; - not r20 into r868; - and r867 r868 into r869; - not r21 into r870; - and r869 r870 into r871; - not r22 into r872; - and r871 r872 into r873; - not r23 into r874; - and r873 r874 into r875; - and r875 r24 into r876; - ternary r876 15u8 r830 into r877; - not r1 into r878; - not r2 into r879; - and r878 r879 into r880; - not r3 into r881; - and r880 r881 into r882; - not r4 into r883; - and r882 r883 into r884; - not r5 into r885; - and r884 r885 into r886; - not r6 into r887; - and r886 r887 into r888; - not r7 into r889; - and r888 r889 into r890; - not r8 into r891; - and r890 r891 into r892; - not r9 into r893; - and r892 r893 into r894; - not r10 into r895; - and r894 r895 into r896; - not r11 into r897; - and r896 r897 into r898; - not r12 into r899; - and r898 r899 into r900; - not r13 into r901; - and r900 r901 into r902; - not r14 into r903; - and r902 r903 into r904; - not r15 into r905; - and r904 r905 into r906; - not r16 into r907; - and r906 r907 into r908; - not r17 into r909; - and r908 r909 into r910; - not r18 into r911; - and r910 r911 into r912; - not r19 into r913; - and r912 r913 into r914; - not r20 into r915; - and r914 r915 into r916; - not r21 into r917; - and r916 r917 into r918; - not r22 into r919; - and r918 r919 into r920; - and r920 r23 into r921; - ternary r921 31u8 r877 into r922; - not r1 into r923; - not r2 into r924; - and r923 r924 into r925; - not r3 into r926; - and r925 r926 into r927; - not r4 into r928; - and r927 r928 into r929; - not r5 into r930; - and r929 r930 into r931; - not r6 into r932; - and r931 r932 into r933; - not r7 into r934; - and r933 r934 into r935; - not r8 into r936; - and r935 r936 into r937; - not r9 into r938; - and r937 r938 into r939; - not r10 into r940; - and r939 r940 into r941; - not r11 into r942; - and r941 r942 into r943; - not r12 into r944; - and r943 r944 into r945; - not r13 into r946; - and r945 r946 into r947; - not r14 into r948; - and r947 r948 into r949; - not r15 into r950; - and r949 r950 into r951; - not r16 into r952; - and r951 r952 into r953; - not r17 into r954; - and r953 r954 into r955; - not r18 into r956; - and r955 r956 into r957; - not r19 into r958; - and r957 r958 into r959; - not r20 into r960; - and r959 r960 into r961; - not r21 into r962; - and r961 r962 into r963; - and r963 r22 into r964; - ternary r964 22u8 r922 into r965; - not r1 into r966; - not r2 into r967; - and r966 r967 into r968; - not r3 into r969; - and r968 r969 into r970; - not r4 into r971; - and r970 r971 into r972; - not r5 into r973; - and r972 r973 into r974; - not r6 into r975; - and r974 r975 into r976; - not r7 into r977; - and r976 r977 into r978; - not r8 into r979; - and r978 r979 into r980; - not r9 into r981; - and r980 r981 into r982; - not r10 into r983; - and r982 r983 into r984; - not r11 into r985; - and r984 r985 into r986; - not r12 into r987; - and r986 r987 into r988; - not r13 into r989; - and r988 r989 into r990; - not r14 into r991; - and r990 r991 into r992; - not r15 into r993; - and r992 r993 into r994; - not r16 into r995; - and r994 r995 into r996; - not r17 into r997; - and r996 r997 into r998; - not r18 into r999; - and r998 r999 into r1000; - not r19 into r1001; - and r1000 r1001 into r1002; - not r20 into r1003; - and r1002 r1003 into r1004; - and r1004 r21 into r1005; - ternary r1005 25u8 r965 into r1006; - not r1 into r1007; - not r2 into r1008; - and r1007 r1008 into r1009; - not r3 into r1010; - and r1009 r1010 into r1011; - not r4 into r1012; - and r1011 r1012 into r1013; - not r5 into r1014; - and r1013 r1014 into r1015; - not r6 into r1016; - and r1015 r1016 into r1017; - not r7 into r1018; - and r1017 r1018 into r1019; - not r8 into r1020; - and r1019 r1020 into r1021; - not r9 into r1022; - and r1021 r1022 into r1023; - not r10 into r1024; - and r1023 r1024 into r1025; - not r11 into r1026; - and r1025 r1026 into r1027; - not r12 into r1028; - and r1027 r1028 into r1029; - not r13 into r1030; - and r1029 r1030 into r1031; - not r14 into r1032; - and r1031 r1032 into r1033; - not r15 into r1034; - and r1033 r1034 into r1035; - not r16 into r1036; - and r1035 r1036 into r1037; - not r17 into r1038; - and r1037 r1038 into r1039; - not r18 into r1040; - and r1039 r1040 into r1041; - not r19 into r1042; - and r1041 r1042 into r1043; - and r1043 r20 into r1044; - ternary r1044 0u8 r1006 into r1045; - not r1 into r1046; - not r2 into r1047; - and r1046 r1047 into r1048; - not r3 into r1049; - and r1048 r1049 into r1050; - not r4 into r1051; - and r1050 r1051 into r1052; - not r5 into r1053; - and r1052 r1053 into r1054; - not r6 into r1055; - and r1054 r1055 into r1056; - not r7 into r1057; - and r1056 r1057 into r1058; - not r8 into r1059; - and r1058 r1059 into r1060; - not r9 into r1061; - and r1060 r1061 into r1062; - not r10 into r1063; - and r1062 r1063 into r1064; - not r11 into r1065; - and r1064 r1065 into r1066; - not r12 into r1067; - and r1066 r1067 into r1068; - not r13 into r1069; - and r1068 r1069 into r1070; - not r14 into r1071; - and r1070 r1071 into r1072; - not r15 into r1073; - and r1072 r1073 into r1074; - not r16 into r1075; - and r1074 r1075 into r1076; - not r17 into r1077; - and r1076 r1077 into r1078; - not r18 into r1079; - and r1078 r1079 into r1080; - and r1080 r19 into r1081; - ternary r1081 17u8 r1045 into r1082; - not r1 into r1083; - not r2 into r1084; - and r1083 r1084 into r1085; - not r3 into r1086; - and r1085 r1086 into r1087; - not r4 into r1088; - and r1087 r1088 into r1089; - not r5 into r1090; - and r1089 r1090 into r1091; - not r6 into r1092; - and r1091 r1092 into r1093; - not r7 into r1094; - and r1093 r1094 into r1095; - not r8 into r1096; - and r1095 r1096 into r1097; - not r9 into r1098; - and r1097 r1098 into r1099; - not r10 into r1100; - and r1099 r1100 into r1101; - not r11 into r1102; - and r1101 r1102 into r1103; - not r12 into r1104; - and r1103 r1104 into r1105; - not r13 into r1106; - and r1105 r1106 into r1107; - not r14 into r1108; - and r1107 r1108 into r1109; - not r15 into r1110; - and r1109 r1110 into r1111; - not r16 into r1112; - and r1111 r1112 into r1113; - not r17 into r1114; - and r1113 r1114 into r1115; - and r1115 r18 into r1116; - ternary r1116 7u8 r1082 into r1117; - not r1 into r1118; - not r2 into r1119; - and r1118 r1119 into r1120; - not r3 into r1121; - and r1120 r1121 into r1122; - not r4 into r1123; - and r1122 r1123 into r1124; - not r5 into r1125; - and r1124 r1125 into r1126; - not r6 into r1127; - and r1126 r1127 into r1128; - not r7 into r1129; - and r1128 r1129 into r1130; - not r8 into r1131; - and r1130 r1131 into r1132; - not r9 into r1133; - and r1132 r1133 into r1134; - not r10 into r1135; - and r1134 r1135 into r1136; - not r11 into r1137; - and r1136 r1137 into r1138; - not r12 into r1139; - and r1138 r1139 into r1140; - not r13 into r1141; - and r1140 r1141 into r1142; - not r14 into r1143; - and r1142 r1143 into r1144; - not r15 into r1145; - and r1144 r1145 into r1146; - not r16 into r1147; - and r1146 r1147 into r1148; - and r1148 r17 into r1149; - ternary r1149 4u8 r1117 into r1150; - not r1 into r1151; - not r2 into r1152; - and r1151 r1152 into r1153; - not r3 into r1154; - and r1153 r1154 into r1155; - not r4 into r1156; - and r1155 r1156 into r1157; - not r5 into r1158; - and r1157 r1158 into r1159; - not r6 into r1160; - and r1159 r1160 into r1161; - not r7 into r1162; - and r1161 r1162 into r1163; - not r8 into r1164; - and r1163 r1164 into r1165; - not r9 into r1166; - and r1165 r1166 into r1167; - not r10 into r1168; - and r1167 r1168 into r1169; - not r11 into r1170; - and r1169 r1170 into r1171; - not r12 into r1172; - and r1171 r1172 into r1173; - not r13 into r1174; - and r1173 r1174 into r1175; - not r14 into r1176; - and r1175 r1176 into r1177; - not r15 into r1178; - and r1177 r1178 into r1179; - and r1179 r16 into r1180; - ternary r1180 13u8 r1150 into r1181; - not r1 into r1182; - not r2 into r1183; - and r1182 r1183 into r1184; - not r3 into r1185; - and r1184 r1185 into r1186; - not r4 into r1187; - and r1186 r1187 into r1188; - not r5 into r1189; - and r1188 r1189 into r1190; - not r6 into r1191; - and r1190 r1191 into r1192; - not r7 into r1193; - and r1192 r1193 into r1194; - not r8 into r1195; - and r1194 r1195 into r1196; - not r9 into r1197; - and r1196 r1197 into r1198; - not r10 into r1199; - and r1198 r1199 into r1200; - not r11 into r1201; - and r1200 r1201 into r1202; - not r12 into r1203; - and r1202 r1203 into r1204; - not r13 into r1205; - and r1204 r1205 into r1206; - not r14 into r1207; - and r1206 r1207 into r1208; - and r1208 r15 into r1209; - ternary r1209 0u8 r1181 into r1210; - not r1 into r1211; - not r2 into r1212; - and r1211 r1212 into r1213; - not r3 into r1214; - and r1213 r1214 into r1215; - not r4 into r1216; - and r1215 r1216 into r1217; - not r5 into r1218; - and r1217 r1218 into r1219; - not r6 into r1220; - and r1219 r1220 into r1221; - not r7 into r1222; - and r1221 r1222 into r1223; - not r8 into r1224; - and r1223 r1224 into r1225; - not r9 into r1226; - and r1225 r1226 into r1227; - not r10 into r1228; - and r1227 r1228 into r1229; - not r11 into r1230; - and r1229 r1230 into r1231; - not r12 into r1232; - and r1231 r1232 into r1233; - not r13 into r1234; - and r1233 r1234 into r1235; - and r1235 r14 into r1236; - ternary r1236 11u8 r1210 into r1237; - not r1 into r1238; - not r2 into r1239; - and r1238 r1239 into r1240; - not r3 into r1241; - and r1240 r1241 into r1242; - not r4 into r1243; - and r1242 r1243 into r1244; - not r5 into r1245; - and r1244 r1245 into r1246; - not r6 into r1247; - and r1246 r1247 into r1248; - not r7 into r1249; - and r1248 r1249 into r1250; - not r8 into r1251; - and r1250 r1251 into r1252; - not r9 into r1253; - and r1252 r1253 into r1254; - not r10 into r1255; - and r1254 r1255 into r1256; - not r11 into r1257; - and r1256 r1257 into r1258; - not r12 into r1259; - and r1258 r1259 into r1260; - and r1260 r13 into r1261; - ternary r1261 28u8 r1237 into r1262; - not r1 into r1263; - not r2 into r1264; - and r1263 r1264 into r1265; - not r3 into r1266; - and r1265 r1266 into r1267; - not r4 into r1268; - and r1267 r1268 into r1269; - not r5 into r1270; - and r1269 r1270 into r1271; - not r6 into r1272; - and r1271 r1272 into r1273; - not r7 into r1274; - and r1273 r1274 into r1275; - not r8 into r1276; - and r1275 r1276 into r1277; - not r9 into r1278; - and r1277 r1278 into r1279; - not r10 into r1280; - and r1279 r1280 into r1281; - not r11 into r1282; - and r1281 r1282 into r1283; - and r1283 r12 into r1284; - ternary r1284 30u8 r1262 into r1285; - not r1 into r1286; - not r2 into r1287; - and r1286 r1287 into r1288; - not r3 into r1289; - and r1288 r1289 into r1290; - not r4 into r1291; - and r1290 r1291 into r1292; - not r5 into r1293; - and r1292 r1293 into r1294; - not r6 into r1295; - and r1294 r1295 into r1296; - not r7 into r1297; - and r1296 r1297 into r1298; - not r8 into r1299; - and r1298 r1299 into r1300; - not r9 into r1301; - and r1300 r1301 into r1302; - not r10 into r1303; - and r1302 r1303 into r1304; - and r1304 r11 into r1305; - ternary r1305 24u8 r1285 into r1306; - not r1 into r1307; - not r2 into r1308; - and r1307 r1308 into r1309; - not r3 into r1310; - and r1309 r1310 into r1311; - not r4 into r1312; - and r1311 r1312 into r1313; - not r5 into r1314; - and r1313 r1314 into r1315; - not r6 into r1316; - and r1315 r1316 into r1317; - not r7 into r1318; - and r1317 r1318 into r1319; - not r8 into r1320; - and r1319 r1320 into r1321; - not r9 into r1322; - and r1321 r1322 into r1323; - and r1323 r10 into r1324; - ternary r1324 16u8 r1306 into r1325; - not r1 into r1326; - not r2 into r1327; - and r1326 r1327 into r1328; - not r3 into r1329; - and r1328 r1329 into r1330; - not r4 into r1331; - and r1330 r1331 into r1332; - not r5 into r1333; - and r1332 r1333 into r1334; - not r6 into r1335; - and r1334 r1335 into r1336; - not r7 into r1337; - and r1336 r1337 into r1338; - not r8 into r1339; - and r1338 r1339 into r1340; - and r1340 r9 into r1341; - ternary r1341 3u8 r1325 into r1342; - not r1 into r1343; - not r2 into r1344; - and r1343 r1344 into r1345; - not r3 into r1346; - and r1345 r1346 into r1347; - not r4 into r1348; - and r1347 r1348 into r1349; - not r5 into r1350; - and r1349 r1350 into r1351; - not r6 into r1352; - and r1351 r1352 into r1353; - not r7 into r1354; - and r1353 r1354 into r1355; - and r1355 r8 into r1356; - ternary r1356 0u8 r1342 into r1357; - not r1 into r1358; - not r2 into r1359; - and r1358 r1359 into r1360; - not r3 into r1361; - and r1360 r1361 into r1362; - not r4 into r1363; - and r1362 r1363 into r1364; - not r5 into r1365; - and r1364 r1365 into r1366; - not r6 into r1367; - and r1366 r1367 into r1368; - and r1368 r7 into r1369; - ternary r1369 27u8 r1357 into r1370; - not r1 into r1371; - not r2 into r1372; - and r1371 r1372 into r1373; - not r3 into r1374; - and r1373 r1374 into r1375; - not r4 into r1376; - and r1375 r1376 into r1377; - not r5 into r1378; - and r1377 r1378 into r1379; - and r1379 r6 into r1380; - ternary r1380 23u8 r1370 into r1381; - not r1 into r1382; - not r2 into r1383; - and r1382 r1383 into r1384; - not r3 into r1385; - and r1384 r1385 into r1386; - not r4 into r1387; - and r1386 r1387 into r1388; - and r1388 r5 into r1389; - ternary r1389 2u8 r1381 into r1390; - not r1 into r1391; - not r2 into r1392; - and r1391 r1392 into r1393; - not r3 into r1394; - and r1393 r1394 into r1395; - and r1395 r4 into r1396; - ternary r1396 26u8 r1390 into r1397; - not r1 into r1398; - not r2 into r1399; - and r1398 r1399 into r1400; - and r1400 r3 into r1401; - ternary r1401 1u8 r1397 into r1402; - not r1 into r1403; - and r1403 r2 into r1404; - ternary r1404 0u8 r1402 into r1405; - ternary r1 32u8 r1405 into r1406; - output r1406 as u8; - - -function main: - input r0 as u32.public; - sub.w 0u32 r0 into r1; - and r0 r1 into r2; - rem.w r2 37u32 into r3; - call reisersTableLookup r3 into r4; - output r4 as u8.private; diff --git a/examples/hackers-delight/ntzreisers/build/program.json b/examples/hackers-delight/ntzreisers/build/program.json deleted file mode 100644 index 8fe238723f..0000000000 --- a/examples/hackers-delight/ntzreisers/build/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "ntzreisers.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/hackers-delight/ntzreisers/inputs/ntzreisers.in b/examples/hackers-delight/ntzreisers/inputs/ntzreisers.in deleted file mode 100644 index b140da3eb3..0000000000 --- a/examples/hackers-delight/ntzreisers/inputs/ntzreisers.in +++ /dev/null @@ -1 +0,0 @@ -2147483648u32 diff --git a/examples/hackers-delight/ntzreisers/leo.lock b/examples/hackers-delight/ntzreisers/leo.lock deleted file mode 100644 index c4293b3b9f..0000000000 --- a/examples/hackers-delight/ntzreisers/leo.lock +++ /dev/null @@ -1 +0,0 @@ -package = [] diff --git a/examples/hackers-delight/ntzreisers/program.json b/examples/hackers-delight/ntzreisers/program.json deleted file mode 100644 index 8fe238723f..0000000000 --- a/examples/hackers-delight/ntzreisers/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "ntzreisers.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/hackers-delight/ntzreisers/src/main.leo b/examples/hackers-delight/ntzreisers/src/main.leo deleted file mode 100644 index 3b08d98b94..0000000000 --- a/examples/hackers-delight/ntzreisers/src/main.leo +++ /dev/null @@ -1,60 +0,0 @@ -program ntzreisers.aleo { - // The 'ntzreisers' main function. - // From Hacker's Delight 2nd ed. figure 5-27 - transition main(public x: u32) -> u8 { - x = (x & 0u32.sub_wrapped(x)).rem_wrapped(37u32); - return reisersTableLookup(x); - } - - // There are 37 entries here - // {32, 0, 1, 26, 2, 23, 27, - // u, 3, 16, 24, 30, 28, 11, u, 13, 4, - // 7, 17, u, 25, 22, 31, 15, 29, 10, 12, - // 6, u, 21, 14, 9, 5, 20, 8, 19, 18}; - - function reisersTableLookup(i: u32) -> u8 { - - if i == 0u32 {return 32u8;} else - if i == 1u32 {return 0u8;} else - if i == 2u32 {return 1u8;} else - if i == 3u32 {return 26u8;} else - if i == 4u32 {return 2u8;} else - if i == 5u32 {return 23u8;} else - if i == 6u32 {return 27u8;} else - - if i == 7u32 {return 0u8;} else // unused - if i == 8u32 {return 3u8;} else - if i == 9u32 {return 16u8;} else - if i == 10u32 {return 24u8;} else - if i == 11u32 {return 30u8;} else - if i == 12u32 {return 28u8;} else - if i == 13u32 {return 11u8;} else - if i == 14u32 {return 0u8;} else // unused - if i == 15u32 {return 13u8;} else - if i == 16u32 {return 4u8;} else - - if i == 17u32 {return 7u8;} else - if i == 18u32 {return 17u8;} else - if i == 19u32 {return 0u8;} else // unused - if i == 20u32 {return 25u8;} else - if i == 21u32 {return 22u8;} else - if i == 22u32 {return 31u8;} else - if i == 23u32 {return 15u8;} else - if i == 24u32 {return 29u8;} else - if i == 25u32 {return 10u8;} else - if i == 26u32 {return 12u8;} else - - if i == 27u32 {return 6u8;} else - if i == 28u32 {return 0u8;} else // unused - if i == 29u32 {return 21u8;} else - if i == 30u32 {return 14u8;} else - if i == 31u32 {return 9u8;} else - if i == 32u32 {return 5u8;} else - if i == 33u32 {return 20u8;} else - if i == 34u32 {return 8u8;} else - if i == 35u32 {return 19u8;} else - if i == 36u32 {return 18u8;} else - - {return 0u8;} // unused - } -} diff --git a/examples/hackers-delight/ntzseals/.env b/examples/hackers-delight/ntzseals/.env deleted file mode 100644 index ab204ee457..0000000000 --- a/examples/hackers-delight/ntzseals/.env +++ /dev/null @@ -1,3 +0,0 @@ -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH -ENDPOINT=http://localhost:3030 diff --git a/examples/hackers-delight/ntzseals/.gitignore b/examples/hackers-delight/ntzseals/.gitignore deleted file mode 100644 index 750b56f237..0000000000 --- a/examples/hackers-delight/ntzseals/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -outputs/ -*.avm -*.prover -*.verifier \ No newline at end of file diff --git a/examples/hackers-delight/ntzseals/README.md b/examples/hackers-delight/ntzseals/README.md deleted file mode 100644 index c5bd65c1a2..0000000000 --- a/examples/hackers-delight/ntzseals/README.md +++ /dev/null @@ -1,33 +0,0 @@ -# src/ntzseals.leo - -## Build Guide - -To compile and run this Leo program, run: -```bash -leo run -``` -## The Algorithm - -This algorithm is detailed in "Hacker's Delight, 2nd edition" -by Henry S. Warren, section 5-4, figure 5-25. - -First we isolate the rightmost `1` bit in the 32-bit input by -using the C idiom `x & (-x)`. In Leo, the `-x` is -written as `0u32.sub_wrapped(x)`. - -A constant was discovered with the property that when it was multiplied by -by 0, 1, 2, 4, ... 2**31, the 33 values all had different patterns of their -6 highest bits. The constant was also chosen to make multiplication easy to do with -a small number of shifts and adds on conventional hardware. - -In the algorithm, the 6 high bits are used as an index into a table, -where 31 of the entries are unused. The 33 used values were chosen so -that they gave the correct number of trailing zeros for the inputs. - -This algorithm was proposed by David Seal in the comp.sys.acorn.tech -newsgroup, February 16, 1994: -https://groups.google.com/g/comp.sys.acorn.tech/c/blRy-AiIQ-0/m/3JxNHeKN75IJ - -A further post that includes the table used was made by Michael Williams in the -comp.arch.arithmetic newsgroup, December 4, 1998: -https://groups.google.com/g/comp.arch.arithmetic/c/yBt-QHRVEGE/m/stFPPMD0b7AJ diff --git a/examples/hackers-delight/ntzseals/build/main.aleo b/examples/hackers-delight/ntzseals/build/main.aleo deleted file mode 100644 index bcc1636815..0000000000 --- a/examples/hackers-delight/ntzseals/build/main.aleo +++ /dev/null @@ -1,1657 +0,0 @@ -program ntzseals.aleo; - - - -closure sealsTableLookup: - input r0 as u32; - is.eq r0 0u32 into r1; - is.eq r0 1u32 into r2; - is.eq r0 2u32 into r3; - is.eq r0 3u32 into r4; - is.eq r0 4u32 into r5; - is.eq r0 5u32 into r6; - is.eq r0 6u32 into r7; - is.eq r0 7u32 into r8; - is.eq r0 8u32 into r9; - is.eq r0 9u32 into r10; - is.eq r0 10u32 into r11; - is.eq r0 11u32 into r12; - is.eq r0 12u32 into r13; - is.eq r0 13u32 into r14; - is.eq r0 14u32 into r15; - is.eq r0 15u32 into r16; - is.eq r0 16u32 into r17; - is.eq r0 17u32 into r18; - is.eq r0 18u32 into r19; - is.eq r0 19u32 into r20; - is.eq r0 20u32 into r21; - is.eq r0 21u32 into r22; - is.eq r0 22u32 into r23; - is.eq r0 23u32 into r24; - is.eq r0 24u32 into r25; - is.eq r0 25u32 into r26; - is.eq r0 26u32 into r27; - is.eq r0 27u32 into r28; - is.eq r0 28u32 into r29; - is.eq r0 29u32 into r30; - is.eq r0 30u32 into r31; - is.eq r0 31u32 into r32; - is.eq r0 32u32 into r33; - is.eq r0 33u32 into r34; - is.eq r0 34u32 into r35; - is.eq r0 35u32 into r36; - is.eq r0 36u32 into r37; - is.eq r0 37u32 into r38; - is.eq r0 38u32 into r39; - is.eq r0 39u32 into r40; - not r1 into r41; - not r2 into r42; - and r41 r42 into r43; - not r3 into r44; - and r43 r44 into r45; - not r4 into r46; - and r45 r46 into r47; - not r5 into r48; - and r47 r48 into r49; - not r6 into r50; - and r49 r50 into r51; - not r7 into r52; - and r51 r52 into r53; - not r8 into r54; - and r53 r54 into r55; - not r9 into r56; - and r55 r56 into r57; - not r10 into r58; - and r57 r58 into r59; - not r11 into r60; - and r59 r60 into r61; - not r12 into r62; - and r61 r62 into r63; - not r13 into r64; - and r63 r64 into r65; - not r14 into r66; - and r65 r66 into r67; - not r15 into r68; - and r67 r68 into r69; - not r16 into r70; - and r69 r70 into r71; - not r17 into r72; - and r71 r72 into r73; - not r18 into r74; - and r73 r74 into r75; - not r19 into r76; - and r75 r76 into r77; - not r20 into r78; - and r77 r78 into r79; - not r21 into r80; - and r79 r80 into r81; - not r22 into r82; - and r81 r82 into r83; - not r23 into r84; - and r83 r84 into r85; - not r24 into r86; - and r85 r86 into r87; - not r25 into r88; - and r87 r88 into r89; - not r26 into r90; - and r89 r90 into r91; - not r27 into r92; - and r91 r92 into r93; - not r28 into r94; - and r93 r94 into r95; - not r29 into r96; - and r95 r96 into r97; - not r30 into r98; - and r97 r98 into r99; - not r31 into r100; - and r99 r100 into r101; - not r32 into r102; - and r101 r102 into r103; - not r33 into r104; - and r103 r104 into r105; - not r34 into r106; - and r105 r106 into r107; - not r35 into r108; - and r107 r108 into r109; - not r36 into r110; - and r109 r110 into r111; - not r37 into r112; - and r111 r112 into r113; - not r38 into r114; - and r113 r114 into r115; - not r39 into r116; - and r115 r116 into r117; - and r117 r40 into r118; - ternary r118 0u8 0u8 into r119; - not r1 into r120; - not r2 into r121; - and r120 r121 into r122; - not r3 into r123; - and r122 r123 into r124; - not r4 into r125; - and r124 r125 into r126; - not r5 into r127; - and r126 r127 into r128; - not r6 into r129; - and r128 r129 into r130; - not r7 into r131; - and r130 r131 into r132; - not r8 into r133; - and r132 r133 into r134; - not r9 into r135; - and r134 r135 into r136; - not r10 into r137; - and r136 r137 into r138; - not r11 into r139; - and r138 r139 into r140; - not r12 into r141; - and r140 r141 into r142; - not r13 into r143; - and r142 r143 into r144; - not r14 into r145; - and r144 r145 into r146; - not r15 into r147; - and r146 r147 into r148; - not r16 into r149; - and r148 r149 into r150; - not r17 into r151; - and r150 r151 into r152; - not r18 into r153; - and r152 r153 into r154; - not r19 into r155; - and r154 r155 into r156; - not r20 into r157; - and r156 r157 into r158; - not r21 into r159; - and r158 r159 into r160; - not r22 into r161; - and r160 r161 into r162; - not r23 into r163; - and r162 r163 into r164; - not r24 into r165; - and r164 r165 into r166; - not r25 into r167; - and r166 r167 into r168; - not r26 into r169; - and r168 r169 into r170; - not r27 into r171; - and r170 r171 into r172; - not r28 into r173; - and r172 r173 into r174; - not r29 into r175; - and r174 r175 into r176; - not r30 into r177; - and r176 r177 into r178; - not r31 into r179; - and r178 r179 into r180; - not r32 into r181; - and r180 r181 into r182; - not r33 into r183; - and r182 r183 into r184; - not r34 into r185; - and r184 r185 into r186; - not r35 into r187; - and r186 r187 into r188; - not r36 into r189; - and r188 r189 into r190; - not r37 into r191; - and r190 r191 into r192; - not r38 into r193; - and r192 r193 into r194; - and r194 r39 into r195; - ternary r195 0u8 r119 into r196; - not r1 into r197; - not r2 into r198; - and r197 r198 into r199; - not r3 into r200; - and r199 r200 into r201; - not r4 into r202; - and r201 r202 into r203; - not r5 into r204; - and r203 r204 into r205; - not r6 into r206; - and r205 r206 into r207; - not r7 into r208; - and r207 r208 into r209; - not r8 into r210; - and r209 r210 into r211; - not r9 into r212; - and r211 r212 into r213; - not r10 into r214; - and r213 r214 into r215; - not r11 into r216; - and r215 r216 into r217; - not r12 into r218; - and r217 r218 into r219; - not r13 into r220; - and r219 r220 into r221; - not r14 into r222; - and r221 r222 into r223; - not r15 into r224; - and r223 r224 into r225; - not r16 into r226; - and r225 r226 into r227; - not r17 into r228; - and r227 r228 into r229; - not r18 into r230; - and r229 r230 into r231; - not r19 into r232; - and r231 r232 into r233; - not r20 into r234; - and r233 r234 into r235; - not r21 into r236; - and r235 r236 into r237; - not r22 into r238; - and r237 r238 into r239; - not r23 into r240; - and r239 r240 into r241; - not r24 into r242; - and r241 r242 into r243; - not r25 into r244; - and r243 r244 into r245; - not r26 into r246; - and r245 r246 into r247; - not r27 into r248; - and r247 r248 into r249; - not r28 into r250; - and r249 r250 into r251; - not r29 into r252; - and r251 r252 into r253; - not r30 into r254; - and r253 r254 into r255; - not r31 into r256; - and r255 r256 into r257; - not r32 into r258; - and r257 r258 into r259; - not r33 into r260; - and r259 r260 into r261; - not r34 into r262; - and r261 r262 into r263; - not r35 into r264; - and r263 r264 into r265; - not r36 into r266; - and r265 r266 into r267; - not r37 into r268; - and r267 r268 into r269; - and r269 r38 into r270; - ternary r270 0u8 r196 into r271; - not r1 into r272; - not r2 into r273; - and r272 r273 into r274; - not r3 into r275; - and r274 r275 into r276; - not r4 into r277; - and r276 r277 into r278; - not r5 into r279; - and r278 r279 into r280; - not r6 into r281; - and r280 r281 into r282; - not r7 into r283; - and r282 r283 into r284; - not r8 into r285; - and r284 r285 into r286; - not r9 into r287; - and r286 r287 into r288; - not r10 into r289; - and r288 r289 into r290; - not r11 into r291; - and r290 r291 into r292; - not r12 into r293; - and r292 r293 into r294; - not r13 into r295; - and r294 r295 into r296; - not r14 into r297; - and r296 r297 into r298; - not r15 into r299; - and r298 r299 into r300; - not r16 into r301; - and r300 r301 into r302; - not r17 into r303; - and r302 r303 into r304; - not r18 into r305; - and r304 r305 into r306; - not r19 into r307; - and r306 r307 into r308; - not r20 into r309; - and r308 r309 into r310; - not r21 into r311; - and r310 r311 into r312; - not r22 into r313; - and r312 r313 into r314; - not r23 into r315; - and r314 r315 into r316; - not r24 into r317; - and r316 r317 into r318; - not r25 into r319; - and r318 r319 into r320; - not r26 into r321; - and r320 r321 into r322; - not r27 into r323; - and r322 r323 into r324; - not r28 into r325; - and r324 r325 into r326; - not r29 into r327; - and r326 r327 into r328; - not r30 into r329; - and r328 r329 into r330; - not r31 into r331; - and r330 r331 into r332; - not r32 into r333; - and r332 r333 into r334; - not r33 into r335; - and r334 r335 into r336; - not r34 into r337; - and r336 r337 into r338; - not r35 into r339; - and r338 r339 into r340; - not r36 into r341; - and r340 r341 into r342; - and r342 r37 into r343; - ternary r343 0u8 r271 into r344; - not r1 into r345; - not r2 into r346; - and r345 r346 into r347; - not r3 into r348; - and r347 r348 into r349; - not r4 into r350; - and r349 r350 into r351; - not r5 into r352; - and r351 r352 into r353; - not r6 into r354; - and r353 r354 into r355; - not r7 into r356; - and r355 r356 into r357; - not r8 into r358; - and r357 r358 into r359; - not r9 into r360; - and r359 r360 into r361; - not r10 into r362; - and r361 r362 into r363; - not r11 into r364; - and r363 r364 into r365; - not r12 into r366; - and r365 r366 into r367; - not r13 into r368; - and r367 r368 into r369; - not r14 into r370; - and r369 r370 into r371; - not r15 into r372; - and r371 r372 into r373; - not r16 into r374; - and r373 r374 into r375; - not r17 into r376; - and r375 r376 into r377; - not r18 into r378; - and r377 r378 into r379; - not r19 into r380; - and r379 r380 into r381; - not r20 into r382; - and r381 r382 into r383; - not r21 into r384; - and r383 r384 into r385; - not r22 into r386; - and r385 r386 into r387; - not r23 into r388; - and r387 r388 into r389; - not r24 into r390; - and r389 r390 into r391; - not r25 into r392; - and r391 r392 into r393; - not r26 into r394; - and r393 r394 into r395; - not r27 into r396; - and r395 r396 into r397; - not r28 into r398; - and r397 r398 into r399; - not r29 into r400; - and r399 r400 into r401; - not r30 into r402; - and r401 r402 into r403; - not r31 into r404; - and r403 r404 into r405; - not r32 into r406; - and r405 r406 into r407; - not r33 into r408; - and r407 r408 into r409; - not r34 into r410; - and r409 r410 into r411; - not r35 into r412; - and r411 r412 into r413; - and r413 r36 into r414; - ternary r414 0u8 r344 into r415; - not r1 into r416; - not r2 into r417; - and r416 r417 into r418; - not r3 into r419; - and r418 r419 into r420; - not r4 into r421; - and r420 r421 into r422; - not r5 into r423; - and r422 r423 into r424; - not r6 into r425; - and r424 r425 into r426; - not r7 into r427; - and r426 r427 into r428; - not r8 into r429; - and r428 r429 into r430; - not r9 into r431; - and r430 r431 into r432; - not r10 into r433; - and r432 r433 into r434; - not r11 into r435; - and r434 r435 into r436; - not r12 into r437; - and r436 r437 into r438; - not r13 into r439; - and r438 r439 into r440; - not r14 into r441; - and r440 r441 into r442; - not r15 into r443; - and r442 r443 into r444; - not r16 into r445; - and r444 r445 into r446; - not r17 into r447; - and r446 r447 into r448; - not r18 into r449; - and r448 r449 into r450; - not r19 into r451; - and r450 r451 into r452; - not r20 into r453; - and r452 r453 into r454; - not r21 into r455; - and r454 r455 into r456; - not r22 into r457; - and r456 r457 into r458; - not r23 into r459; - and r458 r459 into r460; - not r24 into r461; - and r460 r461 into r462; - not r25 into r463; - and r462 r463 into r464; - not r26 into r465; - and r464 r465 into r466; - not r27 into r467; - and r466 r467 into r468; - not r28 into r469; - and r468 r469 into r470; - not r29 into r471; - and r470 r471 into r472; - not r30 into r473; - and r472 r473 into r474; - not r31 into r475; - and r474 r475 into r476; - not r32 into r477; - and r476 r477 into r478; - not r33 into r479; - and r478 r479 into r480; - not r34 into r481; - and r480 r481 into r482; - and r482 r35 into r483; - ternary r483 5u8 r415 into r484; - not r1 into r485; - not r2 into r486; - and r485 r486 into r487; - not r3 into r488; - and r487 r488 into r489; - not r4 into r490; - and r489 r490 into r491; - not r5 into r492; - and r491 r492 into r493; - not r6 into r494; - and r493 r494 into r495; - not r7 into r496; - and r495 r496 into r497; - not r8 into r498; - and r497 r498 into r499; - not r9 into r500; - and r499 r500 into r501; - not r10 into r502; - and r501 r502 into r503; - not r11 into r504; - and r503 r504 into r505; - not r12 into r506; - and r505 r506 into r507; - not r13 into r508; - and r507 r508 into r509; - not r14 into r510; - and r509 r510 into r511; - not r15 into r512; - and r511 r512 into r513; - not r16 into r514; - and r513 r514 into r515; - not r17 into r516; - and r515 r516 into r517; - not r18 into r518; - and r517 r518 into r519; - not r19 into r520; - and r519 r520 into r521; - not r20 into r522; - and r521 r522 into r523; - not r21 into r524; - and r523 r524 into r525; - not r22 into r526; - and r525 r526 into r527; - not r23 into r528; - and r527 r528 into r529; - not r24 into r530; - and r529 r530 into r531; - not r25 into r532; - and r531 r532 into r533; - not r26 into r534; - and r533 r534 into r535; - not r27 into r536; - and r535 r536 into r537; - not r28 into r538; - and r537 r538 into r539; - not r29 into r540; - and r539 r540 into r541; - not r30 into r542; - and r541 r542 into r543; - not r31 into r544; - and r543 r544 into r545; - not r32 into r546; - and r545 r546 into r547; - not r33 into r548; - and r547 r548 into r549; - and r549 r34 into r550; - ternary r550 11u8 r484 into r551; - not r1 into r552; - not r2 into r553; - and r552 r553 into r554; - not r3 into r555; - and r554 r555 into r556; - not r4 into r557; - and r556 r557 into r558; - not r5 into r559; - and r558 r559 into r560; - not r6 into r561; - and r560 r561 into r562; - not r7 into r563; - and r562 r563 into r564; - not r8 into r565; - and r564 r565 into r566; - not r9 into r567; - and r566 r567 into r568; - not r10 into r569; - and r568 r569 into r570; - not r11 into r571; - and r570 r571 into r572; - not r12 into r573; - and r572 r573 into r574; - not r13 into r575; - and r574 r575 into r576; - not r14 into r577; - and r576 r577 into r578; - not r15 into r579; - and r578 r579 into r580; - not r16 into r581; - and r580 r581 into r582; - not r17 into r583; - and r582 r583 into r584; - not r18 into r585; - and r584 r585 into r586; - not r19 into r587; - and r586 r587 into r588; - not r20 into r589; - and r588 r589 into r590; - not r21 into r591; - and r590 r591 into r592; - not r22 into r593; - and r592 r593 into r594; - not r23 into r595; - and r594 r595 into r596; - not r24 into r597; - and r596 r597 into r598; - not r25 into r599; - and r598 r599 into r600; - not r26 into r601; - and r600 r601 into r602; - not r27 into r603; - and r602 r603 into r604; - not r28 into r605; - and r604 r605 into r606; - not r29 into r607; - and r606 r607 into r608; - not r30 into r609; - and r608 r609 into r610; - not r31 into r611; - and r610 r611 into r612; - not r32 into r613; - and r612 r613 into r614; - and r614 r33 into r615; - ternary r615 31u8 r551 into r616; - not r1 into r617; - not r2 into r618; - and r617 r618 into r619; - not r3 into r620; - and r619 r620 into r621; - not r4 into r622; - and r621 r622 into r623; - not r5 into r624; - and r623 r624 into r625; - not r6 into r626; - and r625 r626 into r627; - not r7 into r628; - and r627 r628 into r629; - not r8 into r630; - and r629 r630 into r631; - not r9 into r632; - and r631 r632 into r633; - not r10 into r634; - and r633 r634 into r635; - not r11 into r636; - and r635 r636 into r637; - not r12 into r638; - and r637 r638 into r639; - not r13 into r640; - and r639 r640 into r641; - not r14 into r642; - and r641 r642 into r643; - not r15 into r644; - and r643 r644 into r645; - not r16 into r646; - and r645 r646 into r647; - not r17 into r648; - and r647 r648 into r649; - not r18 into r650; - and r649 r650 into r651; - not r19 into r652; - and r651 r652 into r653; - not r20 into r654; - and r653 r654 into r655; - not r21 into r656; - and r655 r656 into r657; - not r22 into r658; - and r657 r658 into r659; - not r23 into r660; - and r659 r660 into r661; - not r24 into r662; - and r661 r662 into r663; - not r25 into r664; - and r663 r664 into r665; - not r26 into r666; - and r665 r666 into r667; - not r27 into r668; - and r667 r668 into r669; - not r28 into r670; - and r669 r670 into r671; - not r29 into r672; - and r671 r672 into r673; - not r30 into r674; - and r673 r674 into r675; - not r31 into r676; - and r675 r676 into r677; - and r677 r32 into r678; - ternary r678 15u8 r616 into r679; - not r1 into r680; - not r2 into r681; - and r680 r681 into r682; - not r3 into r683; - and r682 r683 into r684; - not r4 into r685; - and r684 r685 into r686; - not r5 into r687; - and r686 r687 into r688; - not r6 into r689; - and r688 r689 into r690; - not r7 into r691; - and r690 r691 into r692; - not r8 into r693; - and r692 r693 into r694; - not r9 into r695; - and r694 r695 into r696; - not r10 into r697; - and r696 r697 into r698; - not r11 into r699; - and r698 r699 into r700; - not r12 into r701; - and r700 r701 into r702; - not r13 into r703; - and r702 r703 into r704; - not r14 into r705; - and r704 r705 into r706; - not r15 into r707; - and r706 r707 into r708; - not r16 into r709; - and r708 r709 into r710; - not r17 into r711; - and r710 r711 into r712; - not r18 into r713; - and r712 r713 into r714; - not r19 into r715; - and r714 r715 into r716; - not r20 into r717; - and r716 r717 into r718; - not r21 into r719; - and r718 r719 into r720; - not r22 into r721; - and r720 r721 into r722; - not r23 into r723; - and r722 r723 into r724; - not r24 into r725; - and r724 r725 into r726; - not r25 into r727; - and r726 r727 into r728; - not r26 into r729; - and r728 r729 into r730; - not r27 into r731; - and r730 r731 into r732; - not r28 into r733; - and r732 r733 into r734; - not r29 into r735; - and r734 r735 into r736; - not r30 into r737; - and r736 r737 into r738; - and r738 r31 into r739; - ternary r739 27u8 r679 into r740; - not r1 into r741; - not r2 into r742; - and r741 r742 into r743; - not r3 into r744; - and r743 r744 into r745; - not r4 into r746; - and r745 r746 into r747; - not r5 into r748; - and r747 r748 into r749; - not r6 into r750; - and r749 r750 into r751; - not r7 into r752; - and r751 r752 into r753; - not r8 into r754; - and r753 r754 into r755; - not r9 into r756; - and r755 r756 into r757; - not r10 into r758; - and r757 r758 into r759; - not r11 into r760; - and r759 r760 into r761; - not r12 into r762; - and r761 r762 into r763; - not r13 into r764; - and r763 r764 into r765; - not r14 into r766; - and r765 r766 into r767; - not r15 into r768; - and r767 r768 into r769; - not r16 into r770; - and r769 r770 into r771; - not r17 into r772; - and r771 r772 into r773; - not r18 into r774; - and r773 r774 into r775; - not r19 into r776; - and r775 r776 into r777; - not r20 into r778; - and r777 r778 into r779; - not r21 into r780; - and r779 r780 into r781; - not r22 into r782; - and r781 r782 into r783; - not r23 into r784; - and r783 r784 into r785; - not r24 into r786; - and r785 r786 into r787; - not r25 into r788; - and r787 r788 into r789; - not r26 into r790; - and r789 r790 into r791; - not r27 into r792; - and r791 r792 into r793; - not r28 into r794; - and r793 r794 into r795; - not r29 into r796; - and r795 r796 into r797; - and r797 r30 into r798; - ternary r798 21u8 r740 into r799; - not r1 into r800; - not r2 into r801; - and r800 r801 into r802; - not r3 into r803; - and r802 r803 into r804; - not r4 into r805; - and r804 r805 into r806; - not r5 into r807; - and r806 r807 into r808; - not r6 into r809; - and r808 r809 into r810; - not r7 into r811; - and r810 r811 into r812; - not r8 into r813; - and r812 r813 into r814; - not r9 into r815; - and r814 r815 into r816; - not r10 into r817; - and r816 r817 into r818; - not r11 into r819; - and r818 r819 into r820; - not r12 into r821; - and r820 r821 into r822; - not r13 into r823; - and r822 r823 into r824; - not r14 into r825; - and r824 r825 into r826; - not r15 into r827; - and r826 r827 into r828; - not r16 into r829; - and r828 r829 into r830; - not r17 into r831; - and r830 r831 into r832; - not r18 into r833; - and r832 r833 into r834; - not r19 into r835; - and r834 r835 into r836; - not r20 into r837; - and r836 r837 into r838; - not r21 into r839; - and r838 r839 into r840; - not r22 into r841; - and r840 r841 into r842; - not r23 into r843; - and r842 r843 into r844; - not r24 into r845; - and r844 r845 into r846; - not r25 into r847; - and r846 r847 into r848; - not r26 into r849; - and r848 r849 into r850; - not r27 into r851; - and r850 r851 into r852; - not r28 into r853; - and r852 r853 into r854; - and r854 r29 into r855; - ternary r855 0u8 r799 into r856; - not r1 into r857; - not r2 into r858; - and r857 r858 into r859; - not r3 into r860; - and r859 r860 into r861; - not r4 into r862; - and r861 r862 into r863; - not r5 into r864; - and r863 r864 into r865; - not r6 into r866; - and r865 r866 into r867; - not r7 into r868; - and r867 r868 into r869; - not r8 into r870; - and r869 r870 into r871; - not r9 into r872; - and r871 r872 into r873; - not r10 into r874; - and r873 r874 into r875; - not r11 into r876; - and r875 r876 into r877; - not r12 into r878; - and r877 r878 into r879; - not r13 into r880; - and r879 r880 into r881; - not r14 into r882; - and r881 r882 into r883; - not r15 into r884; - and r883 r884 into r885; - not r16 into r886; - and r885 r886 into r887; - not r17 into r888; - and r887 r888 into r889; - not r18 into r890; - and r889 r890 into r891; - not r19 into r892; - and r891 r892 into r893; - not r20 into r894; - and r893 r894 into r895; - not r21 into r896; - and r895 r896 into r897; - not r22 into r898; - and r897 r898 into r899; - not r23 into r900; - and r899 r900 into r901; - not r24 into r902; - and r901 r902 into r903; - not r25 into r904; - and r903 r904 into r905; - not r26 into r906; - and r905 r906 into r907; - not r27 into r908; - and r907 r908 into r909; - and r909 r28 into r910; - ternary r910 0u8 r856 into r911; - not r1 into r912; - not r2 into r913; - and r912 r913 into r914; - not r3 into r915; - and r914 r915 into r916; - not r4 into r917; - and r916 r917 into r918; - not r5 into r919; - and r918 r919 into r920; - not r6 into r921; - and r920 r921 into r922; - not r7 into r923; - and r922 r923 into r924; - not r8 into r925; - and r924 r925 into r926; - not r9 into r927; - and r926 r927 into r928; - not r10 into r929; - and r928 r929 into r930; - not r11 into r931; - and r930 r931 into r932; - not r12 into r933; - and r932 r933 into r934; - not r13 into r935; - and r934 r935 into r936; - not r14 into r937; - and r936 r937 into r938; - not r15 into r939; - and r938 r939 into r940; - not r16 into r941; - and r940 r941 into r942; - not r17 into r943; - and r942 r943 into r944; - not r18 into r945; - and r944 r945 into r946; - not r19 into r947; - and r946 r947 into r948; - not r20 into r949; - and r948 r949 into r950; - not r21 into r951; - and r950 r951 into r952; - not r22 into r953; - and r952 r953 into r954; - not r23 into r955; - and r954 r955 into r956; - not r24 into r957; - and r956 r957 into r958; - not r25 into r959; - and r958 r959 into r960; - not r26 into r961; - and r960 r961 into r962; - and r962 r27 into r963; - ternary r963 0u8 r911 into r964; - not r1 into r965; - not r2 into r966; - and r965 r966 into r967; - not r3 into r968; - and r967 r968 into r969; - not r4 into r970; - and r969 r970 into r971; - not r5 into r972; - and r971 r972 into r973; - not r6 into r974; - and r973 r974 into r975; - not r7 into r976; - and r975 r976 into r977; - not r8 into r978; - and r977 r978 into r979; - not r9 into r980; - and r979 r980 into r981; - not r10 into r982; - and r981 r982 into r983; - not r11 into r984; - and r983 r984 into r985; - not r12 into r986; - and r985 r986 into r987; - not r13 into r988; - and r987 r988 into r989; - not r14 into r990; - and r989 r990 into r991; - not r15 into r992; - and r991 r992 into r993; - not r16 into r994; - and r993 r994 into r995; - not r17 into r996; - and r995 r996 into r997; - not r18 into r998; - and r997 r998 into r999; - not r19 into r1000; - and r999 r1000 into r1001; - not r20 into r1002; - and r1001 r1002 into r1003; - not r21 into r1004; - and r1003 r1004 into r1005; - not r22 into r1006; - and r1005 r1006 into r1007; - not r23 into r1008; - and r1007 r1008 into r1009; - not r24 into r1010; - and r1009 r1010 into r1011; - not r25 into r1012; - and r1011 r1012 into r1013; - and r1013 r26 into r1014; - ternary r1014 0u8 r964 into r1015; - not r1 into r1016; - not r2 into r1017; - and r1016 r1017 into r1018; - not r3 into r1019; - and r1018 r1019 into r1020; - not r4 into r1021; - and r1020 r1021 into r1022; - not r5 into r1023; - and r1022 r1023 into r1024; - not r6 into r1025; - and r1024 r1025 into r1026; - not r7 into r1027; - and r1026 r1027 into r1028; - not r8 into r1029; - and r1028 r1029 into r1030; - not r9 into r1031; - and r1030 r1031 into r1032; - not r10 into r1033; - and r1032 r1033 into r1034; - not r11 into r1035; - and r1034 r1035 into r1036; - not r12 into r1037; - and r1036 r1037 into r1038; - not r13 into r1039; - and r1038 r1039 into r1040; - not r14 into r1041; - and r1040 r1041 into r1042; - not r15 into r1043; - and r1042 r1043 into r1044; - not r16 into r1045; - and r1044 r1045 into r1046; - not r17 into r1047; - and r1046 r1047 into r1048; - not r18 into r1049; - and r1048 r1049 into r1050; - not r19 into r1051; - and r1050 r1051 into r1052; - not r20 into r1053; - and r1052 r1053 into r1054; - not r21 into r1055; - and r1054 r1055 into r1056; - not r22 into r1057; - and r1056 r1057 into r1058; - not r23 into r1059; - and r1058 r1059 into r1060; - not r24 into r1061; - and r1060 r1061 into r1062; - and r1062 r25 into r1063; - ternary r1063 0u8 r1015 into r1064; - not r1 into r1065; - not r2 into r1066; - and r1065 r1066 into r1067; - not r3 into r1068; - and r1067 r1068 into r1069; - not r4 into r1070; - and r1069 r1070 into r1071; - not r5 into r1072; - and r1071 r1072 into r1073; - not r6 into r1074; - and r1073 r1074 into r1075; - not r7 into r1076; - and r1075 r1076 into r1077; - not r8 into r1078; - and r1077 r1078 into r1079; - not r9 into r1080; - and r1079 r1080 into r1081; - not r10 into r1082; - and r1081 r1082 into r1083; - not r11 into r1084; - and r1083 r1084 into r1085; - not r12 into r1086; - and r1085 r1086 into r1087; - not r13 into r1088; - and r1087 r1088 into r1089; - not r14 into r1090; - and r1089 r1090 into r1091; - not r15 into r1092; - and r1091 r1092 into r1093; - not r16 into r1094; - and r1093 r1094 into r1095; - not r17 into r1096; - and r1095 r1096 into r1097; - not r18 into r1098; - and r1097 r1098 into r1099; - not r19 into r1100; - and r1099 r1100 into r1101; - not r20 into r1102; - and r1101 r1102 into r1103; - not r21 into r1104; - and r1103 r1104 into r1105; - not r22 into r1106; - and r1105 r1106 into r1107; - not r23 into r1108; - and r1107 r1108 into r1109; - and r1109 r24 into r1110; - ternary r1110 25u8 r1064 into r1111; - not r1 into r1112; - not r2 into r1113; - and r1112 r1113 into r1114; - not r3 into r1115; - and r1114 r1115 into r1116; - not r4 into r1117; - and r1116 r1117 into r1118; - not r5 into r1119; - and r1118 r1119 into r1120; - not r6 into r1121; - and r1120 r1121 into r1122; - not r7 into r1123; - and r1122 r1123 into r1124; - not r8 into r1125; - and r1124 r1125 into r1126; - not r9 into r1127; - and r1126 r1127 into r1128; - not r10 into r1129; - and r1128 r1129 into r1130; - not r11 into r1131; - and r1130 r1131 into r1132; - not r12 into r1133; - and r1132 r1133 into r1134; - not r13 into r1135; - and r1134 r1135 into r1136; - not r14 into r1137; - and r1136 r1137 into r1138; - not r15 into r1139; - and r1138 r1139 into r1140; - not r16 into r1141; - and r1140 r1141 into r1142; - not r17 into r1143; - and r1142 r1143 into r1144; - not r18 into r1145; - and r1144 r1145 into r1146; - not r19 into r1147; - and r1146 r1147 into r1148; - not r20 into r1149; - and r1148 r1149 into r1150; - not r21 into r1151; - and r1150 r1151 into r1152; - not r22 into r1153; - and r1152 r1153 into r1154; - and r1154 r23 into r1155; - ternary r1155 0u8 r1111 into r1156; - not r1 into r1157; - not r2 into r1158; - and r1157 r1158 into r1159; - not r3 into r1160; - and r1159 r1160 into r1161; - not r4 into r1162; - and r1161 r1162 into r1163; - not r5 into r1164; - and r1163 r1164 into r1165; - not r6 into r1166; - and r1165 r1166 into r1167; - not r7 into r1168; - and r1167 r1168 into r1169; - not r8 into r1170; - and r1169 r1170 into r1171; - not r9 into r1172; - and r1171 r1172 into r1173; - not r10 into r1174; - and r1173 r1174 into r1175; - not r11 into r1176; - and r1175 r1176 into r1177; - not r12 into r1178; - and r1177 r1178 into r1179; - not r13 into r1180; - and r1179 r1180 into r1181; - not r14 into r1182; - and r1181 r1182 into r1183; - not r15 into r1184; - and r1183 r1184 into r1185; - not r16 into r1186; - and r1185 r1186 into r1187; - not r17 into r1188; - and r1187 r1188 into r1189; - not r18 into r1190; - and r1189 r1190 into r1191; - not r19 into r1192; - and r1191 r1192 into r1193; - not r20 into r1194; - and r1193 r1194 into r1195; - not r21 into r1196; - and r1195 r1196 into r1197; - and r1197 r22 into r1198; - ternary r1198 0u8 r1156 into r1199; - not r1 into r1200; - not r2 into r1201; - and r1200 r1201 into r1202; - not r3 into r1203; - and r1202 r1203 into r1204; - not r4 into r1205; - and r1204 r1205 into r1206; - not r5 into r1207; - and r1206 r1207 into r1208; - not r6 into r1209; - and r1208 r1209 into r1210; - not r7 into r1211; - and r1210 r1211 into r1212; - not r8 into r1213; - and r1212 r1213 into r1214; - not r9 into r1215; - and r1214 r1215 into r1216; - not r10 into r1217; - and r1216 r1217 into r1218; - not r11 into r1219; - and r1218 r1219 into r1220; - not r12 into r1221; - and r1220 r1221 into r1222; - not r13 into r1223; - and r1222 r1223 into r1224; - not r14 into r1225; - and r1224 r1225 into r1226; - not r15 into r1227; - and r1226 r1227 into r1228; - not r16 into r1229; - and r1228 r1229 into r1230; - not r17 into r1231; - and r1230 r1231 into r1232; - not r18 into r1233; - and r1232 r1233 into r1234; - not r19 into r1235; - and r1234 r1235 into r1236; - not r20 into r1237; - and r1236 r1237 into r1238; - and r1238 r21 into r1239; - ternary r1239 8u8 r1199 into r1240; - not r1 into r1241; - not r2 into r1242; - and r1241 r1242 into r1243; - not r3 into r1244; - and r1243 r1244 into r1245; - not r4 into r1246; - and r1245 r1246 into r1247; - not r5 into r1248; - and r1247 r1248 into r1249; - not r6 into r1250; - and r1249 r1250 into r1251; - not r7 into r1252; - and r1251 r1252 into r1253; - not r8 into r1254; - and r1253 r1254 into r1255; - not r9 into r1256; - and r1255 r1256 into r1257; - not r10 into r1258; - and r1257 r1258 into r1259; - not r11 into r1260; - and r1259 r1260 into r1261; - not r12 into r1262; - and r1261 r1262 into r1263; - not r13 into r1264; - and r1263 r1264 into r1265; - not r14 into r1266; - and r1265 r1266 into r1267; - not r15 into r1268; - and r1267 r1268 into r1269; - not r16 into r1270; - and r1269 r1270 into r1271; - not r17 into r1272; - and r1271 r1272 into r1273; - not r18 into r1274; - and r1273 r1274 into r1275; - not r19 into r1276; - and r1275 r1276 into r1277; - and r1277 r20 into r1278; - ternary r1278 0u8 r1240 into r1279; - not r1 into r1280; - not r2 into r1281; - and r1280 r1281 into r1282; - not r3 into r1283; - and r1282 r1283 into r1284; - not r4 into r1285; - and r1284 r1285 into r1286; - not r5 into r1287; - and r1286 r1287 into r1288; - not r6 into r1289; - and r1288 r1289 into r1290; - not r7 into r1291; - and r1290 r1291 into r1292; - not r8 into r1293; - and r1292 r1293 into r1294; - not r9 into r1295; - and r1294 r1295 into r1296; - not r10 into r1297; - and r1296 r1297 into r1298; - not r11 into r1299; - and r1298 r1299 into r1300; - not r12 into r1301; - and r1300 r1301 into r1302; - not r13 into r1303; - and r1302 r1303 into r1304; - not r14 into r1305; - and r1304 r1305 into r1306; - not r15 into r1307; - and r1306 r1307 into r1308; - not r16 into r1309; - and r1308 r1309 into r1310; - not r17 into r1311; - and r1310 r1311 into r1312; - not r18 into r1313; - and r1312 r1313 into r1314; - and r1314 r19 into r1315; - ternary r1315 0u8 r1279 into r1316; - not r1 into r1317; - not r2 into r1318; - and r1317 r1318 into r1319; - not r3 into r1320; - and r1319 r1320 into r1321; - not r4 into r1322; - and r1321 r1322 into r1323; - not r5 into r1324; - and r1323 r1324 into r1325; - not r6 into r1326; - and r1325 r1326 into r1327; - not r7 into r1328; - and r1327 r1328 into r1329; - not r8 into r1330; - and r1329 r1330 into r1331; - not r9 into r1332; - and r1331 r1332 into r1333; - not r10 into r1334; - and r1333 r1334 into r1335; - not r11 into r1336; - and r1335 r1336 into r1337; - not r12 into r1338; - and r1337 r1338 into r1339; - not r13 into r1340; - and r1339 r1340 into r1341; - not r14 into r1342; - and r1341 r1342 into r1343; - not r15 into r1344; - and r1343 r1344 into r1345; - not r16 into r1346; - and r1345 r1346 into r1347; - not r17 into r1348; - and r1347 r1348 into r1349; - and r1349 r18 into r1350; - ternary r1350 4u8 r1316 into r1351; - not r1 into r1352; - not r2 into r1353; - and r1352 r1353 into r1354; - not r3 into r1355; - and r1354 r1355 into r1356; - not r4 into r1357; - and r1356 r1357 into r1358; - not r5 into r1359; - and r1358 r1359 into r1360; - not r6 into r1361; - and r1360 r1361 into r1362; - not r7 into r1363; - and r1362 r1363 into r1364; - not r8 into r1365; - and r1364 r1365 into r1366; - not r9 into r1367; - and r1366 r1367 into r1368; - not r10 into r1369; - and r1368 r1369 into r1370; - not r11 into r1371; - and r1370 r1371 into r1372; - not r12 into r1373; - and r1372 r1373 into r1374; - not r13 into r1375; - and r1374 r1375 into r1376; - not r14 into r1377; - and r1376 r1377 into r1378; - not r15 into r1379; - and r1378 r1379 into r1380; - not r16 into r1381; - and r1380 r1381 into r1382; - and r1382 r17 into r1383; - ternary r1383 10u8 r1351 into r1384; - not r1 into r1385; - not r2 into r1386; - and r1385 r1386 into r1387; - not r3 into r1388; - and r1387 r1388 into r1389; - not r4 into r1390; - and r1389 r1390 into r1391; - not r5 into r1392; - and r1391 r1392 into r1393; - not r6 into r1394; - and r1393 r1394 into r1395; - not r7 into r1396; - and r1395 r1396 into r1397; - not r8 into r1398; - and r1397 r1398 into r1399; - not r9 into r1400; - and r1399 r1400 into r1401; - not r10 into r1402; - and r1401 r1402 into r1403; - not r11 into r1404; - and r1403 r1404 into r1405; - not r12 into r1406; - and r1405 r1406 into r1407; - not r13 into r1408; - and r1407 r1408 into r1409; - not r14 into r1410; - and r1409 r1410 into r1411; - not r15 into r1412; - and r1411 r1412 into r1413; - and r1413 r16 into r1414; - ternary r1414 14u8 r1384 into r1415; - not r1 into r1416; - not r2 into r1417; - and r1416 r1417 into r1418; - not r3 into r1419; - and r1418 r1419 into r1420; - not r4 into r1421; - and r1420 r1421 into r1422; - not r5 into r1423; - and r1422 r1423 into r1424; - not r6 into r1425; - and r1424 r1425 into r1426; - not r7 into r1427; - and r1426 r1427 into r1428; - not r8 into r1429; - and r1428 r1429 into r1430; - not r9 into r1431; - and r1430 r1431 into r1432; - not r10 into r1433; - and r1432 r1433 into r1434; - not r11 into r1435; - and r1434 r1435 into r1436; - not r12 into r1437; - and r1436 r1437 into r1438; - not r13 into r1439; - and r1438 r1439 into r1440; - not r14 into r1441; - and r1440 r1441 into r1442; - and r1442 r15 into r1443; - ternary r1443 0u8 r1415 into r1444; - not r1 into r1445; - not r2 into r1446; - and r1445 r1446 into r1447; - not r3 into r1448; - and r1447 r1448 into r1449; - not r4 into r1450; - and r1449 r1450 into r1451; - not r5 into r1452; - and r1451 r1452 into r1453; - not r6 into r1454; - and r1453 r1454 into r1455; - not r7 into r1456; - and r1455 r1456 into r1457; - not r8 into r1458; - and r1457 r1458 into r1459; - not r9 into r1460; - and r1459 r1460 into r1461; - not r10 into r1462; - and r1461 r1462 into r1463; - not r11 into r1464; - and r1463 r1464 into r1465; - not r12 into r1466; - and r1465 r1466 into r1467; - not r13 into r1468; - and r1467 r1468 into r1469; - and r1469 r14 into r1470; - ternary r1470 0u8 r1444 into r1471; - not r1 into r1472; - not r2 into r1473; - and r1472 r1473 into r1474; - not r3 into r1475; - and r1474 r1475 into r1476; - not r4 into r1477; - and r1476 r1477 into r1478; - not r5 into r1479; - and r1478 r1479 into r1480; - not r6 into r1481; - and r1480 r1481 into r1482; - not r7 into r1483; - and r1482 r1483 into r1484; - not r8 into r1485; - and r1484 r1485 into r1486; - not r9 into r1487; - and r1486 r1487 into r1488; - not r10 into r1489; - and r1488 r1489 into r1490; - not r11 into r1491; - and r1490 r1491 into r1492; - not r12 into r1493; - and r1492 r1493 into r1494; - and r1494 r13 into r1495; - ternary r1495 0u8 r1471 into r1496; - not r1 into r1497; - not r2 into r1498; - and r1497 r1498 into r1499; - not r3 into r1500; - and r1499 r1500 into r1501; - not r4 into r1502; - and r1501 r1502 into r1503; - not r5 into r1504; - and r1503 r1504 into r1505; - not r6 into r1506; - and r1505 r1506 into r1507; - not r7 into r1508; - and r1507 r1508 into r1509; - not r8 into r1510; - and r1509 r1510 into r1511; - not r9 into r1512; - and r1511 r1512 into r1513; - not r10 into r1514; - and r1513 r1514 into r1515; - not r11 into r1516; - and r1515 r1516 into r1517; - and r1517 r12 into r1518; - ternary r1518 0u8 r1496 into r1519; - not r1 into r1520; - not r2 into r1521; - and r1520 r1521 into r1522; - not r3 into r1523; - and r1522 r1523 into r1524; - not r4 into r1525; - and r1524 r1525 into r1526; - not r5 into r1527; - and r1526 r1527 into r1528; - not r6 into r1529; - and r1528 r1529 into r1530; - not r7 into r1531; - and r1530 r1531 into r1532; - not r8 into r1533; - and r1532 r1533 into r1534; - not r9 into r1535; - and r1534 r1535 into r1536; - not r10 into r1537; - and r1536 r1537 into r1538; - and r1538 r11 into r1539; - ternary r1539 7u8 r1519 into r1540; - not r1 into r1541; - not r2 into r1542; - and r1541 r1542 into r1543; - not r3 into r1544; - and r1543 r1544 into r1545; - not r4 into r1546; - and r1545 r1546 into r1547; - not r5 into r1548; - and r1547 r1548 into r1549; - not r6 into r1550; - and r1549 r1550 into r1551; - not r7 into r1552; - and r1551 r1552 into r1553; - not r8 into r1554; - and r1553 r1554 into r1555; - not r9 into r1556; - and r1555 r1556 into r1557; - and r1557 r10 into r1558; - ternary r1558 0u8 r1540 into r1559; - not r1 into r1560; - not r2 into r1561; - and r1560 r1561 into r1562; - not r3 into r1563; - and r1562 r1563 into r1564; - not r4 into r1565; - and r1564 r1565 into r1566; - not r5 into r1567; - and r1566 r1567 into r1568; - not r6 into r1569; - and r1568 r1569 into r1570; - not r7 into r1571; - and r1570 r1571 into r1572; - not r8 into r1573; - and r1572 r1573 into r1574; - and r1574 r9 into r1575; - ternary r1575 3u8 r1559 into r1576; - not r1 into r1577; - not r2 into r1578; - and r1577 r1578 into r1579; - not r3 into r1580; - and r1579 r1580 into r1581; - not r4 into r1582; - and r1581 r1582 into r1583; - not r5 into r1584; - and r1583 r1584 into r1585; - not r6 into r1586; - and r1585 r1586 into r1587; - not r7 into r1588; - and r1587 r1588 into r1589; - and r1589 r8 into r1590; - ternary r1590 13u8 r1576 into r1591; - not r1 into r1592; - not r2 into r1593; - and r1592 r1593 into r1594; - not r3 into r1595; - and r1594 r1595 into r1596; - not r4 into r1597; - and r1596 r1597 into r1598; - not r5 into r1599; - and r1598 r1599 into r1600; - not r6 into r1601; - and r1600 r1601 into r1602; - and r1602 r7 into r1603; - ternary r1603 0u8 r1591 into r1604; - not r1 into r1605; - not r2 into r1606; - and r1605 r1606 into r1607; - not r3 into r1608; - and r1607 r1608 into r1609; - not r4 into r1610; - and r1609 r1610 into r1611; - not r5 into r1612; - and r1611 r1612 into r1613; - and r1613 r6 into r1614; - ternary r1614 6u8 r1604 into r1615; - not r1 into r1616; - not r2 into r1617; - and r1616 r1617 into r1618; - not r3 into r1619; - and r1618 r1619 into r1620; - not r4 into r1621; - and r1620 r1621 into r1622; - and r1622 r5 into r1623; - ternary r1623 2u8 r1615 into r1624; - not r1 into r1625; - not r2 into r1626; - and r1625 r1626 into r1627; - not r3 into r1628; - and r1627 r1628 into r1629; - and r1629 r4 into r1630; - ternary r1630 12u8 r1624 into r1631; - not r1 into r1632; - not r2 into r1633; - and r1632 r1633 into r1634; - and r1634 r3 into r1635; - ternary r1635 1u8 r1631 into r1636; - not r1 into r1637; - and r1637 r2 into r1638; - ternary r1638 0u8 r1636 into r1639; - ternary r1 32u8 r1639 into r1640; - output r1640 as u8; - - -function main: - input r0 as u32.public; - sub.w 0u32 r0 into r1; - and r0 r1 into r2; - mul.w r2 72416175u32 into r3; - shr r3 26u8 into r4; - call sealsTableLookup r4 into r5; - output r5 as u8.private; diff --git a/examples/hackers-delight/ntzseals/build/program.json b/examples/hackers-delight/ntzseals/build/program.json deleted file mode 100644 index 86c375804d..0000000000 --- a/examples/hackers-delight/ntzseals/build/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "ntzseals.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/hackers-delight/ntzseals/inputs/ntzseals.in b/examples/hackers-delight/ntzseals/inputs/ntzseals.in deleted file mode 100644 index b140da3eb3..0000000000 --- a/examples/hackers-delight/ntzseals/inputs/ntzseals.in +++ /dev/null @@ -1 +0,0 @@ -2147483648u32 diff --git a/examples/hackers-delight/ntzseals/leo.lock b/examples/hackers-delight/ntzseals/leo.lock deleted file mode 100644 index c4293b3b9f..0000000000 --- a/examples/hackers-delight/ntzseals/leo.lock +++ /dev/null @@ -1 +0,0 @@ -package = [] diff --git a/examples/hackers-delight/ntzseals/program.json b/examples/hackers-delight/ntzseals/program.json deleted file mode 100644 index 86c375804d..0000000000 --- a/examples/hackers-delight/ntzseals/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "ntzseals.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/hackers-delight/ntzseals/src/main.leo b/examples/hackers-delight/ntzseals/src/main.leo deleted file mode 100644 index 04c3064456..0000000000 --- a/examples/hackers-delight/ntzseals/src/main.leo +++ /dev/null @@ -1,92 +0,0 @@ -program ntzseals.aleo { - // The 'nztseals' main function. - // From Hacker's Delight 2nd ed. figure 5-25 - transition main(public x: u32) -> u8 { - // 0x0450FBAF = 72416175 - x = (x & 0u32.sub_wrapped(x)).mul_wrapped(72416175u32); - return sealsTableLookup(x >> 26u8); - } - - // Right now we do not have any structure that allows - // computable indexing, so simulate that with a function. - // {32, 0, 1,12, 2, 6, u,13, 3, u, 7, u, u, u, u,14, - // 10, 4, u, u, 8, u, u,25, u, u, u, u, u,21,27,15, - // 31,11, 5, u, u, u, u, u, 9, u, u,24, u, u,20,26, - // 30, u, u, u, u,23, u,19, 29, u,22,18,28,17,16, u}; - - function sealsTableLookup(i: u32) -> u8 { - - if i == 0u32 {return 32u8;} else - if i == 1u32 {return 0u8;} else - if i == 2u32 {return 1u8;} else - if i == 3u32 {return 12u8;} else - if i == 4u32 {return 2u8;} else - if i == 5u32 {return 6u8;} else - if i == 6u32 {return 0u8;} else // unused - if i == 7u32 {return 13u8;} else - - if i == 8u32 {return 3u8;} else - if i == 9u32 {return 0u8;} else // unused - if i == 10u32 {return 7u8;} else - if i == 11u32 {return 0u8;} else // unused - if i == 12u32 {return 0u8;} else // unused - if i == 13u32 {return 0u8;} else // unused - if i == 14u32 {return 0u8;} else // unused - if i == 15u32 {return 14u8;} else - - if i == 16u32 {return 10u8;} else - if i == 17u32 {return 4u8;} else - if i == 18u32 {return 0u8;} else // unused - if i == 19u32 {return 0u8;} else // unused - if i == 20u32 {return 8u8;} else - if i == 21u32 {return 0u8;} else // unused - if i == 22u32 {return 0u8;} else // unused - if i == 23u32 {return 25u8;} else - - if i == 24u32 {return 0u8;} else // unused - if i == 25u32 {return 0u8;} else // unused - if i == 26u32 {return 0u8;} else // unused - if i == 27u32 {return 0u8;} else // unused - if i == 28u32 {return 0u8;} else // unused - if i == 29u32 {return 21u8;} else - if i == 30u32 {return 27u8;} else - if i == 31u32 {return 15u8;} else - - if i == 32u32 {return 31u8;} else - if i == 33u32 {return 11u8;} else - if i == 34u32 {return 5u8;} else - if i == 35u32 {return 0u8;} else // unused - if i == 36u32 {return 0u8;} else // unused - if i == 37u32 {return 0u8;} else // unused - if i == 38u32 {return 0u8;} else // unused - if i == 39u32 {return 0u8;} else // unused - - // if i == 40u32 {return 9u8;} else - // if i == 41u32 {return 0u8;} else // unused - // if i == 42u32 {return 0u8;} else // unused - // if i == 43u32 {return 24u8;} else - // if i == 44u32 {return 0u8;} else // unused - // if i == 45u32 {return 0u8;} else // unused - // if i == 46u32 {return 20u8;} else - // if i == 47u32 {return 26u8;} else - - // if i == 48u32 {return 30u8;} else - // if i == 49u32 {return 0u8;} else // unused - // if i == 50u32 {return 0u8;} else // unused - // if i == 51u32 {return 0u8;} else // unused - // if i == 52u32 {return 0u8;} else // unused - // if i == 53u32 {return 23u8;} else - // if i == 54u32 {return 0u8;} else // unused - // if i == 55u32 {return 19u8;} else - - // if i == 56u32 {return 29u8;} else - // if i == 57u32 {return 0u8;} else // unused - // if i == 58u32 {return 22u8;} else - // if i == 59u32 {return 18u8;} else - // if i == 60u32 {return 28u8;} else - // if i == 61u32 {return 17u8;} else - // if i == 62u32 {return 16u8;} else - // if i == 63u32 {return 0u8;} else // unused - {return 0u8;} // unused - } -} diff --git a/examples/hackers-delight/ntzsearchtree/.env b/examples/hackers-delight/ntzsearchtree/.env deleted file mode 100644 index ab204ee457..0000000000 --- a/examples/hackers-delight/ntzsearchtree/.env +++ /dev/null @@ -1,3 +0,0 @@ -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH -ENDPOINT=http://localhost:3030 diff --git a/examples/hackers-delight/ntzsearchtree/.gitignore b/examples/hackers-delight/ntzsearchtree/.gitignore deleted file mode 100644 index 750b56f237..0000000000 --- a/examples/hackers-delight/ntzsearchtree/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -outputs/ -*.avm -*.prover -*.verifier \ No newline at end of file diff --git a/examples/hackers-delight/ntzsearchtree/README.md b/examples/hackers-delight/ntzsearchtree/README.md deleted file mode 100644 index 147cbd23b1..0000000000 --- a/examples/hackers-delight/ntzsearchtree/README.md +++ /dev/null @@ -1,22 +0,0 @@ -# src/ntzsearchtree.leo - -## Build Guide - -To compile and run this Leo program, run: -```bash -leo run -``` - -## The Algorithm - -An 8-bit version of this algorithm is described in "Hacker's Delight, 2nd -edition" by Henry S. Warren, section 5-4, figure 5-22. - -This algorithm contains a fully-explicated search tree to find where the lowest -order 1 bit is in a 32-bit input, and returns the number of trailing zeros for -each case. - -In the second half of the function, the low 16 bits are zero, so the masks that -select the higher bits are larger. To make the numbers more readable, we -multiply the first half constants by `65536u32` which will be constant-folded -during Leo compilation and should not increase the resulting circuit size. diff --git a/examples/hackers-delight/ntzsearchtree/build/main.aleo b/examples/hackers-delight/ntzsearchtree/build/main.aleo deleted file mode 100644 index d8d62bfef3..0000000000 --- a/examples/hackers-delight/ntzsearchtree/build/main.aleo +++ /dev/null @@ -1,326 +0,0 @@ -program ntzsearchtree.aleo; - - - -function main: - input r0 as u32.public; - and r0 65535u32 into r1; - is.neq r1 0u32 into r2; - and r0 255u32 into r3; - is.neq r3 0u32 into r4; - and r0 15u32 into r5; - is.neq r5 0u32 into r6; - and r0 3u32 into r7; - is.neq r7 0u32 into r8; - and r0 1u32 into r9; - is.neq r9 0u32 into r10; - and r0 4u32 into r11; - is.neq r11 0u32 into r12; - and r0 48u32 into r13; - is.neq r13 0u32 into r14; - and r0 16u32 into r15; - is.neq r15 0u32 into r16; - and r0 64u32 into r17; - is.neq r17 0u32 into r18; - and r0 3840u32 into r19; - is.neq r19 0u32 into r20; - and r0 768u32 into r21; - is.neq r21 0u32 into r22; - and r0 256u32 into r23; - is.neq r23 0u32 into r24; - and r0 1024u32 into r25; - is.neq r25 0u32 into r26; - and r0 12288u32 into r27; - is.neq r27 0u32 into r28; - and r0 4096u32 into r29; - is.neq r29 0u32 into r30; - and r0 16384u32 into r31; - is.neq r31 0u32 into r32; - mul 255u32 65536u32 into r33; - and r0 r33 into r34; - is.neq r34 0u32 into r35; - mul 15u32 65536u32 into r36; - and r0 r36 into r37; - is.neq r37 0u32 into r38; - mul 3u32 65536u32 into r39; - and r0 r39 into r40; - is.neq r40 0u32 into r41; - mul 1u32 65536u32 into r42; - and r0 r42 into r43; - is.neq r43 0u32 into r44; - mul 4u32 65536u32 into r45; - and r0 r45 into r46; - is.neq r46 0u32 into r47; - mul 48u32 65536u32 into r48; - and r0 r48 into r49; - is.neq r49 0u32 into r50; - mul 16u32 65536u32 into r51; - and r0 r51 into r52; - is.neq r52 0u32 into r53; - mul 64u32 65536u32 into r54; - and r0 r54 into r55; - is.neq r55 0u32 into r56; - mul 3840u32 65536u32 into r57; - and r0 r57 into r58; - is.neq r58 0u32 into r59; - mul 768u32 65536u32 into r60; - and r0 r60 into r61; - is.neq r61 0u32 into r62; - mul 256u32 65536u32 into r63; - and r0 r63 into r64; - is.neq r64 0u32 into r65; - mul 1024u32 65536u32 into r66; - and r0 r66 into r67; - is.neq r67 0u32 into r68; - mul 12288u32 65536u32 into r69; - and r0 r69 into r70; - is.neq r70 0u32 into r71; - mul 4096u32 65536u32 into r72; - and r0 r72 into r73; - is.neq r73 0u32 into r74; - mul 16384u32 65536u32 into r75; - and r0 r75 into r76; - is.neq r76 0u32 into r77; - is.neq r0 0u32 into r78; - not r2 into r79; - not r35 into r80; - and r79 r80 into r81; - not r59 into r82; - and r81 r82 into r83; - not r71 into r84; - and r83 r84 into r85; - not r77 into r86; - and r85 r86 into r87; - and r87 r78 into r88; - ternary r88 31u8 32u8 into r89; - not r2 into r90; - not r35 into r91; - and r90 r91 into r92; - not r59 into r93; - and r92 r93 into r94; - not r71 into r95; - and r94 r95 into r96; - and r96 r77 into r97; - ternary r97 30u8 r89 into r98; - not r2 into r99; - not r35 into r100; - and r99 r100 into r101; - not r59 into r102; - and r101 r102 into r103; - and r103 r71 into r104; - not r74 into r105; - and r104 r105 into r106; - ternary r106 29u8 r98 into r107; - not r2 into r108; - not r35 into r109; - and r108 r109 into r110; - not r59 into r111; - and r110 r111 into r112; - and r112 r71 into r113; - and r113 r74 into r114; - ternary r114 28u8 r107 into r115; - not r2 into r116; - not r35 into r117; - and r116 r117 into r118; - and r118 r59 into r119; - not r62 into r120; - and r119 r120 into r121; - not r68 into r122; - and r121 r122 into r123; - ternary r123 27u8 r115 into r124; - not r2 into r125; - not r35 into r126; - and r125 r126 into r127; - and r127 r59 into r128; - not r62 into r129; - and r128 r129 into r130; - and r130 r68 into r131; - ternary r131 26u8 r124 into r132; - not r2 into r133; - not r35 into r134; - and r133 r134 into r135; - and r135 r59 into r136; - and r136 r62 into r137; - not r65 into r138; - and r137 r138 into r139; - ternary r139 25u8 r132 into r140; - not r2 into r141; - not r35 into r142; - and r141 r142 into r143; - and r143 r59 into r144; - and r144 r62 into r145; - and r145 r65 into r146; - ternary r146 24u8 r140 into r147; - not r2 into r148; - and r148 r35 into r149; - not r38 into r150; - and r149 r150 into r151; - not r50 into r152; - and r151 r152 into r153; - not r56 into r154; - and r153 r154 into r155; - ternary r155 23u8 r147 into r156; - not r2 into r157; - and r157 r35 into r158; - not r38 into r159; - and r158 r159 into r160; - not r50 into r161; - and r160 r161 into r162; - and r162 r56 into r163; - ternary r163 22u8 r156 into r164; - not r2 into r165; - and r165 r35 into r166; - not r38 into r167; - and r166 r167 into r168; - and r168 r50 into r169; - not r53 into r170; - and r169 r170 into r171; - ternary r171 21u8 r164 into r172; - not r2 into r173; - and r173 r35 into r174; - not r38 into r175; - and r174 r175 into r176; - and r176 r50 into r177; - and r177 r53 into r178; - ternary r178 20u8 r172 into r179; - not r2 into r180; - and r180 r35 into r181; - and r181 r38 into r182; - not r41 into r183; - and r182 r183 into r184; - not r47 into r185; - and r184 r185 into r186; - ternary r186 19u8 r179 into r187; - not r2 into r188; - and r188 r35 into r189; - and r189 r38 into r190; - not r41 into r191; - and r190 r191 into r192; - and r192 r47 into r193; - ternary r193 18u8 r187 into r194; - not r2 into r195; - and r195 r35 into r196; - and r196 r38 into r197; - and r197 r41 into r198; - not r44 into r199; - and r198 r199 into r200; - ternary r200 17u8 r194 into r201; - not r2 into r202; - and r202 r35 into r203; - and r203 r38 into r204; - and r204 r41 into r205; - and r205 r44 into r206; - ternary r206 16u8 r201 into r207; - not r4 into r208; - and r2 r208 into r209; - not r20 into r210; - and r209 r210 into r211; - not r28 into r212; - and r211 r212 into r213; - not r32 into r214; - and r213 r214 into r215; - ternary r215 15u8 r207 into r216; - not r4 into r217; - and r2 r217 into r218; - not r20 into r219; - and r218 r219 into r220; - not r28 into r221; - and r220 r221 into r222; - and r222 r32 into r223; - ternary r223 14u8 r216 into r224; - not r4 into r225; - and r2 r225 into r226; - not r20 into r227; - and r226 r227 into r228; - and r228 r28 into r229; - not r30 into r230; - and r229 r230 into r231; - ternary r231 13u8 r224 into r232; - not r4 into r233; - and r2 r233 into r234; - not r20 into r235; - and r234 r235 into r236; - and r236 r28 into r237; - and r237 r30 into r238; - ternary r238 12u8 r232 into r239; - not r4 into r240; - and r2 r240 into r241; - and r241 r20 into r242; - not r22 into r243; - and r242 r243 into r244; - not r26 into r245; - and r244 r245 into r246; - ternary r246 11u8 r239 into r247; - not r4 into r248; - and r2 r248 into r249; - and r249 r20 into r250; - not r22 into r251; - and r250 r251 into r252; - and r252 r26 into r253; - ternary r253 10u8 r247 into r254; - not r4 into r255; - and r2 r255 into r256; - and r256 r20 into r257; - and r257 r22 into r258; - not r24 into r259; - and r258 r259 into r260; - ternary r260 9u8 r254 into r261; - not r4 into r262; - and r2 r262 into r263; - and r263 r20 into r264; - and r264 r22 into r265; - and r265 r24 into r266; - ternary r266 8u8 r261 into r267; - and r2 r4 into r268; - not r6 into r269; - and r268 r269 into r270; - not r14 into r271; - and r270 r271 into r272; - not r18 into r273; - and r272 r273 into r274; - ternary r274 7u8 r267 into r275; - and r2 r4 into r276; - not r6 into r277; - and r276 r277 into r278; - not r14 into r279; - and r278 r279 into r280; - and r280 r18 into r281; - ternary r281 6u8 r275 into r282; - and r2 r4 into r283; - not r6 into r284; - and r283 r284 into r285; - and r285 r14 into r286; - not r16 into r287; - and r286 r287 into r288; - ternary r288 5u8 r282 into r289; - and r2 r4 into r290; - not r6 into r291; - and r290 r291 into r292; - and r292 r14 into r293; - and r293 r16 into r294; - ternary r294 4u8 r289 into r295; - and r2 r4 into r296; - and r296 r6 into r297; - not r8 into r298; - and r297 r298 into r299; - not r12 into r300; - and r299 r300 into r301; - ternary r301 3u8 r295 into r302; - and r2 r4 into r303; - and r303 r6 into r304; - not r8 into r305; - and r304 r305 into r306; - and r306 r12 into r307; - ternary r307 2u8 r302 into r308; - and r2 r4 into r309; - and r309 r6 into r310; - and r310 r8 into r311; - not r10 into r312; - and r311 r312 into r313; - ternary r313 1u8 r308 into r314; - and r2 r4 into r315; - and r315 r6 into r316; - and r316 r8 into r317; - and r317 r10 into r318; - ternary r318 0u8 r314 into r319; - output r319 as u8.private; diff --git a/examples/hackers-delight/ntzsearchtree/build/program.json b/examples/hackers-delight/ntzsearchtree/build/program.json deleted file mode 100644 index 0137aac8db..0000000000 --- a/examples/hackers-delight/ntzsearchtree/build/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "ntzsearchtree.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/hackers-delight/ntzsearchtree/inputs/ntzsearchtree.in b/examples/hackers-delight/ntzsearchtree/inputs/ntzsearchtree.in deleted file mode 100644 index b140da3eb3..0000000000 --- a/examples/hackers-delight/ntzsearchtree/inputs/ntzsearchtree.in +++ /dev/null @@ -1 +0,0 @@ -2147483648u32 diff --git a/examples/hackers-delight/ntzsearchtree/leo.lock b/examples/hackers-delight/ntzsearchtree/leo.lock deleted file mode 100644 index c4293b3b9f..0000000000 --- a/examples/hackers-delight/ntzsearchtree/leo.lock +++ /dev/null @@ -1 +0,0 @@ -package = [] diff --git a/examples/hackers-delight/ntzsearchtree/program.json b/examples/hackers-delight/ntzsearchtree/program.json deleted file mode 100644 index 0137aac8db..0000000000 --- a/examples/hackers-delight/ntzsearchtree/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "ntzsearchtree.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/hackers-delight/ntzsearchtree/src/main.leo b/examples/hackers-delight/ntzsearchtree/src/main.leo deleted file mode 100644 index 39aa4baf2e..0000000000 --- a/examples/hackers-delight/ntzsearchtree/src/main.leo +++ /dev/null @@ -1,76 +0,0 @@ -program ntzsearchtree.aleo { - // The 'ntzsearchtree' main function. - // From Hacker's Delight 2nd ed. figure 5-22, - // expanded to a 32-bit version. - transition main(public x: u32) -> u8 { - if (x & 65535u32 != 0u32) { - if (x & 255u32 != 0u32) { - if (x & 15u32 != 0u32) { - if (x & 3u32 != 0u32) { - if (x & 1u32 != 0u32) {return 0u8;} - else {return 1u8;} } - else { - if (x & 4u32 != 0u32) {return 2u8;} - else {return 3u8;} } } - else { // low 4 bits are 0 but low 8 bits are not zero - if (x & 48u32 != 0u32) { // 48 = 0011 0000 - if (x & 16u32 != 0u32) {return 4u8;} - else {return 5u8;} } - else {if (x & 64u32 != 0u32) {return 6u8;} - else {return 7u8;} } } } - else { // low 8 bits are 0 but low 16 bits are not zero - // 3840 = 00001111 00000000 - if (x & 3840u32 != 0u32) { - // 768 = 00000011 00000000 - if (x & 768u32 != 0u32) { - if (x & 256u32 != 0u32) {return 8u8;} - else {return 9u8;} } - else { // 1024 = 00000100 00000000 - if (x & 1024u32 != 0u32) {return 10u8;} - else {return 11u8;} } } - else { // low 12 bits are 0 but low 16 bits are not zero - // 12288 = 0011 0000 0000 0000 - if (x & 12288u32 != 0u32) { - // 4096 = 0001 0000 0000 0000 - if (x & 4096u32 != 0u32) {return 12u8;} - else {return 13u8;} } - else { // low 14 bits are 0 but low 16 bits are not zero - // 16384 = 0100 0000 0000 0000 - if (x & 16384u32 != 0u32) {return 14u8;} - else {return 15u8;} } } } } - else { // low 16 bits are zero, now look at high 16 bits - // Simply by multiplying the previous constants by 65536 - if (x & (255u32 * 65536u32) != 0u32) { - if (x & (15u32 * 65536u32) != 0u32) { - if (x & (3u32 * 65536u32) != 0u32) { - if (x & (1u32 * 65536u32) != 0u32) {return 16u8;} - else {return 17u8;} } - else { - if (x & (4u32 * 65536u32) != 0u32) {return 18u8;} - else {return 19u8;} } } - else { - if (x & (48u32 * 65536u32) != 0u32) { - if (x & (16u32 * 65536u32) != 0u32) {return 20u8;} - else {return 21u8;} } - else { - if (x & (64u32 * 65536u32) != 0u32) {return 22u8;} - else {return 23u8;} } } } - else { - if (x & (3840u32 * 65536u32) != 0u32) { - if (x & (768u32 * 65536u32) != 0u32) { - if (x & (256u32 * 65536u32) != 0u32) {return 24u8;} - else {return 25u8;} } - else { - if (x & (1024u32 * 65536u32) != 0u32) {return 26u8;} - else {return 27u8;} } } - else { - if (x & (12288u32 * 65536u32) != 0u32) { - if (x & (4096u32 * 65536u32) != 0u32) {return 28u8;} - else {return 29u8;} } - else { - if (x & (16384u32 * 65536u32) != 0u32) {return 30u8;} - else { - if (x != 0u32) {return 31u8;} - else {return 32u8;} } } } } } - } -} diff --git a/examples/hackers-delight/ntzsmallvals/.env b/examples/hackers-delight/ntzsmallvals/.env deleted file mode 100644 index ab204ee457..0000000000 --- a/examples/hackers-delight/ntzsmallvals/.env +++ /dev/null @@ -1,3 +0,0 @@ -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH -ENDPOINT=http://localhost:3030 diff --git a/examples/hackers-delight/ntzsmallvals/.gitignore b/examples/hackers-delight/ntzsmallvals/.gitignore deleted file mode 100644 index 750b56f237..0000000000 --- a/examples/hackers-delight/ntzsmallvals/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -outputs/ -*.avm -*.prover -*.verifier \ No newline at end of file diff --git a/examples/hackers-delight/ntzsmallvals/README.md b/examples/hackers-delight/ntzsmallvals/README.md deleted file mode 100644 index 1b99a7f4ff..0000000000 --- a/examples/hackers-delight/ntzsmallvals/README.md +++ /dev/null @@ -1,22 +0,0 @@ -# src/ntzsmallvals.leo - -## Build Guide - -To compile and run this Leo program, run: -```bash -leo run -``` - -## The Algorithm - -This algorithm is mentioned in "Hacker's Delight, 2nd edition" -by Henry S. Warren, section 5-4, section 5-4, figure 5-21. - -It is similar to the algorithm described in the `ntzmasks` example -(figure 5-20 in the book) in that it uses binary search to find the -number of trailing zeros. However, instead of using masks to select -the lower `N` bits, it shifts `x` left (discarding high bits) into -another variable `y` to check if the result is nonzero, and it counts -down from 31 instead of up from 1. Another difference is that the -constant values is this algorithm are smaller, so it is easier to -read. diff --git a/examples/hackers-delight/ntzsmallvals/build/main.aleo b/examples/hackers-delight/ntzsmallvals/build/main.aleo deleted file mode 100644 index 6cfca114cd..0000000000 --- a/examples/hackers-delight/ntzsmallvals/build/main.aleo +++ /dev/null @@ -1,33 +0,0 @@ -program ntzsmallvals.aleo; - - - -function main: - input r0 as u32.public; - is.eq r0 0u32 into r1; - shl.w r0 16u8 into r2; - is.neq r2 0u32 into r3; - sub 31u8 16u8 into r4; - ternary r3 r4 31u8 into r5; - ternary r3 r2 r0 into r6; - shl.w r6 8u8 into r7; - is.neq r7 0u32 into r8; - sub r5 8u8 into r9; - ternary r8 r9 r5 into r10; - ternary r8 r7 r6 into r11; - shl.w r11 4u8 into r12; - is.neq r12 0u32 into r13; - sub r10 4u8 into r14; - ternary r13 r14 r10 into r15; - ternary r13 r12 r11 into r16; - shl.w r16 2u8 into r17; - is.neq r17 0u32 into r18; - sub r15 2u8 into r19; - ternary r18 r19 r15 into r20; - ternary r18 r17 r16 into r21; - shl.w r21 1u8 into r22; - is.neq r22 0u32 into r23; - sub r20 1u8 into r24; - ternary r23 r24 r20 into r25; - ternary r1 32u8 r25 into r26; - output r26 as u8.private; diff --git a/examples/hackers-delight/ntzsmallvals/build/program.json b/examples/hackers-delight/ntzsmallvals/build/program.json deleted file mode 100644 index 1f9bebd3ef..0000000000 --- a/examples/hackers-delight/ntzsmallvals/build/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "ntzsmallvals.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/hackers-delight/ntzsmallvals/inputs/ntzsmallvals.in b/examples/hackers-delight/ntzsmallvals/inputs/ntzsmallvals.in deleted file mode 100644 index b140da3eb3..0000000000 --- a/examples/hackers-delight/ntzsmallvals/inputs/ntzsmallvals.in +++ /dev/null @@ -1 +0,0 @@ -2147483648u32 diff --git a/examples/hackers-delight/ntzsmallvals/leo.lock b/examples/hackers-delight/ntzsmallvals/leo.lock deleted file mode 100644 index c4293b3b9f..0000000000 --- a/examples/hackers-delight/ntzsmallvals/leo.lock +++ /dev/null @@ -1 +0,0 @@ -package = [] diff --git a/examples/hackers-delight/ntzsmallvals/program.json b/examples/hackers-delight/ntzsmallvals/program.json deleted file mode 100644 index 1f9bebd3ef..0000000000 --- a/examples/hackers-delight/ntzsmallvals/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "ntzsmallvals.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/hackers-delight/ntzsmallvals/src/main.leo b/examples/hackers-delight/ntzsmallvals/src/main.leo deleted file mode 100644 index 14a1694895..0000000000 --- a/examples/hackers-delight/ntzsmallvals/src/main.leo +++ /dev/null @@ -1,14 +0,0 @@ -program ntzsmallvals.aleo { - // The 'ntzsmallvals' main function. - // From Hacker's Delight 2nd ed. figure 5-21 - transition main(public x: u32) -> u8 { - if (x == 0u32) {return 32u8;} - let n: u8 = 31u8; - let y: u32 = x.shl_wrapped(16u8); if (y != 0u32) {n = n - 16u8; x = y;} - y = x.shl_wrapped(8u8); if (y != 0u32) {n = n - 8u8; x = y;} - y = x.shl_wrapped(4u8); if (y != 0u32) {n = n - 4u8; x = y;} - y = x.shl_wrapped(2u8); if (y != 0u32) {n = n - 2u8; x = y;} - y = x.shl_wrapped(1u8); if (y != 0u32) {n = n - 1u8;} - return n; - } -} diff --git a/examples/helloworld/.env b/examples/helloworld/.env deleted file mode 100644 index ab204ee457..0000000000 --- a/examples/helloworld/.env +++ /dev/null @@ -1,3 +0,0 @@ -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH -ENDPOINT=http://localhost:3030 diff --git a/examples/helloworld/.gitignore b/examples/helloworld/.gitignore deleted file mode 100644 index 750b56f237..0000000000 --- a/examples/helloworld/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -outputs/ -*.avm -*.prover -*.verifier \ No newline at end of file diff --git a/examples/helloworld/README.md b/examples/helloworld/README.md deleted file mode 100644 index 75fa0f1793..0000000000 --- a/examples/helloworld/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# Leo helloworld - -## Run Guide - -To run this program, run: -```bash -leo run -``` - -## Execute Guide - -To execute this program, run: -```bash -leo execute main -``` - -## Overview - -This example shows how to sum two u32 numbers. - -It takes the input data from inputs/helloworld.in diff --git a/examples/helloworld/build/main.aleo b/examples/helloworld/build/main.aleo deleted file mode 100644 index 5c4658f7a2..0000000000 --- a/examples/helloworld/build/main.aleo +++ /dev/null @@ -1,9 +0,0 @@ -program helloworld.aleo; - - - -function main: - input r0 as u32.public; - input r1 as u32.private; - add r0 r1 into r2; - output r2 as u32.private; diff --git a/examples/helloworld/build/program.json b/examples/helloworld/build/program.json deleted file mode 100644 index df13181a2c..0000000000 --- a/examples/helloworld/build/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "helloworld.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/helloworld/hello/.gitignore b/examples/helloworld/hello/.gitignore deleted file mode 100644 index f721f7f6f4..0000000000 --- a/examples/helloworld/hello/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -.env -*.avm -*.prover -*.verifier -outputs/ diff --git a/examples/helloworld/hello/README.md b/examples/helloworld/hello/README.md deleted file mode 100644 index 53cfde8c89..0000000000 --- a/examples/helloworld/hello/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# hello.aleo - -## Build Guide - -To compile this Aleo program, run: -```bash -snarkvm build -``` - -To execute this Aleo program, run: -```bash -snarkvm run hello -``` diff --git a/examples/helloworld/hello/build/main.aleo b/examples/helloworld/hello/build/main.aleo deleted file mode 100644 index 7cdbe45740..0000000000 --- a/examples/helloworld/hello/build/main.aleo +++ /dev/null @@ -1,9 +0,0 @@ -program hello.aleo; - - - -function main: - input r0 as u32.public; - input r1 as u32.private; - add r0 r1 into r2; - output r2 as u32.private; diff --git a/examples/helloworld/hello/build/program.json b/examples/helloworld/hello/build/program.json deleted file mode 100644 index a4c305481b..0000000000 --- a/examples/helloworld/hello/build/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "hello.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/helloworld/hello/inputs/hello.in b/examples/helloworld/hello/inputs/hello.in deleted file mode 100644 index 70824e61eb..0000000000 --- a/examples/helloworld/hello/inputs/hello.in +++ /dev/null @@ -1,4 +0,0 @@ -// The program input for hello/src/main.leo -[main] -public a: u32 = 1u32; -b: u32 = 2u32; diff --git a/examples/helloworld/hello/program.json b/examples/helloworld/hello/program.json deleted file mode 100644 index a4c305481b..0000000000 --- a/examples/helloworld/hello/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "hello.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/helloworld/hello/src/main.leo b/examples/helloworld/hello/src/main.leo deleted file mode 100644 index dc5295871c..0000000000 --- a/examples/helloworld/hello/src/main.leo +++ /dev/null @@ -1,7 +0,0 @@ -// The 'hello' program. -program hello.aleo { - transition main(public a: u32, b: u32) -> u32 { - let c: u32 = a + b; - return c; - } -} diff --git a/examples/helloworld/inputs/helloworld.in b/examples/helloworld/inputs/helloworld.in deleted file mode 100644 index 35ea052c38..0000000000 --- a/examples/helloworld/inputs/helloworld.in +++ /dev/null @@ -1 +0,0 @@ -1u32 2u32 diff --git a/examples/helloworld/leo.lock b/examples/helloworld/leo.lock deleted file mode 100644 index c4293b3b9f..0000000000 --- a/examples/helloworld/leo.lock +++ /dev/null @@ -1 +0,0 @@ -package = [] diff --git a/examples/helloworld/program.json b/examples/helloworld/program.json deleted file mode 100644 index df13181a2c..0000000000 --- a/examples/helloworld/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "helloworld.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/helloworld/src/main.leo b/examples/helloworld/src/main.leo deleted file mode 100644 index f676c1cfe4..0000000000 --- a/examples/helloworld/src/main.leo +++ /dev/null @@ -1,7 +0,0 @@ -program helloworld.aleo { - // The 'helloworld' main function. - transition main(public a: u32, b: u32) -> u32 { - return a + b; - } -} - diff --git a/examples/interest/.env b/examples/interest/.env deleted file mode 100644 index ab204ee457..0000000000 --- a/examples/interest/.env +++ /dev/null @@ -1,3 +0,0 @@ -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH -ENDPOINT=http://localhost:3030 diff --git a/examples/interest/.gitignore b/examples/interest/.gitignore deleted file mode 100644 index 750b56f237..0000000000 --- a/examples/interest/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -outputs/ -*.avm -*.prover -*.verifier \ No newline at end of file diff --git a/examples/interest/README.md b/examples/interest/README.md deleted file mode 100644 index 06ef484d11..0000000000 --- a/examples/interest/README.md +++ /dev/null @@ -1,27 +0,0 @@ -# Calculating Interest - -This program provides utilities for calculating interest over a fixed or bounded number of iterations. - -## Running the Program - -To run this program, run: -```bash -leo run -``` -where `` is one of the following: -* `fixed_iteration_interest` -* `bounded_iteration_interest` - -Be sure to update `inputs/interest.in` with the desired inputs. - -## Executing the Program - -To execute this program, run: -```bash -leo execute -``` -where `` is one of the following: -* `fixed_iteration_interest` -* `bounded_iteration_interest` - -Be sure to update `inputs/interest.in` with the desired inputs. diff --git a/examples/interest/build/main.aleo b/examples/interest/build/main.aleo deleted file mode 100644 index 4fd7f9a479..0000000000 --- a/examples/interest/build/main.aleo +++ /dev/null @@ -1,397 +0,0 @@ -program interest.aleo; - - - -function fixed_iteration_interest: - input r0 as u32.private; - input r1 as u32.public; - mul r0 r1 into r2; - div r2 100u32 into r3; - add r0 r3 into r4; - mul r4 r1 into r5; - div r5 100u32 into r6; - add r4 r6 into r7; - mul r7 r1 into r8; - div r8 100u32 into r9; - add r7 r9 into r10; - mul r10 r1 into r11; - div r11 100u32 into r12; - add r10 r12 into r13; - mul r13 r1 into r14; - div r14 100u32 into r15; - add r13 r15 into r16; - mul r16 r1 into r17; - div r17 100u32 into r18; - add r16 r18 into r19; - mul r19 r1 into r20; - div r20 100u32 into r21; - add r19 r21 into r22; - mul r22 r1 into r23; - div r23 100u32 into r24; - add r22 r24 into r25; - mul r25 r1 into r26; - div r26 100u32 into r27; - add r25 r27 into r28; - mul r28 r1 into r29; - div r29 100u32 into r30; - add r28 r30 into r31; - output r31 as u32.private; - - -function bounded_iteration_interest: - input r0 as u32.private; - input r1 as u32.public; - input r2 as u8.private; - lte r2 50u8 into r3; - assert.eq r3 true; - lt 0u8 r2 into r4; - mul r0 r1 into r5; - div r5 100u32 into r6; - add r0 r6 into r7; - ternary r4 r7 r0 into r8; - is.eq 0u8 40u8 into r9; - lt 1u8 r2 into r10; - mul r8 r1 into r11; - div r11 100u32 into r12; - add r8 r12 into r13; - ternary r10 r13 r8 into r14; - is.eq 1u8 40u8 into r15; - lt 2u8 r2 into r16; - mul r14 r1 into r17; - div r17 100u32 into r18; - add r14 r18 into r19; - ternary r16 r19 r14 into r20; - is.eq 2u8 40u8 into r21; - lt 3u8 r2 into r22; - mul r20 r1 into r23; - div r23 100u32 into r24; - add r20 r24 into r25; - ternary r22 r25 r20 into r26; - is.eq 3u8 40u8 into r27; - lt 4u8 r2 into r28; - mul r26 r1 into r29; - div r29 100u32 into r30; - add r26 r30 into r31; - ternary r28 r31 r26 into r32; - is.eq 4u8 40u8 into r33; - lt 5u8 r2 into r34; - mul r32 r1 into r35; - div r35 100u32 into r36; - add r32 r36 into r37; - ternary r34 r37 r32 into r38; - is.eq 5u8 40u8 into r39; - lt 6u8 r2 into r40; - mul r38 r1 into r41; - div r41 100u32 into r42; - add r38 r42 into r43; - ternary r40 r43 r38 into r44; - is.eq 6u8 40u8 into r45; - lt 7u8 r2 into r46; - mul r44 r1 into r47; - div r47 100u32 into r48; - add r44 r48 into r49; - ternary r46 r49 r44 into r50; - is.eq 7u8 40u8 into r51; - lt 8u8 r2 into r52; - mul r50 r1 into r53; - div r53 100u32 into r54; - add r50 r54 into r55; - ternary r52 r55 r50 into r56; - is.eq 8u8 40u8 into r57; - lt 9u8 r2 into r58; - mul r56 r1 into r59; - div r59 100u32 into r60; - add r56 r60 into r61; - ternary r58 r61 r56 into r62; - is.eq 9u8 40u8 into r63; - lt 10u8 r2 into r64; - mul r62 r1 into r65; - div r65 100u32 into r66; - add r62 r66 into r67; - ternary r64 r67 r62 into r68; - is.eq 10u8 40u8 into r69; - lt 11u8 r2 into r70; - mul r68 r1 into r71; - div r71 100u32 into r72; - add r68 r72 into r73; - ternary r70 r73 r68 into r74; - is.eq 11u8 40u8 into r75; - lt 12u8 r2 into r76; - mul r74 r1 into r77; - div r77 100u32 into r78; - add r74 r78 into r79; - ternary r76 r79 r74 into r80; - is.eq 12u8 40u8 into r81; - lt 13u8 r2 into r82; - mul r80 r1 into r83; - div r83 100u32 into r84; - add r80 r84 into r85; - ternary r82 r85 r80 into r86; - is.eq 13u8 40u8 into r87; - lt 14u8 r2 into r88; - mul r86 r1 into r89; - div r89 100u32 into r90; - add r86 r90 into r91; - ternary r88 r91 r86 into r92; - is.eq 14u8 40u8 into r93; - lt 15u8 r2 into r94; - mul r92 r1 into r95; - div r95 100u32 into r96; - add r92 r96 into r97; - ternary r94 r97 r92 into r98; - is.eq 15u8 40u8 into r99; - lt 16u8 r2 into r100; - mul r98 r1 into r101; - div r101 100u32 into r102; - add r98 r102 into r103; - ternary r100 r103 r98 into r104; - is.eq 16u8 40u8 into r105; - lt 17u8 r2 into r106; - mul r104 r1 into r107; - div r107 100u32 into r108; - add r104 r108 into r109; - ternary r106 r109 r104 into r110; - is.eq 17u8 40u8 into r111; - lt 18u8 r2 into r112; - mul r110 r1 into r113; - div r113 100u32 into r114; - add r110 r114 into r115; - ternary r112 r115 r110 into r116; - is.eq 18u8 40u8 into r117; - lt 19u8 r2 into r118; - mul r116 r1 into r119; - div r119 100u32 into r120; - add r116 r120 into r121; - ternary r118 r121 r116 into r122; - is.eq 19u8 40u8 into r123; - lt 20u8 r2 into r124; - mul r122 r1 into r125; - div r125 100u32 into r126; - add r122 r126 into r127; - ternary r124 r127 r122 into r128; - is.eq 20u8 40u8 into r129; - lt 21u8 r2 into r130; - mul r128 r1 into r131; - div r131 100u32 into r132; - add r128 r132 into r133; - ternary r130 r133 r128 into r134; - is.eq 21u8 40u8 into r135; - lt 22u8 r2 into r136; - mul r134 r1 into r137; - div r137 100u32 into r138; - add r134 r138 into r139; - ternary r136 r139 r134 into r140; - is.eq 22u8 40u8 into r141; - lt 23u8 r2 into r142; - mul r140 r1 into r143; - div r143 100u32 into r144; - add r140 r144 into r145; - ternary r142 r145 r140 into r146; - is.eq 23u8 40u8 into r147; - lt 24u8 r2 into r148; - mul r146 r1 into r149; - div r149 100u32 into r150; - add r146 r150 into r151; - ternary r148 r151 r146 into r152; - is.eq 24u8 40u8 into r153; - lt 25u8 r2 into r154; - mul r152 r1 into r155; - div r155 100u32 into r156; - add r152 r156 into r157; - ternary r154 r157 r152 into r158; - is.eq 25u8 40u8 into r159; - lt 26u8 r2 into r160; - mul r158 r1 into r161; - div r161 100u32 into r162; - add r158 r162 into r163; - ternary r160 r163 r158 into r164; - is.eq 26u8 40u8 into r165; - lt 27u8 r2 into r166; - mul r164 r1 into r167; - div r167 100u32 into r168; - add r164 r168 into r169; - ternary r166 r169 r164 into r170; - is.eq 27u8 40u8 into r171; - lt 28u8 r2 into r172; - mul r170 r1 into r173; - div r173 100u32 into r174; - add r170 r174 into r175; - ternary r172 r175 r170 into r176; - is.eq 28u8 40u8 into r177; - lt 29u8 r2 into r178; - mul r176 r1 into r179; - div r179 100u32 into r180; - add r176 r180 into r181; - ternary r178 r181 r176 into r182; - is.eq 29u8 40u8 into r183; - lt 30u8 r2 into r184; - mul r182 r1 into r185; - div r185 100u32 into r186; - add r182 r186 into r187; - ternary r184 r187 r182 into r188; - is.eq 30u8 40u8 into r189; - lt 31u8 r2 into r190; - mul r188 r1 into r191; - div r191 100u32 into r192; - add r188 r192 into r193; - ternary r190 r193 r188 into r194; - is.eq 31u8 40u8 into r195; - lt 32u8 r2 into r196; - mul r194 r1 into r197; - div r197 100u32 into r198; - add r194 r198 into r199; - ternary r196 r199 r194 into r200; - is.eq 32u8 40u8 into r201; - lt 33u8 r2 into r202; - mul r200 r1 into r203; - div r203 100u32 into r204; - add r200 r204 into r205; - ternary r202 r205 r200 into r206; - is.eq 33u8 40u8 into r207; - lt 34u8 r2 into r208; - mul r206 r1 into r209; - div r209 100u32 into r210; - add r206 r210 into r211; - ternary r208 r211 r206 into r212; - is.eq 34u8 40u8 into r213; - lt 35u8 r2 into r214; - mul r212 r1 into r215; - div r215 100u32 into r216; - add r212 r216 into r217; - ternary r214 r217 r212 into r218; - is.eq 35u8 40u8 into r219; - lt 36u8 r2 into r220; - mul r218 r1 into r221; - div r221 100u32 into r222; - add r218 r222 into r223; - ternary r220 r223 r218 into r224; - is.eq 36u8 40u8 into r225; - lt 37u8 r2 into r226; - mul r224 r1 into r227; - div r227 100u32 into r228; - add r224 r228 into r229; - ternary r226 r229 r224 into r230; - is.eq 37u8 40u8 into r231; - lt 38u8 r2 into r232; - mul r230 r1 into r233; - div r233 100u32 into r234; - add r230 r234 into r235; - ternary r232 r235 r230 into r236; - is.eq 38u8 40u8 into r237; - lt 39u8 r2 into r238; - mul r236 r1 into r239; - div r239 100u32 into r240; - add r236 r240 into r241; - ternary r238 r241 r236 into r242; - is.eq 39u8 40u8 into r243; - lt 40u8 r2 into r244; - mul r242 r1 into r245; - div r245 100u32 into r246; - add r242 r246 into r247; - ternary r244 r247 r242 into r248; - is.eq 40u8 40u8 into r249; - lt 41u8 r2 into r250; - mul r248 r1 into r251; - div r251 100u32 into r252; - add r248 r252 into r253; - ternary r250 r253 r248 into r254; - is.eq 41u8 40u8 into r255; - lt 42u8 r2 into r256; - mul r254 r1 into r257; - div r257 100u32 into r258; - add r254 r258 into r259; - ternary r256 r259 r254 into r260; - is.eq 42u8 40u8 into r261; - lt 43u8 r2 into r262; - mul r260 r1 into r263; - div r263 100u32 into r264; - add r260 r264 into r265; - ternary r262 r265 r260 into r266; - is.eq 43u8 40u8 into r267; - lt 44u8 r2 into r268; - mul r266 r1 into r269; - div r269 100u32 into r270; - add r266 r270 into r271; - ternary r268 r271 r266 into r272; - is.eq 44u8 40u8 into r273; - lt 45u8 r2 into r274; - mul r272 r1 into r275; - div r275 100u32 into r276; - add r272 r276 into r277; - ternary r274 r277 r272 into r278; - is.eq 45u8 40u8 into r279; - lt 46u8 r2 into r280; - mul r278 r1 into r281; - div r281 100u32 into r282; - add r278 r282 into r283; - ternary r280 r283 r278 into r284; - is.eq 46u8 40u8 into r285; - lt 47u8 r2 into r286; - mul r284 r1 into r287; - div r287 100u32 into r288; - add r284 r288 into r289; - ternary r286 r289 r284 into r290; - is.eq 47u8 40u8 into r291; - lt 48u8 r2 into r292; - mul r290 r1 into r293; - div r293 100u32 into r294; - add r290 r294 into r295; - ternary r292 r295 r290 into r296; - is.eq 48u8 40u8 into r297; - lt 49u8 r2 into r298; - mul r296 r1 into r299; - div r299 100u32 into r300; - add r296 r300 into r301; - ternary r298 r301 r296 into r302; - is.eq 49u8 40u8 into r303; - ternary r303 r302 r302 into r304; - ternary r297 r296 r304 into r305; - ternary r291 r290 r305 into r306; - ternary r285 r284 r306 into r307; - ternary r279 r278 r307 into r308; - ternary r273 r272 r308 into r309; - ternary r267 r266 r309 into r310; - ternary r261 r260 r310 into r311; - ternary r255 r254 r311 into r312; - ternary r249 r248 r312 into r313; - ternary r243 r242 r313 into r314; - ternary r237 r236 r314 into r315; - ternary r231 r230 r315 into r316; - ternary r225 r224 r316 into r317; - ternary r219 r218 r317 into r318; - ternary r213 r212 r318 into r319; - ternary r207 r206 r319 into r320; - ternary r201 r200 r320 into r321; - ternary r195 r194 r321 into r322; - ternary r189 r188 r322 into r323; - ternary r183 r182 r323 into r324; - ternary r177 r176 r324 into r325; - ternary r171 r170 r325 into r326; - ternary r165 r164 r326 into r327; - ternary r159 r158 r327 into r328; - ternary r153 r152 r328 into r329; - ternary r147 r146 r329 into r330; - ternary r141 r140 r330 into r331; - ternary r135 r134 r331 into r332; - ternary r129 r128 r332 into r333; - ternary r123 r122 r333 into r334; - ternary r117 r116 r334 into r335; - ternary r111 r110 r335 into r336; - ternary r105 r104 r336 into r337; - ternary r99 r98 r337 into r338; - ternary r93 r92 r338 into r339; - ternary r87 r86 r339 into r340; - ternary r81 r80 r340 into r341; - ternary r75 r74 r341 into r342; - ternary r69 r68 r342 into r343; - ternary r63 r62 r343 into r344; - ternary r57 r56 r344 into r345; - ternary r51 r50 r345 into r346; - ternary r45 r44 r346 into r347; - ternary r39 r38 r347 into r348; - ternary r33 r32 r348 into r349; - ternary r27 r26 r349 into r350; - ternary r21 r20 r350 into r351; - ternary r15 r14 r351 into r352; - ternary r9 r8 r352 into r353; - output r353 as u32.private; diff --git a/examples/interest/build/program.json b/examples/interest/build/program.json deleted file mode 100644 index 1724ffab2b..0000000000 --- a/examples/interest/build/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "interest.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/interest/inputs/bounded.in b/examples/interest/inputs/bounded.in deleted file mode 100644 index 01909ddbde..0000000000 --- a/examples/interest/inputs/bounded.in +++ /dev/null @@ -1 +0,0 @@ -80u32 5u32 10u8 diff --git a/examples/interest/inputs/fixed.in b/examples/interest/inputs/fixed.in deleted file mode 100644 index 95572d3936..0000000000 --- a/examples/interest/inputs/fixed.in +++ /dev/null @@ -1 +0,0 @@ -80u32 5u32 diff --git a/examples/interest/leo.lock b/examples/interest/leo.lock deleted file mode 100644 index c4293b3b9f..0000000000 --- a/examples/interest/leo.lock +++ /dev/null @@ -1 +0,0 @@ -package = [] diff --git a/examples/interest/program.json b/examples/interest/program.json deleted file mode 100644 index 1724ffab2b..0000000000 --- a/examples/interest/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "interest.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/interest/src/main.leo b/examples/interest/src/main.leo deleted file mode 100644 index 2932fbd384..0000000000 --- a/examples/interest/src/main.leo +++ /dev/null @@ -1,37 +0,0 @@ -program interest.aleo { - // This function calculates the interest accrued - // over ten iterations for some `capital` and `rate`. - transition fixed_iteration_interest(capital: u32, public rate: u32) -> u32 { - let amount: u32 = capital; - - // Accrue for exactly 10 iterations. - for i:u8 in 0u8..10u8 { - // Note that the added amount is rounded down. - amount += (amount * rate) / 100u32; - } - return amount; - } - - - // This function calculates the interest accrued - // over a variable number of iterations (max 50) for some `capital` and `rate`. - transition bounded_iteration_interest(capital: u32, - public rate: u32, - iterations: u8) -> u32 { - assert(iterations <= 50u8); - let amount: u32 = capital; - - // Accrue for up to 50 iterations. - for i:u8 in 0u8..50u8 { - if i < iterations { - // Note that the added amount is rounded down. - amount += (amount * rate) / 100u32; - - } // Skip the remaining iterations. - if i == 40u8 { - return amount; - } - } - return amount; - } -} diff --git a/examples/lottery/.env b/examples/lottery/.env deleted file mode 100644 index ab204ee457..0000000000 --- a/examples/lottery/.env +++ /dev/null @@ -1,3 +0,0 @@ -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH -ENDPOINT=http://localhost:3030 diff --git a/examples/lottery/.gitignore b/examples/lottery/.gitignore deleted file mode 100644 index 750b56f237..0000000000 --- a/examples/lottery/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -outputs/ -*.avm -*.prover -*.verifier \ No newline at end of file diff --git a/examples/lottery/README.md b/examples/lottery/README.md deleted file mode 100644 index 87512a4a2a..0000000000 --- a/examples/lottery/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# lottery.aleo - -## Run Guide - -To run this program, run: -```bash -leo run play - -or - -./run.sh -``` - -## Execute Guide - -To execute this program, run: -```bash -leo execute play -``` diff --git a/examples/lottery/build/main.aleo b/examples/lottery/build/main.aleo deleted file mode 100644 index 859e6208e0..0000000000 --- a/examples/lottery/build/main.aleo +++ /dev/null @@ -1,28 +0,0 @@ -program lottery.aleo; - -record Ticket: - owner as address.private; - - -mapping num_winners: - key as u8.public; - value as u8.public; - - -function play: - cast self.caller into r0 as Ticket.record; - async play into r1; - output r0 as Ticket.record; - output r1 as lottery.aleo/play.future; - -finalize play: - lte block.height 1000u32 into r0; - assert.eq r0 true; - rand.chacha into r1 as boolean; - assert.eq r1 true; - get.or_use num_winners[0u8] 0u8 into r2; - lt r2 5u8 into r3; - assert.eq r3 true; - add r2 1u8 into r4; - set r4 into num_winners[0u8]; - diff --git a/examples/lottery/build/program.json b/examples/lottery/build/program.json deleted file mode 100644 index 45f0f3399a..0000000000 --- a/examples/lottery/build/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "lottery.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/lottery/leo.lock b/examples/lottery/leo.lock deleted file mode 100644 index c4293b3b9f..0000000000 --- a/examples/lottery/leo.lock +++ /dev/null @@ -1 +0,0 @@ -package = [] diff --git a/examples/lottery/program.json b/examples/lottery/program.json deleted file mode 100644 index 45f0f3399a..0000000000 --- a/examples/lottery/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "lottery.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/lottery/run.sh b/examples/lottery/run.sh deleted file mode 100755 index 2a7677c14e..0000000000 --- a/examples/lottery/run.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -# First check that Leo is installed. -if ! command -v leo &> /dev/null -then - echo "leo is not installed." - exit -fi - -# Run the lottery example -leo run play || exit \ No newline at end of file diff --git a/examples/lottery/src/main.leo b/examples/lottery/src/main.leo deleted file mode 100644 index 27485fdeda..0000000000 --- a/examples/lottery/src/main.leo +++ /dev/null @@ -1,30 +0,0 @@ -// The 'lottery' program. -program lottery.aleo { - - mapping num_winners: u8 => u8; - - record Ticket { - owner: address, - } - - async transition play() -> (Ticket, Future) { - let ticket: Ticket = Ticket { - owner: self.caller, - }; - return (ticket, finalize_play()); - } - - async function finalize_play() { - // Check that the lottery has not expired. - assert(block.height <= 1000u32); - - // Randomly select whether or not the ticket is a winner. - assert(ChaCha::rand_bool()); - - // Check that the maximum number of winners have not been reached. - let winners: u8 = num_winners.get_or_use(0u8, 0u8); - assert(winners < 5u8); - num_winners.set(0u8, winners + 1u8); - - } -} diff --git a/examples/message/.env b/examples/message/.env deleted file mode 100644 index ab204ee457..0000000000 --- a/examples/message/.env +++ /dev/null @@ -1,3 +0,0 @@ -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH -ENDPOINT=http://localhost:3030 diff --git a/examples/message/.gitignore b/examples/message/.gitignore deleted file mode 100644 index 750b56f237..0000000000 --- a/examples/message/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -outputs/ -*.avm -*.prover -*.verifier \ No newline at end of file diff --git a/examples/message/README.md b/examples/message/README.md deleted file mode 100644 index c2476a63b2..0000000000 --- a/examples/message/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# Leo message struct -A basic example showing how to declare a struct in the Leo language. - -## Run Guide - -To run this program, run: -```bash -leo run main -``` - -## Execute Guide - -To execute this program, run: -```bash -leo execute main -``` diff --git a/examples/message/build/main.aleo b/examples/message/build/main.aleo deleted file mode 100644 index 488da209d5..0000000000 --- a/examples/message/build/main.aleo +++ /dev/null @@ -1,12 +0,0 @@ -program message.aleo; - -struct Message: - first as field; - second as field; - - -function main: - input r0 as Message.private; - cast r0.first r0.second into r1 as Message; - add r1.first r1.second into r2; - output r2 as field.private; diff --git a/examples/message/build/program.json b/examples/message/build/program.json deleted file mode 100644 index cf32514fed..0000000000 --- a/examples/message/build/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "message.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/message/inputs/message.in b/examples/message/inputs/message.in deleted file mode 100644 index 1f0ce50e2e..0000000000 --- a/examples/message/inputs/message.in +++ /dev/null @@ -1,4 +0,0 @@ -{ - first: 2field, - second: 3field -} diff --git a/examples/message/leo.lock b/examples/message/leo.lock deleted file mode 100644 index c4293b3b9f..0000000000 --- a/examples/message/leo.lock +++ /dev/null @@ -1 +0,0 @@ -package = [] diff --git a/examples/message/program.json b/examples/message/program.json deleted file mode 100644 index cf32514fed..0000000000 --- a/examples/message/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "message.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/message/src/main.leo b/examples/message/src/main.leo deleted file mode 100644 index 216891754e..0000000000 --- a/examples/message/src/main.leo +++ /dev/null @@ -1,27 +0,0 @@ -// This example demonstrates the definition and initialization of a "struct" in Leo. -program message.aleo { - // The "Message" struct. - struct Message { - // A struct member named "first" with type "field". - first: field, - // A struct member named "second" with type "field". - second: field, - } - - // The "main" function of this Leo program takes a "Message" struct type as input. - // To see how to input variable "m" is passed in open up `inputs/message.in`. - transition main(m: Message) -> field { - - // 1. Define the "Message" type. - // 2. Use brackets `{ }` to enclose the struct members. - // 3. Define each struct member `name : value`. - let m1: Message = Message { - first: m.first, - second: m.second, - }; - - // Access the members of a struct with dot syntax. - // `struct_name.member` - return m1.first + m1.second; - } -} diff --git a/examples/simple_token/.env b/examples/simple_token/.env deleted file mode 100644 index ab204ee457..0000000000 --- a/examples/simple_token/.env +++ /dev/null @@ -1,3 +0,0 @@ -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH -ENDPOINT=http://localhost:3030 diff --git a/examples/simple_token/.gitignore b/examples/simple_token/.gitignore deleted file mode 100644 index 750b56f237..0000000000 --- a/examples/simple_token/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -outputs/ -*.avm -*.prover -*.verifier \ No newline at end of file diff --git a/examples/simple_token/README.md b/examples/simple_token/README.md deleted file mode 100644 index 46c3a2da0d..0000000000 --- a/examples/simple_token/README.md +++ /dev/null @@ -1,17 +0,0 @@ -# token - -## Run Guide - -To run this program, run: -```bash -leo run mint -leo run transfer # update private key first -``` - -## Execute Guide - -To execute this program, run: -```bash -leo execute mint -leo execute transfer # update private key first -``` diff --git a/examples/simple_token/build/main.aleo b/examples/simple_token/build/main.aleo deleted file mode 100644 index ff7355e27f..0000000000 --- a/examples/simple_token/build/main.aleo +++ /dev/null @@ -1,23 +0,0 @@ -program simple_token.aleo; - -record Token: - owner as address.private; - amount as u64.private; - - -function mint: - input r0 as address.private; - input r1 as u64.private; - cast r0 r1 into r2 as Token.record; - output r2 as Token.record; - - -function transfer: - input r0 as Token.record; - input r1 as address.private; - input r2 as u64.private; - sub r0.amount r2 into r3; - cast r0.owner r3 into r4 as Token.record; - cast r1 r2 into r5 as Token.record; - output r4 as Token.record; - output r5 as Token.record; diff --git a/examples/simple_token/build/program.json b/examples/simple_token/build/program.json deleted file mode 100644 index 2e05c74d43..0000000000 --- a/examples/simple_token/build/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "simple_token.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/simple_token/inputs/mint.in b/examples/simple_token/inputs/mint.in deleted file mode 100644 index f949c17fa5..0000000000 --- a/examples/simple_token/inputs/mint.in +++ /dev/null @@ -1 +0,0 @@ -aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px 100u64 diff --git a/examples/simple_token/inputs/transfer.in b/examples/simple_token/inputs/transfer.in deleted file mode 100644 index a013141903..0000000000 --- a/examples/simple_token/inputs/transfer.in +++ /dev/null @@ -1,7 +0,0 @@ -{ - owner: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - amount: 100u64.private, - _nonce: 0group.public -} -aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px -50u64 diff --git a/examples/simple_token/leo.lock b/examples/simple_token/leo.lock deleted file mode 100644 index c4293b3b9f..0000000000 --- a/examples/simple_token/leo.lock +++ /dev/null @@ -1 +0,0 @@ -package = [] diff --git a/examples/simple_token/program.json b/examples/simple_token/program.json deleted file mode 100644 index 2e05c74d43..0000000000 --- a/examples/simple_token/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "simple_token.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/simple_token/src/main.leo b/examples/simple_token/src/main.leo deleted file mode 100644 index de3012b069..0000000000 --- a/examples/simple_token/src/main.leo +++ /dev/null @@ -1,45 +0,0 @@ -// This example demonstrates an example of a minting and transferring a token in Leo. -program simple_token.aleo { - // The `Token` record datatype. - record Token { - // The token owner. - owner: address, - // The token amount. - amount: u64, - } - - // The `mint` function initializes a new record with the - // specified number of tokens assigned to the specified receiver. - transition mint(owner: address, amount: u64) -> Token { - return Token { - owner: owner, - amount: amount, - }; - } - - // The `transfer` function sends the specified number of tokens - // to the receiver from the provided token record. - transition transfer(token: Token, to: address, amount: u64) -> (Token, Token) { - - // Checks the given token record has sufficient balance. - // This `sub` operation is safe, and the proof will fail - // if an overflow occurs. - // `difference` holds the change amount to be returned to sender. - let difference: u64 = token.amount - amount; - - // Produce a token record with the change amount for the sender. - let remaining: Token = Token { - owner: token.owner, - amount: difference, - }; - - // Produce a token record for the specified receiver. - let transferred: Token = Token { - owner: to, - amount: amount, - }; - - // Output the sender's change record and the receiver's record. - return (remaining, transferred); - } -} diff --git a/examples/tictactoe/.env b/examples/tictactoe/.env deleted file mode 100644 index ab204ee457..0000000000 --- a/examples/tictactoe/.env +++ /dev/null @@ -1,3 +0,0 @@ -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH -ENDPOINT=http://localhost:3030 diff --git a/examples/tictactoe/.gitignore b/examples/tictactoe/.gitignore deleted file mode 100644 index 750b56f237..0000000000 --- a/examples/tictactoe/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -outputs/ -*.avm -*.prover -*.verifier \ No newline at end of file diff --git a/examples/tictactoe/README.md b/examples/tictactoe/README.md deleted file mode 100644 index 1696d144a7..0000000000 --- a/examples/tictactoe/README.md +++ /dev/null @@ -1,72 +0,0 @@ - - -[//]: # (workshop/tictactoe) - -A standard game of Tic-Tac-Toe in Leo. - -⭕ ❕ ⭕ ❕ ❌ - -➖ ➕ ➖ ➕ ➖ - -⭕ ❕ ⁣❌ ❕ ⭕ - -➖ ➕ ➖ ➕ ➖ - -❌ ❕ ❌ ❕ ⭕ - -## Representing State -Leo allows users to define composite data types with the `struct` keyword. -The game board is represented by a struct called `Board`, which contains three `Row`s. -An alternative representation would be to use an array, however, these are not yet supported in Leo. - -## Language Features -- `struct` declarations -- conditional statements -- early termination. Leo allows users to return from a function early using the `return` keyword. - -## Running the Program - -Leo provides users with a command line interface for compiling and running Leo programs. - -### Providing inputs via the command line. -```bash -leo run ... -``` -See `./run.sh` for an example. - -## Executing the Program -```bash -leo execute ... -``` - -## Playing the Game - -### 1. Create a new game board -```bash -leo run new -``` -| | | | -|---|---|---| -| 0 | 0 | 0 | -| 0 | 0 | 0 | -| 0 | 0 | 0 | - -### 2. Player 1 makes a move -```bash -leo run make_move 1u8 1u8 1u8 "{ r1: { c1: 0u8, c2: 0u8, c3: 0u8 }, r2: { c1: 0u8, c2: 0u8, c3: 0u8 }, r3: { c1: 0u8, c2: 0u8, c3: 0u8 } }" -``` -| | | | -|---|---|---| -| 1 | 0 | 0 | -| 0 | 0 | 0 | -| 0 | 0 | 0 | - -### 3. Player 2 makes a move -```bash -leo run make_move 2u8 2u8 2u8 "{ r1: { c1: 1u8, c2: 0u8, c3: 0u8 }, r2: { c1: 0u8, c2: 0u8, c3: 0u8 }, r3: { c1: 0u8, c2: 0u8, c3: 0u8 } }" -``` -| | | | -|---|---|---| -| 1 | 0 | 0 | -| 0 | 2 | 0 | -| 0 | 0 | 0 | diff --git a/examples/tictactoe/build/main.aleo b/examples/tictactoe/build/main.aleo deleted file mode 100644 index f557eeff0f..0000000000 --- a/examples/tictactoe/build/main.aleo +++ /dev/null @@ -1,237 +0,0 @@ -program tictactoe.aleo; - -struct Row: - c1 as u8; - c2 as u8; - c3 as u8; - -struct Board: - r1 as Row; - r2 as Row; - r3 as Row; - - -function new: - cast 0u8 0u8 0u8 into r0 as Row; - cast 0u8 0u8 0u8 into r1 as Row; - cast 0u8 0u8 0u8 into r2 as Row; - cast r0 r1 r2 into r3 as Board; - output r3 as Board.private; - - -closure check_for_win: - input r0 as Board; - input r1 as u8; - is.eq r0.r1.c1 r1 into r2; - is.eq r0.r1.c2 r1 into r3; - and r2 r3 into r4; - is.eq r0.r1.c3 r1 into r5; - and r4 r5 into r6; - is.eq r0.r2.c1 r1 into r7; - is.eq r0.r2.c2 r1 into r8; - and r7 r8 into r9; - is.eq r0.r2.c3 r1 into r10; - and r9 r10 into r11; - or r6 r11 into r12; - is.eq r0.r3.c1 r1 into r13; - is.eq r0.r3.c2 r1 into r14; - and r13 r14 into r15; - is.eq r0.r3.c3 r1 into r16; - and r15 r16 into r17; - or r12 r17 into r18; - is.eq r0.r1.c1 r1 into r19; - is.eq r0.r2.c1 r1 into r20; - and r19 r20 into r21; - is.eq r0.r3.c1 r1 into r22; - and r21 r22 into r23; - or r18 r23 into r24; - is.eq r0.r1.c2 r1 into r25; - is.eq r0.r2.c2 r1 into r26; - and r25 r26 into r27; - is.eq r0.r3.c2 r1 into r28; - and r27 r28 into r29; - or r24 r29 into r30; - is.eq r0.r1.c3 r1 into r31; - is.eq r0.r2.c3 r1 into r32; - and r31 r32 into r33; - is.eq r0.r3.c3 r1 into r34; - and r33 r34 into r35; - or r30 r35 into r36; - is.eq r0.r1.c1 r1 into r37; - is.eq r0.r2.c2 r1 into r38; - and r37 r38 into r39; - is.eq r0.r3.c3 r1 into r40; - and r39 r40 into r41; - or r36 r41 into r42; - is.eq r0.r1.c3 r1 into r43; - is.eq r0.r2.c2 r1 into r44; - and r43 r44 into r45; - is.eq r0.r3.c1 r1 into r46; - and r45 r46 into r47; - or r42 r47 into r48; - output r48 as boolean; - - -function make_move: - input r0 as u8.private; - input r1 as u8.private; - input r2 as u8.private; - input r3 as Board.private; - is.eq r0 1u8 into r4; - is.eq r0 2u8 into r5; - or r4 r5 into r6; - assert.eq r6 true; - lte 1u8 r1 into r7; - lte r1 3u8 into r8; - and r7 r8 into r9; - assert.eq r9 true; - lte 1u8 r2 into r10; - lte r2 3u8 into r11; - and r10 r11 into r12; - assert.eq r12 true; - is.eq r1 1u8 into r13; - is.eq r2 1u8 into r14; - and r13 r14 into r15; - is.eq r3.r1.c1 0u8 into r16; - and r15 r16 into r17; - is.eq r1 1u8 into r18; - is.eq r2 2u8 into r19; - and r18 r19 into r20; - is.eq r3.r1.c2 0u8 into r21; - and r20 r21 into r22; - is.eq r1 1u8 into r23; - is.eq r2 3u8 into r24; - and r23 r24 into r25; - is.eq r3.r1.c3 0u8 into r26; - and r25 r26 into r27; - is.eq r1 2u8 into r28; - is.eq r2 1u8 into r29; - and r28 r29 into r30; - is.eq r3.r2.c1 0u8 into r31; - and r30 r31 into r32; - is.eq r1 2u8 into r33; - is.eq r2 2u8 into r34; - and r33 r34 into r35; - is.eq r3.r2.c2 0u8 into r36; - and r35 r36 into r37; - is.eq r1 2u8 into r38; - is.eq r2 3u8 into r39; - and r38 r39 into r40; - is.eq r3.r2.c3 0u8 into r41; - and r40 r41 into r42; - is.eq r1 3u8 into r43; - is.eq r2 1u8 into r44; - and r43 r44 into r45; - is.eq r3.r3.c1 0u8 into r46; - and r45 r46 into r47; - is.eq r1 3u8 into r48; - is.eq r2 2u8 into r49; - and r48 r49 into r50; - is.eq r3.r3.c2 0u8 into r51; - and r50 r51 into r52; - is.eq r1 3u8 into r53; - is.eq r2 3u8 into r54; - and r53 r54 into r55; - is.eq r3.r3.c3 0u8 into r56; - and r55 r56 into r57; - ternary r57 r0 r3.r3.c3 into r58; - ternary r52 r0 r3.r3.c2 into r59; - ternary r52 r3.r3.c3 r58 into r60; - ternary r47 r0 r3.r3.c1 into r61; - ternary r47 r3.r3.c2 r59 into r62; - ternary r47 r3.r3.c3 r60 into r63; - ternary r42 r0 r3.r2.c3 into r64; - ternary r42 r3.r3.c1 r61 into r65; - ternary r42 r3.r3.c2 r62 into r66; - ternary r42 r3.r3.c3 r63 into r67; - ternary r37 r0 r3.r2.c2 into r68; - ternary r37 r3.r2.c3 r64 into r69; - ternary r37 r3.r3.c1 r65 into r70; - ternary r37 r3.r3.c2 r66 into r71; - ternary r37 r3.r3.c3 r67 into r72; - ternary r32 r0 r3.r2.c1 into r73; - ternary r32 r3.r2.c2 r68 into r74; - ternary r32 r3.r2.c3 r69 into r75; - ternary r32 r3.r3.c1 r70 into r76; - ternary r32 r3.r3.c2 r71 into r77; - ternary r32 r3.r3.c3 r72 into r78; - ternary r27 r0 r3.r1.c3 into r79; - ternary r27 r3.r2.c1 r73 into r80; - ternary r27 r3.r2.c2 r74 into r81; - ternary r27 r3.r2.c3 r75 into r82; - ternary r27 r3.r3.c1 r76 into r83; - ternary r27 r3.r3.c2 r77 into r84; - ternary r27 r3.r3.c3 r78 into r85; - ternary r22 r0 r3.r1.c2 into r86; - ternary r22 r3.r1.c3 r79 into r87; - ternary r22 r3.r2.c1 r80 into r88; - ternary r22 r3.r2.c2 r81 into r89; - ternary r22 r3.r2.c3 r82 into r90; - ternary r22 r3.r3.c1 r83 into r91; - ternary r22 r3.r3.c2 r84 into r92; - ternary r22 r3.r3.c3 r85 into r93; - ternary r17 r0 r3.r1.c1 into r94; - ternary r17 r3.r1.c2 r86 into r95; - ternary r17 r3.r1.c3 r87 into r96; - ternary r17 r3.r2.c1 r88 into r97; - ternary r17 r3.r2.c2 r89 into r98; - ternary r17 r3.r2.c3 r90 into r99; - ternary r17 r3.r3.c1 r91 into r100; - ternary r17 r3.r3.c2 r92 into r101; - ternary r17 r3.r3.c3 r93 into r102; - cast r94 r95 r96 into r103 as Row; - cast r97 r98 r99 into r104 as Row; - cast r100 r101 r102 into r105 as Row; - cast r103 r104 r105 into r106 as Board; - call check_for_win r106 1u8 into r107; - call check_for_win r106 2u8 into r108; - not r107 into r109; - and r109 r108 into r110; - ternary r110 r106.r1.c1 r106.r1.c1 into r111; - not r107 into r112; - and r112 r108 into r113; - ternary r113 r106.r1.c2 r106.r1.c2 into r114; - not r107 into r115; - and r115 r108 into r116; - ternary r116 r106.r1.c3 r106.r1.c3 into r117; - cast r111 r114 r117 into r118 as Row; - not r107 into r119; - and r119 r108 into r120; - ternary r120 r106.r2.c1 r106.r2.c1 into r121; - not r107 into r122; - and r122 r108 into r123; - ternary r123 r106.r2.c2 r106.r2.c2 into r124; - not r107 into r125; - and r125 r108 into r126; - ternary r126 r106.r2.c3 r106.r2.c3 into r127; - cast r121 r124 r127 into r128 as Row; - not r107 into r129; - and r129 r108 into r130; - ternary r130 r106.r3.c1 r106.r3.c1 into r131; - not r107 into r132; - and r132 r108 into r133; - ternary r133 r106.r3.c2 r106.r3.c2 into r134; - not r107 into r135; - and r135 r108 into r136; - ternary r136 r106.r3.c3 r106.r3.c3 into r137; - cast r131 r134 r137 into r138 as Row; - cast r118 r128 r138 into r139 as Board; - not r107 into r140; - and r140 r108 into r141; - ternary r141 2u8 0u8 into r142; - ternary r107 r106.r1.c1 r139.r1.c1 into r143; - ternary r107 r106.r1.c2 r139.r1.c2 into r144; - ternary r107 r106.r1.c3 r139.r1.c3 into r145; - cast r143 r144 r145 into r146 as Row; - ternary r107 r106.r2.c1 r139.r2.c1 into r147; - ternary r107 r106.r2.c2 r139.r2.c2 into r148; - ternary r107 r106.r2.c3 r139.r2.c3 into r149; - cast r147 r148 r149 into r150 as Row; - ternary r107 r106.r3.c1 r139.r3.c1 into r151; - ternary r107 r106.r3.c2 r139.r3.c2 into r152; - ternary r107 r106.r3.c3 r139.r3.c3 into r153; - cast r151 r152 r153 into r154 as Row; - cast r146 r150 r154 into r155 as Board; - ternary r107 1u8 r142 into r156; - output r155 as Board.private; - output r156 as u8.private; diff --git a/examples/tictactoe/build/program.json b/examples/tictactoe/build/program.json deleted file mode 100644 index a2f5a13696..0000000000 --- a/examples/tictactoe/build/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "tictactoe.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/tictactoe/inputs/tictactoe.in b/examples/tictactoe/inputs/tictactoe.in deleted file mode 100644 index 5f799d5991..0000000000 --- a/examples/tictactoe/inputs/tictactoe.in +++ /dev/null @@ -1,8 +0,0 @@ -1u8 -1u8 -1u8 -{ - r1: { c1: 0u8, c2: 0u8, c3: 0u8 }, - r2: { c1: 0u8, c2: 0u8, c3: 0u8 }, - r3: { c1: 0u8, c2: 0u8, c3: 0u8 } -} diff --git a/examples/tictactoe/leo.lock b/examples/tictactoe/leo.lock deleted file mode 100644 index c4293b3b9f..0000000000 --- a/examples/tictactoe/leo.lock +++ /dev/null @@ -1 +0,0 @@ -package = [] diff --git a/examples/tictactoe/program.json b/examples/tictactoe/program.json deleted file mode 100644 index a2f5a13696..0000000000 --- a/examples/tictactoe/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "tictactoe.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/tictactoe/run.sh b/examples/tictactoe/run.sh deleted file mode 100755 index 0c57c04e4e..0000000000 --- a/examples/tictactoe/run.sh +++ /dev/null @@ -1,157 +0,0 @@ -#!/bin/bash -# First check that Leo is installed. -if ! command -v leo &> /dev/null -then - echo "leo is not installed." - exit -fi -# Create a new game. -echo " -############################################################################### -######## ######## -######## STEP 0: Creating a new game of Tic-Tac-Toe ######## -######## ######## -######## | | | | ######## -######## | | | | ######## -######## | | | | ######## -######## ######## -############################################################################### -" -leo run new || exit - -# Have the Player 1 make a move. -echo " -############################################################################### -######## ######## -######## STEP 1: Player 1 makes the 1st move. ######## -######## ######## -######## | x | | | ######## -######## | | | | ######## -######## | | | | ######## -######## ######## -############################################################################### -" -leo run make_move 1u8 1u8 1u8 "{ r1: { c1: 0u8, c2: 0u8, c3: 0u8 }, r2: { c1: 0u8, c2: 0u8, c3: 0u8 }, r3: { c1: 0u8, c2: 0u8, c3: 0u8 } }" || exit - -# Have the Player 2 make a move. -echo " -############################################################################### -######## ######## -######## STEP 2: Player 2 makes the 2nd move. ######## -######## ######## -######## | x | | | ######## -######## | | o | | ######## -######## | | | | ######## -######## ######## -############################################################################### -" -leo run make_move 2u8 2u8 2u8 "{ r1: { c1: 1u8, c2: 0u8, c3: 0u8 }, r2: { c1: 0u8, c2: 0u8, c3: 0u8 }, r3: { c1: 0u8, c2: 0u8, c3: 0u8 } }" || exit - -# Have the Player 1 make a move. -echo " -############################################################################### -######## ######## -######## STEP 3: Player 1 makes the 3rd move. ######## -######## ######## -######## | x | | | ######## -######## | | o | | ######## -######## | x | | | ######## -######## ######## -############################################################################### -" -leo run make_move 1u8 3u8 1u8 "{ r1: { c1: 1u8, c2: 0u8, c3: 0u8 }, r2: { c1: 0u8, c2: 2u8, c3: 0u8 }, r3: { c1: 0u8, c2: 0u8, c3: 0u8 } }" || exit - -# Have the Player 2 make a move. -echo " -############################################################################### -######## ######## -######## STEP 4: Player 2 makes the 4th move. ######## -######## ######## -######## | x | | | ######## -######## | o | o | | ######## -######## | x | | | ######## -######## ######## -############################################################################### -" -leo run make_move 2u8 2u8 1u8 "{ r1: { c1: 1u8, c2: 0u8, c3: 0u8 }, r2: { c1: 0u8, c2: 2u8, c3: 0u8 }, r3: { c1: 1u8, c2: 0u8, c3: 0u8 } }" || exit - -# Have the Player 1 make a move. -echo " -############################################################################### -######## ######## -######## STEP 5: Player 1 makes the 5th move. ######## -######## ######## -######## | x | | | ######## -######## | o | o | x | ######## -######## | x | | | ######## -######## ######## -############################################################################### -" -leo run make_move 1u8 2u8 3u8 "{ r1: { c1: 1u8, c2: 0u8, c3: 0u8 }, r2: { c1: 2u8, c2: 2u8, c3: 0u8 }, r3: { c1: 1u8, c2: 0u8, c3: 0u8 } }" || exit - -# Have the Player 2 make a move. -echo " -############################################################################### -######## ######## -######## STEP 6: Player 2 makes the 6th move. ######## -######## ######## -######## | x | o | | ######## -######## | o | o | x | ######## -######## | x | | | ######## -######## ######## -############################################################################### -" -leo run make_move 2u8 1u8 2u8 "{ r1: { c1: 1u8, c2: 0u8, c3: 0u8 }, r2: { c1: 2u8, c2: 2u8, c3: 1u8 }, r3: { c1: 1u8, c2: 0u8, c3: 0u8 } }" || exit - -# Have the Player 1 make a move. -echo " -############################################################################### -######## ######## -######## STEP 7: Player 1 makes the 7th move. ######## -######## ######## -######## | x | o | | ######## -######## | o | o | x | ######## -######## | x | x | | ######## -######## ######## -############################################################################### -" -leo run make_move 1u8 3u8 2u8 "{ r1: { c1: 1u8, c2: 2u8, c3: 0u8 }, r2: { c1: 2u8, c2: 2u8, c3: 1u8 }, r3: { c1: 1u8, c2: 0u8, c3: 0u8 } }" || exit - -# Have the Player 2 make a move. -echo " -############################################################################### -######## ######## -######## STEP 8: Player 2 makes the 8th move. ######## -######## ######## -######## | x | o | | ######## -######## | o | o | x | ######## -######## | x | x | o | ######## -######## ######## -############################################################################### -" -leo run make_move 2u8 3u8 3u8 "{ r1: { c1: 1u8, c2: 2u8, c3: 0u8 }, r2: { c1: 2u8, c2: 2u8, c3: 1u8 }, r3: { c1: 1u8, c2: 1u8, c3: 0u8 } }" || exit - -echo " -############################################################################### -######## ######## -######## STEP 9: Player 1 makes the 9th move. ######## -######## ######## -######## | x | o | x | ######## -######## | o | o | x | ######## -######## | x | x | o | ######## -######## ######## -############################################################################### -" -leo run make_move 1u8 1u8 3u8 "{ r1: { c1: 1u8, c2: 2u8, c3: 0u8 }, r2: { c1: 2u8, c2: 2u8, c3: 1u8 }, r3: { c1: 1u8, c2: 1u8, c3: 2u8 } }" || exit - -echo " -############################################################################### -######## ######## -######## Game Complete! Players 1 & 2 Tied ######## -######## ######## -######## | x | o | x | ######## -######## | o | o | x | ######## -######## | x | x | o | ######## -######## ######## -############################################################################### -" diff --git a/examples/tictactoe/src/main.leo b/examples/tictactoe/src/main.leo deleted file mode 100644 index e7feadd7a7..0000000000 --- a/examples/tictactoe/src/main.leo +++ /dev/null @@ -1,111 +0,0 @@ -program tictactoe.aleo { - // A row in a tic tac toe board. - // - `c1` : The first entry in the row. - // - `c2` : The second entry in the row. - // - `c3` : The third entry in the row. - // A valid entry is either 0, 1, or 2, where 0 is empty, 1 corresponds to player 1, and 2 corresponds to player 2. - // Any other values are invalid. - struct Row { - c1: u8, - c2: u8, - c3: u8 - } - - // A tic tac toe board. - // - `r1` : The first row in the board. - // - `r2` : The second row in the board. - // - `r3` : The third row in the board. - struct Board { - r1: Row, - r2: Row, - r3: Row, - } - - // Returns an empty board. - transition new() -> Board { - return Board { - r1: Row { c1: 0u8, c2: 0u8, c3: 0u8 }, - r2: Row { c1: 0u8, c2: 0u8, c3: 0u8 }, - r3: Row { c1: 0u8, c2: 0u8, c3: 0u8 }, - }; - } - - // Returns `true` if there exists a row, column, or diagonal with all entries occupied by the same player. - // - `b` : A tic tac toe board. - // - `p` : A number corresponding to a player. - function check_for_win(b: Board, p: u8) -> bool { - return - (b.r1.c1 == p && b.r1.c2 == p && b.r1.c3 == p) || // row 1 - (b.r2.c1 == p && b.r2.c2 == p && b.r2.c3 == p) || // row 2 - (b.r3.c1 == p && b.r3.c2 == p && b.r3.c3 == p) || // row 3 - (b.r1.c1 == p && b.r2.c1 == p && b.r3.c1 == p) || // column 1 - (b.r1.c2 == p && b.r2.c2 == p && b.r3.c2 == p) || // column 2 - (b.r1.c3 == p && b.r2.c3 == p && b.r3.c3 == p) || // column 3 - (b.r1.c1 == p && b.r2.c2 == p && b.r3.c3 == p) || // diagonal - (b.r1.c3 == p && b.r2.c2 == p && b.r3.c1 == p); // other diagonal - } - - // Returns an updated tic tac toe board with a move made by a player. - // Returns a `u8` corresponding to the player who won the game, or 0 if no one has won yet. - // - `player` : A number corresponding to a player. - // - `row` : The row of the move. - // - `col` : The column of the move. - // - `board` : A tic tac toe board. - // Assumes that `player` is either 1 or 2. - // Assumes that `row` and `col` are valid indices into the board. - // If an entry is already occupied, the move is invalid and the board is returned unchanged. - transition make_move(player: u8, row: u8, col: u8, board: Board) -> (Board, u8) { - // Check that inputs are valid. - assert(player == 1u8 || player == 2u8); - assert(1u8 <= row && row <= 3u8); - assert(1u8 <= col && col <= 3u8); - - // Unpack the entries in the board into variables. - let r1c1: u8 = board.r1.c1; - let r1c2: u8 = board.r1.c2; - let r1c3: u8 = board.r1.c3; - let r2c1: u8 = board.r2.c1; - let r2c2: u8 = board.r2.c2; - let r2c3: u8 = board.r2.c3; - let r3c1: u8 = board.r3.c1; - let r3c2: u8 = board.r3.c2; - let r3c3: u8 = board.r3.c3; - - // Update the appropriate entry with the given move. - if row == 1u8 && col == 1u8 && r1c1 == 0u8 { - r1c1 = player; - } else if row == 1u8 && col == 2u8 && r1c2 == 0u8 { - r1c2 = player; - } else if row == 1u8 && col == 3u8 && r1c3 == 0u8 { - r1c3 = player; - } else if row == 2u8 && col == 1u8 && r2c1 == 0u8 { - r2c1 = player; - } else if row == 2u8 && col == 2u8 && r2c2 == 0u8 { - r2c2 = player; - } else if row == 2u8 && col == 3u8 && r2c3 == 0u8 { - r2c3 = player; - } else if row == 3u8 && col == 1u8 && r3c1 == 0u8 { - r3c1 = player; - } else if row == 3u8 && col == 2u8 && r3c2 == 0u8 { - r3c2 = player; - } else if row == 3u8 && col == 3u8 && r3c3 == 0u8 { - r3c3 = player; - } - - // Construct the updated game board. - let updated: Board = Board { - r1: Row { c1: r1c1, c2: r1c2, c3: r1c3 }, - r2: Row { c1: r2c1, c2: r2c2, c3: r2c3 }, - r3: Row { c1: r3c1, c2: r3c2, c3: r3c3 }, - }; - - // Check if the game is over. - if check_for_win(updated, 1u8) { - return (updated, 1u8); - } else if check_for_win(updated, 2u8) { - return (updated, 2u8); - } else { - return (updated, 0u8); - } - } -} diff --git a/examples/token/.env b/examples/token/.env deleted file mode 100644 index 75bc722f06..0000000000 --- a/examples/token/.env +++ /dev/null @@ -1,4 +0,0 @@ - -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH -ENDPOINT=http://localhost:3030 diff --git a/examples/token/.gitignore b/examples/token/.gitignore deleted file mode 100644 index 750b56f237..0000000000 --- a/examples/token/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -outputs/ -*.avm -*.prover -*.verifier \ No newline at end of file diff --git a/examples/token/README.md b/examples/token/README.md deleted file mode 100644 index cbf994273b..0000000000 --- a/examples/token/README.md +++ /dev/null @@ -1,12 +0,0 @@ - - -[//]: # (workshop/token) - -A transparent & shielded custom token in Leo. - -## Run Guide - -To run this program, run: -```bash -./run.sh -``` \ No newline at end of file diff --git a/examples/token/build/main.aleo b/examples/token/build/main.aleo deleted file mode 100644 index f7711f83c4..0000000000 --- a/examples/token/build/main.aleo +++ /dev/null @@ -1,101 +0,0 @@ -program token.aleo; - -record token: - owner as address.private; - amount as u64.private; - - -mapping account: - key as address.public; - value as u64.public; - - -function mint_public: - input r0 as address.public; - input r1 as u64.public; - async mint_public r0 r1 into r2; - output r2 as token.aleo/mint_public.future; - -finalize mint_public: - input r0 as address.public; - input r1 as u64.public; - get.or_use account[r0] 0u64 into r2; - add r2 r1 into r3; - set r3 into account[r0]; - - - -function mint_private: - input r0 as address.private; - input r1 as u64.private; - cast r0 r1 into r2 as token.record; - output r2 as token.record; - - - -function transfer_public: - input r0 as address.public; - input r1 as u64.public; - async transfer_public self.caller r0 r1 into r2; - output r2 as token.aleo/transfer_public.future; - -finalize transfer_public: - input r0 as address.public; - input r1 as address.public; - input r2 as u64.public; - get.or_use account[r0] 0u64 into r3; - sub r3 r2 into r4; - set r4 into account[r0]; - get.or_use account[r1] 0u64 into r5; - add r5 r2 into r6; - set r6 into account[r1]; - - - -function transfer_private: - input r0 as token.record; - input r1 as address.private; - input r2 as u64.private; - sub r0.amount r2 into r3; - cast r0.owner r3 into r4 as token.record; - cast r1 r2 into r5 as token.record; - output r4 as token.record; - output r5 as token.record; - - - -function transfer_private_to_public: - input r0 as token.record; - input r1 as address.public; - input r2 as u64.public; - sub r0.amount r2 into r3; - cast r0.owner r3 into r4 as token.record; - async transfer_private_to_public r1 r2 into r5; - output r4 as token.record; - output r5 as token.aleo/transfer_private_to_public.future; - -finalize transfer_private_to_public: - input r0 as address.public; - input r1 as u64.public; - get.or_use account[r0] 0u64 into r2; - add r2 r1 into r3; - set r3 into account[r0]; - - - - -function transfer_public_to_private: - input r0 as address.public; - input r1 as u64.public; - cast r0 r1 into r2 as token.record; - async transfer_public_to_private self.caller r1 into r3; - output r2 as token.record; - output r3 as token.aleo/transfer_public_to_private.future; - -finalize transfer_public_to_private: - input r0 as address.public; - input r1 as u64.public; - get.or_use account[r0] 0u64 into r2; - sub r2 r1 into r3; - set r3 into account[r0]; - diff --git a/examples/token/build/program.json b/examples/token/build/program.json deleted file mode 100644 index 94d9bc9824..0000000000 --- a/examples/token/build/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "token.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/token/leo.lock b/examples/token/leo.lock deleted file mode 100644 index c4293b3b9f..0000000000 --- a/examples/token/leo.lock +++ /dev/null @@ -1 +0,0 @@ -package = [] diff --git a/examples/token/program.json b/examples/token/program.json deleted file mode 100644 index 94d9bc9824..0000000000 --- a/examples/token/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "token.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/token/run.sh b/examples/token/run.sh deleted file mode 100755 index 660a45a936..0000000000 --- a/examples/token/run.sh +++ /dev/null @@ -1,246 +0,0 @@ -#!/bin/bash -# First check that Leo is installed. -if ! command -v leo &> /dev/null -then - echo "leo is not installed." - exit -fi - -# The private key and address of Alice. -# Swap these into program.json, when running transactions as the first bidder. -# NETWORK=testnet -# PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH - -# The private key and address of Bob. -# Swap these into program.json, when running transactions as the second bidder. -# NETWORK=testnet -# PRIVATE_KEY=APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh - -# Swap in the private key of Alice. -echo " -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH -ENDPOINT=http://localhost:3030 -" > .env - -# Publicly mint 100 tokens for Alice. -echo " -############################################################################### -######## ######## -######## STEP 1: Publicly mint 100 tokens for Alice ######## -######## ######## -######## ----------------------------------------- ######## -######## | PUBLIC BALANCES | ######## -######## ----------------------------------------- ######## -######## ----------------------------------------- ######## -######## | Alice | 100 | ######## -######## ----------------------------------------- ######## -######## | Bob | 0 | ######## -######## ----------------------------------------- ######## -######## ######## -######## ----------------------------------------- ######## -######## | PRIVATE BALANCES | ######## -######## ----------------------------------------- ######## -######## ----------------------------------------- ######## -######## | Alice | 0 | ######## -######## ----------------------------------------- ######## -######## | Bob | 0 | ######## -######## ----------------------------------------- ######## -######## ######## -############################################################################### -" -leo run mint_public aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px 100u64 - -# Swap in the private key of Bob. -echo " -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh -ENDPOINT=http://localhost:3030 -" > .env - -# Privately mint 100 tokens for Bob. -echo " -############################################################################### -######## ######## -######## STEP 2: Privately mint 100 tokens for Bob ######## -######## ######## -######## ----------------------------------------- ######## -######## | PUBLIC BALANCES | ######## -######## ----------------------------------------- ######## -######## ----------------------------------------- ######## -######## | Alice | 100 | ######## -######## ----------------------------------------- ######## -######## | Bob | 0 | ######## -######## ----------------------------------------- ######## -######## ######## -######## ----------------------------------------- ######## -######## | PRIVATE BALANCES | ######## -######## ----------------------------------------- ######## -######## ----------------------------------------- ######## -######## | Alice | 0 | ######## -######## ----------------------------------------- ######## -######## | Bob | 100 | ######## -######## ----------------------------------------- ######## -######## ######## -############################################################################### -" -leo run mint_private aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t 100u64 - -# Swap in the private key of Alice. -echo " -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH -ENDPOINT=http://localhost:3030 -" > .env - -# Publicly transfer 10 tokens from Alice to Bob. -echo " -############################################################################### -######## ######## -######## STEP 3: Publicly transfer 10 tokens from Alice to Bob ######## -######## ######## -######## ----------------------------------------- ######## -######## | PUBLIC BALANCES | ######## -######## ----------------------------------------- ######## -######## ----------------------------------------- ######## -######## | Alice | 90 | ######## -######## ----------------------------------------- ######## -######## | Bob | 10 | ######## -######## ----------------------------------------- ######## -######## ######## -######## ----------------------------------------- ######## -######## | PRIVATE BALANCES | ######## -######## ----------------------------------------- ######## -######## ----------------------------------------- ######## -######## | Alice | 0 | ######## -######## ----------------------------------------- ######## -######## | Bob | 100 | ######## -######## ----------------------------------------- ######## -######## ######## -############################################################################### -" -leo run transfer_public aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t 10u64 - -# Swap in the private key of Bob. -echo " -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh -ENDPOINT=http://localhost:3030 -" > .env - -# Privately transfer 20 tokens from Bob to Alice. -echo " -############################################################################### -######## ######## -######## STEP 4: Privately transfer 20 tokens from Bob to Alice ######## -######## ######## -######## ----------------------------------------- ######## -######## | PUBLIC BALANCES | ######## -######## ----------------------------------------- ######## -######## ----------------------------------------- ######## -######## | Alice | 90 | ######## -######## ----------------------------------------- ######## -######## | Bob | 10 | ######## -######## ----------------------------------------- ######## -######## ######## -######## ----------------------------------------- ######## -######## | PRIVATE BALANCES | ######## -######## ----------------------------------------- ######## -######## ----------------------------------------- ######## -######## | Alice | 20 | ######## -######## ----------------------------------------- ######## -######## | Bob | 80 | ######## -######## ----------------------------------------- ######## -######## ######## -############################################################################### -" -leo run transfer_private "{ - owner: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - amount: 100u64.private, - _nonce: 6586771265379155927089644749305420610382723873232320906747954786091923851913group.public - }" aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px 20u64 - -# Swap in the private key of Alice. -echo " -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH -ENDPOINT=http://localhost:3030 -" > .env - -# Convert 30 public tokens from Alice into 30 private tokens for Bob. -echo " -############################################################################### -######## ######## -######## STEP 5: Convert 30 public tokens from Alice into 30 ######## -######## private tokens for Bob. ######## -######## ######## -######## ----------------------------------------- ######## -######## | PUBLIC BALANCES | ######## -######## ----------------------------------------- ######## -######## ----------------------------------------- ######## -######## | Alice | 60 | ######## -######## ----------------------------------------- ######## -######## | Bob | 10 | ######## -######## ----------------------------------------- ######## -######## ######## -######## ----------------------------------------- ######## -######## | PRIVATE BALANCES | ######## -######## ----------------------------------------- ######## -######## ----------------------------------------- ######## -######## | Alice | 20 | ######## -######## ----------------------------------------- ######## -######## | Bob | 110 | ######## -######## ----------------------------------------- ######## -######## ######## -############################################################################### -" -leo run transfer_public_to_private aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t 30u64 - -# Swap in the private key of Bob. -echo " -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh -ENDPOINT=http://localhost:3030 -" > .env - -# Convert 40 private tokens from Bob into 40 public tokens for Alice. -echo " -############################################################################### -######## ######## -######## STEP 6: Convert 40 private tokens from Bob into 40 ######## -######## public tokens for Alice. ######## -######## ######## -######## ----------------------------------------- ######## -######## | PUBLIC BALANCES | ######## -######## ----------------------------------------- ######## -######## ----------------------------------------- ######## -######## | Alice | 100 | ######## -######## ----------------------------------------- ######## -######## | Bob | 10 | ######## -######## ----------------------------------------- ######## -######## ######## -######## ----------------------------------------- ######## -######## | PRIVATE BALANCES | ######## -######## ----------------------------------------- ######## -######## ----------------------------------------- ######## -######## | Alice | 20 | ######## -######## ----------------------------------------- ######## -######## | Bob | 70 | ######## -######## ----------------------------------------- ######## -######## ######## -############################################################################### -" -leo run transfer_private_to_public "{ - owner: aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t.private, - amount: 80u64.private, - _nonce: 1852830456042139988098466781381363679605019151318121788109768539956661608520group.public - }" aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px 40u64 - - -# Swap in the private key of Alice. -# This is done to ensure that program.json is the same after every execution of ./run.sh. -echo " -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH -ENDPOINT=http://localhost:3030 -" > .env diff --git a/examples/token/src/main.leo b/examples/token/src/main.leo deleted file mode 100644 index 7746348eec..0000000000 --- a/examples/token/src/main.leo +++ /dev/null @@ -1,128 +0,0 @@ -program token.aleo { - // On-chain storage of an `account` map, with `address` as the key, - // and `u64` as the value. - mapping account: address => u64; - - record token { - // The token owner. - owner: address, - // The token amount. - amount: u64, - } - - /* Mint */ - - // The function `mint_public` issues the specified token amount for the token receiver publicly on the network. - async transition mint_public(public receiver: address, public amount: u64) -> Future { - // Mint the tokens publicly by invoking the computation on-chain. - return finalize_mint_public(receiver, amount); - } - - async function finalize_mint_public(public receiver: address, public amount: u64) { - // Increments `account[receiver]` by `amount`. - // If `account[receiver]` does not exist, it will be created. - // If `account[receiver] + amount` overflows, `mint_public` is reverted. - let current_amount: u64 = Mapping::get_or_use(account, receiver, 0u64); - Mapping::set(account, receiver, current_amount + amount); - } - - // The function `mint_private` initializes a new record with the specified amount of tokens for the receiver. - transition mint_private(receiver: address, amount: u64) -> token { - return token { - owner: receiver, - amount: amount, - }; - } - - /* Transfer */ - async transition transfer_public(public receiver: address, public amount: u64) -> Future { - // Transfer the tokens publicly, by invoking the computation on-chain. - return finalize_transfer_public(self.caller, receiver, amount); - } - - async function finalize_transfer_public(public sender: address, public receiver: address, public amount: u64) { - // Decrements `account[sender]` by `amount`. - // If `account[sender]` does not exist, it will be created. - // If `account[sender] - amount` underflows, `transfer_public` is reverted. - let sender_amount: u64 = Mapping::get_or_use(account, sender, 0u64); - Mapping::set(account, sender, sender_amount - amount); - // Increments `account[receiver]` by `amount`. - // If `account[receiver]` does not exist, it will be created. - // If `account[receiver] + amount` overflows, `transfer_public` is reverted. - let receiver_amount: u64 = Mapping::get_or_use(account, receiver, 0u64); - Mapping::set(account, receiver, receiver_amount + amount); - } - - // The function `transfer_private` sends the specified token amount to the token receiver from the specified token record. - transition transfer_private(sender: token, receiver: address, amount: u64) -> (token, token) { - // Checks the given token record has sufficient balance. - // This `sub` operation is safe, and the proof will fail if an overflow occurs. - // `difference` holds the change amount to be returned to sender. - let difference: u64 = sender.amount - amount; - - // Produce a token record with the change amount for the sender. - let remaining: token = token { - owner: sender.owner, - amount: difference, - }; - - // Produce a token record for the specified receiver. - let transferred: token = token { - owner: receiver, - amount: amount, - }; - - // Output the sender's change record and the receiver's record. - return (remaining, transferred); - } - - // The function `transfer_private_to_public` turns a specified token amount from a token record into public tokens for the specified receiver. - // This function preserves privacy for the sender's record, however it publicly reveals the token receiver and the token amount. - async transition transfer_private_to_public(sender: token, public receiver: address, public amount: u64) -> (token, Future) { - // Checks the given token record has a sufficient token amount. - // This `sub` operation is safe, and the proof will fail if an underflow occurs. - // `difference` holds the change amount for the caller. - let difference: u64 = sender.amount - amount; - - // Produces a token record with the change amount for the caller. - let remaining: token = token { - owner: sender.owner, - amount: difference, - }; - - // Output the sender's change record. - // Increment the token amount publicly for the token receiver. - return (remaining, finalize_transfer_private_to_public(receiver, amount)); - } - - async function finalize_transfer_private_to_public(public receiver: address, public amount: u64) { - // Increments `account[receiver]` by `amount`. - // If `account[receiver]` does not exist, it will be created. - // If `account[receiver] + amount` overflows, `transfer_private_to_public` is reverted. - let current_amount: u64 = Mapping::get_or_use(account, receiver, 0u64); - Mapping::set(account, receiver, current_amount + amount); - } - - // The function `transfer_public_to_private` turns a specified token amount from `account` into a token record for the specified receiver. - // This function preserves privacy for the receiver's record, however it publicly reveals the caller and the specified token amount. - async transition transfer_public_to_private(public receiver: address, public amount: u64) -> (token, Future) { - // Produces a token record for the token receiver. - let transferred: token = token { - owner: receiver, - amount: amount, - }; - - // Output the receiver's record. - // Decrement the token amount of the caller publicly. - return (transferred, finalize_transfer_public_to_private(self.caller, amount)); - } - - async function finalize_transfer_public_to_private(public sender: address, public amount: u64) { - // Decrements `account[sender]` by `amount`. - // If `account[sender]` does not exist, it will be created. - // If `account[sender] - amount` underflows, `transfer_public_to_private` is reverted. - let current_amount: u64 = Mapping::get_or_use(account, sender, 0u64); - Mapping::set(account, sender, current_amount - amount); - } - -} diff --git a/examples/twoadicity/.env b/examples/twoadicity/.env deleted file mode 100644 index ab204ee457..0000000000 --- a/examples/twoadicity/.env +++ /dev/null @@ -1,3 +0,0 @@ -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH -ENDPOINT=http://localhost:3030 diff --git a/examples/twoadicity/.gitignore b/examples/twoadicity/.gitignore deleted file mode 100644 index 750b56f237..0000000000 --- a/examples/twoadicity/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -outputs/ -*.avm -*.prover -*.verifier \ No newline at end of file diff --git a/examples/twoadicity/README.md b/examples/twoadicity/README.md deleted file mode 100644 index d3cbb467fa..0000000000 --- a/examples/twoadicity/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# src/twoadicity.leo - -## Run Guide - -To run this program, run: -```bash -leo run main -``` - -## Execute Guide - -To execute this program, run: -```bash -leo execute main -``` diff --git a/examples/twoadicity/build/main.aleo b/examples/twoadicity/build/main.aleo deleted file mode 100644 index 9486ba36d5..0000000000 --- a/examples/twoadicity/build/main.aleo +++ /dev/null @@ -1,1274 +0,0 @@ -program twoadicity.aleo; - - - -closure is_even_and_nonzero: - input r0 as field; - div r0 2field into r1; - lt r1 r0 into r2; - output r2 as boolean; - - -function main: - input r0 as field.public; - call is_even_and_nonzero r0 into r1; - div r0 2field into r2; - add 0u8 1u8 into r3; - ternary r1 r2 r0 into r4; - ternary r1 r3 0u8 into r5; - call is_even_and_nonzero r4 into r6; - div r4 2field into r7; - add r5 1u8 into r8; - ternary r6 r7 r4 into r9; - ternary r6 r8 r5 into r10; - call is_even_and_nonzero r9 into r11; - div r9 2field into r12; - add r10 1u8 into r13; - ternary r11 r12 r9 into r14; - ternary r11 r13 r10 into r15; - call is_even_and_nonzero r14 into r16; - div r14 2field into r17; - add r15 1u8 into r18; - ternary r16 r17 r14 into r19; - ternary r16 r18 r15 into r20; - call is_even_and_nonzero r19 into r21; - div r19 2field into r22; - add r20 1u8 into r23; - ternary r21 r22 r19 into r24; - ternary r21 r23 r20 into r25; - call is_even_and_nonzero r24 into r26; - div r24 2field into r27; - add r25 1u8 into r28; - ternary r26 r27 r24 into r29; - ternary r26 r28 r25 into r30; - call is_even_and_nonzero r29 into r31; - div r29 2field into r32; - add r30 1u8 into r33; - ternary r31 r32 r29 into r34; - ternary r31 r33 r30 into r35; - call is_even_and_nonzero r34 into r36; - div r34 2field into r37; - add r35 1u8 into r38; - ternary r36 r37 r34 into r39; - ternary r36 r38 r35 into r40; - call is_even_and_nonzero r39 into r41; - div r39 2field into r42; - add r40 1u8 into r43; - ternary r41 r42 r39 into r44; - ternary r41 r43 r40 into r45; - call is_even_and_nonzero r44 into r46; - div r44 2field into r47; - add r45 1u8 into r48; - ternary r46 r47 r44 into r49; - ternary r46 r48 r45 into r50; - call is_even_and_nonzero r49 into r51; - div r49 2field into r52; - add r50 1u8 into r53; - ternary r51 r52 r49 into r54; - ternary r51 r53 r50 into r55; - call is_even_and_nonzero r54 into r56; - div r54 2field into r57; - add r55 1u8 into r58; - ternary r56 r57 r54 into r59; - ternary r56 r58 r55 into r60; - call is_even_and_nonzero r59 into r61; - div r59 2field into r62; - add r60 1u8 into r63; - ternary r61 r62 r59 into r64; - ternary r61 r63 r60 into r65; - call is_even_and_nonzero r64 into r66; - div r64 2field into r67; - add r65 1u8 into r68; - ternary r66 r67 r64 into r69; - ternary r66 r68 r65 into r70; - call is_even_and_nonzero r69 into r71; - div r69 2field into r72; - add r70 1u8 into r73; - ternary r71 r72 r69 into r74; - ternary r71 r73 r70 into r75; - call is_even_and_nonzero r74 into r76; - div r74 2field into r77; - add r75 1u8 into r78; - ternary r76 r77 r74 into r79; - ternary r76 r78 r75 into r80; - call is_even_and_nonzero r79 into r81; - div r79 2field into r82; - add r80 1u8 into r83; - ternary r81 r82 r79 into r84; - ternary r81 r83 r80 into r85; - call is_even_and_nonzero r84 into r86; - div r84 2field into r87; - add r85 1u8 into r88; - ternary r86 r87 r84 into r89; - ternary r86 r88 r85 into r90; - call is_even_and_nonzero r89 into r91; - div r89 2field into r92; - add r90 1u8 into r93; - ternary r91 r92 r89 into r94; - ternary r91 r93 r90 into r95; - call is_even_and_nonzero r94 into r96; - div r94 2field into r97; - add r95 1u8 into r98; - ternary r96 r97 r94 into r99; - ternary r96 r98 r95 into r100; - call is_even_and_nonzero r99 into r101; - div r99 2field into r102; - add r100 1u8 into r103; - ternary r101 r102 r99 into r104; - ternary r101 r103 r100 into r105; - call is_even_and_nonzero r104 into r106; - div r104 2field into r107; - add r105 1u8 into r108; - ternary r106 r107 r104 into r109; - ternary r106 r108 r105 into r110; - call is_even_and_nonzero r109 into r111; - div r109 2field into r112; - add r110 1u8 into r113; - ternary r111 r112 r109 into r114; - ternary r111 r113 r110 into r115; - call is_even_and_nonzero r114 into r116; - div r114 2field into r117; - add r115 1u8 into r118; - ternary r116 r117 r114 into r119; - ternary r116 r118 r115 into r120; - call is_even_and_nonzero r119 into r121; - div r119 2field into r122; - add r120 1u8 into r123; - ternary r121 r122 r119 into r124; - ternary r121 r123 r120 into r125; - call is_even_and_nonzero r124 into r126; - div r124 2field into r127; - add r125 1u8 into r128; - ternary r126 r127 r124 into r129; - ternary r126 r128 r125 into r130; - call is_even_and_nonzero r129 into r131; - div r129 2field into r132; - add r130 1u8 into r133; - ternary r131 r132 r129 into r134; - ternary r131 r133 r130 into r135; - call is_even_and_nonzero r134 into r136; - div r134 2field into r137; - add r135 1u8 into r138; - ternary r136 r137 r134 into r139; - ternary r136 r138 r135 into r140; - call is_even_and_nonzero r139 into r141; - div r139 2field into r142; - add r140 1u8 into r143; - ternary r141 r142 r139 into r144; - ternary r141 r143 r140 into r145; - call is_even_and_nonzero r144 into r146; - div r144 2field into r147; - add r145 1u8 into r148; - ternary r146 r147 r144 into r149; - ternary r146 r148 r145 into r150; - call is_even_and_nonzero r149 into r151; - div r149 2field into r152; - add r150 1u8 into r153; - ternary r151 r152 r149 into r154; - ternary r151 r153 r150 into r155; - call is_even_and_nonzero r154 into r156; - div r154 2field into r157; - add r155 1u8 into r158; - ternary r156 r157 r154 into r159; - ternary r156 r158 r155 into r160; - call is_even_and_nonzero r159 into r161; - div r159 2field into r162; - add r160 1u8 into r163; - ternary r161 r162 r159 into r164; - ternary r161 r163 r160 into r165; - call is_even_and_nonzero r164 into r166; - div r164 2field into r167; - add r165 1u8 into r168; - ternary r166 r167 r164 into r169; - ternary r166 r168 r165 into r170; - call is_even_and_nonzero r169 into r171; - div r169 2field into r172; - add r170 1u8 into r173; - ternary r171 r172 r169 into r174; - ternary r171 r173 r170 into r175; - call is_even_and_nonzero r174 into r176; - div r174 2field into r177; - add r175 1u8 into r178; - ternary r176 r177 r174 into r179; - ternary r176 r178 r175 into r180; - call is_even_and_nonzero r179 into r181; - div r179 2field into r182; - add r180 1u8 into r183; - ternary r181 r182 r179 into r184; - ternary r181 r183 r180 into r185; - call is_even_and_nonzero r184 into r186; - div r184 2field into r187; - add r185 1u8 into r188; - ternary r186 r187 r184 into r189; - ternary r186 r188 r185 into r190; - call is_even_and_nonzero r189 into r191; - div r189 2field into r192; - add r190 1u8 into r193; - ternary r191 r192 r189 into r194; - ternary r191 r193 r190 into r195; - call is_even_and_nonzero r194 into r196; - div r194 2field into r197; - add r195 1u8 into r198; - ternary r196 r197 r194 into r199; - ternary r196 r198 r195 into r200; - call is_even_and_nonzero r199 into r201; - div r199 2field into r202; - add r200 1u8 into r203; - ternary r201 r202 r199 into r204; - ternary r201 r203 r200 into r205; - call is_even_and_nonzero r204 into r206; - div r204 2field into r207; - add r205 1u8 into r208; - ternary r206 r207 r204 into r209; - ternary r206 r208 r205 into r210; - call is_even_and_nonzero r209 into r211; - div r209 2field into r212; - add r210 1u8 into r213; - ternary r211 r212 r209 into r214; - ternary r211 r213 r210 into r215; - call is_even_and_nonzero r214 into r216; - div r214 2field into r217; - add r215 1u8 into r218; - ternary r216 r217 r214 into r219; - ternary r216 r218 r215 into r220; - call is_even_and_nonzero r219 into r221; - div r219 2field into r222; - add r220 1u8 into r223; - ternary r221 r222 r219 into r224; - ternary r221 r223 r220 into r225; - call is_even_and_nonzero r224 into r226; - div r224 2field into r227; - add r225 1u8 into r228; - ternary r226 r227 r224 into r229; - ternary r226 r228 r225 into r230; - call is_even_and_nonzero r229 into r231; - div r229 2field into r232; - add r230 1u8 into r233; - ternary r231 r232 r229 into r234; - ternary r231 r233 r230 into r235; - call is_even_and_nonzero r234 into r236; - div r234 2field into r237; - add r235 1u8 into r238; - ternary r236 r237 r234 into r239; - ternary r236 r238 r235 into r240; - call is_even_and_nonzero r239 into r241; - div r239 2field into r242; - add r240 1u8 into r243; - ternary r241 r242 r239 into r244; - ternary r241 r243 r240 into r245; - call is_even_and_nonzero r244 into r246; - div r244 2field into r247; - add r245 1u8 into r248; - ternary r246 r247 r244 into r249; - ternary r246 r248 r245 into r250; - call is_even_and_nonzero r249 into r251; - div r249 2field into r252; - add r250 1u8 into r253; - ternary r251 r252 r249 into r254; - ternary r251 r253 r250 into r255; - call is_even_and_nonzero r254 into r256; - div r254 2field into r257; - add r255 1u8 into r258; - ternary r256 r257 r254 into r259; - ternary r256 r258 r255 into r260; - call is_even_and_nonzero r259 into r261; - div r259 2field into r262; - add r260 1u8 into r263; - ternary r261 r262 r259 into r264; - ternary r261 r263 r260 into r265; - call is_even_and_nonzero r264 into r266; - div r264 2field into r267; - add r265 1u8 into r268; - ternary r266 r267 r264 into r269; - ternary r266 r268 r265 into r270; - call is_even_and_nonzero r269 into r271; - div r269 2field into r272; - add r270 1u8 into r273; - ternary r271 r272 r269 into r274; - ternary r271 r273 r270 into r275; - call is_even_and_nonzero r274 into r276; - div r274 2field into r277; - add r275 1u8 into r278; - ternary r276 r277 r274 into r279; - ternary r276 r278 r275 into r280; - call is_even_and_nonzero r279 into r281; - div r279 2field into r282; - add r280 1u8 into r283; - ternary r281 r282 r279 into r284; - ternary r281 r283 r280 into r285; - call is_even_and_nonzero r284 into r286; - div r284 2field into r287; - add r285 1u8 into r288; - ternary r286 r287 r284 into r289; - ternary r286 r288 r285 into r290; - call is_even_and_nonzero r289 into r291; - div r289 2field into r292; - add r290 1u8 into r293; - ternary r291 r292 r289 into r294; - ternary r291 r293 r290 into r295; - call is_even_and_nonzero r294 into r296; - div r294 2field into r297; - add r295 1u8 into r298; - ternary r296 r297 r294 into r299; - ternary r296 r298 r295 into r300; - call is_even_and_nonzero r299 into r301; - div r299 2field into r302; - add r300 1u8 into r303; - ternary r301 r302 r299 into r304; - ternary r301 r303 r300 into r305; - call is_even_and_nonzero r304 into r306; - div r304 2field into r307; - add r305 1u8 into r308; - ternary r306 r307 r304 into r309; - ternary r306 r308 r305 into r310; - call is_even_and_nonzero r309 into r311; - div r309 2field into r312; - add r310 1u8 into r313; - ternary r311 r312 r309 into r314; - ternary r311 r313 r310 into r315; - call is_even_and_nonzero r314 into r316; - div r314 2field into r317; - add r315 1u8 into r318; - ternary r316 r317 r314 into r319; - ternary r316 r318 r315 into r320; - call is_even_and_nonzero r319 into r321; - div r319 2field into r322; - add r320 1u8 into r323; - ternary r321 r322 r319 into r324; - ternary r321 r323 r320 into r325; - call is_even_and_nonzero r324 into r326; - div r324 2field into r327; - add r325 1u8 into r328; - ternary r326 r327 r324 into r329; - ternary r326 r328 r325 into r330; - call is_even_and_nonzero r329 into r331; - div r329 2field into r332; - add r330 1u8 into r333; - ternary r331 r332 r329 into r334; - ternary r331 r333 r330 into r335; - call is_even_and_nonzero r334 into r336; - div r334 2field into r337; - add r335 1u8 into r338; - ternary r336 r337 r334 into r339; - ternary r336 r338 r335 into r340; - call is_even_and_nonzero r339 into r341; - div r339 2field into r342; - add r340 1u8 into r343; - ternary r341 r342 r339 into r344; - ternary r341 r343 r340 into r345; - call is_even_and_nonzero r344 into r346; - div r344 2field into r347; - add r345 1u8 into r348; - ternary r346 r347 r344 into r349; - ternary r346 r348 r345 into r350; - call is_even_and_nonzero r349 into r351; - div r349 2field into r352; - add r350 1u8 into r353; - ternary r351 r352 r349 into r354; - ternary r351 r353 r350 into r355; - call is_even_and_nonzero r354 into r356; - div r354 2field into r357; - add r355 1u8 into r358; - ternary r356 r357 r354 into r359; - ternary r356 r358 r355 into r360; - call is_even_and_nonzero r359 into r361; - div r359 2field into r362; - add r360 1u8 into r363; - ternary r361 r362 r359 into r364; - ternary r361 r363 r360 into r365; - call is_even_and_nonzero r364 into r366; - div r364 2field into r367; - add r365 1u8 into r368; - ternary r366 r367 r364 into r369; - ternary r366 r368 r365 into r370; - call is_even_and_nonzero r369 into r371; - div r369 2field into r372; - add r370 1u8 into r373; - ternary r371 r372 r369 into r374; - ternary r371 r373 r370 into r375; - call is_even_and_nonzero r374 into r376; - div r374 2field into r377; - add r375 1u8 into r378; - ternary r376 r377 r374 into r379; - ternary r376 r378 r375 into r380; - call is_even_and_nonzero r379 into r381; - div r379 2field into r382; - add r380 1u8 into r383; - ternary r381 r382 r379 into r384; - ternary r381 r383 r380 into r385; - call is_even_and_nonzero r384 into r386; - div r384 2field into r387; - add r385 1u8 into r388; - ternary r386 r387 r384 into r389; - ternary r386 r388 r385 into r390; - call is_even_and_nonzero r389 into r391; - div r389 2field into r392; - add r390 1u8 into r393; - ternary r391 r392 r389 into r394; - ternary r391 r393 r390 into r395; - call is_even_and_nonzero r394 into r396; - div r394 2field into r397; - add r395 1u8 into r398; - ternary r396 r397 r394 into r399; - ternary r396 r398 r395 into r400; - call is_even_and_nonzero r399 into r401; - div r399 2field into r402; - add r400 1u8 into r403; - ternary r401 r402 r399 into r404; - ternary r401 r403 r400 into r405; - call is_even_and_nonzero r404 into r406; - div r404 2field into r407; - add r405 1u8 into r408; - ternary r406 r407 r404 into r409; - ternary r406 r408 r405 into r410; - call is_even_and_nonzero r409 into r411; - div r409 2field into r412; - add r410 1u8 into r413; - ternary r411 r412 r409 into r414; - ternary r411 r413 r410 into r415; - call is_even_and_nonzero r414 into r416; - div r414 2field into r417; - add r415 1u8 into r418; - ternary r416 r417 r414 into r419; - ternary r416 r418 r415 into r420; - call is_even_and_nonzero r419 into r421; - div r419 2field into r422; - add r420 1u8 into r423; - ternary r421 r422 r419 into r424; - ternary r421 r423 r420 into r425; - call is_even_and_nonzero r424 into r426; - div r424 2field into r427; - add r425 1u8 into r428; - ternary r426 r427 r424 into r429; - ternary r426 r428 r425 into r430; - call is_even_and_nonzero r429 into r431; - div r429 2field into r432; - add r430 1u8 into r433; - ternary r431 r432 r429 into r434; - ternary r431 r433 r430 into r435; - call is_even_and_nonzero r434 into r436; - div r434 2field into r437; - add r435 1u8 into r438; - ternary r436 r437 r434 into r439; - ternary r436 r438 r435 into r440; - call is_even_and_nonzero r439 into r441; - div r439 2field into r442; - add r440 1u8 into r443; - ternary r441 r442 r439 into r444; - ternary r441 r443 r440 into r445; - call is_even_and_nonzero r444 into r446; - div r444 2field into r447; - add r445 1u8 into r448; - ternary r446 r447 r444 into r449; - ternary r446 r448 r445 into r450; - call is_even_and_nonzero r449 into r451; - div r449 2field into r452; - add r450 1u8 into r453; - ternary r451 r452 r449 into r454; - ternary r451 r453 r450 into r455; - call is_even_and_nonzero r454 into r456; - div r454 2field into r457; - add r455 1u8 into r458; - ternary r456 r457 r454 into r459; - ternary r456 r458 r455 into r460; - call is_even_and_nonzero r459 into r461; - div r459 2field into r462; - add r460 1u8 into r463; - ternary r461 r462 r459 into r464; - ternary r461 r463 r460 into r465; - call is_even_and_nonzero r464 into r466; - div r464 2field into r467; - add r465 1u8 into r468; - ternary r466 r467 r464 into r469; - ternary r466 r468 r465 into r470; - call is_even_and_nonzero r469 into r471; - div r469 2field into r472; - add r470 1u8 into r473; - ternary r471 r472 r469 into r474; - ternary r471 r473 r470 into r475; - call is_even_and_nonzero r474 into r476; - div r474 2field into r477; - add r475 1u8 into r478; - ternary r476 r477 r474 into r479; - ternary r476 r478 r475 into r480; - call is_even_and_nonzero r479 into r481; - div r479 2field into r482; - add r480 1u8 into r483; - ternary r481 r482 r479 into r484; - ternary r481 r483 r480 into r485; - call is_even_and_nonzero r484 into r486; - div r484 2field into r487; - add r485 1u8 into r488; - ternary r486 r487 r484 into r489; - ternary r486 r488 r485 into r490; - call is_even_and_nonzero r489 into r491; - div r489 2field into r492; - add r490 1u8 into r493; - ternary r491 r492 r489 into r494; - ternary r491 r493 r490 into r495; - call is_even_and_nonzero r494 into r496; - div r494 2field into r497; - add r495 1u8 into r498; - ternary r496 r497 r494 into r499; - ternary r496 r498 r495 into r500; - call is_even_and_nonzero r499 into r501; - div r499 2field into r502; - add r500 1u8 into r503; - ternary r501 r502 r499 into r504; - ternary r501 r503 r500 into r505; - call is_even_and_nonzero r504 into r506; - div r504 2field into r507; - add r505 1u8 into r508; - ternary r506 r507 r504 into r509; - ternary r506 r508 r505 into r510; - call is_even_and_nonzero r509 into r511; - div r509 2field into r512; - add r510 1u8 into r513; - ternary r511 r512 r509 into r514; - ternary r511 r513 r510 into r515; - call is_even_and_nonzero r514 into r516; - div r514 2field into r517; - add r515 1u8 into r518; - ternary r516 r517 r514 into r519; - ternary r516 r518 r515 into r520; - call is_even_and_nonzero r519 into r521; - div r519 2field into r522; - add r520 1u8 into r523; - ternary r521 r522 r519 into r524; - ternary r521 r523 r520 into r525; - call is_even_and_nonzero r524 into r526; - div r524 2field into r527; - add r525 1u8 into r528; - ternary r526 r527 r524 into r529; - ternary r526 r528 r525 into r530; - call is_even_and_nonzero r529 into r531; - div r529 2field into r532; - add r530 1u8 into r533; - ternary r531 r532 r529 into r534; - ternary r531 r533 r530 into r535; - call is_even_and_nonzero r534 into r536; - div r534 2field into r537; - add r535 1u8 into r538; - ternary r536 r537 r534 into r539; - ternary r536 r538 r535 into r540; - call is_even_and_nonzero r539 into r541; - div r539 2field into r542; - add r540 1u8 into r543; - ternary r541 r542 r539 into r544; - ternary r541 r543 r540 into r545; - call is_even_and_nonzero r544 into r546; - div r544 2field into r547; - add r545 1u8 into r548; - ternary r546 r547 r544 into r549; - ternary r546 r548 r545 into r550; - call is_even_and_nonzero r549 into r551; - div r549 2field into r552; - add r550 1u8 into r553; - ternary r551 r552 r549 into r554; - ternary r551 r553 r550 into r555; - call is_even_and_nonzero r554 into r556; - div r554 2field into r557; - add r555 1u8 into r558; - ternary r556 r557 r554 into r559; - ternary r556 r558 r555 into r560; - call is_even_and_nonzero r559 into r561; - div r559 2field into r562; - add r560 1u8 into r563; - ternary r561 r562 r559 into r564; - ternary r561 r563 r560 into r565; - call is_even_and_nonzero r564 into r566; - div r564 2field into r567; - add r565 1u8 into r568; - ternary r566 r567 r564 into r569; - ternary r566 r568 r565 into r570; - call is_even_and_nonzero r569 into r571; - div r569 2field into r572; - add r570 1u8 into r573; - ternary r571 r572 r569 into r574; - ternary r571 r573 r570 into r575; - call is_even_and_nonzero r574 into r576; - div r574 2field into r577; - add r575 1u8 into r578; - ternary r576 r577 r574 into r579; - ternary r576 r578 r575 into r580; - call is_even_and_nonzero r579 into r581; - div r579 2field into r582; - add r580 1u8 into r583; - ternary r581 r582 r579 into r584; - ternary r581 r583 r580 into r585; - call is_even_and_nonzero r584 into r586; - div r584 2field into r587; - add r585 1u8 into r588; - ternary r586 r587 r584 into r589; - ternary r586 r588 r585 into r590; - call is_even_and_nonzero r589 into r591; - div r589 2field into r592; - add r590 1u8 into r593; - ternary r591 r592 r589 into r594; - ternary r591 r593 r590 into r595; - call is_even_and_nonzero r594 into r596; - div r594 2field into r597; - add r595 1u8 into r598; - ternary r596 r597 r594 into r599; - ternary r596 r598 r595 into r600; - call is_even_and_nonzero r599 into r601; - div r599 2field into r602; - add r600 1u8 into r603; - ternary r601 r602 r599 into r604; - ternary r601 r603 r600 into r605; - call is_even_and_nonzero r604 into r606; - div r604 2field into r607; - add r605 1u8 into r608; - ternary r606 r607 r604 into r609; - ternary r606 r608 r605 into r610; - call is_even_and_nonzero r609 into r611; - div r609 2field into r612; - add r610 1u8 into r613; - ternary r611 r612 r609 into r614; - ternary r611 r613 r610 into r615; - call is_even_and_nonzero r614 into r616; - div r614 2field into r617; - add r615 1u8 into r618; - ternary r616 r617 r614 into r619; - ternary r616 r618 r615 into r620; - call is_even_and_nonzero r619 into r621; - div r619 2field into r622; - add r620 1u8 into r623; - ternary r621 r622 r619 into r624; - ternary r621 r623 r620 into r625; - call is_even_and_nonzero r624 into r626; - div r624 2field into r627; - add r625 1u8 into r628; - ternary r626 r627 r624 into r629; - ternary r626 r628 r625 into r630; - call is_even_and_nonzero r629 into r631; - div r629 2field into r632; - add r630 1u8 into r633; - ternary r631 r632 r629 into r634; - ternary r631 r633 r630 into r635; - call is_even_and_nonzero r634 into r636; - div r634 2field into r637; - add r635 1u8 into r638; - ternary r636 r637 r634 into r639; - ternary r636 r638 r635 into r640; - call is_even_and_nonzero r639 into r641; - div r639 2field into r642; - add r640 1u8 into r643; - ternary r641 r642 r639 into r644; - ternary r641 r643 r640 into r645; - call is_even_and_nonzero r644 into r646; - div r644 2field into r647; - add r645 1u8 into r648; - ternary r646 r647 r644 into r649; - ternary r646 r648 r645 into r650; - call is_even_and_nonzero r649 into r651; - div r649 2field into r652; - add r650 1u8 into r653; - ternary r651 r652 r649 into r654; - ternary r651 r653 r650 into r655; - call is_even_and_nonzero r654 into r656; - div r654 2field into r657; - add r655 1u8 into r658; - ternary r656 r657 r654 into r659; - ternary r656 r658 r655 into r660; - call is_even_and_nonzero r659 into r661; - div r659 2field into r662; - add r660 1u8 into r663; - ternary r661 r662 r659 into r664; - ternary r661 r663 r660 into r665; - call is_even_and_nonzero r664 into r666; - div r664 2field into r667; - add r665 1u8 into r668; - ternary r666 r667 r664 into r669; - ternary r666 r668 r665 into r670; - call is_even_and_nonzero r669 into r671; - div r669 2field into r672; - add r670 1u8 into r673; - ternary r671 r672 r669 into r674; - ternary r671 r673 r670 into r675; - call is_even_and_nonzero r674 into r676; - div r674 2field into r677; - add r675 1u8 into r678; - ternary r676 r677 r674 into r679; - ternary r676 r678 r675 into r680; - call is_even_and_nonzero r679 into r681; - div r679 2field into r682; - add r680 1u8 into r683; - ternary r681 r682 r679 into r684; - ternary r681 r683 r680 into r685; - call is_even_and_nonzero r684 into r686; - div r684 2field into r687; - add r685 1u8 into r688; - ternary r686 r687 r684 into r689; - ternary r686 r688 r685 into r690; - call is_even_and_nonzero r689 into r691; - div r689 2field into r692; - add r690 1u8 into r693; - ternary r691 r692 r689 into r694; - ternary r691 r693 r690 into r695; - call is_even_and_nonzero r694 into r696; - div r694 2field into r697; - add r695 1u8 into r698; - ternary r696 r697 r694 into r699; - ternary r696 r698 r695 into r700; - call is_even_and_nonzero r699 into r701; - div r699 2field into r702; - add r700 1u8 into r703; - ternary r701 r702 r699 into r704; - ternary r701 r703 r700 into r705; - call is_even_and_nonzero r704 into r706; - div r704 2field into r707; - add r705 1u8 into r708; - ternary r706 r707 r704 into r709; - ternary r706 r708 r705 into r710; - call is_even_and_nonzero r709 into r711; - div r709 2field into r712; - add r710 1u8 into r713; - ternary r711 r712 r709 into r714; - ternary r711 r713 r710 into r715; - call is_even_and_nonzero r714 into r716; - div r714 2field into r717; - add r715 1u8 into r718; - ternary r716 r717 r714 into r719; - ternary r716 r718 r715 into r720; - call is_even_and_nonzero r719 into r721; - div r719 2field into r722; - add r720 1u8 into r723; - ternary r721 r722 r719 into r724; - ternary r721 r723 r720 into r725; - call is_even_and_nonzero r724 into r726; - div r724 2field into r727; - add r725 1u8 into r728; - ternary r726 r727 r724 into r729; - ternary r726 r728 r725 into r730; - call is_even_and_nonzero r729 into r731; - div r729 2field into r732; - add r730 1u8 into r733; - ternary r731 r732 r729 into r734; - ternary r731 r733 r730 into r735; - call is_even_and_nonzero r734 into r736; - div r734 2field into r737; - add r735 1u8 into r738; - ternary r736 r737 r734 into r739; - ternary r736 r738 r735 into r740; - call is_even_and_nonzero r739 into r741; - div r739 2field into r742; - add r740 1u8 into r743; - ternary r741 r742 r739 into r744; - ternary r741 r743 r740 into r745; - call is_even_and_nonzero r744 into r746; - div r744 2field into r747; - add r745 1u8 into r748; - ternary r746 r747 r744 into r749; - ternary r746 r748 r745 into r750; - call is_even_and_nonzero r749 into r751; - div r749 2field into r752; - add r750 1u8 into r753; - ternary r751 r752 r749 into r754; - ternary r751 r753 r750 into r755; - call is_even_and_nonzero r754 into r756; - div r754 2field into r757; - add r755 1u8 into r758; - ternary r756 r757 r754 into r759; - ternary r756 r758 r755 into r760; - call is_even_and_nonzero r759 into r761; - div r759 2field into r762; - add r760 1u8 into r763; - ternary r761 r762 r759 into r764; - ternary r761 r763 r760 into r765; - call is_even_and_nonzero r764 into r766; - div r764 2field into r767; - add r765 1u8 into r768; - ternary r766 r767 r764 into r769; - ternary r766 r768 r765 into r770; - call is_even_and_nonzero r769 into r771; - div r769 2field into r772; - add r770 1u8 into r773; - ternary r771 r772 r769 into r774; - ternary r771 r773 r770 into r775; - call is_even_and_nonzero r774 into r776; - div r774 2field into r777; - add r775 1u8 into r778; - ternary r776 r777 r774 into r779; - ternary r776 r778 r775 into r780; - call is_even_and_nonzero r779 into r781; - div r779 2field into r782; - add r780 1u8 into r783; - ternary r781 r782 r779 into r784; - ternary r781 r783 r780 into r785; - call is_even_and_nonzero r784 into r786; - div r784 2field into r787; - add r785 1u8 into r788; - ternary r786 r787 r784 into r789; - ternary r786 r788 r785 into r790; - call is_even_and_nonzero r789 into r791; - div r789 2field into r792; - add r790 1u8 into r793; - ternary r791 r792 r789 into r794; - ternary r791 r793 r790 into r795; - call is_even_and_nonzero r794 into r796; - div r794 2field into r797; - add r795 1u8 into r798; - ternary r796 r797 r794 into r799; - ternary r796 r798 r795 into r800; - call is_even_and_nonzero r799 into r801; - div r799 2field into r802; - add r800 1u8 into r803; - ternary r801 r802 r799 into r804; - ternary r801 r803 r800 into r805; - call is_even_and_nonzero r804 into r806; - div r804 2field into r807; - add r805 1u8 into r808; - ternary r806 r807 r804 into r809; - ternary r806 r808 r805 into r810; - call is_even_and_nonzero r809 into r811; - div r809 2field into r812; - add r810 1u8 into r813; - ternary r811 r812 r809 into r814; - ternary r811 r813 r810 into r815; - call is_even_and_nonzero r814 into r816; - div r814 2field into r817; - add r815 1u8 into r818; - ternary r816 r817 r814 into r819; - ternary r816 r818 r815 into r820; - call is_even_and_nonzero r819 into r821; - div r819 2field into r822; - add r820 1u8 into r823; - ternary r821 r822 r819 into r824; - ternary r821 r823 r820 into r825; - call is_even_and_nonzero r824 into r826; - div r824 2field into r827; - add r825 1u8 into r828; - ternary r826 r827 r824 into r829; - ternary r826 r828 r825 into r830; - call is_even_and_nonzero r829 into r831; - div r829 2field into r832; - add r830 1u8 into r833; - ternary r831 r832 r829 into r834; - ternary r831 r833 r830 into r835; - call is_even_and_nonzero r834 into r836; - div r834 2field into r837; - add r835 1u8 into r838; - ternary r836 r837 r834 into r839; - ternary r836 r838 r835 into r840; - call is_even_and_nonzero r839 into r841; - div r839 2field into r842; - add r840 1u8 into r843; - ternary r841 r842 r839 into r844; - ternary r841 r843 r840 into r845; - call is_even_and_nonzero r844 into r846; - div r844 2field into r847; - add r845 1u8 into r848; - ternary r846 r847 r844 into r849; - ternary r846 r848 r845 into r850; - call is_even_and_nonzero r849 into r851; - div r849 2field into r852; - add r850 1u8 into r853; - ternary r851 r852 r849 into r854; - ternary r851 r853 r850 into r855; - call is_even_and_nonzero r854 into r856; - div r854 2field into r857; - add r855 1u8 into r858; - ternary r856 r857 r854 into r859; - ternary r856 r858 r855 into r860; - call is_even_and_nonzero r859 into r861; - div r859 2field into r862; - add r860 1u8 into r863; - ternary r861 r862 r859 into r864; - ternary r861 r863 r860 into r865; - call is_even_and_nonzero r864 into r866; - div r864 2field into r867; - add r865 1u8 into r868; - ternary r866 r867 r864 into r869; - ternary r866 r868 r865 into r870; - call is_even_and_nonzero r869 into r871; - div r869 2field into r872; - add r870 1u8 into r873; - ternary r871 r872 r869 into r874; - ternary r871 r873 r870 into r875; - call is_even_and_nonzero r874 into r876; - div r874 2field into r877; - add r875 1u8 into r878; - ternary r876 r877 r874 into r879; - ternary r876 r878 r875 into r880; - call is_even_and_nonzero r879 into r881; - div r879 2field into r882; - add r880 1u8 into r883; - ternary r881 r882 r879 into r884; - ternary r881 r883 r880 into r885; - call is_even_and_nonzero r884 into r886; - div r884 2field into r887; - add r885 1u8 into r888; - ternary r886 r887 r884 into r889; - ternary r886 r888 r885 into r890; - call is_even_and_nonzero r889 into r891; - div r889 2field into r892; - add r890 1u8 into r893; - ternary r891 r892 r889 into r894; - ternary r891 r893 r890 into r895; - call is_even_and_nonzero r894 into r896; - div r894 2field into r897; - add r895 1u8 into r898; - ternary r896 r897 r894 into r899; - ternary r896 r898 r895 into r900; - call is_even_and_nonzero r899 into r901; - div r899 2field into r902; - add r900 1u8 into r903; - ternary r901 r902 r899 into r904; - ternary r901 r903 r900 into r905; - call is_even_and_nonzero r904 into r906; - div r904 2field into r907; - add r905 1u8 into r908; - ternary r906 r907 r904 into r909; - ternary r906 r908 r905 into r910; - call is_even_and_nonzero r909 into r911; - div r909 2field into r912; - add r910 1u8 into r913; - ternary r911 r912 r909 into r914; - ternary r911 r913 r910 into r915; - call is_even_and_nonzero r914 into r916; - div r914 2field into r917; - add r915 1u8 into r918; - ternary r916 r917 r914 into r919; - ternary r916 r918 r915 into r920; - call is_even_and_nonzero r919 into r921; - div r919 2field into r922; - add r920 1u8 into r923; - ternary r921 r922 r919 into r924; - ternary r921 r923 r920 into r925; - call is_even_and_nonzero r924 into r926; - div r924 2field into r927; - add r925 1u8 into r928; - ternary r926 r927 r924 into r929; - ternary r926 r928 r925 into r930; - call is_even_and_nonzero r929 into r931; - div r929 2field into r932; - add r930 1u8 into r933; - ternary r931 r932 r929 into r934; - ternary r931 r933 r930 into r935; - call is_even_and_nonzero r934 into r936; - div r934 2field into r937; - add r935 1u8 into r938; - ternary r936 r937 r934 into r939; - ternary r936 r938 r935 into r940; - call is_even_and_nonzero r939 into r941; - div r939 2field into r942; - add r940 1u8 into r943; - ternary r941 r942 r939 into r944; - ternary r941 r943 r940 into r945; - call is_even_and_nonzero r944 into r946; - div r944 2field into r947; - add r945 1u8 into r948; - ternary r946 r947 r944 into r949; - ternary r946 r948 r945 into r950; - call is_even_and_nonzero r949 into r951; - div r949 2field into r952; - add r950 1u8 into r953; - ternary r951 r952 r949 into r954; - ternary r951 r953 r950 into r955; - call is_even_and_nonzero r954 into r956; - div r954 2field into r957; - add r955 1u8 into r958; - ternary r956 r957 r954 into r959; - ternary r956 r958 r955 into r960; - call is_even_and_nonzero r959 into r961; - div r959 2field into r962; - add r960 1u8 into r963; - ternary r961 r962 r959 into r964; - ternary r961 r963 r960 into r965; - call is_even_and_nonzero r964 into r966; - div r964 2field into r967; - add r965 1u8 into r968; - ternary r966 r967 r964 into r969; - ternary r966 r968 r965 into r970; - call is_even_and_nonzero r969 into r971; - div r969 2field into r972; - add r970 1u8 into r973; - ternary r971 r972 r969 into r974; - ternary r971 r973 r970 into r975; - call is_even_and_nonzero r974 into r976; - div r974 2field into r977; - add r975 1u8 into r978; - ternary r976 r977 r974 into r979; - ternary r976 r978 r975 into r980; - call is_even_and_nonzero r979 into r981; - div r979 2field into r982; - add r980 1u8 into r983; - ternary r981 r982 r979 into r984; - ternary r981 r983 r980 into r985; - call is_even_and_nonzero r984 into r986; - div r984 2field into r987; - add r985 1u8 into r988; - ternary r986 r987 r984 into r989; - ternary r986 r988 r985 into r990; - call is_even_and_nonzero r989 into r991; - div r989 2field into r992; - add r990 1u8 into r993; - ternary r991 r992 r989 into r994; - ternary r991 r993 r990 into r995; - call is_even_and_nonzero r994 into r996; - div r994 2field into r997; - add r995 1u8 into r998; - ternary r996 r997 r994 into r999; - ternary r996 r998 r995 into r1000; - call is_even_and_nonzero r999 into r1001; - div r999 2field into r1002; - add r1000 1u8 into r1003; - ternary r1001 r1002 r999 into r1004; - ternary r1001 r1003 r1000 into r1005; - call is_even_and_nonzero r1004 into r1006; - div r1004 2field into r1007; - add r1005 1u8 into r1008; - ternary r1006 r1007 r1004 into r1009; - ternary r1006 r1008 r1005 into r1010; - call is_even_and_nonzero r1009 into r1011; - div r1009 2field into r1012; - add r1010 1u8 into r1013; - ternary r1011 r1012 r1009 into r1014; - ternary r1011 r1013 r1010 into r1015; - call is_even_and_nonzero r1014 into r1016; - div r1014 2field into r1017; - add r1015 1u8 into r1018; - ternary r1016 r1017 r1014 into r1019; - ternary r1016 r1018 r1015 into r1020; - call is_even_and_nonzero r1019 into r1021; - div r1019 2field into r1022; - add r1020 1u8 into r1023; - ternary r1021 r1022 r1019 into r1024; - ternary r1021 r1023 r1020 into r1025; - call is_even_and_nonzero r1024 into r1026; - div r1024 2field into r1027; - add r1025 1u8 into r1028; - ternary r1026 r1027 r1024 into r1029; - ternary r1026 r1028 r1025 into r1030; - call is_even_and_nonzero r1029 into r1031; - div r1029 2field into r1032; - add r1030 1u8 into r1033; - ternary r1031 r1032 r1029 into r1034; - ternary r1031 r1033 r1030 into r1035; - call is_even_and_nonzero r1034 into r1036; - div r1034 2field into r1037; - add r1035 1u8 into r1038; - ternary r1036 r1037 r1034 into r1039; - ternary r1036 r1038 r1035 into r1040; - call is_even_and_nonzero r1039 into r1041; - div r1039 2field into r1042; - add r1040 1u8 into r1043; - ternary r1041 r1042 r1039 into r1044; - ternary r1041 r1043 r1040 into r1045; - call is_even_and_nonzero r1044 into r1046; - div r1044 2field into r1047; - add r1045 1u8 into r1048; - ternary r1046 r1047 r1044 into r1049; - ternary r1046 r1048 r1045 into r1050; - call is_even_and_nonzero r1049 into r1051; - div r1049 2field into r1052; - add r1050 1u8 into r1053; - ternary r1051 r1052 r1049 into r1054; - ternary r1051 r1053 r1050 into r1055; - call is_even_and_nonzero r1054 into r1056; - div r1054 2field into r1057; - add r1055 1u8 into r1058; - ternary r1056 r1057 r1054 into r1059; - ternary r1056 r1058 r1055 into r1060; - call is_even_and_nonzero r1059 into r1061; - div r1059 2field into r1062; - add r1060 1u8 into r1063; - ternary r1061 r1062 r1059 into r1064; - ternary r1061 r1063 r1060 into r1065; - call is_even_and_nonzero r1064 into r1066; - div r1064 2field into r1067; - add r1065 1u8 into r1068; - ternary r1066 r1067 r1064 into r1069; - ternary r1066 r1068 r1065 into r1070; - call is_even_and_nonzero r1069 into r1071; - div r1069 2field into r1072; - add r1070 1u8 into r1073; - ternary r1071 r1072 r1069 into r1074; - ternary r1071 r1073 r1070 into r1075; - call is_even_and_nonzero r1074 into r1076; - div r1074 2field into r1077; - add r1075 1u8 into r1078; - ternary r1076 r1077 r1074 into r1079; - ternary r1076 r1078 r1075 into r1080; - call is_even_and_nonzero r1079 into r1081; - div r1079 2field into r1082; - add r1080 1u8 into r1083; - ternary r1081 r1082 r1079 into r1084; - ternary r1081 r1083 r1080 into r1085; - call is_even_and_nonzero r1084 into r1086; - div r1084 2field into r1087; - add r1085 1u8 into r1088; - ternary r1086 r1087 r1084 into r1089; - ternary r1086 r1088 r1085 into r1090; - call is_even_and_nonzero r1089 into r1091; - div r1089 2field into r1092; - add r1090 1u8 into r1093; - ternary r1091 r1092 r1089 into r1094; - ternary r1091 r1093 r1090 into r1095; - call is_even_and_nonzero r1094 into r1096; - div r1094 2field into r1097; - add r1095 1u8 into r1098; - ternary r1096 r1097 r1094 into r1099; - ternary r1096 r1098 r1095 into r1100; - call is_even_and_nonzero r1099 into r1101; - div r1099 2field into r1102; - add r1100 1u8 into r1103; - ternary r1101 r1102 r1099 into r1104; - ternary r1101 r1103 r1100 into r1105; - call is_even_and_nonzero r1104 into r1106; - div r1104 2field into r1107; - add r1105 1u8 into r1108; - ternary r1106 r1107 r1104 into r1109; - ternary r1106 r1108 r1105 into r1110; - call is_even_and_nonzero r1109 into r1111; - div r1109 2field into r1112; - add r1110 1u8 into r1113; - ternary r1111 r1112 r1109 into r1114; - ternary r1111 r1113 r1110 into r1115; - call is_even_and_nonzero r1114 into r1116; - div r1114 2field into r1117; - add r1115 1u8 into r1118; - ternary r1116 r1117 r1114 into r1119; - ternary r1116 r1118 r1115 into r1120; - call is_even_and_nonzero r1119 into r1121; - div r1119 2field into r1122; - add r1120 1u8 into r1123; - ternary r1121 r1122 r1119 into r1124; - ternary r1121 r1123 r1120 into r1125; - call is_even_and_nonzero r1124 into r1126; - div r1124 2field into r1127; - add r1125 1u8 into r1128; - ternary r1126 r1127 r1124 into r1129; - ternary r1126 r1128 r1125 into r1130; - call is_even_and_nonzero r1129 into r1131; - div r1129 2field into r1132; - add r1130 1u8 into r1133; - ternary r1131 r1132 r1129 into r1134; - ternary r1131 r1133 r1130 into r1135; - call is_even_and_nonzero r1134 into r1136; - div r1134 2field into r1137; - add r1135 1u8 into r1138; - ternary r1136 r1137 r1134 into r1139; - ternary r1136 r1138 r1135 into r1140; - call is_even_and_nonzero r1139 into r1141; - div r1139 2field into r1142; - add r1140 1u8 into r1143; - ternary r1141 r1142 r1139 into r1144; - ternary r1141 r1143 r1140 into r1145; - call is_even_and_nonzero r1144 into r1146; - div r1144 2field into r1147; - add r1145 1u8 into r1148; - ternary r1146 r1147 r1144 into r1149; - ternary r1146 r1148 r1145 into r1150; - call is_even_and_nonzero r1149 into r1151; - div r1149 2field into r1152; - add r1150 1u8 into r1153; - ternary r1151 r1152 r1149 into r1154; - ternary r1151 r1153 r1150 into r1155; - call is_even_and_nonzero r1154 into r1156; - div r1154 2field into r1157; - add r1155 1u8 into r1158; - ternary r1156 r1157 r1154 into r1159; - ternary r1156 r1158 r1155 into r1160; - call is_even_and_nonzero r1159 into r1161; - div r1159 2field into r1162; - add r1160 1u8 into r1163; - ternary r1161 r1162 r1159 into r1164; - ternary r1161 r1163 r1160 into r1165; - call is_even_and_nonzero r1164 into r1166; - div r1164 2field into r1167; - add r1165 1u8 into r1168; - ternary r1166 r1167 r1164 into r1169; - ternary r1166 r1168 r1165 into r1170; - call is_even_and_nonzero r1169 into r1171; - div r1169 2field into r1172; - add r1170 1u8 into r1173; - ternary r1171 r1172 r1169 into r1174; - ternary r1171 r1173 r1170 into r1175; - call is_even_and_nonzero r1174 into r1176; - div r1174 2field into r1177; - add r1175 1u8 into r1178; - ternary r1176 r1177 r1174 into r1179; - ternary r1176 r1178 r1175 into r1180; - call is_even_and_nonzero r1179 into r1181; - div r1179 2field into r1182; - add r1180 1u8 into r1183; - ternary r1181 r1182 r1179 into r1184; - ternary r1181 r1183 r1180 into r1185; - call is_even_and_nonzero r1184 into r1186; - div r1184 2field into r1187; - add r1185 1u8 into r1188; - ternary r1186 r1187 r1184 into r1189; - ternary r1186 r1188 r1185 into r1190; - call is_even_and_nonzero r1189 into r1191; - div r1189 2field into r1192; - add r1190 1u8 into r1193; - ternary r1191 r1192 r1189 into r1194; - ternary r1191 r1193 r1190 into r1195; - call is_even_and_nonzero r1194 into r1196; - div r1194 2field into r1197; - add r1195 1u8 into r1198; - ternary r1196 r1197 r1194 into r1199; - ternary r1196 r1198 r1195 into r1200; - call is_even_and_nonzero r1199 into r1201; - div r1199 2field into r1202; - add r1200 1u8 into r1203; - ternary r1201 r1202 r1199 into r1204; - ternary r1201 r1203 r1200 into r1205; - call is_even_and_nonzero r1204 into r1206; - div r1204 2field into r1207; - add r1205 1u8 into r1208; - ternary r1206 r1207 r1204 into r1209; - ternary r1206 r1208 r1205 into r1210; - call is_even_and_nonzero r1209 into r1211; - div r1209 2field into r1212; - add r1210 1u8 into r1213; - ternary r1211 r1212 r1209 into r1214; - ternary r1211 r1213 r1210 into r1215; - call is_even_and_nonzero r1214 into r1216; - div r1214 2field into r1217; - add r1215 1u8 into r1218; - ternary r1216 r1217 r1214 into r1219; - ternary r1216 r1218 r1215 into r1220; - call is_even_and_nonzero r1219 into r1221; - div r1219 2field into r1222; - add r1220 1u8 into r1223; - ternary r1221 r1222 r1219 into r1224; - ternary r1221 r1223 r1220 into r1225; - call is_even_and_nonzero r1224 into r1226; - div r1224 2field into r1227; - add r1225 1u8 into r1228; - ternary r1226 r1227 r1224 into r1229; - ternary r1226 r1228 r1225 into r1230; - call is_even_and_nonzero r1229 into r1231; - div r1229 2field into r1232; - add r1230 1u8 into r1233; - ternary r1231 r1232 r1229 into r1234; - ternary r1231 r1233 r1230 into r1235; - call is_even_and_nonzero r1234 into r1236; - div r1234 2field into r1237; - add r1235 1u8 into r1238; - ternary r1236 r1237 r1234 into r1239; - ternary r1236 r1238 r1235 into r1240; - call is_even_and_nonzero r1239 into r1241; - div r1239 2field into r1242; - add r1240 1u8 into r1243; - ternary r1241 r1242 r1239 into r1244; - ternary r1241 r1243 r1240 into r1245; - call is_even_and_nonzero r1244 into r1246; - div r1244 2field into r1247; - add r1245 1u8 into r1248; - ternary r1246 r1247 r1244 into r1249; - ternary r1246 r1248 r1245 into r1250; - call is_even_and_nonzero r1249 into r1251; - div r1249 2field into r1252; - add r1250 1u8 into r1253; - ternary r1251 r1252 r1249 into r1254; - ternary r1251 r1253 r1250 into r1255; - call is_even_and_nonzero r1254 into r1256; - div r1254 2field into r1257; - add r1255 1u8 into r1258; - ternary r1256 r1257 r1254 into r1259; - ternary r1256 r1258 r1255 into r1260; - output r1260 as u8.private; diff --git a/examples/twoadicity/build/program.json b/examples/twoadicity/build/program.json deleted file mode 100644 index 088f14957d..0000000000 --- a/examples/twoadicity/build/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "twoadicity.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/twoadicity/inputs/twoadicity.in b/examples/twoadicity/inputs/twoadicity.in deleted file mode 100644 index c01cac0720..0000000000 --- a/examples/twoadicity/inputs/twoadicity.in +++ /dev/null @@ -1 +0,0 @@ -8444461749428370424248824938781546531375899335154063827935233455917409239040field diff --git a/examples/twoadicity/leo.lock b/examples/twoadicity/leo.lock deleted file mode 100644 index c4293b3b9f..0000000000 --- a/examples/twoadicity/leo.lock +++ /dev/null @@ -1 +0,0 @@ -package = [] diff --git a/examples/twoadicity/program.json b/examples/twoadicity/program.json deleted file mode 100644 index 088f14957d..0000000000 --- a/examples/twoadicity/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "twoadicity.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/twoadicity/src/main.leo b/examples/twoadicity/src/main.leo deleted file mode 100644 index e8c6359bdb..0000000000 --- a/examples/twoadicity/src/main.leo +++ /dev/null @@ -1,28 +0,0 @@ -program twoadicity.aleo { - // This function calculates the number of powers of two ("twoadicity") - // in the prime factorization of the input number `n`. - transition main(public n: field) -> u8 { - let remaining_n: field = n; - let powers_of_two: u8 = 0u8; - // Since field ints are 253 bits or fewer, any number in the field - // will have at most 252 powers of two in its prime factoring. - for i:u8 in 0u8..252u8 { - if is_even_and_nonzero(remaining_n) { - remaining_n = remaining_n / 2field; - powers_of_two = powers_of_two + 1u8; - } - } - return powers_of_two; - } - - /* We define the is_even predicate on fields as follows. - If n is even and nonzero, clearly n/2 < n. - If n is odd, n-p is a field-equivalent negative number that is even, and - (n-p)/2 is a field-equivalent negative number closer to 0, greater than n-p. - If we add p to both of these negative numbers, we have - n/2 = (n-p)/2 + p = (n+p)/2 is greater than n and still less than p. - */ - function is_even_and_nonzero (n: field) -> bool { - return n / 2field < n; - } -} diff --git a/examples/vote/.env b/examples/vote/.env deleted file mode 100644 index ab204ee457..0000000000 --- a/examples/vote/.env +++ /dev/null @@ -1,3 +0,0 @@ -NETWORK=testnet -PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH -ENDPOINT=http://localhost:3030 diff --git a/examples/vote/.gitignore b/examples/vote/.gitignore deleted file mode 100644 index 750b56f237..0000000000 --- a/examples/vote/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -outputs/ -*.avm -*.prover -*.verifier \ No newline at end of file diff --git a/examples/vote/README.md b/examples/vote/README.md deleted file mode 100644 index 8dba4968b5..0000000000 --- a/examples/vote/README.md +++ /dev/null @@ -1,94 +0,0 @@ - - -[//]: # (workshop/vote) - -## Summary - -`vote.leo` is a general vote program. - -Anyone can issue new proposals, -proposers can issue tickets to the voters, -and voters can vote without exposing their identity. - -This example is inspired by the [aleo-vote](https://github.com/zkprivacy/aleo-vote) example written by the Aleo community. - -## Noteworthy Features - -Voter identity is concealed by privately passing a voter's ballot into a function. -Proposal information and voting results are revealed using the public `mapping` datatype in Leo. - -## How to Run - -To compile this Leo program, run: -```bash -leo run -``` - -Make changes to `vote/inputs/vote.in` before running each command. - -### Propose - -Anyone can issue a new proposal publicly by calling `propose` function. - -Run `propose`: - -``` -leo run propose -``` - -Output sample: - -``` - { - owner: aleo1kkk52quhnxgn2nfrcd9jqk7c9x27c23f2wvw7fyzcze56yahvcgszgttu2.private, - id: 2805252584833208809872967597325381727971256629741137995614832105537063464740field.private, - info: { - title: 2077160157502449938194577302446444field.private, - content: 1452374294790018907888397545906607852827800436field.private, - proposer: aleo1kkk52quhnxgn2nfrcd9jqk7c9x27c23f2wvw7fyzcze56yahvcgszgttu2.private - }, - _nonce: 1639660347839832220966145410710039205878572956621820215177036061076060242021group.public -} -``` - -### Create Ticket - -Proposers can create new tickets for proposed proposals. - -Ticket is a record with `owner` and `pid`, -it can be used to vote for the specific proposal - `pid`, -and can only be used(voted) by the ticket `owner`. - -Run `new_ticket`: - -``` -leo run new_ticket -``` - -Output sample: - -``` -{ - owner: aleo1kkk52quhnxgn2nfrcd9jqk7c9x27c23f2wvw7fyzcze56yahvcgszgttu2.private, - pid: 2264670486490520844857553240576860973319410481267184439818180411609250173817field.private, - _nonce: 1637267040221574073903539416642641433705357302885235345311606754421919550724group.public -} -``` - -### Vote - -A ticket owner can use their ticket record to vote `agree` / `disagree` with the specific proposal - `pid`. - -Since the ticket record can be used as an input privately, the voter's privacy is protected. - -Run `agree`: - -``` -leo run agree -``` - -Run `disagree`: - -``` -leo run disagree -``` diff --git a/examples/vote/build/main.aleo b/examples/vote/build/main.aleo deleted file mode 100644 index 4da3939022..0000000000 --- a/examples/vote/build/main.aleo +++ /dev/null @@ -1,95 +0,0 @@ -program vote.aleo; - -struct ProposalInfo: - title as field; - content as field; - proposer as address; - -record Proposal: - owner as address.private; - id as field.private; - info as ProposalInfo.private; - -record Ticket: - owner as address.private; - pid as field.private; - - -mapping proposals: - key as field.public; - value as ProposalInfo.public; - - -mapping tickets: - key as field.public; - value as u64.public; - - -mapping agree_votes: - key as field.public; - value as u64.public; - - -mapping disagree_votes: - key as field.public; - value as u64.public; - - -function propose: - input r0 as ProposalInfo.public; - assert.eq self.caller r0.proposer; - hash.bhp256 r0.title into r1 as field; - cast self.caller r1 r0 into r2 as Proposal.record; - async propose r1 into r3; - output r2 as Proposal.record; - output r3 as vote.aleo/propose.future; - -finalize propose: - input r0 as field.public; - set 0u64 into tickets[r0]; - - - - -function new_ticket: - input r0 as field.public; - input r1 as address.public; - cast r1 r0 into r2 as Ticket.record; - async new_ticket r0 into r3; - output r2 as Ticket.record; - output r3 as vote.aleo/new_ticket.future; - -finalize new_ticket: - input r0 as field.public; - get.or_use tickets[r0] 0u64 into r1; - add r1 1u64 into r2; - set r2 into tickets[r0]; - - - - -function agree: - input r0 as Ticket.record; - async agree r0.pid into r1; - output r1 as vote.aleo/agree.future; - -finalize agree: - input r0 as field.public; - get.or_use agree_votes[r0] 0u64 into r1; - add r1 1u64 into r2; - set r2 into agree_votes[r0]; - - - - -function disagree: - input r0 as Ticket.record; - async disagree r0.pid into r1; - output r1 as vote.aleo/disagree.future; - -finalize disagree: - input r0 as field.public; - get.or_use disagree_votes[r0] 0u64 into r1; - add r1 1u64 into r2; - set r2 into disagree_votes[r0]; - diff --git a/examples/vote/build/program.json b/examples/vote/build/program.json deleted file mode 100644 index 8a46439caf..0000000000 --- a/examples/vote/build/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "vote.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/vote/inputs/agree.in b/examples/vote/inputs/agree.in deleted file mode 100644 index 24364799d1..0000000000 --- a/examples/vote/inputs/agree.in +++ /dev/null @@ -1,5 +0,0 @@ -{ - owner: aleo1mgfq6g40l6zkhsm063n3uhr43qk5e0zsua5aszeq5080dsvlcvxsn0rrau.private, - pid: 2264670486490520844857553240576860973319410481267184439818180411609250173817field.private, - _nonce: 1637267040221574073903539416642641433705357302885235345311606754421919550724group.public -} diff --git a/examples/vote/inputs/disagree.in b/examples/vote/inputs/disagree.in deleted file mode 100644 index 24364799d1..0000000000 --- a/examples/vote/inputs/disagree.in +++ /dev/null @@ -1,5 +0,0 @@ -{ - owner: aleo1mgfq6g40l6zkhsm063n3uhr43qk5e0zsua5aszeq5080dsvlcvxsn0rrau.private, - pid: 2264670486490520844857553240576860973319410481267184439818180411609250173817field.private, - _nonce: 1637267040221574073903539416642641433705357302885235345311606754421919550724group.public -} diff --git a/examples/vote/inputs/new_ticket.in b/examples/vote/inputs/new_ticket.in deleted file mode 100644 index 4cbadd2fce..0000000000 --- a/examples/vote/inputs/new_ticket.in +++ /dev/null @@ -1 +0,0 @@ -2264670486490520844857553240576860973319410481267184439818180411609250173817field aleo1mgfq6g40l6zkhsm063n3uhr43qk5e0zsua5aszeq5080dsvlcvxsn0rrau diff --git a/examples/vote/inputs/propose.in b/examples/vote/inputs/propose.in deleted file mode 100644 index 73b06c1914..0000000000 --- a/examples/vote/inputs/propose.in +++ /dev/null @@ -1,5 +0,0 @@ -{ - title: 2077160157502449938194577302446444field, - content: 1452374294790018907888397545906607852827800436field, - proposer: aleo1kkk52quhnxgn2nfrcd9jqk7c9x27c23f2wvw7fyzcze56yahvcgszgttu2 -} diff --git a/examples/vote/leo.lock b/examples/vote/leo.lock deleted file mode 100644 index c4293b3b9f..0000000000 --- a/examples/vote/leo.lock +++ /dev/null @@ -1 +0,0 @@ -package = [] diff --git a/examples/vote/program.json b/examples/vote/program.json deleted file mode 100644 index 8a46439caf..0000000000 --- a/examples/vote/program.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "program": "vote.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" -} diff --git a/examples/vote/run.sh b/examples/vote/run.sh deleted file mode 100755 index 59d236dd29..0000000000 --- a/examples/vote/run.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash -# First check that Leo is installed. -if ! command -v leo &> /dev/null -then - echo "leo is not installed." - exit -fi - -echo " -############################################################################### -######## ######## -######## STEP 1: Propose a new ballot ######## -######## ######## -######## --------------------------- ######## -######## | | Yes | No | ######## -######## --------------------------- ######## -######## | Votes | | | ######## -######## --------------------------- ######## -######## ######## -############################################################################### -" -# Run the `propose` program function -leo run propose "{ - title: 2077160157502449938194577302446444field, - content: 1452374294790018907888397545906607852827800436field, - proposer: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px -}" || exit - -echo " -############################################################################### -######## ######## -######## STEP 2: Issue a new ballot ticket ######## -######## ######## -######## --------------------------- ######## -######## | | Yes | No | ######## -######## --------------------------- ######## -######## | Votes | 0 | 0 | ######## -######## --------------------------- ######## -######## ######## -############################################################################### -" -# Run the `new_ticket` program function -leo run new_ticket 2264670486490520844857553240576860973319410481267184439818180411609250173817field aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px || exit - -echo " -############################################################################### -######## ######## -######## STEP 3: Vote 'Yes' on the ballot ticket ######## -######## ######## -######## --------------------------- ######## -######## | | Yes | No | ######## -######## --------------------------- ######## -######## | Votes | 1 | 0 | ######## -######## --------------------------- ######## -######## ######## -############################################################################### -" -# Run the `agree` or `disagree` program function -leo run agree "{ - owner: aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px.private, - pid: 2264670486490520844857553240576860973319410481267184439818180411609250173817field.private, - _nonce: 1637267040221574073903539416642641433705357302885235345311606754421919550724group.public -}" || exit -#cat ./inputs/disagree.in | xargs leo run disagree || exit diff --git a/examples/vote/src/main.leo b/examples/vote/src/main.leo deleted file mode 100644 index d31f6efa77..0000000000 --- a/examples/vote/src/main.leo +++ /dev/null @@ -1,87 +0,0 @@ -// The 'vote.leo' program. -program vote.aleo { - // Proposal details - struct ProposalInfo { - title: field, - content: field, - proposer: address, - } - - // Proposal record records proposal info publicly - record Proposal { - owner: address, - id: field, - info: ProposalInfo, - } - - // Save proposal info in public storage. - mapping proposals: field => ProposalInfo; - - // Privacy tickets to vote - record Ticket { - owner: address, - pid: field, - } - - // Count the total tickets issued for each proposal - mapping tickets: field => u64; - - mapping agree_votes: field => u64; - - mapping disagree_votes: field => u64; - - // Propose a new proposal to vote on. - async transition propose(public info: ProposalInfo) -> (Proposal, Future) { - // Authenticate proposer. - assert_eq(self.caller, info.proposer); - - // Generate a new proposal id. - let id: field = BHP256::hash_to_field(info.title); - - - // Return a new record for the proposal. - // Finalize the proposal id. - return (Proposal { owner: self.caller, id, info }, finalize_propose(id)); - } - // Create a new proposal in the "tickets" mapping. - async function finalize_propose(public id: field) { - Mapping::set(tickets, id, 0u64); - } - - // Create a new ticket to vote with. - async transition new_ticket( - public pid: field, - public voter: address, - ) -> (Ticket, Future) { - - // Finalize the proposal id for the ticket. - return (Ticket { owner: voter, pid }, finalize_new_ticket(pid)); - } - // Create a new ticket on a proposal in the "tickets" mapping. - async function finalize_new_ticket(public pid: field) { - let current: u64 = Mapping::get_or_use(tickets, pid, 0u64); - Mapping::set(tickets, pid, current + 1u64); - } - - // Vote privately to agree with a proposal. - async transition agree(ticket: Ticket) -> Future { - // Finalize this vote. - return finalize_agree(ticket.pid); - } - async function finalize_agree(public pid: field) { - // Publicly increment the number of agree votes. - let current: u64 = Mapping::get_or_use(agree_votes, pid, 0u64); - Mapping::set(agree_votes, pid, current + 1u64); - } - - // Vote privately to disagree with a proposal. - async transition disagree(ticket: Ticket) -> Future { - // Finalize this vote. - return finalize_disagree(ticket.pid); - } - async function finalize_disagree(pid: field) { - // Publicly increment the number of disagree votes. - let current: u64 = Mapping::get_or_use(disagree_votes, pid, 0u64); - Mapping::set(disagree_votes, pid, current + 1u64); - } -}