Merge remote-tracking branch 'refs/remotes/harmony-one/master' into gometalinter_p2p

pull/304/head
Eugene Kim 6 years ago
commit 954b481499
  1. 13
      .travis.yml
  2. 39
      test/crypto/bls/main.go

@ -3,8 +3,19 @@ go:
- master
install:
- export GOPATH=$HOME/gopath
- export CGO_CPPFLAGS="-I$GOPATH/src/github.com/harmony-one/bls/include -I$GOPATH/src/github.com/harmony-one/mcl/include"
- export CGO_LDFLAGS="-L$GOPATH/src/github.com/harmony-one/bls/lib -L$GOPATH/src/github.com/harmony-one/mcl/lib"
- export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GOPATH/src/github.com/harmony-one/bls/lib:$GOPATH/src/github.com/harmony-one/mcl/lib
- cd $HOME/gopath/src
- cd github.com/harmony-one/harmony
- cd github.com/harmony-one
- git clone https://github.com/harmony-one/mcl.git
- cd mcl
- make
- cd ..
- git clone https://github.com/harmony-one/bls.git
- cd bls
- make
- cd ../harmony
- go get -t -v ./...
- go get -u golang.org/x/lint/golint
- go get gopkg.in/check.v1

@ -0,0 +1,39 @@
package main
import (
"github.com/harmony-one/bls/ffi/go/bls"
"log"
"time"
)
func main() {
m := "message to sign"
var aggSig *bls.Sign
var aggPub *bls.PublicKey
startTime := time.Now()
for i := 0; i < 1000; i++ {
bls.Init(bls.BLS12_381)
var sec bls.SecretKey
sec.SetByCSPRNG()
if i == 0 {
aggSig = sec.Sign(m)
aggPub = sec.GetPublicKey()
} else {
aggSig.Add(sec.Sign(m))
aggPub.Add(sec.GetPublicKey())
}
}
endTime := time.Now()
log.Printf("Time required to sign 1000 messages and aggregate 1000 pub keys and signatures: %f seconds", endTime.Sub(startTime).Seconds())
log.Printf("Aggregate Signature: 0x%x", aggSig.GetHexString())
log.Printf("Aggregate Public Key: 0x%x", aggPub.GetHexString())
startTime = time.Now()
if !aggSig.Verify(aggPub, m) {
log.Fatal("Aggregate Signature Does Not Verify")
}
log.Printf("Aggregate Signature Verifies Correctly!")
endTime = time.Now()
log.Printf("Time required to verify aggregate sig: %f seconds", endTime.Sub(startTime).Seconds())
}
Loading…
Cancel
Save