Skip to content

Commit

Permalink
added test contract for bls primitives
Browse files Browse the repository at this point in the history
  • Loading branch information
mschoenebeck committed Jul 17, 2023
1 parent 9007161 commit e050376
Show file tree
Hide file tree
Showing 10 changed files with 997 additions and 2 deletions.
2 changes: 1 addition & 1 deletion libraries/chain/webassembly/crypto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ namespace eosio { namespace chain { namespace webassembly {
if(i%10 == 0)
context.trx_context.checktime();
}
bls12_381::g1 r = bls12_381::g1::multiExp(pv, sv).value(); // accessing value is safe
bls12_381::g1 r = bls12_381::g1::multiExp(pv, sv, [this](){ context.trx_context.checktime(); }).value(); // accessing value is safe
r.toJacobianBytesLE({reinterpret_cast<uint8_t*>(result.data()), 144}, true);
return return_code::success;
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/libfc/libraries/bls12-381
Submodule bls12-381 updated 2 files
+1 −1 include/g.hpp
+5 −1 src/g.cpp
511 changes: 511 additions & 0 deletions unittests/bls_primitives_tests.cpp

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions unittests/test-contracts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@ add_subdirectory( action_results )
add_subdirectory( wasm_config_bios )
add_subdirectory( params_test )
add_subdirectory( crypto_primitives_test )
add_subdirectory( bls_primitives_test )
add_subdirectory( get_block_num_test )
add_subdirectory( nested_container_multi_index )
6 changes: 6 additions & 0 deletions unittests/test-contracts/bls_primitives_test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
if( EOSIO_COMPILE_TEST_CONTRACTS )
add_contract( bls_primitives_test bls_primitives_test bls_primitives_test.cpp )
else()
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/bls_primitives_test.wasm ${CMAKE_CURRENT_BINARY_DIR}/bls_primitives_test.wasm COPYONLY )
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/bls_primitives_test.abi ${CMAKE_CURRENT_BINARY_DIR}/bls_primitives_test.abi COPYONLY )
endif()
260 changes: 260 additions & 0 deletions unittests/test-contracts/bls_primitives_test/bls_primitives_test.abi
Original file line number Diff line number Diff line change
@@ -0,0 +1,260 @@
{
"____comment": "This file was generated with eosio-abigen. DO NOT EDIT ",
"version": "eosio::abi/1.2",
"types": [],
"structs": [
{
"name": "testg1add",
"base": "",
"fields": [
{
"name": "op1",
"type": "bytes"
},
{
"name": "op2",
"type": "bytes"
},
{
"name": "res",
"type": "bytes"
},
{
"name": "expected_error",
"type": "int32"
}
]
},
{
"name": "testg1exp",
"base": "",
"fields": [
{
"name": "points",
"type": "bytes"
},
{
"name": "scalars",
"type": "bytes"
},
{
"name": "num",
"type": "uint32"
},
{
"name": "res",
"type": "bytes"
},
{
"name": "expected_error",
"type": "int32"
}
]
},
{
"name": "testg1map",
"base": "",
"fields": [
{
"name": "e",
"type": "bytes"
},
{
"name": "res",
"type": "bytes"
},
{
"name": "expected_error",
"type": "int32"
}
]
},
{
"name": "testg1mul",
"base": "",
"fields": [
{
"name": "point",
"type": "bytes"
},
{
"name": "scalar",
"type": "bytes"
},
{
"name": "res",
"type": "bytes"
},
{
"name": "expected_error",
"type": "int32"
}
]
},
{
"name": "testg2add",
"base": "",
"fields": [
{
"name": "op1",
"type": "bytes"
},
{
"name": "op2",
"type": "bytes"
},
{
"name": "res",
"type": "bytes"
},
{
"name": "expected_error",
"type": "int32"
}
]
},
{
"name": "testg2exp",
"base": "",
"fields": [
{
"name": "points",
"type": "bytes"
},
{
"name": "scalars",
"type": "bytes"
},
{
"name": "num",
"type": "uint32"
},
{
"name": "res",
"type": "bytes"
},
{
"name": "expected_error",
"type": "int32"
}
]
},
{
"name": "testg2map",
"base": "",
"fields": [
{
"name": "e",
"type": "bytes"
},
{
"name": "res",
"type": "bytes"
},
{
"name": "expected_error",
"type": "int32"
}
]
},
{
"name": "testg2mul",
"base": "",
"fields": [
{
"name": "point",
"type": "bytes"
},
{
"name": "scalar",
"type": "bytes"
},
{
"name": "res",
"type": "bytes"
},
{
"name": "expected_error",
"type": "int32"
}
]
},
{
"name": "testpairing",
"base": "",
"fields": [
{
"name": "g1_points",
"type": "bytes"
},
{
"name": "g2_points",
"type": "bytes"
},
{
"name": "num",
"type": "uint32"
},
{
"name": "res",
"type": "bytes"
},
{
"name": "expected_error",
"type": "int32"
}
]
}
],
"actions": [
{
"name": "testg1add",
"type": "testg1add",
"ricardian_contract": ""
},
{
"name": "testg1exp",
"type": "testg1exp",
"ricardian_contract": ""
},
{
"name": "testg1map",
"type": "testg1map",
"ricardian_contract": ""
},
{
"name": "testg1mul",
"type": "testg1mul",
"ricardian_contract": ""
},
{
"name": "testg2add",
"type": "testg2add",
"ricardian_contract": ""
},
{
"name": "testg2exp",
"type": "testg2exp",
"ricardian_contract": ""
},
{
"name": "testg2map",
"type": "testg2map",
"ricardian_contract": ""
},
{
"name": "testg2mul",
"type": "testg2mul",
"ricardian_contract": ""
},
{
"name": "testpairing",
"type": "testpairing",
"ricardian_contract": ""
}
],
"tables": [],
"ricardian_clauses": [],
"variants": [],
"action_results": []
}
Loading

0 comments on commit e050376

Please sign in to comment.