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

[crypto] multiple improvements of the code base #4397

Merged
merged 11 commits into from
May 31, 2023

Conversation

tarakby
Copy link
Contributor

@tarakby tarakby commented May 31, 2023

Multiple improvements of the crypto package code base. The improvements are unrelated to each other and small, they were therefore grouped in one PR:

  • clean up headers and included files in bls12_381_utils.h
  • BLST internally defines bool_t as a C boolean type. The first version of the package C layer used bool_t for simplicity. This PR updates the boolean type to use the C native bool type assuming cgo only supports new C compilers.
  • add sanity tests of hardcoded scalar multiplications in G1 and G2, to catch obvious bugs or wrong setup.
  • consolidate length constants (G1, G2 and Fr serializations) and their respective roles in BLS signature scheme. Remove all duplicated constants.
  • use C macros directly in Go code and remove macro wrappers (since newer versions of cgo allow importing C macros)
  • Define new C layer error constants and abstract away BLST errors (BLST_ERROR).
  • Update the methods used to map points to G1's complement and G2`s complement by using isogenous mapping (test only tools)
  • Update the package and run tests to work with the uncompressed G1 and G2 serializations setup. Although the package only works for one specific setup (compression is default and no dynamic switch of serializations), the objective is to support a dynamic switch in the future so that a user can choose the desired serialization of G1 and G2.
  • update returned errors of BLSReconstructThresholdSignature stateless API to match the stateful API errors.

@tarakby tarakby changed the title [crypto] WIP [crypto] multiple improvements of the code base May 31, 2023
@codecov-commenter
Copy link

codecov-commenter commented May 31, 2023

Codecov Report

Merging #4397 (01b64c5) into feature/blst-based-crypto (33c5e0e) will decrease coverage by 0.01%.
The diff coverage is n/a.

@@                      Coverage Diff                      @@
##           feature/blst-based-crypto    #4397      +/-   ##
=============================================================
- Coverage                      53.71%   53.71%   -0.01%     
=============================================================
  Files                            857      857              
  Lines                          79948    79948              
=============================================================
- Hits                           42943    42941       -2     
- Misses                         33607    33610       +3     
+ Partials                        3398     3397       -1     
Flag Coverage Δ
unittests 53.71% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 7 files with indirect coverage changes

@tarakby tarakby marked this pull request as ready for review May 31, 2023 16:49
@tarakby tarakby merged commit f5c3668 into feature/blst-based-crypto May 31, 2023
@tarakby tarakby deleted the tarak/blst-improv branch May 31, 2023 18:07
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants