Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/herumi/bls-eth-go-binary
https://github.com/herumi/bls-eth-go-binary
Last synced: 13 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/herumi/bls-eth-go-binary
- Owner: herumi
- Created: 2019-10-19T01:47:46.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-09-03T03:14:23.000Z (2 months ago)
- Last Synced: 2024-10-13T20:46:02.239Z (about 1 month ago)
- Language: Go
- Size: 99 MB
- Stars: 68
- Watchers: 5
- Forks: 41
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
[![Build Status](https://github.com/herumi/bls-eth-go-binary/actions/workflows/main.yml/badge.svg)](https://github.com/herumi/bls-eth-go-binary/actions/workflows/main.yml)
# bls for eth with compiled static library
This repository contains compiled static library of https://github.com/herumi/bls with `BLS_ETH=1`.
* SecretKey; Fr
* PublicKey; G1
* Sign; G2# News
- 2023/Aug/17 The performance of Sign is a little improved.
- 2023/Jun/12 move static libraries to release branch
- 2021/Jan/28 (change specification) enable VerifySignatureOrder and VerifyPublicKeyOrder by default
- 2021/Jan/28 (change specification) verify returns false for zero public key
- 2021/Jan/02 support arm64 golang on M1 mac
- 2020/Oct/15 `add SecretKey::GetSafePublicKey()`, which returns an error if sec is zero
- 2020/Oct/08 `MultiVerify` returns true only if all signatures are valid.
- 2020/Sep/18 static binary for x64 is JIT-less mode, which uses code pre-generated by Xbyak.
- 2020/Jul/03 remove old tests and use the latest hash function defined at [draft-07](https://www.ietf.org/id/draft-irtf-cfrg-hash-to-curve-07.txt) is set by default.
- 2020/May/22 `SignHashWithDomain`, `VerifyHashWithDomain`, `VerifyAggregateHashWithDomain` are removed.
- 2020/May/15 `EthModeDraft07` is added for [draft-07](https://www.ietf.org/id/draft-irtf-cfrg-hash-to-curve-07.txt).
- 2020/Apr/20 `EthModeDraft06` is default. Call `SetETHmode(EthModeDraft05)` to use older evrsion.
- 2020/Mar/26 The signature value in `SetETHmode(2)` has changed because of changing DST in hash-to-curve function.
- 2020/Mar/17 This library supports [eth2.0 functions](https://github.com/ethereum/eth2.0-specs/blob/dev/specs/phase0/beacon-chain.md#bls-signatures). But the spec of hash-to-curve function may be changed.Init as the followings:
```
Init(BLS12_381)
```then, you can use the following functions.
bls-eth-go-binary | eth2.0 spec name|
------|-----------------|
SecretKey::SignByte|Sign|
PublicKey::VerifyByte|Verify|
Sign::Aggregate|Aggregate|
Sign::FastAggregateVerify|FastAggregateVerify|
Sign::AggregateVerifyNoCheck|AggregateVerify|The size of message must be 32 byte.
Check functions:
- VerifySignatureOrder ; make `deserialize` check the correctness of the order
- Sign::IsValidOrder ; check the correctness of the order
- VerifyPublicKeyOrder ; make `deserialize` check the correctness of the order
- PublicKey::IsValidOrder ; check the correctness of the order
- AreAllMsgDifferent ; check that all messages are different each other# How to run `examples/sample.go`
```
go get github.com/herumi/bls-eth-go-binary/
go run examples/sample.go
```# How to build the static binary
The following steps are not necessary if you use compiled binary in this repository.```
git clone --recursive https://github.com/herumi/bls-go-binary
cd bls-go-binary
#git submodule update --init --recursive
go test ./bls -bench "Pairing|Sign|Verify" -count=1
```## Linux, Mac, Windows(mingw64)
On x64 Linux,
```
make
```Otherwise, clang is necessary to build ll files.
```
make CXX=clang++
```### Cross compile on macOS
```
make ARCH=x86_64 # for Intel mac
make ARCH=arm64 # for M1 mac
```### Cross compile of aarch64 on x64 Linux
```
sudo apt-get install gcc-multilib
make -C src/bls -f Makefile.onelib build_aarch64 CXX=clang++ -j OUT_DIR=../..
```# Android
```
make android
```If you need a shared library, then after `make clean`,
```
make android BLS_LIB_SHARED=1
```# iOS
```
make ios
```## How to cross-compile for armeabi-v7a
Check `llc --version` shows to support the target armv7a.```
make ../mcl/src/base32.ll
env CXX=clang++ BIT=32 ARCH=arm _OS=android _ARCH=armeabi-v7a make MCL_USE_GMP=0 UNIT=4 CFLAGS_USER="-target armv7a-linux-eabi -fPIC"
```* Remark : clang++ must support `armv7a-linux-eabi`.
### How to build sample.go for armeabi-v7a```
env CC=arm-linux-gnueabi-gcc CGO_ENABLED=1 GOOS=linux GOARM=7 GOARCH=arm go build examples/sample.go
env QEMU_LD_PREFIX=/usr/arm-linux-gnueabi qemu-arm ./sample
```## How to cross-compile for mipsel
Check `llc --version` shows to support the target mips.```
make ../mcl/src/base32.ll
env CXX=clang++ BIT=32 ARCH=mipsel _OS=linux _ARCH=mipsle make MCL_USE_GMP=0 UNIT=4 CFLAGS_USER="-target mipsel-linux -fPIC"
```* Remark : clang++ must support `mipsel-linux`.
### How to build sample.go for mipsel```
env CC=mipsel-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=mipsle GOMIPS=softfloat go build examples/sample.go
env QEMU_LD_PREFIX=/usr/mipsel-linux-gnu qemu-mipsel ./sample
```# How to use the static library from C
```
#define BLS_ETH
#include
#include
```# Author
MITSUNARI Shigeo([email protected])# Sponsors welcome
[GitHub Sponsor](https://github.com/sponsors/herumi)