WASM/PVM: Add ec pairing check host function
What
This MR implements ec_pairing_check_bls12_381 host function.
Why
The ec_pairing_check host function would be used in threshold encryption, and would be called once during validation of one key share, four of which needed to decryption one transaction. ec_pairing_check is quite expensive in the kernel, taking 7ms to run on a Mac. This can translate to 28ms per transaction(More details can be found in !14450 (closed) ).
It is therefore very reasonable to introduce a host function to speed this up. And since Bls12_381.Pairing.pairing_check is already widely used in Tezos layer 1, this is not very complex.
How
The is very similar to other host functions, and uses Bls12_381.Pairing.pairing_check as the underlying implementation.
Manually testing the MR
dune exec src/lib_scoru_wasm/test/main.exe -- --file test_wasm_pvm.ml
dune exec src/lib_scoru_wasm/test/main.exe -- --file test_crypto.ml
Checklist
-
Document the interface of any function added or modified (see the coding guidelines) -
Document any change to the user interface, including configuration parameters (see node configuration) -
Provide automatic testing (see the testing guide). -
For new features and bug fixes, add an item in the appropriate changelog ( docs/protocols/alpha.rstfor the protocol and the environment,CHANGES.rstat the root of the repository for everything else). -
Select suitable reviewers using the Reviewersfield below. -
Select as Assigneethe next person who should take action on that MR
Edited by Hantang Sun