Merge pull request #261 from AleoHQ/fix/example-bugs

Fix/example bugs
This commit is contained in:
Howard Wu 2020-08-18 23:47:56 -07:00 committed by GitHub
commit 9f8bdb2d7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 48 additions and 29 deletions

View File

@ -26,7 +26,7 @@ use crate::{
GroupType, GroupType,
Integer, Integer,
}; };
use leo_typed::{Circuit, Function, Identifier, Span, Type}; use leo_typed::{Circuit, Function, GroupValue, Identifier, Span, Type};
use snarkos_errors::gadgets::SynthesisError; use snarkos_errors::gadgets::SynthesisError;
use snarkos_models::{ use snarkos_models::{
@ -85,7 +85,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedValue<F, G> {
Type::Address => Ok(ConstrainedValue::Address(Address::new(value, span)?)), Type::Address => Ok(ConstrainedValue::Address(Address::new(value, span)?)),
Type::Boolean => Ok(ConstrainedValue::Boolean(new_bool_constant(value, span)?)), Type::Boolean => Ok(ConstrainedValue::Boolean(new_bool_constant(value, span)?)),
Type::Field => Ok(ConstrainedValue::Field(FieldType::constant(value, span)?)), Type::Field => Ok(ConstrainedValue::Field(FieldType::constant(value, span)?)),
Type::Group => Err(ValueError::implicit_group(span)), Type::Group => Ok(ConstrainedValue::Group(G::constant(GroupValue::Single(value, span))?)),
Type::IntegerType(integer_type) => Ok(ConstrainedValue::Integer(Integer::new_constant( Type::IntegerType(integer_type) => Ok(ConstrainedValue::Integer(Integer::new_constant(
integer_type, integer_type,
value, value,

View File

@ -1,3 +1,6 @@
[package] [package]
name = "fibonacci" name = "fibonacci"
version = "0.1.0" version = "0.1.0"
description = "Returns a fibonnaci sequence"
remote = "aleo/fibonacci"
license = "LICENSE-MIT"

View File

@ -0,0 +1,6 @@
[package]
name = "hello-world"
version = "0.1.0"
description = "Returns the sum of two u32 integers"
remote = "aleo/hello-world"
license = "LICENSE-MIT"

View File

@ -0,0 +1,6 @@
[main]
a: u32 = 1;
b: u32 = 2;
[registers]
r0: u32 = 0;

View File

@ -0,0 +1,5 @@
// The 'hello-world' main function.
function main(a: u32, b: u32) -> u32 {
let c: u32 = a + b;
return c
}

View File

@ -1,3 +0,0 @@
[package]
name = "hello_world"
version = "0.1.0"

View File

@ -1,2 +0,0 @@
[registers]
r0: u32 = 0;

View File

@ -1,5 +0,0 @@
// The 'hello_world' main function.
function main() -> u32 {
let a: u32 = 1 + 1;
return a
}

View File

@ -0,0 +1,6 @@
[package]
name = "pedersen-hash"
version = "0.1.0"
description = "A 256bit hash function"
remote = "aleo/pedersen-hash"
license = "LICENSE-MIT"

View File

@ -17,7 +17,7 @@ circuit PedersenHash {
} }
} }
// The 'pedersen_hash' main function. // The 'pedersen-hash' main function.
function main() -> group { function main() -> group {
const parameters = [1group; 256]; const parameters = [1group; 256];
const pedersen = PedersenHash::new(parameters); const pedersen = PedersenHash::new(parameters);

View File

@ -1,3 +0,0 @@
[package]
name = "pedersen_hash"
version = "0.1.0"

View File

@ -0,0 +1,6 @@
[package]
name = "square-root"
version = "0.1.0"
description = "prove knowledge of the square root `a` of a number `b`"
remote = "aleo/square-root"
license = "LICENSE-MIT"

View File

@ -1,7 +1,7 @@
// The program input for square_root/src/main.leo // The program input for square_root/src/main.leo
[main] [main]
a: field = 337; a: u32 = 337;
b: field = 113569; b: u32 = 113569;
[registers] [registers]
r0: bool = false; r0: bool = false;

View File

@ -0,0 +1,5 @@
// The 'square-root' main function.
// prove knowledge of the square root `a` of a number `b`
function main(a: u32, b: u32) -> bool {
return a * a == b
}

View File

@ -1,3 +0,0 @@
[package]
name = "square_root"
version = "0.1.0"

View File

@ -1,5 +0,0 @@
// The 'square_root' main function.
// prove knowledge of the square root `a` of a number `b`:
function main(a: field, b: field) -> bool {
return a * a == b
}

View File

@ -118,7 +118,7 @@ impl CLI for PublishCommand {
// If not logged in, then try logging in using JWT. // If not logged in, then try logging in using JWT.
Err(_error) => { Err(_error) => {
log::warn!("You should be logged before publish the package"); log::warn!("You should be logged in before attempting to publish a package");
log::info!("Trying to log in using JWT..."); log::info!("Trying to log in using JWT...");
let options = (None, None, None); let options = (None, None, None);

View File

@ -95,10 +95,13 @@ impl Manifest {
fn template(&self) -> String { fn template(&self) -> String {
format!( format!(
r#"[package] r#"[package]
name = "{}" name = "{name}"
version = "0.1.0" version = "0.1.0"
description = "The {name} package"
remote = "[AUTHOR]/{name}"
license = "LICENSE-MIT"
"#, "#,
self.package.name name = self.package.name
) )
} }
} }