{"id":13629779,"url":"https://github.com/herumi/mcl","last_synced_at":"2025-04-13T02:20:07.522Z","repository":{"id":31503386,"uuid":"35067668","full_name":"herumi/mcl","owner":"herumi","description":"a portable and fast pairing-based cryptography library","archived":false,"fork":false,"pushed_at":"2024-05-22T08:01:47.000Z","size":7841,"stargazers_count":436,"open_issues_count":4,"forks_count":149,"subscribers_count":19,"default_branch":"master","last_synced_at":"2024-05-22T09:26:29.016Z","etag":null,"topics":["cryptography","pairing"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/herumi.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-05-05T00:18:39.000Z","updated_at":"2024-05-30T04:04:05.479Z","dependencies_parsed_at":"2024-05-30T04:04:00.186Z","dependency_job_id":"32ab003a-4b45-4ffa-af38-253a42854ba9","html_url":"https://github.com/herumi/mcl","commit_stats":{"total_commits":3217,"total_committers":21,"mean_commits":153.1904761904762,"dds":"0.013677339135840794","last_synced_commit":"a1f0aa49b90c17a67a2fc69aab16520106e972c3"},"previous_names":[],"tags_count":89,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/herumi%2Fmcl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/herumi%2Fmcl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/herumi%2Fmcl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/herumi%2Fmcl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/herumi","download_url":"https://codeload.github.com/herumi/mcl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248654569,"owners_count":21140325,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cryptography","pairing"],"created_at":"2024-08-01T22:01:19.005Z","updated_at":"2025-04-13T02:20:07.485Z","avatar_url":"https://github.com/herumi.png","language":"C++","funding_links":["https://github.com/sponsors/herumi"],"categories":["C++"],"sub_categories":[],"readme":"[![Build Status](https://github.com/herumi/mcl/actions/workflows/main.yml/badge.svg)](https://github.com/herumi/mcl/actions/workflows/main.yml)\r\n\r\n# mcl\r\n\r\nA portable and fast pairing-based cryptography library.\r\n\r\n# Abstract\r\n\r\nmcl is a library for pairing-based cryptography,\r\nwhich supports the optimal Ate pairing over BN curves and BLS12-381 curves.\r\n\r\n# News\r\n- support BLS12_377 pairing\r\n- mulVec (resp. mulEach) with AVX-512 IFMA is 1.52 (resp. 3.26) times faster than without it.\r\n- Add {Fp,Fr,Fp2}::squareRoot.\r\n- Improve the performance of squareRoot.\r\n- Add batch inversion for Fr and Fp elements, and batch normalization for G1 and G2 points.\r\n- mulVec is a little improved.\r\n- mulEach with AVX-512 IFMA is improved slightly and 2.8 times faster than G1::mul on BLS12-381.\r\n- mulVec (multi scalar multiplication) with AVX-512 IFMA is 1.4 times faster on Xeon w9-3495X\r\n- a little performance improvement of G1::mulVec of BLS12-381\r\n- improve performance of Fr::inv on M1 mac\r\n- add mcl::bn::isValidGT(x) and mclBnGT_isValid(x) to check x in GT for x in Fp12.\r\n- support BN\\_P256 (hash-to-curve is not yet standard way.)\r\n- the performance of `{G1,G2}::mulVec(z, xVec, yVec, n)` has improved for n \u003e= 256. (about 2x speed up for n = 512).\r\n  - But it changes the type of xVec from `const G*` to `G*` because xVec may be normalized when computing.\r\n  - fix mul(G, G, F) for F = Fp at v1.61\r\n- add set DST functions for hashMapToGi\r\n- add F::invVec, G::normalizeVec\r\n- improve SECP256K1 for x64\r\n- add G1::mulVecMT, G2::mulVecMT (enabled by MCL_USE_OMP=1)\r\n- improve mulMod of SECP256K1 for wasm\r\n- fix FpToG1(P, u, v) and Fp2ToG2(P, u, v) when u == v (This bug does not affect mapToG1 and mapToG2).\r\n- add millerLoopVecMT (enabled if built with MCL_USE_OMP=1)\r\n- support s390x(systemz)\r\n- improve M1 mac performance\r\n- set default `MCL_MAX_BIT_SIZE=512` so disable to support `NICT_P521`.\r\n- improve performance\r\n- support M1 mac\r\n\r\n# Support architecture\r\n\r\n- x86-64 Windows + Visual Studio 2015 (or later)\r\n- x86, x86-64 Linux + gcc/clang\r\n- x86-64, M1 macOS\r\n- ARM / ARM64 Linux\r\n- WebAssembly : see [mcl-wasm](https://github.com/herumi/mcl-wasm)\r\n- Android : see [mcl-android](https://github.com/herumi/mcl-android)\r\n- iPhone\r\n- s390x(systemz)\r\n  - install llvm and clang, and `make UPDATE_ASM=1` once.\r\n- (maybe any platform to be supported by LLVM)\r\n\r\n# Support curves\r\n\r\n- BN curve ; p(z) = 36z^4 + 36z^3 + 24z^2 + 6z + 1.\r\n  - BN254 ; a BN curve over the 254-bit prime p(z) where z = -(2^62 + 2^55 + 1).\r\n  - BN\\_SNARK1 ; a BN curve over a 254-bit prime p such that n := p + 1 - t has high 2-adicity.\r\n  - BN381\\_1 ; a BN curve over the 381-bit prime p(z) where z = -(2^94 + 2^76 + 2^72 + 1).\r\n  - BN462 ; a BN curve over the 462-bit prime p(z) where z = 2^114 + 2^101 - 2^14 - 1.\r\n- BLS12\\_381 ; [a BLS12-381 curve](https://blog.z.cash/new-snark-curve/)\r\n\r\n# BLS signature\r\nSee [bls](https://github.com/herumi/bls) if you want mcl for BLS-signature.\r\n\r\n# C-API\r\nSee [api.md](api.md) and [FAQ](api.md#faq) for serialization and hash-to-curve.\r\n\r\n# How to build on Linux and macOS\r\nx86-64/ARM/ARM64 Linux, macOS and mingw64 are supported.\r\n\r\nGMP is necessary only to build test programs.\r\n- `sudo apt install libgmp-dev` on Ubuntu\r\n- `brew install gmp` on macOS\r\n\r\nOpenMP is optional (`make MCL_USE_OMP=1` to use OpenMP for `mulVec`)\r\n- `sudo apt install libomp-dev` on Ubuntu\r\n- `brew install libomp`\r\n\r\n## How to build with Makefile\r\n\r\nFor x86-64 Linux and macOS,\r\n\r\n```\r\ngit clone https://github.com/herumi/mcl\r\ncd mcl\r\nmake -j4\r\n```\r\nclang++ is required except for x86-64 on Linux and Windows.\r\n\r\n```\r\nmake -j4 CXX=clang++\r\n```\r\n\r\n- `lib/libmcl.*` ; core library\r\n- `lib/libmclbn384_256.*` ; library to use C-API of BLS12-381 pairing\r\n\r\n# How to build with CMake\r\n\r\nFor x86-64 Linux and macOS.\r\n```\r\nmkdir build\r\ncd build\r\ncmake ..\r\nmake\r\n```\r\n\r\nFor the other platform (including mingw), clang++ is required.\r\n```\r\nmkdir build\r\ncd build\r\ncmake .. -DCMAKE_CXX_COMPILER=clang++\r\nmake\r\n```\r\nUse `clang++` instead of gcc on mingw.\r\n\r\nFor Visual Studio, (REMARK : It is not maintained; use the vcxproj file.)\r\n```\r\nmkdir build\r\ncd build\r\ncmake .. -A x64\r\nmsbuild mcl.sln /p:Configuration=Release /m\r\n```\r\n\r\n## How to build a static library with Visual Studio\r\nOpen `mcl.sln` and build it.\r\n`src/proj/lib/lib.vcxproj` is to build a static library `lib/mcl.lib` which is defined `MCL_MAX_BIT_SIZE=384`.\r\n\r\n## options\r\n\r\nsee `cmake .. -LA`.\r\n\r\n## tests\r\nmake test binaries in `./bin`.\r\n```\r\ncmake .. -DBUILD_TESTING=ON\r\nmake -j4\r\n```\r\n\r\n\r\n## How to make from src/{base,bint}{32,64}.ll\r\n\r\nclang (clang-cl on Windows) is necessary to build files with a suffix ll.\r\n\r\n- BIT = 64 (if 64-bit CPU) else 32\r\n- `src/base${BIT}.ll` is necessary if `MCL_USE_LLVM` is defined.\r\n  - This code is used if xbyak is not used.\r\n- `src/bint${BIT}.ll` is necessary if `MCL_BINT_ASM=1`.\r\n  - `src/bint-x64-{amd64,win}.asm` is used instead if `MCL_BINT_ASM_X64=1`.\r\n  - It is faster than `src/bint64.ll` because it uses mulx/adox/adcx.\r\n\r\nThese files may be going to be unified in the future.\r\n\r\n## How to test of BLS12-381 pairing\r\n\r\n```\r\n# C\r\nmake bin/bn_c384_256_test.exe \u0026\u0026 bin/bn_c384_256_test.exe\r\n\r\n# C++\r\nmake bin/bls12_test.exe \u0026\u0026 bin/bls12_test.exe\r\n```\r\n\r\n### How to make a library for BLS12-381 without Xbyak\r\nOn x64 environment, mcl uses JIT code, but if you want to avoid them,\r\n\r\n```\r\nmake lib/libmcl.a MCL_STATIC_CODE=1 -j\r\n# test of pairing\r\nmake test_static\r\n```\r\nThe generated library supports only *BLS12_381* and requires compiler options `-DMCL_MAX_BIT_SIZE=384 -DMCL_STATIC_CODE`.\r\n\r\n## How to profile on Linux\r\n\r\n### Use perf\r\n```\r\nmake MCL_USE_PROF=1 bin/bls12_test.exe\r\nenv MCL_PROF=1 bin/bls12_test.exe\r\n```\r\n\r\n### Use Intel VTune profiler\r\nSupporse VTune is installed in `/opt/intel/vtune_amplifier/`.\r\n```\r\nmake MCL_USE_PROF=2 bin/bls12_test.exe\r\nenv MCL_PROF=2 bin/bls12_test.exe\r\n```\r\n\r\n## How to build on 32-bit x86 Linux\r\n\r\nBuild GMP for 32-bit mode.\r\n\r\n```\r\nsudo apt install g++-multilib\r\nsudo apt install clang-14\r\ncd \u003cGMP dir\u003e\r\nenv ABI=32 ./configure --enable-cxx --prefix=\u003cinstall dir\u003e\r\nmake -j install\r\ncd \u003cmcl dir\u003e\r\nmake ARCH=x86 LLVM_VER=-14 GMP_DIR=\u003cinstall dir\u003e\r\n```\r\n\r\n# How to build a library for arm with clang++ on Linux\r\n\r\n```\r\nmake -f Makefile.cross BIT=32 TARGET=armv7l\r\nsudo apt install g++-arm-linux-gnueabi\r\narm-linux-gnueabi-g++ sample/pairing.cpp -O3 -DNDEBUG -I ./include/ lib/libmclbn384_256.a -DMCL_MAX_BIT_SIZE=384\r\nenv QEMU_LD_PREFIX=/usr/arm-linux-gnueabi/ qemu-arm ./a.out\r\n```\r\n\r\nThe static library `libbls384_256.a` built by `bls/Makefile.onelib` in [bls](https://github.com/herumi/bls) contains all mcl functions. So please see [the comment of Makefile.onelib](https://github.com/herumi/bls/blob/master/Makefile.onelib#L198) if you want to build this library on the other platform such as Mingw64 on Linux.\r\n\r\n# How to build on 64-bit Windows with Visual Studio\r\n\r\nPython3 is necessary.\r\nOpen a console window, and\r\n```\r\ngit clone https://github.com/herumi/mcl\r\ncd mcl\r\n\r\n# static library\r\nmklib\r\nmk -s test\\bls12_test.cpp \u0026\u0026 bin\\bls12_test.exe\r\n\r\n# dynamic library\r\nmklib dll\r\nmk -d test\\bls12_test.cpp \u0026\u0026 bin\\bls12_test.exe\r\n```\r\n(not maintenanced)\r\nOpen mcl.sln and build or if you have msbuild.exe\r\n```\r\nmsbuild /p:Configuration=Release\r\n```\r\n\r\n# C# test\r\n\r\n```\r\ncd mcl\r\nmklib dll\r\ncd ffi/cs\r\ndotnet build mcl.sln\r\ncd ../../bin\r\n../ffi/cs/test/bin/Debug/netcoreapp3.1/test.exe\r\n```\r\n\r\n# How to build for wasm(WebAssembly)\r\nmcl supports emcc (Emscripten) and `test/bn_test.cpp` runs on browers such as Firefox, Chrome and Edge.\r\n\r\n* [IBE on browser](https://herumi.github.io/mcl-wasm/ibe-demo.html)\r\n* [SHE on browser](https://herumi.github.io/she-wasm/she-demo.html)\r\n* [BLS signature on brower](https://herumi.github.io/bls-wasm/bls-demo.html)\r\n\r\nThe timing of a pairing on `BN254` is 2.8msec on 64-bit Firefox with Skylake 3.4GHz.\r\n\r\n# Node.js\r\n\r\n* [mcl-wasm](https://www.npmjs.com/package/mcl-wasm) pairing library\r\n* [bls-wasm](https://www.npmjs.com/package/bls-wasm) BLS signature library\r\n* [she-wasm](https://www.npmjs.com/package/she-wasm) 2 Level Homomorphic Encryption library\r\n\r\n# Benchmark\r\n\r\n## The latest benchmark(2018/11/7)\r\n\r\n### Intel Core i7-6700 3.4GHz(Skylake), Ubuntu 18.04.1 LTS\r\n\r\ncurveType |              binary|clang-6.0.0|gcc-7.3.0|\r\n----------|--------------------|-----------|---------|\r\nBN254     |    bin/bn\\_test.exe|    882Kclk|  933Kclk|\r\nBLS12-381 | bin/bls12\\_test.exe|   2290Kclk| 2630Kclk|\r\n\r\n### Intel Core i7-7700 3.6GHz(Kaby Lake), Ubuntu 18.04.1 LTS on Windows 10 Vmware\r\n\r\ncurveType |              binary|clang-6.0.0|gcc-7.3.0|\r\n----------|--------------------|-----------|---------|\r\nBN254     |    bin/bn\\_test.exe|    900Kclk|  954Kclk|\r\nBLS12-381 | bin/bls12\\_test.exe|   2340Kclk| 2680Kclk|\r\n\r\n* now investigating the reason why gcc is slower than clang.\r\n\r\n## Higher-bit BN curve benchmark\r\n\r\nFor JavaScript(WebAssembly), see [ID based encryption demo](https://herumi.github.io/mcl-wasm/ibe-demo.html).\r\n\r\nparamter   |  x64| Firefox on x64|Safari on iPhone7|\r\n-----------|-----|---------------|-----------------|\r\nBN254      | 0.25|           2.48|             4.78|\r\nBN381\\_1   | 0.95|           7.91|            11.74|\r\nBN462      | 2.16|          14.73|            22.77|\r\n\r\n* x64 : 'Kaby Lake Core i7-7700(3.6GHz)'.\r\n* Firefox : 64-bit version 58.\r\n* iPhone7 : iOS 11.2.1.\r\n* BN254 is by `test/bn_test.cpp`.\r\n* BN381\\_1 and BN462 are  by `test/bn512_test.cpp`.\r\n* All the timings  are given in ms(milliseconds).\r\n\r\nThe other benchmark results are [bench.txt](bench.txt).\r\n\r\n## An old benchmark of a BN curve BN254(2016/12/25).\r\n\r\n* x64, x86 ; Inte Core i7-6700 3.4GHz(Skylake) upto 4GHz on Ubuntu 16.04.\r\n    * `sudo cpufreq-set -g performance`\r\n* arm ; 900MHz quad-core ARM Cortex-A7 on Raspberry Pi2, Linux 4.4.11-v7+\r\n* arm64 ; 1.2GHz ARM Cortex-A53 [HiKey](http://www.96boards.org/product/hikey/)\r\n\r\nsoftware                                                 |   x64|  x86| arm|arm64(msec)\r\n---------------------------------------------------------|------|-----|----|-----\r\n[ate-pairing](https://github.com/herumi/ate-pairing)     | 0.21 |   - |  - |    -\r\nmcl                                                      | 0.31 | 1.6 |22.6|  3.9\r\n[TEPLA](http://www.cipher.risk.tsukuba.ac.jp/tepla/)     | 1.76 | 3.7 | 37 | 17.9\r\n[RELIC](https://github.com/relic-toolkit/relic) PRIME=254| 0.30 | 3.5 | 36 |    -\r\n[MIRACL](https://github.com/miracl/MIRACL) ake12bnx      | 4.2  |   - | 78 |    -\r\n[NEONabe](http://sandia.cs.cinvestav.mx/Site/NEONabe)    |   -  |   - | 16 |    -\r\n\r\n* compile option for RELIC\r\n```\r\ncmake -DARITH=x64-asm-254 -DFP_PRIME=254 -DFPX_METHD=\"INTEG;INTEG;LAZYR\" -DPP_METHD=\"LAZYR;OATEP\"\r\n```\r\n\r\n# SELinux\r\nmcl uses Xbyak JIT engine if it is available on x64 architecture,\r\notherwise mcl uses a little slower functions generated by LLVM.\r\nThe default mode enables SELinux security policy on CentOS, then JIT is disabled.\r\n```\r\n% sudo setenforce 1\r\n% getenforce\r\nEnforcing\r\n% bin/bn_test.exe\r\nJIT 0\r\npairing   1.496Mclk\r\nfinalExp 581.081Kclk\r\n\r\n% sudo setenforce 0\r\n% getenforce\r\nPermissive\r\n% bin/bn_test.exe\r\nJIT 1\r\npairing   1.394Mclk\r\nfinalExp 546.259Kclk\r\n```\r\n\r\n# How to make asm files (optional)\r\nThe asm files generated by this way are already put in `src/asm`, then it is not necessary to do this.\r\n\r\nInstall [LLVM](http://llvm.org/).\r\n```\r\nmake MCL_USE_LLVM=1 LLVM_VER=\u003cllvm-version\u003e UPDATE_ASM=1\r\n```\r\nFor example, specify `-3.8` for `\u003cllvm-version\u003e` if `opt-3.8` and `llc-3.8` are installed.\r\n\r\nIf you want to use Fp with 1024-bit prime on x86-64, then\r\n```\r\nmake MCL_USE_LLVM=1 LLVM_VER=\u003cllvm-version\u003e UPDATE_ASM=1 MCL_MAX_BIT_SIZE=1024\r\n```\r\n\r\n# API for Two level homomorphic encryption\r\n* [_Efficient Two-level Homomorphic Encryption in Prime-order Bilinear Groups and A Fast Implementation in WebAssembly_](https://dl.acm.org/citation.cfm?doid=3196494.3196552), N. Attrapadung, G. Hanaoka, S. Mitsunari, Y. Sakai,\r\nK. Shimizu, and T. Teruya. ASIACCS 2018\r\n* [she-api](https://github.com/herumi/mcl/blob/master/misc/she/she-api.md)\r\n* [she-api(Japanese)](https://github.com/herumi/mcl/blob/master/misc/she/she-api-ja.md)\r\n\r\n# Java API\r\nSee [java.md](https://github.com/herumi/mcl/blob/master/ffi/java/java.md)\r\n\r\n# License\r\n\r\nmodified new BSD License\r\nhttp://opensource.org/licenses/BSD-3-Clause\r\n\r\nThis library contains some part of the followings software licensed by BSD-3-Clause.\r\n* [xbyak](https://github.com/herumi/xbyak)\r\n* [cybozulib](https://github.com/herumi/cybozulib)\r\n* [Lifted-ElGamal](https://github.com/aistcrypt/Lifted-ElGamal)\r\n\r\n# References\r\n* [ate-pairing](https://github.com/herumi/ate-pairing/)\r\n* [_Faster Explicit Formulas for Computing Pairings over Ordinary Curves_](http://dx.doi.org/10.1007/978-3-642-20465-4_5),\r\n D.F. Aranha, K. Karabina, P. Longa, C.H. Gebotys, J. Lopez,\r\n EUROCRYPTO 2011, ([preprint](http://eprint.iacr.org/2010/526))\r\n* [_High-Speed Software Implementation of the Optimal Ate Pairing over Barreto-Naehrig Curves_](http://dx.doi.org/10.1007/978-3-642-17455-1_2),\r\n   Jean-Luc Beuchat, Jorge Enrique González Díaz, Shigeo Mitsunari, Eiji Okamoto, Francisco Rodríguez-Henríquez, Tadanori Teruya,\r\n  Pairing 2010, ([preprint](http://eprint.iacr.org/2010/354))\r\n* [_Faster hashing to G2_](https://link.springer.com/chapter/10.1007/978-3-642-28496-0_25),Laura Fuentes-Castañeda,  Edward Knapp,  Francisco Rodríguez-Henríquez,\r\n  SAC 2011, ([PDF](http://cacr.uwaterloo.ca/techreports/2011/cacr2011-26.pdf))\r\n* [_Skew Frobenius Map and Efficient Scalar Multiplication for Pairing–Based Cryptography_](https://www.researchgate.net/publication/221282560_Skew_Frobenius_Map_and_Efficient_Scalar_Multiplication_for_Pairing-Based_Cryptography),\r\nY. Sakemi, Y. Nogami, K. Okeya, Y. Morikawa, CANS 2008.\r\n\r\n# compatilibity\r\n\r\n- mclBnGT_inv returns a - b w, a conjugate of x for x = a + b w in Fp12 = Fp6[w]\r\n  - use mclBnGT_invGeneric if x is not in GT\r\n- mclBn_setETHserialization(true) (de)serialize acoording to [ETH2.0 serialization of BLS12-381](https://github.com/ethereum/eth2.0-specs/blob/dev/specs/bls_signature.md#point-representations) when BLS12-381 is used.\r\n- (Break backward compatibility) libmcl_dy.a is renamed to libmcl.a\r\n  - The option SHARE_BASENAME_SUF is removed\r\n- 2nd argument of `mclBn_init` is changed from `maxUnitSize` to `compiledTimeVar`, which must be `MCLBN_COMPILED_TIME_VAR`.\r\n- break backward compatibility of mapToGi for BLS12. A map-to-function for BN is used.\r\nIf `MCL_USE_OLD_MAPTO_FOR_BLS12` is defined, then the old function is used, but this will be removed in the future.\r\n\r\n# FAQ\r\n\r\n## How do I set the hash value to Fr?\r\nThe behavior of `setHashOf` function may be a little different from what you want.\r\n  - https://github.com/herumi/mcl/blob/master/api.md#hash-and-mapto-functions\r\n  - https://github.com/herumi/mcl/blob/master/api.md#set-buf0bufsize-1-to-x-with-masking-according-to-the-following-way\r\n\r\nPlease use the following code:\r\n```\r\ntemplate\u003cclass F\u003e\r\nvoid setHash(F\u0026 x, const void *msg, size_t msgSize)\r\n{\r\n    uint8_t md[32];\r\n    mcl::fp::sha256(md, sizeof(md), msg, msgSize);\r\n    x.setBigEndianMod(md, sizeof(md));\r\n    // or x.setLittleEndianMod(md, sizeof(md));\r\n}\r\n```\r\n\r\n\r\n# History\r\n- 2022/Apr/10 v1.60 improve {G1,G2}::mulVec\r\n- 2022/Mar/25 v1.59 add set DST functions for hashMapToGi\r\n- 2022/Mar/24 add F::invVec, G::normalizeVec\r\n- 2022/Mar/08 v1.58 improve SECP256K1 for x64\r\n- 2022/Feb/13 v1.57 add mulVecMT\r\n- 2021/Aug/26 v1.52 improve {G1,G2}::isValidOrder() for BLS12-381\r\n- 2021/May/04 v1.50 support s390x(systemz)\r\n- 2021/Apr/21 v1.41 fix inner function of mapToGi for large dst (not affect hashAndMapToGi)\r\n- 2021/May/24 v1.40 fix sigsegv in valgrind\r\n- 2021/Jan/28 v1.31 fix : call setOrder in init for isValidOrder\r\n- 2021/Jan/28 v1.30 a little optimization of Fp operations\r\n- 2020/Nov/14 v1.28 support M1 mac\r\n- 2020/Jun/07 v1.22 remove old hash-to-curve functions\r\n- 2020/Jun/04 v1.21 mapToG1 and hashAndMapToG1 are compatible to irtf/eip-2537\r\n- 2020/May/13 v1.09 support draft-irtf-cfrg-hash-to-curve-07\r\n- 2020/Mar/26 v1.07 change DST for hash-to-curve-06\r\n- 2020/Mar/15 v1.06 support hash-to-curve-06\r\n- 2020/Jan/31 v1.05 mclBn_ethMsgToFp2 has changed to append zero byte at the end of msg\r\n- 2020/Jan/25 v1.04 add new hash functions\r\n- 2019/Dec/05 v1.03 disable to check the order in setStr\r\n- 2019/Sep/30 v1.00 add some functions to bn.h ; [api.md](api.md).\r\n- 2019/Sep/22 v0.99 add mclBnG1_mulVec, etc.\r\n- 2019/Sep/08 v0.98 bugfix Ec::add(P, Q, R) when P == R\r\n- 2019/Aug/14 v0.97 add some C api functions\r\n- 2019/Jul/26 v0.96 improved scalar multiplication\r\n- 2019/Jun/03 v0.95 fix a parser of 0b10 with base = 16\r\n- 2019/Apr/29 v0.94 mclBn_setETHserialization supports [ETH2.0 serialization of BLS12-381](https://github.com/ethereum/eth2.0-specs/blob/dev/specs/bls_signature.md#point-representations)\r\n- 2019/Apr/24 v0.93 support ios\r\n- 2019/Mar/22 v0.92 shortcut for Ec::mul(Px, P, x) if P = 0\r\n- 2019/Mar/21 python binding of she256 for Linux/Mac/Windows\r\n- 2019/Mar/14 v0.91 modp supports mcl-wasm\r\n- 2019/Mar/12 v0.90 fix Vint::setArray(x) for x == this\r\n- 2019/Mar/07 add mclBnFr_setLittleEndianMod, mclBnFp_setLittleEndianMod\r\n- 2019/Feb/20 LagrangeInterpolation sets out = yVec[0] if k = 1\r\n- 2019/Jan/31 add mclBnFp_mapToG1, mclBnFp2_mapToG2\r\n- 2019/Jan/31 fix crash on x64-CPU without AVX (thanks to mortdeus)\r\n\r\n# Author\r\n\r\nMITSUNARI Shigeo(herumi@nifty.com)\r\n\r\n# Sponsors welcome\r\n[GitHub Sponsor](https://github.com/sponsors/herumi)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fherumi%2Fmcl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fherumi%2Fmcl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fherumi%2Fmcl/lists"}