From b4bd9280b23f62209800f0ccaca9d76612abad2c Mon Sep 17 00:00:00 2001 From: Rongjian Lan Date: Tue, 22 Jan 2019 21:02:30 +0000 Subject: [PATCH 01/16] Add test program for BLS go implementation --- test/crypto/bls/main.go | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 test/crypto/bls/main.go diff --git a/test/crypto/bls/main.go b/test/crypto/bls/main.go new file mode 100644 index 000000000..b239c4b78 --- /dev/null +++ b/test/crypto/bls/main.go @@ -0,0 +1,40 @@ +package main + +import ( + "fmt" + "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()) +} From d369bca38cf338dc150efdb28307b46e45c65057 Mon Sep 17 00:00:00 2001 From: Rongjian Lan Date: Tue, 22 Jan 2019 21:26:54 +0000 Subject: [PATCH 02/16] Add build path for BLS --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 93e9dc226..d17b6e4fd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,9 @@ 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 - cd $HOME/gopath/src - cd github.com/harmony-one/harmony - go get -t -v ./... From 68fc1e3edf14832319ef077c8ed2eb2f519da735 Mon Sep 17 00:00:00 2001 From: Rongjian Lan Date: Tue, 22 Jan 2019 21:43:45 +0000 Subject: [PATCH 03/16] Add mcl package checkout --- .travis.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d17b6e4fd..639143c58 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,11 @@ install: - 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 - cd $HOME/gopath/src - - cd github.com/harmony-one/harmony + - cd github.com/harmony-one + - git clone git@github.com:harmony-one/mcl.git + - cd mcl + - make test + - cd ../harmony - go get -t -v ./... - go get -u golang.org/x/lint/golint - go get gopkg.in/check.v1 From 47cc02cb7fa54475b20fab9ccb09fea6e15c6ac7 Mon Sep 17 00:00:00 2001 From: Rongjian Lan Date: Tue, 22 Jan 2019 21:02:30 +0000 Subject: [PATCH 04/16] Add test program for BLS go implementation --- test/crypto/bls/main.go | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 test/crypto/bls/main.go diff --git a/test/crypto/bls/main.go b/test/crypto/bls/main.go new file mode 100644 index 000000000..b239c4b78 --- /dev/null +++ b/test/crypto/bls/main.go @@ -0,0 +1,40 @@ +package main + +import ( + "fmt" + "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()) +} From 3fc730af9acd097cadf1c16a8c16c9432e0b62bb Mon Sep 17 00:00:00 2001 From: Rongjian Lan Date: Tue, 22 Jan 2019 21:26:54 +0000 Subject: [PATCH 05/16] Add build path for BLS --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 93e9dc226..d17b6e4fd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,9 @@ 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 - cd $HOME/gopath/src - cd github.com/harmony-one/harmony - go get -t -v ./... From 0b64c00c67ccc41a92ee805d4bbf5f3964686e67 Mon Sep 17 00:00:00 2001 From: Rongjian Lan Date: Tue, 22 Jan 2019 21:43:45 +0000 Subject: [PATCH 06/16] Add mcl package checkout --- .travis.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d17b6e4fd..639143c58 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,11 @@ install: - 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 - cd $HOME/gopath/src - - cd github.com/harmony-one/harmony + - cd github.com/harmony-one + - git clone git@github.com:harmony-one/mcl.git + - cd mcl + - make test + - cd ../harmony - go get -t -v ./... - go get -u golang.org/x/lint/golint - go get gopkg.in/check.v1 From cf44817240905fd1d3793abeb3cea2cdedb6b9fb Mon Sep 17 00:00:00 2001 From: Rongjian Lan Date: Tue, 22 Jan 2019 22:08:54 +0000 Subject: [PATCH 07/16] Use https instead of ssh for git clone --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 639143c58..85d815f04 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ install: - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GOPATH/src/github.com/harmony-one/bls/lib - cd $HOME/gopath/src - cd github.com/harmony-one - - git clone git@github.com:harmony-one/mcl.git + - git clone https://github.com/harmony-one/mcl.git - cd mcl - make test - cd ../harmony From ea0578dedf42c917cae4ec6d313e2f3e69d7f148 Mon Sep 17 00:00:00 2001 From: Rongjian Lan Date: Tue, 22 Jan 2019 22:27:43 +0000 Subject: [PATCH 08/16] clone bls repo too in the build --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 85d815f04..852452d8b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,10 @@ install: - git clone https://github.com/harmony-one/mcl.git - cd mcl - make test + - cd .. + - git clone https://github.com/harmony-one/bls.git + - cd bls + - make test - cd ../harmony - go get -t -v ./... - go get -u golang.org/x/lint/golint From cee494936dafa0bd77ce0c950484537775e07aba Mon Sep 17 00:00:00 2001 From: Rongjian Lan Date: Wed, 23 Jan 2019 00:23:45 +0000 Subject: [PATCH 09/16] Fix travis build --- .travis.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 852452d8b..bf6c53b4f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,13 +9,8 @@ install: - cd $HOME/gopath/src - cd github.com/harmony-one - git clone https://github.com/harmony-one/mcl.git - - cd mcl - - make test - - cd .. - git clone https://github.com/harmony-one/bls.git - - cd bls - - make test - - cd ../harmony + - cd harmony - go get -t -v ./... - go get -u golang.org/x/lint/golint - go get gopkg.in/check.v1 From e0499fef7a1259cc88743fa67944b6f1267a16e3 Mon Sep 17 00:00:00 2001 From: Rongjian Lan Date: Wed, 23 Jan 2019 00:47:00 +0000 Subject: [PATCH 10/16] Fix travis build --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.travis.yml b/.travis.yml index bf6c53b4f..952c60896 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,12 @@ install: - cd $HOME/gopath/src - cd github.com/harmony-one - git clone https://github.com/harmony-one/mcl.git + - cd mcl + - make test + - cd .. - git clone https://github.com/harmony-one/bls.git + - cd bls + - make test - cd harmony - go get -t -v ./... - go get -u golang.org/x/lint/golint From de10e0c2b2a7303744e2a1269712031261a3f00f Mon Sep 17 00:00:00 2001 From: Rongjian Lan Date: Wed, 23 Jan 2019 01:19:11 +0000 Subject: [PATCH 11/16] Change to ci test --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 952c60896..88c65c0b3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,11 +10,11 @@ install: - cd github.com/harmony-one - git clone https://github.com/harmony-one/mcl.git - cd mcl - - make test + - make test_ci - cd .. - git clone https://github.com/harmony-one/bls.git - cd bls - - make test + - make test_ci - cd harmony - go get -t -v ./... - go get -u golang.org/x/lint/golint From 68d795f8030ff6c937d1ab149cd4bd8ff7305fda Mon Sep 17 00:00:00 2001 From: Rongjian Lan Date: Wed, 23 Jan 2019 02:40:46 +0000 Subject: [PATCH 12/16] Fix build failure --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 88c65c0b3..ddf62f3cc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,11 +10,11 @@ install: - cd github.com/harmony-one - git clone https://github.com/harmony-one/mcl.git - cd mcl - - make test_ci + - make test_ci DEBUG=1 -j3 - cd .. - git clone https://github.com/harmony-one/bls.git - cd bls - - make test_ci + - make test_ci DISABLE_THREAD_TEST=1 - cd harmony - go get -t -v ./... - go get -u golang.org/x/lint/golint From aafd537dbdc4cfe57d30bdd7601352af6286b50f Mon Sep 17 00:00:00 2001 From: Rongjian Lan Date: Wed, 23 Jan 2019 07:32:06 +0000 Subject: [PATCH 13/16] Fix travis failure --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index ddf62f3cc..5bf5b3374 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,11 +10,11 @@ install: - cd github.com/harmony-one - git clone https://github.com/harmony-one/mcl.git - cd mcl - - make test_ci DEBUG=1 -j3 + - make - cd .. - git clone https://github.com/harmony-one/bls.git - cd bls - - make test_ci DISABLE_THREAD_TEST=1 + - make - cd harmony - go get -t -v ./... - go get -u golang.org/x/lint/golint From 60e5670cf6a15de85b330ee5bc949452f4561dfd Mon Sep 17 00:00:00 2001 From: Rongjian Lan Date: Wed, 23 Jan 2019 08:25:22 +0000 Subject: [PATCH 14/16] Fix travis failure --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5bf5b3374..975d106c9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ install: - git clone https://github.com/harmony-one/bls.git - cd bls - make - - cd harmony + - cd ../harmony - go get -t -v ./... - go get -u golang.org/x/lint/golint - go get gopkg.in/check.v1 From 9a95aa6a71334d1f2082f7c2d8b185d509dacbc5 Mon Sep 17 00:00:00 2001 From: Rongjian Lan Date: Wed, 23 Jan 2019 08:56:14 +0000 Subject: [PATCH 15/16] Fix build error --- .travis.yml | 2 +- test/crypto/bls/main.go | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 975d106c9..e56346534 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ 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 + - 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 - git clone https://github.com/harmony-one/mcl.git diff --git a/test/crypto/bls/main.go b/test/crypto/bls/main.go index b239c4b78..ba526c309 100644 --- a/test/crypto/bls/main.go +++ b/test/crypto/bls/main.go @@ -1,7 +1,6 @@ package main import ( - "fmt" "github.com/harmony-one/bls/ffi/go/bls" "log" "time" From 37e3c696e357b04e64016d02a1f6023578c0475e Mon Sep 17 00:00:00 2001 From: Rongjian Lan Date: Wed, 23 Jan 2019 09:09:50 +0000 Subject: [PATCH 16/16] Fix lint --- test/crypto/bls/main.go | 60 ++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/test/crypto/bls/main.go b/test/crypto/bls/main.go index ba526c309..bdd7181a2 100644 --- a/test/crypto/bls/main.go +++ b/test/crypto/bls/main.go @@ -1,39 +1,39 @@ package main import ( - "github.com/harmony-one/bls/ffi/go/bls" - "log" - "time" + "github.com/harmony-one/bls/ffi/go/bls" + "log" + "time" ) func main() { - m := "message to sign" - var aggSig *bls.Sign - var aggPub *bls.PublicKey + 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() + 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()) + 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()) }