Code Monkey home page Code Monkey logo

bls-eth-go-binary's Introduction

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

  • 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 library

The following steps are not necessary if you use compiled binary in this repository.

Linux, Mac, Windows(mingw64)

git clone --recursive https://github.com/herumi/bls-eth-go-binary
# git submodule update --init --recursive
cd bls-eth-go-binary
make CXX=clang++
go test ./bls -bench "Pairing|Sign|Verify"

clang generates better binary than gcc.

Android

make android

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([email protected])

Sponsors welcome

GitHub Sponsor

bls-eth-go-binary's People

Contributors

herumi avatar nisdas avatar prestonvanloon avatar protolambda avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.