Skip to content

Commit

Permalink
Merge pull request #815 from Zokrates/patch-libsnark-ci
Browse files Browse the repository at this point in the history
Make sure libsnark is activated where applicable
  • Loading branch information
Schaeff authored Apr 13, 2021
2 parents 9a6956a + 07e27d0 commit f38f837
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 13 deletions.
6 changes: 5 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@
# Exit if any subcommand fails
set -e

cargo build
if [ -n "$WITH_LIBSNARK" ]; then
cargo -Z package-features build --package zokrates_cli --features="libsnark"
else
cargo build
fi
9 changes: 8 additions & 1 deletion ci/before_deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ main() {

test -f Cargo.lock || cargo generate-lockfile

cross build --bin zokrates --target $TARGET --release
case $TRAVIS_OS_NAME in
linux)
cross build --bin zokrates --package zokrates_cli --features="libsnark" --target $TARGET --release
;;
*)
cross build --bin zokrates --package zokrates_cli --target $TARGET --release
;;
esac

# Package artifacts
# Binary
Expand Down
6 changes: 5 additions & 1 deletion full_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@
# Exit if any subcommand fails
set -e

cargo test --release -- --ignored --test-threads=1
if [ -n "$WITH_LIBSNARK" ]; then
cargo -Z package-features test --release --package zokrates_cli --features="libsnark" -- --ignored --test-threads=1
else
cargo test --release -- --ignored --test-threads=1
fi
6 changes: 5 additions & 1 deletion test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@
# Exit if any subcommand fails
set -e

cargo test --release -- --test-threads=1
if [ -n "$WITH_LIBSNARK" ]; then
cargo -Z package-features test --release --package zokrates_cli --features="libsnark" -- --test-threads=1
else
cargo test --release -- --test-threads=1
fi
1 change: 0 additions & 1 deletion zokrates_cli/tests/code/no_public.arguments.json

This file was deleted.

Empty file.
2 changes: 0 additions & 2 deletions zokrates_cli/tests/code/no_public.zok

This file was deleted.

12 changes: 6 additions & 6 deletions zokrates_core/src/proof_system/libsnark/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub fn prepare_public_inputs<T: Field>(public_inputs: Vec<T>) -> (Vec<[u8; 32]>,
let mut public_inputs_arr: Vec<[u8; 32]> = vec![[0u8; 32]; public_inputs_length];

for (index, value) in public_inputs.into_iter().enumerate() {
public_inputs_arr[index] = vec_as_u8_32_array(&value.into_byte_vector());
public_inputs_arr[index] = vec_as_u8_32_array(&value.to_byte_vector());
}

(public_inputs_arr, public_inputs_length)
Expand Down Expand Up @@ -62,21 +62,21 @@ pub fn prepare_setup<T: Field>(
a_vec.push((
row as i32,
idx as i32,
vec_as_u8_32_array(&val.into_byte_vector()),
vec_as_u8_32_array(&val.to_byte_vector()),
));
}
for &(idx, ref val) in &b[row] {
b_vec.push((
row as i32,
idx as i32,
vec_as_u8_32_array(&val.into_byte_vector()),
vec_as_u8_32_array(&val.to_byte_vector()),
));
}
for &(idx, ref val) in &c[row] {
c_vec.push((
row as i32,
idx as i32,
vec_as_u8_32_array(&val.into_byte_vector()),
vec_as_u8_32_array(&val.to_byte_vector()),
));
}
}
Expand Down Expand Up @@ -177,10 +177,10 @@ pub fn prepare_generate_proof<T: Field>(

//convert inputs
for (index, value) in public_inputs.into_iter().enumerate() {
public_inputs_arr[index] = vec_as_u8_32_array(&value.into_byte_vector());
public_inputs_arr[index] = vec_as_u8_32_array(&value.to_byte_vector());
}
for (index, value) in private_inputs.into_iter().enumerate() {
private_inputs_arr[index] = vec_as_u8_32_array(&value.into_byte_vector());
private_inputs_arr[index] = vec_as_u8_32_array(&value.to_byte_vector());
}

(
Expand Down

0 comments on commit f38f837

Please sign in to comment.