Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sidecar
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
sidecar
Commits
22a948ac
Commit
22a948ac
authored
Oct 29, 2021
by
suyanlong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add blst Signature
parent
66d7c81d
Pipeline
#8191
failed with stages
Changes
11
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
125 additions
and
7 deletions
+125
-7
go.mod
go.mod
+1
-0
go.sum
go.sum
+2
-0
mock_client.go
hub/client/mock_client/mock_client.go
+0
-1
mock_executor.go
internal/appchain/mock_executor/mock_executor.go
+0
-1
mock_monitor.go
internal/appchain/mock_monitor/mock_monitor.go
+0
-1
mock_peermgr.go
internal/peermgr/mock_peermgr/mock_peermgr.go
+0
-1
mock_router.go
internal/router/mock_router/mock_router.go
+0
-1
mock_syncer.go
internal/syncer/mock_syncer/mock_syncer.go
+0
-1
bls.go
pkg/crypto/bls/bls.go
+37
-0
bls_test.go
pkg/crypto/bls/bls_test.go
+85
-0
mock_client.go
pkg/plugins/mock_client/mock_client.go
+0
-1
No files found.
go.mod
View file @
22a948ac
...
@@ -170,6 +170,7 @@ require (
...
@@ -170,6 +170,7 @@ require (
github.com/spf13/jwalterweatherman v1.0.0 // indirect
github.com/spf13/jwalterweatherman v1.0.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/supranational/blst v0.3.6 // indirect
github.com/sykesm/zap-logfmt v0.0.3 // indirect
github.com/sykesm/zap-logfmt v0.0.3 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210305035536-64b5b1c73954 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210305035536-64b5b1c73954 // indirect
github.com/tidwall/match v1.0.3 // indirect
github.com/tidwall/match v1.0.3 // indirect
...
...
go.sum
View file @
22a948ac
...
@@ -932,6 +932,8 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc
...
@@ -932,6 +932,8 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/supranational/blst v0.3.6 h1:a24cPQB0qYpXPMZx177aapCM50/YrTMt/TKAUa7TzdM=
github.com/supranational/blst v0.3.6/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw=
github.com/sykesm/zap-logfmt v0.0.3 h1:3Wrhf7+I9JEUD8B6KPtDAr9j2jrS0/EPLy7GCE1t/+U=
github.com/sykesm/zap-logfmt v0.0.3 h1:3Wrhf7+I9JEUD8B6KPtDAr9j2jrS0/EPLy7GCE1t/+U=
github.com/sykesm/zap-logfmt v0.0.3/go.mod h1:AuBd9xQjAe3URrWT1BBDk2v2onAZHkZkWRMiYZXiZWA=
github.com/sykesm/zap-logfmt v0.0.3/go.mod h1:AuBd9xQjAe3URrWT1BBDk2v2onAZHkZkWRMiYZXiZWA=
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
...
...
hub/client/mock_client/mock_client.go
View file @
22a948ac
...
@@ -11,7 +11,6 @@ import (
...
@@ -11,7 +11,6 @@ import (
gomock
"github.com/golang/mock/gomock"
gomock
"github.com/golang/mock/gomock"
crypto
"github.com/meshplus/bitxhub-kit/crypto"
crypto
"github.com/meshplus/bitxhub-kit/crypto"
types
"github.com/meshplus/bitxhub-kit/types"
types
"github.com/meshplus/bitxhub-kit/types"
rpcx
"gitlab.33.cn/link33/sidecar/hub/client"
rpcx
"gitlab.33.cn/link33/sidecar/hub/client"
pb
"gitlab.33.cn/link33/sidecar/model/pb"
pb
"gitlab.33.cn/link33/sidecar/model/pb"
)
)
...
...
internal/appchain/mock_executor/mock_executor.go
View file @
22a948ac
...
@@ -8,7 +8,6 @@ import (
...
@@ -8,7 +8,6 @@ import (
reflect
"reflect"
reflect
"reflect"
gomock
"github.com/golang/mock/gomock"
gomock
"github.com/golang/mock/gomock"
pb
"gitlab.33.cn/link33/sidecar/model/pb"
pb
"gitlab.33.cn/link33/sidecar/model/pb"
)
)
...
...
internal/appchain/mock_monitor/mock_monitor.go
View file @
22a948ac
...
@@ -8,7 +8,6 @@ import (
...
@@ -8,7 +8,6 @@ import (
reflect
"reflect"
reflect
"reflect"
gomock
"github.com/golang/mock/gomock"
gomock
"github.com/golang/mock/gomock"
pb
"gitlab.33.cn/link33/sidecar/model/pb"
pb
"gitlab.33.cn/link33/sidecar/model/pb"
)
)
...
...
internal/peermgr/mock_peermgr/mock_peermgr.go
View file @
22a948ac
...
@@ -9,7 +9,6 @@ import (
...
@@ -9,7 +9,6 @@ import (
gomock
"github.com/golang/mock/gomock"
gomock
"github.com/golang/mock/gomock"
peer
"github.com/libp2p/go-libp2p-core/peer"
peer
"github.com/libp2p/go-libp2p-core/peer"
peermgr
"gitlab.33.cn/link33/sidecar/internal/peermgr"
peermgr
"gitlab.33.cn/link33/sidecar/internal/peermgr"
port
"gitlab.33.cn/link33/sidecar/internal/port"
port
"gitlab.33.cn/link33/sidecar/internal/port"
pb
"gitlab.33.cn/link33/sidecar/model/pb"
pb
"gitlab.33.cn/link33/sidecar/model/pb"
...
...
internal/router/mock_router/mock_router.go
View file @
22a948ac
...
@@ -8,7 +8,6 @@ import (
...
@@ -8,7 +8,6 @@ import (
reflect
"reflect"
reflect
"reflect"
gomock
"github.com/golang/mock/gomock"
gomock
"github.com/golang/mock/gomock"
port
"gitlab.33.cn/link33/sidecar/internal/port"
port
"gitlab.33.cn/link33/sidecar/internal/port"
pb
"gitlab.33.cn/link33/sidecar/model/pb"
pb
"gitlab.33.cn/link33/sidecar/model/pb"
)
)
...
...
internal/syncer/mock_syncer/mock_syncer.go
View file @
22a948ac
...
@@ -9,7 +9,6 @@ import (
...
@@ -9,7 +9,6 @@ import (
gomock
"github.com/golang/mock/gomock"
gomock
"github.com/golang/mock/gomock"
appchain_mgr
"github.com/meshplus/bitxhub-core/appchain-mgr"
appchain_mgr
"github.com/meshplus/bitxhub-core/appchain-mgr"
syncer
"gitlab.33.cn/link33/sidecar/internal/syncer"
syncer
"gitlab.33.cn/link33/sidecar/internal/syncer"
pb
"gitlab.33.cn/link33/sidecar/model/pb"
pb
"gitlab.33.cn/link33/sidecar/model/pb"
)
)
...
...
pkg/crypto/bls/bls.go
0 → 100644
View file @
22a948ac
package
bls
import
(
"crypto/rand"
blst
"github.com/supranational/blst/bindings/go"
)
// Names in this file must be unique to support min-sig so we can't use 'dst'
// here.
var
dstMinSig
=
[]
byte
(
"BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_"
)
//minimal-signature-size operations:
type
PublicKeyMinSig
=
blst
.
P2Affine
type
SignatureMinSig
=
blst
.
P1Affine
type
AggregateSignatureMinSig
=
blst
.
P1Aggregate
type
AggregatePublicKeyMinSig
=
blst
.
P2Aggregate
type
Message
=
blst
.
Message
type
SecretKey
=
blst
.
SecretKey
type
Scalar
=
blst
.
Scalar
func
GenRandomKeyMinSig
()
*
SecretKey
{
// Generate 32 bytes of randomness
var
ikm
[
32
]
byte
_
,
err
:=
rand
.
Read
(
ikm
[
:
])
if
err
!=
nil
{
return
nil
}
return
blst
.
KeyGen
(
ikm
[
:
])
}
pkg/crypto/bls/bls_test.go
0 → 100644
View file @
22a948ac
package
bls
import
(
"fmt"
mrand
"math/rand"
"testing"
blst
"github.com/supranational/blst/bindings/go"
)
func
TestSignMultipleVerifyAggregateMinSig
(
t
*
testing
.
T
)
{
msgCount
:=
5
for
size
:=
1
;
size
<
20
;
size
++
{
msgs
:=
make
([]
Message
,
0
)
sks
:=
make
([]
*
SecretKey
,
0
)
pks
:=
make
([]
*
PublicKeyMinSig
,
0
)
// Generate messages
for
i
:=
0
;
i
<
msgCount
;
i
++
{
msg
:=
Message
(
fmt
.
Sprintf
(
"blst is a blast!! %d %d"
,
i
,
size
))
msgs
=
append
(
msgs
,
msg
)
}
// Generate keypairs
for
i
:=
0
;
i
<
size
;
i
++
{
priv
:=
GenRandomKeyMinSig
()
sks
=
append
(
sks
,
priv
)
pks
=
append
(
pks
,
new
(
PublicKeyMinSig
)
.
From
(
priv
))
}
// All signers sign each message
aggSigs
:=
make
([]
*
SignatureMinSig
,
0
)
aggPks
:=
make
([]
*
PublicKeyMinSig
,
0
)
for
i
:=
0
;
i
<
msgCount
;
i
++
{
sigsToAgg
:=
make
([]
*
SignatureMinSig
,
0
)
pksToAgg
:=
make
([]
*
PublicKeyMinSig
,
0
)
for
j
:=
0
;
j
<
size
;
j
++
{
sigsToAgg
=
append
(
sigsToAgg
,
new
(
SignatureMinSig
)
.
Sign
(
sks
[
j
],
msgs
[
i
],
dstMinSig
))
pksToAgg
=
append
(
pksToAgg
,
pks
[
j
])
}
agSig
:=
new
(
AggregateSignatureMinSig
)
if
!
agSig
.
Aggregate
(
sigsToAgg
,
true
)
{
t
.
Errorf
(
"failed to aggregate"
)
}
afSig
:=
agSig
.
ToAffine
()
agPk
:=
new
(
AggregatePublicKeyMinSig
)
agPk
.
Aggregate
(
pksToAgg
,
false
)
afPk
:=
agPk
.
ToAffine
()
aggSigs
=
append
(
aggSigs
,
afSig
)
aggPks
=
append
(
aggPks
,
afPk
)
// Verify aggregated signature and pk
if
!
afSig
.
Verify
(
false
,
afPk
,
false
,
msgs
[
i
],
dstMinSig
)
{
t
.
Errorf
(
"failed to verify single aggregate size %d"
,
size
)
}
}
randFn
:=
func
(
s
*
Scalar
)
{
var
rbytes
[
blst
.
BLST_SCALAR_BYTES
]
byte
mrand
.
Read
(
rbytes
[
:
])
s
.
FromBEndian
(
rbytes
[
:
])
}
// Verify
randBits
:=
64
if
!
new
(
SignatureMinSig
)
.
MultipleAggregateVerify
(
aggSigs
,
true
,
aggPks
,
false
,
msgs
,
dstMinSig
,
randFn
,
randBits
)
{
t
.
Errorf
(
"failed to verify multiple aggregate size %d"
,
size
)
}
// Negative test
if
new
(
SignatureMinSig
)
.
MultipleAggregateVerify
(
aggSigs
,
true
,
aggPks
,
false
,
msgs
,
dstMinSig
[
1
:
],
randFn
,
randBits
)
{
t
.
Errorf
(
"failed to not verify multiple aggregate size %d"
,
size
)
}
}
}
pkg/plugins/mock_client/mock_client.go
View file @
22a948ac
...
@@ -8,7 +8,6 @@ import (
...
@@ -8,7 +8,6 @@ import (
reflect
"reflect"
reflect
"reflect"
gomock
"github.com/golang/mock/gomock"
gomock
"github.com/golang/mock/gomock"
pb
"gitlab.33.cn/link33/sidecar/model/pb"
pb
"gitlab.33.cn/link33/sidecar/model/pb"
plugins
"gitlab.33.cn/link33/sidecar/pkg/plugins"
plugins
"gitlab.33.cn/link33/sidecar/pkg/plugins"
)
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment