Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.0] Adapt to changes in bls12-381 lib and add tests #1882

Merged
merged 30 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
71a9319
Make code compile with refactored bls12-381.
yarkinwho Nov 9, 2023
eea0ea3
Refactor some interfaces, compiling, not tested yet.
yarkinwho Nov 9, 2023
3d188c7
Merge branch 'release/5.0' into yarkin/update_bls
yarkinwho Nov 9, 2023
fa59891
Refactor bls_gx calls.
yarkinwho Nov 10, 2023
d8dc360
Add bls_fp_mod and bls_fp_exp
yarkinwho Nov 10, 2023
35f375c
Update unit tests.
yarkinwho Nov 13, 2023
77f2be4
Merge branch 'release/5.0' into yarkin/update_bls
yarkinwho Nov 13, 2023
9c42d42
Fix comile.
yarkinwho Nov 13, 2023
49d17e3
Update to use affine form instead of jacobian form for data
yarkinwho Nov 14, 2023
fa5f81e
Merge branch 'release/5.0' into yarkin/update_bls
yarkinwho Nov 14, 2023
4e40590
Fix benchmark
yarkinwho Nov 14, 2023
2a85796
add benchmarking for Montgomery form host functions
linh2931 Nov 15, 2023
9d35e5a
Add tests for fp_mod, fp_exp, fp_mul
yarkinwho Nov 15, 2023
4255d62
Add more test case and update submodule (only contains test updates).
yarkinwho Nov 15, 2023
8819030
fix weighted sum montgomery form flag
linh2931 Nov 15, 2023
f280d5e
add const& to std::string parameters in all _impl methods
linh2931 Nov 15, 2023
dfb05c5
Remove _mont functions.
yarkinwho Nov 16, 2023
e1f67e9
Update comments.
yarkinwho Nov 16, 2023
d9e59b8
Delete unused benchmark.
yarkinwho Nov 16, 2023
36eafc7
Merge remote-tracking branch 'origin/yarkin/update_bls' into more_bls…
linh2931 Nov 16, 2023
65b54ab
resolve merge conflicts
linh2931 Nov 16, 2023
c39e930
remove _mont* functions
linh2931 Nov 16, 2023
6a9a8b1
use std::array instead of std::vector to simply conversion to eosio::…
linh2931 Nov 16, 2023
cc9bba8
Merge pull request #1904 from AntelopeIO/more_bls_benchmark
linh2931 Nov 17, 2023
cb4ceaa
Update feature signature.
yarkinwho Nov 21, 2023
1269951
Update feature manager, fix deep-mind.log accordinglly.
yarkinwho Nov 29, 2023
11640bf
Update to latest bls lib.
yarkinwho Nov 29, 2023
3c5c566
Merge branch 'release/5.0' into yarkin/update_bls
yarkinwho Nov 29, 2023
87738aa
remove `(multi-exponentiation)` from comments.
greg7mdp Nov 29, 2023
804e415
Update bls12 submodule to tip of `main` branch.
greg7mdp Nov 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 72 additions & 16 deletions libraries/chain/include/eosio/chain/webassembly/interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1796,6 +1796,17 @@ namespace webassembly {
*/
int32_t bls_g1_add(span<const char> op1, span<const char> op2, span<char> result) const;

/**
* Host function for G1 addition on the elliptic curve bls12-381
*
* @ingroup crypto
* @param op1 - a span containing the first operand G1 point in Montgemory form.
* @param op2 - a span containing the second operand G1 point in Montgemory form.
* @param[out] result - the result op1 + op2 in Montgemory form.
* @return -1 if there was an error 0 otherwise
*/
int32_t bls_g1_add_mont(span<const char> op1, span<const char> op2, span<char> result) const;

/**
* Host function for G2 addition on the elliptic curve bls12-381
*
Expand All @@ -1808,41 +1819,42 @@ namespace webassembly {
int32_t bls_g2_add(span<const char> op1, span<const char> op2, span<char> result) const;

/**
* Host function for G1 scalar multiplication on the elliptic curve bls12-381
* Host function for G2 addition on the elliptic curve bls12-381
*
* @ingroup crypto
* @param point - a span containing the G1 point operand.
* @param scalar - a span containing the scalar operand.
* @param[out] result - the result: scalar * point.
* @param op1 - a span containing the first operand G2 point in Montgemory form.
* @param op2 - a span containing the second operand G2 point in Montgemory form.
* @param[out] result - the result op1 + op2 in Montgemory form.
greg7mdp marked this conversation as resolved.
Show resolved Hide resolved
* @return -1 if there was an error 0 otherwise
*/
int32_t bls_g1_mul(span<const char> point, span<const char> scalar, span<char> result) const;
int32_t bls_g2_add_mont(span<const char> op1, span<const char> op2, span<char> result) const;

/**
* Host function for G2 scalar multiplication on the elliptic curve bls12-381
* Host function for G1 weighted sum (multi-exponentiation) on the elliptic curve bls12-381
arhag marked this conversation as resolved.
Show resolved Hide resolved
*
* @ingroup crypto
* @param point - a span containing the G2 point operand.
* @param scalar - a span containing the scalar operand.
* @param[out] result - the result op1 * op2.
* @param points - a span containing a list of G1 points (P0, P1, P2... Pn).
* @param scalars - a span containing a list of scalars (s0, s1, s2... sn).
* @param n - the number of elements in the lists.
* @param[out] result - the result s0 * P0 + s1 * P1 + ... + sn * Pn.
* @return -1 if there was an error 0 otherwise
*/
int32_t bls_g2_mul(span<const char> point, span<const char> scalar, span<char> result) const;
int32_t bls_g1_weighted_sum(span<const char> points, span<const char> scalars, const uint32_t n, span<char> result) const;

/**
* Host function for G1 multi-exponentiation on the elliptic curve bls12-381
* Host function for G1 weighted sum (multi-exponentiation) on the elliptic curve bls12-381
*
* @ingroup crypto
* @param points - a span containing a list of G1 points (P0, P1, P2... Pn).
* @param points - a span containing a list of G1 points (P0, P1, P2... Pn) in Montgemory form.
* @param scalars - a span containing a list of scalars (s0, s1, s2... sn).
* @param n - the number of elements in the lists.
* @param[out] result - the result s0 * P0 + s1 * P1 + ... + sn * Pn.
* @param[out] result - the result s0 * P0 + s1 * P1 + ... + sn * Pn in Montgemory form.
* @return -1 if there was an error 0 otherwise
*/
int32_t bls_g1_exp(span<const char> points, span<const char> scalars, const uint32_t n, span<char> result) const;
int32_t bls_g1_weighted_sum_mont(span<const char> points, span<const char> scalars, const uint32_t n, span<char> result) const;

/**
* Host function for G2 multi-exponentiation on the elliptic curve bls12-381
* Host function for G2 weighted sum (multi-exponentiation) on the elliptic curve bls12-381
arhag marked this conversation as resolved.
Show resolved Hide resolved
*
* @ingroup crypto
* @param points - a span containing a list of G2 points (P0, P1, P2... Pn).
Expand All @@ -1851,7 +1863,19 @@ namespace webassembly {
* @param[out] result - the result s0 * P0 + s1 * P1 + ... + sn * Pn.
* @return -1 if there was an error 0 otherwise
*/
int32_t bls_g2_exp(span<const char> points, span<const char> scalars, const uint32_t n, span<char> result) const;
int32_t bls_g2_weighted_sum(span<const char> points, span<const char> scalars, const uint32_t n, span<char> result) const;

/**
* Host function for G2 weighted sum (multi-exponentiation) on the elliptic curve bls12-381
*
* @ingroup crypto
* @param points - a span containing a list of G2 points (P0, P1, P2... Pn) in Montgemory form.
* @param scalars - a span containing a list of scalars (s0, s1, s2... sn).
* @param n - the number of elements in the lists.
* @param[out] result - the result s0 * P0 + s1 * P1 + ... + sn * Pn in Montgemory form.
* @return -1 if there was an error 0 otherwise
greg7mdp marked this conversation as resolved.
Show resolved Hide resolved
*/
int32_t bls_g2_weighted_sum_mont(span<const char> points, span<const char> scalars, const uint32_t n, span<char> result) const;

/**
* Host function to calculate the pairing of (G1, G2) pairs on the elliptic curve bls12-381
Expand All @@ -1865,6 +1889,18 @@ namespace webassembly {
*/
int32_t bls_pairing(span<const char> g1_points, span<const char> g2_points, const uint32_t n, span<char> result) const;

/**
* Host function to calculate the pairing of (G1, G2) pairs on the elliptic curve bls12-381
*
* @ingroup crypto
* @param g1_points - a span containing a list of G1 points (P0, P1, P2... Pn) in Montgemory form.
* @param g2_points - a span containing a list of G2 points (P0, P1, P2... Pn) in Montgemory form.
* @param n - the number of elements in the lists.
* @param[out] result - the result e(g1_0, g2_0) * e(g1_1, g2_1) * ... * e(g1_n, g2_n) in Montgemory form.
* @return -1 if there was an error 0 otherwise
*/
int32_t bls_pairing_mont(span<const char> g1_points, span<const char> g2_points, const uint32_t n, span<char> result) const;

/**
* Host function for mapping fp to G1 on the elliptic curve bls12-381
*
Expand All @@ -1875,6 +1911,16 @@ namespace webassembly {
*/
int32_t bls_g1_map(span<const char> e, span<char> result) const;

/**
* Host function for mapping fp to G1 on the elliptic curve bls12-381
*
* @ingroup crypto
* @param e - a span containing the field element fp to be mapped in Montgemory form.
* @param[out] result - the resulting element in G1 in Montgemory form.
* @return -1 if there was an error 0 otherwise
*/
int32_t bls_g1_map_mont(span<const char> e, span<char> result) const;

/**
* Host function for mapping fp2 to G2 on the elliptic curve bls12-381
*
Expand All @@ -1885,6 +1931,16 @@ namespace webassembly {
*/
int32_t bls_g2_map(span<const char> e, span<char> result) const;

/**
* Host function for mapping fp2 to G2 on the elliptic curve bls12-381
*
* @ingroup crypto
* @param e - a span containing the field element fp2 to be mapped in Montgemory form.
* @param[out] result - the resulting element in G2 in Montgemory form.
* @return -1 if there was an error 0 otherwise
*/
int32_t bls_g2_map_mont(span<const char> e, span<char> result) const;

/**
* Host function for modular reduction of 64 bytes wide scalar to a field element (fp, 48 bytes) of the elliptic curve bls12-381
* Involves Montgomery conversion on the resulting field element.
Expand Down
Loading
Loading