Skip to content

Commit

Permalink
add initial bls12381 examples #54
Browse files Browse the repository at this point in the history
  • Loading branch information
CblPOK-git committed Nov 6, 2023
1 parent ee16b02 commit ea94c8f
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 0 deletions.
2 changes: 2 additions & 0 deletions examples/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,5 @@ add_example_without_proving(balances_tree_cpp_example SOURCES balances_tree.cpp

add_example_without_proving(eddsa_signature_verification_cpp SOURCES eddsa_signature_verification.cpp INPUT eddsa_signature_verification.inp)
add_example_without_proving(zkbridge_cpp SOURCES zkbridge.cpp INPUT zkbridge.inp)

# add_example_with_proving(bls12_381_curve_add SOURCES bls12_381_curve_add.cpp INPUT bls12_381_curve_add.inp)
15 changes: 15 additions & 0 deletions examples/cpp/bls12_381_curve_add.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[[circuit]] __zkllvm_curve_bls12381 add(__zkllvm_curve_bls12381 a, __zkllvm_curve_bls12381 b) {
return a + b;
}


// #include <nil/crypto3/algebra/curves/bls12.hpp>

// using namespace nil::crypto3::algebra::curves;

// [[circuit]] typename bls12<381>::template g1_type<>::value_type hash_to_curve(
// typename bls12<381>::template g1_type<>::value_type a,
// typename bls12<381>::template g1_type<>::value_type b) {

// return a + b;
// }
20 changes: 20 additions & 0 deletions examples/cpp/bls12_381_field_add.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <nil/crypto3/algebra/fields/bls12/base_field.hpp>

using namespace nil::crypto3::algebra::fields;

[[circuit]] typename bls12_base_field<381>::value_type add(
typename bls12_base_field<381>::value_type a,
typename bls12_base_field<381>::value_type b) {

return a + b;
}




// [[circuit]] typename ed25519::template g1_type<nil::crypto3::algebra::curves::coordinates::affine>::value_type curve_mul(
// typename ed25519::template g1_type<nil::crypto3::algebra::curves::coordinates::affine>::value_type point,
// typename ed25519::scalar_field_type::value_type scalar) {

// return point * scalar;
// }
4 changes: 4 additions & 0 deletions examples/inputs/bls12_381_curve_add.inp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[
{"curve":[1, 1]},
{"curve":[1, 1]}
]
2 changes: 2 additions & 0 deletions examples/inputs/bls12_381_field_add.inp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[ {"field":"999"},
{"field":"0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa"} ]

0 comments on commit ea94c8f

Please sign in to comment.