Skip to content

herumi/bls-eth-go-binary

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

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 is set by default.
  • 2020/May/22 SignHashWithDomain, VerifyHashWithDomain, VerifyAggregateHashWithDomain are removed.
  • 2020/May/15 EthModeDraft07 is added for draft-07.
  • 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. 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 <mcl/bn_c384_256.h>
#include <bls/bls.h>

Author

MITSUNARI Shigeo(herumi@nifty.com)

Sponsors welcome

GitHub Sponsor

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published