[Feature] Implement leo execute (#2491)

* bump snarkvm rev

* update default gitignore

* impl leo execute

* bump snarkvm 0.14.5

* modify examples wip

* update run.sh examples

* impl env file

* clippy warning

* fix auction example

* fix auction example env

* generate new private key for new env - tests failing due to env not found err

* commit error changes

* Fix tests; clippy

* Get examples working

* leo build checks that build dir is well formed; clippy

* Clean up

* Update examples/README.md

Co-authored-by: d0cd <pranavsaig@gmail.com>
Signed-off-by: Collin Chin <16715212+collinc97@users.noreply.github.com>

* do not commit .avm files

* use snarkvm commands

---------

Signed-off-by: Collin Chin <16715212+collinc97@users.noreply.github.com>
Co-authored-by: Pranav Gaddamadugu <pranav@aleo.org>
Co-authored-by: d0cd <pranavsaig@gmail.com>
This commit is contained in:
Collin Chin 2023-07-19 18:04:09 -07:00 committed by GitHub
parent 24248c358d
commit d44457fc32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
175 changed files with 11606 additions and 816 deletions

685
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -31,10 +31,10 @@ members = [
]
[workspace.dependencies.snarkvm]
version = "0.12.6"
version = "=0.14.5"
[workspace.dependencies.snarkvm-console]
version = "0.12.3"
version = "=0.14.5"
[lib]
path = "leo/lib.rs"

View File

@ -43,7 +43,14 @@ version = "0.10"
[dev-dependencies.leo-test-framework]
path = "../../tests/test-framework"
version = "1.4.0"
version = "1.8.3"
[dev-dependencies.leo-package]
path = "../../leo/package"
version = "1.8.3"
[dev-dependencies.dotenvy]
version = "0.15.7"
[dev-dependencies.rand]
version = "0.8"

View File

@ -101,6 +101,7 @@ fn run_test(test: Test, handler: &Handler, buf: &BufferEmitter) -> Result<Value,
let bytecode = handler.extend_if_error(compile_and_process(&mut parsed))?;
// Set up the build directory.
// Note that this function checks that the bytecode is well-formed.
let package = setup_build_directory(&program_name, &bytecode, handler)?;
// Get the program process and check all instructions.

View File

@ -18,6 +18,7 @@ mod utilities;
use utilities::{
buffer_if_err,
compile_and_process,
dotenv_private_key,
get_build_options,
get_cwd_option,
hash_asts,
@ -152,8 +153,7 @@ fn run_test(test: Test, handler: &Handler, err_buf: &BufferEmitter) -> Result<Va
// TODO: Add support for custom config like custom private keys.
// Execute the program and get the outputs.
let output_string = match package.run::<Aleo, _>(
None,
package.manifest_file().development_private_key(),
&dotenv_private_key(package.directory()).unwrap(),
function_name,
&inputs,
rng,

View File

@ -20,13 +20,13 @@ use leo_errors::{
LeoError,
LeoWarning,
};
use leo_package::root::env::Env;
use leo_passes::{CodeGenerator, Pass};
use leo_span::source_map::FileName;
use leo_test_framework::Test;
use leo_test_framework::{test::TestConfig, Test};
use snarkvm::prelude::*;
use leo_test_framework::test::TestConfig;
use snarkvm::{file::Manifest, package::Package};
use std::{
cell::RefCell,
@ -109,12 +109,18 @@ pub fn setup_build_directory(program_name: &str, bytecode: &String, handler: &Ha
// Create the manifest file.
let _manifest_file = Manifest::create(&directory, &program_id).unwrap();
// Create the environment file.
Env::<Network>::new().write_to(&directory).unwrap();
if Env::<Network>::exists_at(&directory) {
println!(".env file created at {:?}", &directory);
}
// Create the build directory.
let build_directory = directory.join("build");
fs::create_dir_all(build_directory).unwrap();
// Open the package at the temporary directory.
handler.extend_if_error(Package::<Testnet3>::open(&directory).map_err(LeoError::Anyhow))
handler.extend_if_error(Package::<Network>::open(&directory).map_err(LeoError::Anyhow))
}
pub fn new_compiler(
@ -222,3 +228,14 @@ pub fn compile_and_process<'a>(parsed: &'a mut Compiler<'a>) -> Result<String, L
Ok(bytecode)
}
/// Returns the private key from the .env file specified in the directory.
#[allow(unused)]
pub fn dotenv_private_key(directory: &Path) -> Result<PrivateKey<Network>> {
use std::str::FromStr;
dotenvy::from_path(directory.join(".env")).map_err(|_| anyhow!("Missing a '.env' file in the test directory."))?;
// Load the private key from the environment.
let private_key = dotenvy::var("PRIVATE_KEY").map_err(|e| anyhow!("Missing PRIVATE_KEY - {e}"))?;
// Parse the private key.
PrivateKey::<Network>::from_str(&private_key)
}

View File

@ -458,7 +458,7 @@ impl<'a> CodeGenerator<'a> {
Expression::Identifier(identifier) => identifier.name,
_ => unreachable!("Parsing guarantees that all `input.function` is always an identifier."),
};
let return_type = &self.symbol_table.borrow().functions.get(&function_name).unwrap().output_type;
let return_type = &self.symbol_table.borrow().lookup_fn_symbol(function_name).unwrap().output_type;
match return_type {
Type::Unit => {
call_instruction.push(';');

View File

@ -169,7 +169,7 @@ impl StatementReconstructor for Flattener<'_> {
_ => unreachable!("Parsing guarantees that `function` is an identifier."),
};
let function = self.symbol_table.borrow().functions.get(&function_name).unwrap();
let function = self.symbol_table.borrow().lookup_fn_symbol(function_name).unwrap();
match &function.output_type {
// If the function returns a tuple, reconstruct the assignment and add an entry to `self.tuples`.
Type::Tuple(tuple) => {
@ -246,7 +246,7 @@ impl StatementReconstructor for Flattener<'_> {
Expression::Identifier(identifier) => {
// Retrieve the entry in the symbol table for the mapping.
// Note that this unwrap is safe since type checking ensures that the mapping exists.
let variable = self.symbol_table.borrow().variables.get(&identifier.name).unwrap();
let variable = self.symbol_table.borrow().lookup_variable(identifier.name).unwrap();
match &variable.type_ {
Type::Mapping(mapping_type) => &*mapping_type.value,
_ => unreachable!("Type checking guarantee that `arguments[0]` is a mapping."),
@ -281,7 +281,7 @@ impl StatementReconstructor for Flattener<'_> {
_ => unreachable!("Parsing guarantees that `function` is an identifier."),
};
let function = self.symbol_table.borrow().functions.get(&function_name).unwrap();
let function = self.symbol_table.borrow().lookup_fn_symbol(function_name).unwrap();
let output_type = match &function.output_type {
Type::Tuple(tuple) => tuple.clone(),

View File

@ -201,7 +201,7 @@ impl ExpressionConsumer for StaticSingleAssigner<'_> {
// Lookup the struct definition.
// Note that type checking guarantees that the correct struct definition exists.
let struct_definition: &Struct = self.symbol_table.borrow().structs.get(&input.name.name).unwrap();
let struct_definition: &Struct = self.symbol_table.borrow().lookup_struct(input.name.name).unwrap();
// Initialize the list of reordered members.
let mut reordered_members = Vec::with_capacity(members.len());

View File

@ -89,65 +89,79 @@ create_messages!(
}
@backtraced
failed_to_execute_aleo_build {
failed_to_execute_build {
args: (error: impl Display),
msg: format!("Failed to execute the `aleo build` command.\nSnarkVM Error: {error}"),
msg: format!("Failed to execute the `build` command.\nSnarkVM Error: {error}"),
help: None,
}
@backtraced
failed_to_execute_aleo_new {
failed_to_execute_new {
args: (error: impl Display),
msg: format!("Failed to execute the `aleo new` command.\nSnarkVM Error: {error}"),
msg: format!("Failed to execute the `new` command.\nSnarkVM Error: {error}"),
help: None,
}
@backtraced
failed_to_execute_aleo_run {
failed_to_execute_run {
args: (error: impl Display),
msg: format!("Failed to execute the `aleo run` command.\nSnarkVM Error: {error}"),
msg: format!("Failed to execute the `run` command.\nSnarkVM Error: {error}"),
help: None,
}
@backtraced
failed_to_execute_aleo_node {
failed_to_execute_node {
args: (error: impl Display),
msg: format!("Failed to execute the `aleo node` command.\nSnarkVM Error: {error}"),
msg: format!("Failed to execute the `node` command.\nSnarkVM Error: {error}"),
help: None,
}
@backtraced
failed_to_execute_aleo_deploy {
failed_to_execute_deploy {
args: (error: impl Display),
msg: format!("Failed to execute the `aleo deploy` command.\nSnarkVM Error: {error}"),
msg: format!("Failed to execute the `deploy` command.\nSnarkVM Error: {error}"),
help: None,
}
@backtraced
failed_to_parse_aleo_new {
failed_to_parse_new {
args: (error: impl Display),
msg: format!("Failed to parse the `aleo new` command.\nSnarkVM Error: {error}"),
msg: format!("Failed to parse the `new` command.\nSnarkVM Error: {error}"),
help: None,
}
@backtraced
failed_to_parse_aleo_run {
failed_to_parse_run {
args: (error: impl Display),
msg: format!("Failed to parse the `aleo run` command.\nSnarkVM Error: {error}"),
msg: format!("Failed to parse the `run` command.\nSnarkVM Error: {error}"),
help: None,
}
@backtraced
failed_to_parse_aleo_node {
failed_to_parse_node {
args: (error: impl Display),
msg: format!("Failed to parse the `aleo node` command.\nSnarkVM Error: {error}"),
msg: format!("Failed to parse the `node` command.\nSnarkVM Error: {error}"),
help: None,
}
@backtraced
failed_to_parse_aleo_deploy {
failed_to_parse_deploy {
args: (error: impl Display),
msg: format!("Failed to parse the `aleo deploy` command.\nSnarkVM Error: {error}"),
msg: format!("Failed to parse the `deploy` command.\nSnarkVM Error: {error}"),
help: None,
}
@backtraced
failed_to_parse_execute {
args: (error: impl Display),
msg: format!("Failed to parse the `execute` command.\nSnarkVM Error: {error}"),
help: None,
}
@backtraced
failed_to_execute_execute {
args: (error: impl Display),
msg: format!("Failed to execute the `execute` command.\nSnarkVM Error: {error}"),
help: None,
}
);

View File

@ -305,4 +305,12 @@ create_messages!(
msg: "The `src/` directory can contain only one file and must be named `main.leo`.".to_string(),
help: None,
}
/// For when the environment file has an IO error.
@backtraced
io_error_env_file {
args: (error: impl ErrorArg),
msg: format!("IO error env file from the provided file path - {error}"),
help: None,
}
);

View File

@ -10,16 +10,17 @@ This directory includes the following Leo code examples:
6. Message -> Initialization of a struct
7. Token -> Record example
## Build Guide
To compile each example, run:
```bash
leo build
```
When you run this command for the first time the snarkvm parameters (universal setup) will be downloaded, these are necessary to run the programs.
## Run Guide
To run each program, run:
```bash
leo run main
```
This command will look in the input file inputs/*.in where should find a section [main] and use the variables as inputs to the program.
This command will look in the input file inputs/*.in where should find a section [main] and use the variables as inputs to the program.
## Execute Guide
To execute each program call, run:
```bash
leo execute main <inputs> --endpoint <endpoint>
```

4
examples/auction/.env Normal file
View File

@ -0,0 +1,4 @@
NETWORK=testnet3
PRIVATE_KEY=APrivateKey1zkp5wvamYgK3WCAdpBQxZqQX8XnuN2u11Y6QprZTriVwZVc

View File

@ -1,2 +1,4 @@
outputs/
build/
*.avm
*.prover
*.verifier

View File

@ -38,17 +38,14 @@ Leo provides users with a command line interface for compiling and running Leo p
Users may either specify input values via the command line or provide an input file in `inputs/`.
### Configuring Accounts
The `program.json` file contains a private key and address.
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` and `address` fields in `program.json` to the appropriate values.
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/AleoHQ/leo/tree/testnet3) provides a command line interface for generating new accounts.
To generate a new account, run
```
leo account new
```
The [Aleo SDK](https://github.com/AleoHQ/leo/tree/testnet3) provides an interface for generating new accounts.
To generate a new account, navigate to [aleo.tools](https://aleo.tools).
### Providing inputs via the command line.

View File

@ -0,0 +1,35 @@
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 aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh 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 aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh;
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 aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh;
cast r0.bidder r0.bidder r0.amount true into r1 as Bid.record;
output r1 as Bid.record;

View File

@ -0,0 +1,6 @@
{
"program": "auction.aleo",
"version": "0.0.0",
"description": "",
"license": "MIT"
}

View File

@ -19,7 +19,7 @@ second: Bid = Bid {
bidder: aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh,
amount: 90u64,
is_winner: false,
_nonce: 1635474322959998727812727786860193861506102794050195384593971440884677453921group,
_nonce: 1511010328912449299156978046557700301564153667442988008615502964863620401388group,
};
[finish]

View File

@ -2,9 +2,5 @@
"program": "auction.aleo",
"version": "0.0.0",
"description": "",
"development": {
"private_key": "APrivateKey1zkp5wvamYgK3WCAdpBQxZqQX8XnuN2u11Y6QprZTriVwZVc",
"address": "aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh"
},
"license": "MIT"
}

View File

@ -27,17 +27,11 @@ echo "
######## ########
###############################################################################
"
# Swap in the private key and address of the first bidder to program.json.
echo "{
\"program\": \"auction.aleo\",
\"version\": \"0.0.0\",
\"description\": \"\",
\"development\": {
\"private_key\": \"APrivateKey1zkpG9Af9z5Ha4ejVyMCqVFXRKknSm8L1ELEwcc4htk9YhVK\",
\"address\": \"aleo1yzlta2q5h8t0fqe0v6dyh9mtv4aggd53fgzr068jvplqhvqsnvzq7pj2ke\"
},
\"license\": \"MIT\"
}" > program.json
# Swap in the private key and address of the first bidder to .env.
echo "
NETWORK=testnet3
PRIVATE_KEY=APrivateKey1zkpG9Af9z5Ha4ejVyMCqVFXRKknSm8L1ELEwcc4htk9YhVK
" > .env
# Have the first bidder place a bid of 10.
echo "
@ -55,18 +49,11 @@ echo "
"
leo run place_bid aleo1yzlta2q5h8t0fqe0v6dyh9mtv4aggd53fgzr068jvplqhvqsnvzq7pj2ke 10u64 || exit
# Swap in the private key and address of the second bidder to program.json.
echo "{
\"program\": \"auction.aleo\",
\"version\": \"0.0.0\",
\"description\": \"\",
\"development\": {
\"private_key\": \"APrivateKey1zkpAFshdsj2EqQzXh5zHceDapFWVCwR6wMCJFfkLYRKupug\",
\"address\": \"aleo1esqchvevwn7n5p84e735w4dtwt2hdtu4dpguwgwy94tsxm2p7qpqmlrta4\"
},
\"license\": \"MIT\"
}" > program.json
# Swap in the private key and address of the second bidder to .env.
echo "
NETWORK=testnet3
PRIVATE_KEY=APrivateKey1zkpAFshdsj2EqQzXh5zHceDapFWVCwR6wMCJFfkLYRKupug
" > .env
# Have the second bidder place a bid of 90.
echo "
@ -84,17 +71,11 @@ echo "
"
leo run place_bid aleo1esqchvevwn7n5p84e735w4dtwt2hdtu4dpguwgwy94tsxm2p7qpqmlrta4 90u64 || exit
# Swap in the private key and address of the auctioneer to program.json.
echo "{
\"program\": \"auction.aleo\",
\"version\": \"0.0.0\",
\"description\": \"\",
\"development\": {
\"private_key\": \"APrivateKey1zkp5wvamYgK3WCAdpBQxZqQX8XnuN2u11Y6QprZTriVwZVc\",
\"address\": \"aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh\"
},
\"license\": \"MIT\"
}" > program.json
# Swap in the private key and address of the auctioneer to .env.
echo "
NETWORK=testnet3
PRIVATE_KEY=APrivateKey1zkp5wvamYgK3WCAdpBQxZqQX8XnuN2u11Y6QprZTriVwZVc
" > .env
# Have the auctioneer select the winning bid.
echo "

4
examples/basic_bank/.env Normal file
View File

@ -0,0 +1,4 @@
NETWORK=testnet3
PRIVATE_KEY=APrivateKey1zkpHtqVWT6fSHgUMNxsuVf7eaR6id2cj7TieKY1Z8CP5rCD

View File

@ -1,2 +1,4 @@
outputs/
build/
*.avm
*.prover
*.verifier

View File

@ -39,20 +39,14 @@ Leo provides users with a command line interface for compiling and running Leo p
Users may either specify input values via the command line or provide an input file in `inputs/`.
### Configuring Accounts
The `program.json` file contains a private key and address.
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` and `address` fields in `program.json` to the appropriate values.
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/AleoHQ/leo/tree/testnet3) provides a command line interface for generating new accounts.
To generate a new account, run
```
leo account new
```
The [Aleo SDK](https://github.com/AleoHQ/leo/tree/testnet3) provides an interface for generating new accounts.
To generate a new account, navigate to [aleo.tools](https://aleo.tools).
### Providing inputs via the command line.
1. Run

View File

@ -0,0 +1,561 @@
program basic_bank.aleo;
record Token:
owner as address.private;
amount as u64.private;
mapping balances:
key left as field.public;
value right as u64.public;
function issue:
input r0 as address.private;
input r1 as u64.private;
assert.eq self.caller aleo1t0uer3jgtsgmx5tq6x6f9ecu8tr57rzzfnc2dgmcqldceal0ls9qf6st7a;
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; output r3 as Token.record;
finalize r4 r1;
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 aleo1t0uer3jgtsgmx5tq6x6f9ecu8tr57rzzfnc2dgmcqldceal0ls9qf6st7a;
hash.bhp256 r0 into r4 as field; call calculate_interest r1 r2 r3 into r5;
cast r0 r5 into r6 as Token.record;
output r6 as Token.record;
finalize r4 r1;
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];

View File

@ -0,0 +1,6 @@
{
"program": "basic_bank.aleo",
"version": "0.0.0",
"description": "",
"license": "MIT"
}

View File

@ -2,9 +2,5 @@
"program": "basic_bank.aleo",
"version": "0.0.0",
"description": "",
"development": {
"private_key": "APrivateKey1zkpHtqVWT6fSHgUMNxsuVf7eaR6id2cj7TieKY1Z8CP5rCD",
"address": "aleo1t0uer3jgtsgmx5tq6x6f9ecu8tr57rzzfnc2dgmcqldceal0ls9qf6st7a"
},
"license": "MIT"
}

View File

@ -8,17 +8,11 @@
# "private_key": "APrivateKey1zkp75cpr5NNQpVWc5mfsD9Uf2wg6XvHknf82iwB636q3rtc"
# "address": "aleo1zeklp6dd8e764spe74xez6f8w27dlua3w7hl4z2uln03re52egpsv46ngg"
# Swap in the private key and address of the bank to program.json.
echo "{
\"program\": \"basic_bank.aleo\",
\"version\": \"0.0.0\",
\"description\": \"\",
\"development\": {
\"private_key\": \"APrivateKey1zkpHtqVWT6fSHgUMNxsuVf7eaR6id2cj7TieKY1Z8CP5rCD\",
\"address\": \"aleo1t0uer3jgtsgmx5tq6x6f9ecu8tr57rzzfnc2dgmcqldceal0ls9qf6st7a\"
},
\"license\": \"MIT\"
}" > program.json
# Swap in the private key and address of the bank to .env.
echo "
NETWORK=testnet3
PRIVATE_KEY=APrivateKey1zkpHtqVWT6fSHgUMNxsuVf7eaR6id2cj7TieKY1Z8CP5rCD
" > .env
# Have the bank issue 100 tokens to the user.
echo "
@ -63,17 +57,11 @@ echo "
"
leo run issue aleo1zeklp6dd8e764spe74xez6f8w27dlua3w7hl4z2uln03re52egpsv46ngg 100u64 || exit
# Swap in the private key and address of the user to program.json.
echo "{
\"program\": \"basic_bank.aleo\",
\"version\": \"0.0.0\",
\"description\": \"\",
\"development\": {
\"private_key\": \"APrivateKey1zkp75cpr5NNQpVWc5mfsD9Uf2wg6XvHknf82iwB636q3rtc\",
\"address\": \"aleo1zeklp6dd8e764spe74xez6f8w27dlua3w7hl4z2uln03re52egpsv46ngg\"
},
\"license\": \"MIT\"
}" > program.json
# Swap in the private key and address of the user to .env.
echo "
NETWORK=testnet3
PRIVATE_KEY=APrivateKey1zkp75cpr5NNQpVWc5mfsD9Uf2wg6XvHknf82iwB636q3rtc
" > .env
# Have the user deposit 50 tokens into the bank.
echo "
@ -163,17 +151,11 @@ echo "
###############################################################################
"
# Swap in the private key and address of the bank to program.json.
echo "{
\"program\": \"basic_bank.aleo\",
\"version\": \"0.0.0\",
\"description\": \"\",
\"development\": {
\"private_key\": \"APrivateKey1zkpHtqVWT6fSHgUMNxsuVf7eaR6id2cj7TieKY1Z8CP5rCD\",
\"address\": \"aleo1t0uer3jgtsgmx5tq6x6f9ecu8tr57rzzfnc2dgmcqldceal0ls9qf6st7a\"
},
\"license\": \"MIT\"
}" > program.json
# Swap in the private key and address of the bank to .env.
echo "
NETWORK=testnet3
PRIVATE_KEY=APrivateKey1zkpHtqVWT6fSHgUMNxsuVf7eaR6id2cj7TieKY1Z8CP5rCD
" > .env
# Have the bank withdraw all of the user's tokens with compound interest over 15 periods at 12.34%.
echo "

4
examples/battleship/.env Normal file
View File

@ -0,0 +1,4 @@
NETWORK=testnet3
PRIVATE_KEY=APrivateKey1zkp86FNGdKxjgAdgQZ967bqBanjuHkAaoRe19RK24ZCGsHH

View File

@ -1,2 +1,4 @@
outputs/
build/
*.avm
*.prover
*.verifier

View File

@ -34,7 +34,7 @@ This application was translated into Leo from the [zk-battleship](https://github
To compile this Leo program, run:
```bash
leo build
leo run <function_name> <function_inputs>
```
## How to Run

View File

@ -0,0 +1,46 @@
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;

View File

@ -0,0 +1,24 @@
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;

View File

@ -0,0 +1,73 @@
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;

View File

@ -0,0 +1,59 @@
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;

View File

@ -0,0 +1,6 @@
{
"program": "battleship.aleo",
"version": "0.0.0",
"description": "",
"license": "MIT"
}

View File

@ -2,10 +2,5 @@
"program": "battleship.aleo",
"version": "0.0.0",
"description": "",
"development": {
"private_key": "APrivateKey1zkpGKaJY47BXb6knSqmT3JZnBUEGBDFAWz2nMVSsjwYpJmm",
"view_key": "AViewKey1fSyEPXxfPFVgjL6qcM9izWRGrhSHKXyN3c64BNsAjnA6",
"address": "aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy"
},
"license": "MIT"
}

View File

@ -8,17 +8,11 @@ echo "
######## ########
###############################################################################
"
echo "{
\"program\": \"battleship.aleo\",
\"version\": \"0.0.0\",
\"description\": \"\",
\"development\": {
\"private_key\": \"APrivateKey1zkpGKaJY47BXb6knSqmT3JZnBUEGBDFAWz2nMVSsjwYpJmm\",
\"view_key\": \"AViewKey1fSyEPXxfPFVgjL6qcM9izWRGrhSHKXyN3c64BNsAjnA6\",
\"address\": \"aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy\"
},
\"license\": \"MIT\"
}" > program.json
echo "
NETWORK=testnet3
PRIVATE_KEY=APrivateKey1zkpGKaJY47BXb6knSqmT3JZnBUEGBDFAWz2nMVSsjwYpJmm
" > .env
echo "✅ Successfully initialized Player 1."
@ -65,17 +59,10 @@ echo "
###############################################################################
"
(
echo "{
\"program\": \"battleship.aleo\",
\"version\": \"0.0.0\",
\"description\": \"\",
\"development\": {
\"private_key\": \"APrivateKey1zkp86FNGdKxjgAdgQZ967bqBanjuHkAaoRe19RK24ZCGsHH\",
\"view_key\": \"AViewKey1hh6dvSEgeMdfseP4hfdbNYjX4grETwCuTbKnCftkpMwE\",
\"address\": \"aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry\"
},
\"license\": \"MIT\"
}" > program.json
echo "
NETWORK=testnet3
PRIVATE_KEY=APrivateKey1zkp86FNGdKxjgAdgQZ967bqBanjuHkAaoRe19RK24ZCGsHH
" > .env
leo run initialize_board 31u64 2207646875648u64 224u64 9042383626829824u64 aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy || exit
)
@ -120,17 +107,10 @@ echo "
###############################################################################
"
(
echo "{
\"program\": \"battleship.aleo\",
\"version\": \"0.0.0\",
\"description\": \"\",
\"development\": {
\"private_key\": \"APrivateKey1zkpGKaJY47BXb6knSqmT3JZnBUEGBDFAWz2nMVSsjwYpJmm\",
\"view_key\": \"AViewKey1fSyEPXxfPFVgjL6qcM9izWRGrhSHKXyN3c64BNsAjnA6\",
\"address\": \"aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy\"
},
\"license\": \"MIT\"
}" > program.json
echo "
NETWORK=testnet3
PRIVATE_KEY=APrivateKey1zkpGKaJY47BXb6knSqmT3JZnBUEGBDFAWz2nMVSsjwYpJmm
" > .env
leo run play '{
owner: aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy.private,
@ -162,17 +142,11 @@ echo "
###############################################################################
"
(
echo "{
\"program\": \"battleship.aleo\",
\"version\": \"0.0.0\",
\"description\": \"\",
\"development\": {
\"private_key\": \"APrivateKey1zkp86FNGdKxjgAdgQZ967bqBanjuHkAaoRe19RK24ZCGsHH\",
\"view_key\": \"AViewKey1hh6dvSEgeMdfseP4hfdbNYjX4grETwCuTbKnCftkpMwE\",
\"address\": \"aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry\"
},
\"license\": \"MIT\"
}" > program.json
echo "
NETWORK=testnet3
PRIVATE_KEY=APrivateKey1zkp86FNGdKxjgAdgQZ967bqBanjuHkAaoRe19RK24ZCGsHH
" > .env
leo run play '{
owner: aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry.private,
@ -204,17 +178,10 @@ echo "
###############################################################################
"
(
echo "{
\"program\": \"battleship.aleo\",
\"version\": \"0.0.0\",
\"description\": \"\",
\"development\": {
\"private_key\": \"APrivateKey1zkpGKaJY47BXb6knSqmT3JZnBUEGBDFAWz2nMVSsjwYpJmm\",
\"view_key\": \"AViewKey1fSyEPXxfPFVgjL6qcM9izWRGrhSHKXyN3c64BNsAjnA6\",
\"address\": \"aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy\"
},
\"license\": \"MIT\"
}" > program.json
echo "
NETWORK=testnet3
PRIVATE_KEY=APrivateKey1zkpGKaJY47BXb6knSqmT3JZnBUEGBDFAWz2nMVSsjwYpJmm
" > .env
leo run play '{
owner: aleo15g9c69urtdhvfml0vjl8px07txmxsy454urhgzk57szmcuttpqgq5cvcdy.private,
@ -246,17 +213,11 @@ echo "
###############################################################################
"
(
echo "{
\"program\": \"battleship.aleo\",
\"version\": \"0.0.0\",
\"description\": \"\",
\"development\": {
\"private_key\": \"APrivateKey1zkp86FNGdKxjgAdgQZ967bqBanjuHkAaoRe19RK24ZCGsHH\",
\"view_key\": \"AViewKey1hh6dvSEgeMdfseP4hfdbNYjX4grETwCuTbKnCftkpMwE\",
\"address\": \"aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry\"
},
\"license\": \"MIT\"
}" > program.json
echo "
NETWORK=testnet3
PRIVATE_KEY=APrivateKey1zkp86FNGdKxjgAdgQZ967bqBanjuHkAaoRe19RK24ZCGsHH
" > .env
leo run play '{
owner: aleo1wyvu96dvv0auq9e4qme54kjuhzglyfcf576h0g3nrrmrmr0505pqd6wnry.private,

2
examples/bubblesort/.env Normal file
View File

@ -0,0 +1,2 @@
NETWORK=testnet3
PRIVATE_KEY=APrivateKey1zkpBvXdKZKaXXcLUnwAVFCQNp41jrX6JqTuJo1JShfPoRfx

View File

@ -1,2 +1,3 @@
outputs/
build/
*.prover
*.verifier

View File

@ -1,17 +1,19 @@
# bubblesort
## Build Guide
To compile this program, run:
```bash
leo build
```
## 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.

Binary file not shown.

View File

@ -0,0 +1,105 @@
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;

View File

@ -0,0 +1,6 @@
{
"program": "bubblesort.aleo",
"version": "0.0.0",
"description": "",
"license": "MIT"
}

View File

@ -2,9 +2,5 @@
"program": "bubblesort.aleo",
"version": "0.0.0",
"description": "",
"development": {
"private_key": "APrivateKey1zkpBqRv2cwkSiR4hQ3Tb4AZFD3XzdwPqV9QsEykTKBV1YKT",
"address": "aleo1ht2a9q0gsd38j0se4t9lsfulxgqrens2vgzgry3pkvs93xrrzu8s892zn7"
},
"license": "MIT"
}

2
examples/core/.env Normal file
View File

@ -0,0 +1,2 @@
NETWORK=testnet3
PRIVATE_KEY=APrivateKey1zkpBvXdKZKaXXcLUnwAVFCQNp41jrX6JqTuJo1JShfPoRfx

View File

@ -1,2 +1,4 @@
outputs/
build/
*.avm
*.prover
*.verifier

View File

@ -1,13 +1,15 @@
# Leo core functions
## Build Guide
To compile this program, run:
```bash
leo build
```
## Run Guide
To run this program, run:
```bash
leo run
leo run bubble_sort
```
## Execute Guide
To execute this program, run:
```bash
leo execute bubble_sort
```

View File

@ -0,0 +1,7 @@
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;

View File

@ -0,0 +1,6 @@
{
"program": "core.aleo",
"version": "0.0.0",
"description": "",
"license": "MIT"
}

View File

@ -2,9 +2,5 @@
"program": "core.aleo",
"version": "0.0.0",
"description": "",
"development": {
"private_key": "APrivateKey1zkp71KCjd8jC21RJudasMhxsw7YwPbSdtpK7P6z1yWQPCLo",
"address": "aleo1pjmrd6jf4z7vhwmse3jpsk62a0223fceg54aa89p6dru9l0z4ugqe4w7xf"
},
"license": "MIT"
}

2
examples/fibonacci/.env Normal file
View File

@ -0,0 +1,2 @@
NETWORK=testnet3
PRIVATE_KEY=APrivateKey1zkpBvXdKZKaXXcLUnwAVFCQNp41jrX6JqTuJo1JShfPoRfx

4
examples/fibonacci/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
outputs/
*.avm
*.prover
*.verifier

View File

@ -1,12 +1,19 @@
# fibonacci.aleo
## Build Guide
## 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).

View File

@ -2,9 +2,5 @@
"program": "fibonacci.aleo",
"version": "0.0.0",
"description": "",
"development": {
"private_key": "APrivateKey1zkpFebmqLzRHMbtdwensSVNUPDWV6WnYw5JcNsYVLDuu8ig",
"address": "aleo1l0l25evjzxac3j4r5xf7uwv3jfnqwll2g9h8j0g5vvk0grnnmq8qexra3d"
},
"license": "MIT"
}

2
examples/groups/.env Normal file
View File

@ -0,0 +1,2 @@
NETWORK=testnet3
PRIVATE_KEY=APrivateKey1zkpBvXdKZKaXXcLUnwAVFCQNp41jrX6JqTuJo1JShfPoRfx

View File

@ -1,2 +1,4 @@
outputs/
build/
*.avm
*.prover
*.verifier

View File

@ -1,15 +1,17 @@
# Leo group operations.
## Build Guide
To compile this program, run:
```bash
leo build
```
## Run Guide
To run this program, run:
```bash
leo run main
leo run fibonacci
```
## Execute Guide
To execute this program, run:
```bash
leo execute fibonacci
```
## Overview
@ -28,11 +30,9 @@ Group elements are special since their values can be defined as coordinate pairs
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 b = 0group; // the zero of the group
let a = 0group; // the zero of the group
let a = 1group; // the group generator
let b = group::GEN; // the group generator
let c = 2group; // 2 * the group generator
let d = (0, 1)group; // coordinate notation
let c = (0, 1)group; // coordinate notation
```

View File

@ -0,0 +1,12 @@
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;

View File

@ -0,0 +1,6 @@
{
"program": "groups.aleo",
"version": "0.0.0",
"description": "",
"license": "MIT"
}

View File

@ -2,9 +2,5 @@
"program": "groups.aleo",
"version": "0.0.0",
"description": "",
"development": {
"private_key": "APrivateKey1zkpDfsRvWYGWihXv84dueeABvBUZMqBQbpW6k9AC4zeLpZ8",
"address": "aleo1cnzvtgdlyl3mrdm8cp80rl705ryjm65zs2gcny720d9dn3n2dvpsrfj4f0"
},
"license": "MIT"
}

View File

@ -0,0 +1,2 @@
NETWORK=testnet3
PRIVATE_KEY=APrivateKey1zkpBvXdKZKaXXcLUnwAVFCQNp41jrX6JqTuJo1JShfPoRfx

View File

@ -1,2 +1,4 @@
outputs/
build/
*.avm
*.prover
*.verifier

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,6 @@
{
"program": "ntzdebruijn.aleo",
"version": "0.0.0",
"description": "",
"license": "MIT"
}

View File

@ -2,9 +2,5 @@
"program": "ntzdebruijn.aleo",
"version": "0.0.0",
"description": "",
"development": {
"private_key": "APrivateKey1zkpBAYqv1Em7zjLNyQkGxfRQUtT4JNScLAznYfEDJeNJ8HJ",
"address": "aleo1a6gctkkkwu9fjlzvcfp6970rz2tskp8638x99stjqm3cs4889ufqtc3xg5"
},
"license": "MIT"
}

View File

@ -0,0 +1,2 @@
NETWORK=testnet3
PRIVATE_KEY=APrivateKey1zkpBvXdKZKaXXcLUnwAVFCQNp41jrX6JqTuJo1JShfPoRfx

View File

@ -1,2 +1,4 @@
outputs/
build/
*.avm
*.prover
*.verifier

View File

@ -0,0 +1,31 @@
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;

View File

@ -0,0 +1,6 @@
{
"program": "ntzgaudet.aleo",
"version": "0.0.0",
"description": "",
"license": "MIT"
}

View File

@ -2,9 +2,5 @@
"program": "ntzgaudet.aleo",
"version": "0.0.0",
"description": "",
"development": {
"private_key": "APrivateKey1zkpE119vf79xTdab9GcybudCNwf86oiwZjSiLe1BWYdFNJq",
"address": "aleo1cukvzl26vv9ulwc26ugud3pgnxfhzzzhqaqeqdphhk3vnntvlqyq2uzg53"
},
"license": "MIT"
}

View File

@ -0,0 +1,2 @@
NETWORK=testnet3
PRIVATE_KEY=APrivateKey1zkpBvXdKZKaXXcLUnwAVFCQNp41jrX6JqTuJo1JShfPoRfx

View File

@ -1,2 +1,4 @@
outputs/
build/
*.avm
*.prover
*.verifier

View File

@ -0,0 +1,170 @@
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;

View File

@ -0,0 +1,6 @@
{
"program": "ntzloops.aleo",
"version": "0.0.0",
"description": "",
"license": "MIT"
}

View File

@ -2,9 +2,5 @@
"program": "ntzloops.aleo",
"version": "0.0.0",
"description": "",
"development": {
"private_key": "APrivateKey1zkp3T8ynGSS35DrhWE4nBuBTkuUtd3wkpiyiyJ7452MvYmB",
"address": "aleo14lva4hqc4tpw4elhxndthkwnjuak22kn9gukqmzy6x9xdrjcu5yqvqwak5"
},
"license": "MIT"
}

View File

@ -0,0 +1,2 @@
NETWORK=testnet3
PRIVATE_KEY=APrivateKey1zkpBvXdKZKaXXcLUnwAVFCQNp41jrX6JqTuJo1JShfPoRfx

View File

@ -1,2 +1,4 @@
outputs/
build/
*.avm
*.prover
*.verifier

View File

@ -0,0 +1,37 @@
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;

View File

@ -0,0 +1,6 @@
{
"program": "ntzmasks.aleo",
"version": "0.0.0",
"description": "",
"license": "MIT"
}

View File

@ -2,9 +2,5 @@
"program": "ntzmasks.aleo",
"version": "0.0.0",
"description": "",
"development": {
"private_key": "APrivateKey1zkpJXjqFZijBq4tUsdtrqi5tQeUSfoXbw6JddCYE4mKnCsz",
"address": "aleo1qx4g8w2ju9mpr4hpvavh0gah556q7sxw6xltf98w9e9gjq5f6yysrya2xx"
},
"license": "MIT"
}

View File

@ -0,0 +1,2 @@
NETWORK=testnet3
PRIVATE_KEY=APrivateKey1zkpBvXdKZKaXXcLUnwAVFCQNp41jrX6JqTuJo1JShfPoRfx

View File

@ -1,2 +1,4 @@
outputs/
build/
*.avm
*.prover
*.verifier

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,6 @@
{
"program": "ntzreisers.aleo",
"version": "0.0.0",
"description": "",
"license": "MIT"
}

View File

@ -2,9 +2,5 @@
"program": "ntzreisers.aleo",
"version": "0.0.0",
"description": "",
"development": {
"private_key": "APrivateKey1zkp8vHN4i62UxNKK9pqPZNYpWwUXdXayAzoLfFJQrQtEBFM",
"address": "aleo1wkd43twmdc95qag68rt6wyuhdvws9ux2rzjszm3eazz7wkhp75zsjazdcs"
},
"license": "MIT"
}

View File

@ -0,0 +1,2 @@
NETWORK=testnet3
PRIVATE_KEY=APrivateKey1zkpBvXdKZKaXXcLUnwAVFCQNp41jrX6JqTuJo1JShfPoRfx

View File

@ -1,2 +1,4 @@
outputs/
build/
*.avm
*.prover
*.verifier

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,6 @@
{
"program": "ntzseals.aleo",
"version": "0.0.0",
"description": "",
"license": "MIT"
}

View File

@ -2,9 +2,5 @@
"program": "ntzseals.aleo",
"version": "0.0.0",
"description": "",
"development": {
"private_key": "APrivateKey1zkpG6G5iLouRcupzPXVKpapbwq4AVEmU4tTSQGCe1JGE75h",
"address": "aleo1uds398s2cuju0uc9x6ggcvvrhdlmu682gjj4zdhgflwu0z3htcrsf40cfa"
},
"license": "MIT"
}

View File

@ -0,0 +1,2 @@
NETWORK=testnet3
PRIVATE_KEY=APrivateKey1zkpBvXdKZKaXXcLUnwAVFCQNp41jrX6JqTuJo1JShfPoRfx

View File

@ -1,2 +1,4 @@
outputs/
build/
*.avm
*.prover
*.verifier

View File

@ -0,0 +1,326 @@
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;

View File

@ -0,0 +1,6 @@
{
"program": "ntzsearchtree.aleo",
"version": "0.0.0",
"description": "",
"license": "MIT"
}

View File

@ -2,9 +2,5 @@
"program": "ntzsearchtree.aleo",
"version": "0.0.0",
"description": "",
"development": {
"private_key": "APrivateKey1zkp6FAfhh6Ka5a1Y7pExtTbbxhTbNsYW3BLEu6MN8MR2rMy",
"address": "aleo143kzqw88fcjm74s8tnj3f30ntf9gv6sy7f8d6djxseydkjfjh5ys5khzcs"
},
"license": "MIT"
}

View File

@ -0,0 +1,3 @@
NETWORK=testnet3
PRIVATE_KEY=APrivateKey1zkpBvXdKZKaXXcLUnwAVFCQNp41jrX6JqTuJo1JShfPoRfx

View File

@ -1,2 +1,4 @@
outputs/
build/
*.avm
*.prover
*.verifier

View File

@ -0,0 +1,33 @@
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;

View File

@ -0,0 +1,6 @@
{
"program": "ntzsmallvals.aleo",
"version": "0.0.0",
"description": "",
"license": "MIT"
}

View File

@ -2,9 +2,5 @@
"program": "ntzsmallvals.aleo",
"version": "0.0.0",
"description": "",
"development": {
"private_key": "APrivateKey1zkpHnXXtt92EZ16W2bb7oF8t263qNHagg6apVVV6nJqbFiL",
"address": "aleo1jzancywu7pksrmj2r9ydzqfds49dehzyrxtvvqu0djrcw6ysrszq8c8rgz"
},
"license": "MIT"
}

Some files were not shown because too many files have changed in this diff Show More