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
b587b9f6
Commit
b587b9f6
authored
Dec 02, 2021
by
suyanlong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bug for manager and make fmt
parent
25fd813a
Pipeline
#8328
failed with stages
Changes
24
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
105 additions
and
86 deletions
+105
-86
api.go
api/api.go
+1
-1
error.go
api/error.go
+0
-1
server.go
api/server.go
+1
-1
init.go
cmd/sidecar/init.go
+1
-1
tool.go
cmd/sidecar/tool.go
+1
-1
sidecar.go
internal/app/sidecar.go
+13
-2
appchain.go
internal/appchain/appchain.go
+9
-5
manager.go
internal/appchain/manager.go
+17
-16
port.go
internal/appchain/port.go
+1
-1
lite.go
internal/lite/direct_lite/lite.go
+1
-2
header.go
internal/lite/hub_lite/header.go
+0
-1
router.go
internal/router/router.go
+3
-3
cryptor.go
internal/txcrypto/cryptor.go
+1
-1
ibtpx_test.go
model/pb/ibtpx_test.go
+34
-34
message.pb.go
model/pb/message.pb.go
+1
-1
bls_test.go
pkg/crypto/bls/bls_test.go
+4
-5
complex_policy.go
pkg/validator/validatorlib/complex_policy.go
+1
-0
ecdsa.go
pkg/validator/validatorlib/ecdsa.go
+1
-0
fabric_validation.go
pkg/validator/validatorlib/fabric_validation.go
+2
-1
wasm_validator.go
pkg/validator/wasm_validator.go
+2
-1
wasm_validator_test.go
pkg/validator/wasm_validator_test.go
+2
-1
wasm.go
pkg/wasm/wasm.go
+2
-1
wasm_test.go
pkg/wasm/wasm_test.go
+2
-1
tool.go
tool/tool.go
+5
-5
No files found.
api/api.go
View file @
b587b9f6
...
@@ -36,7 +36,7 @@ func (g *Server) sendTransaction(c *gin.Context) {
...
@@ -36,7 +36,7 @@ func (g *Server) sendTransaction(c *gin.Context) {
return
return
}
}
//TODO
//
TODO
c
.
JSON
(
http
.
StatusOK
,
res
)
c
.
JSON
(
http
.
StatusOK
,
res
)
panic
(
"implement me"
)
panic
(
"implement me"
)
...
...
api/error.go
View file @
b587b9f6
...
@@ -60,7 +60,6 @@ func ErrHandler() gin.HandlerFunc {
...
@@ -60,7 +60,6 @@ func ErrHandler() gin.HandlerFunc {
return
return
}
}
}
}
}
}
}
}
...
...
api/server.go
View file @
b587b9f6
...
@@ -60,7 +60,7 @@ func NewServer(config *repo.Config, router router.Router, logger logrus.FieldLog
...
@@ -60,7 +60,7 @@ func NewServer(config *repo.Config, router router.Router, logger logrus.FieldLog
func
(
g
*
Server
)
Start
()
error
{
func
(
g
*
Server
)
Start
()
error
{
g
.
engine
.
Use
(
gin
.
Recovery
())
g
.
engine
.
Use
(
gin
.
Recovery
())
v1
:=
g
.
engine
.
Group
(
"/v1"
)
v1
:=
g
.
engine
.
Group
(
"/v1"
)
//g.engine.Use(gin.Recovery())
//
g.engine.Use(gin.Recovery())
{
{
v1
.
POST
(
client
.
RegisterAppchainUrl
,
g
.
registerAppchain
)
v1
.
POST
(
client
.
RegisterAppchainUrl
,
g
.
registerAppchain
)
v1
.
POST
(
client
.
UpdateAppchainUrl
,
g
.
updateAppchain
)
v1
.
POST
(
client
.
UpdateAppchainUrl
,
g
.
updateAppchain
)
...
...
cmd/sidecar/init.go
View file @
b587b9f6
...
@@ -55,7 +55,7 @@ func afterWork(ctx *cli.Context, path string) error {
...
@@ -55,7 +55,7 @@ func afterWork(ctx *cli.Context, path string) error {
config
.
Peer
.
Peers
=
make
([]
string
,
1
)
config
.
Peer
.
Peers
=
make
([]
string
,
1
)
}
}
config
.
Peer
.
Peers
[
0
]
=
fmt
.
Sprintf
(
"/ip4/127.0.0.1/tcp/4000/p2p/%s"
,
id
)
config
.
Peer
.
Peers
[
0
]
=
fmt
.
Sprintf
(
"/ip4/127.0.0.1/tcp/4000/p2p/%s"
,
id
)
file
,
err
:=
os
.
OpenFile
(
path
,
os
.
O_RDWR
|
os
.
O_TRUNC
|
os
.
O_CREATE
,
os
.
FileMode
(
0766
))
file
,
err
:=
os
.
OpenFile
(
path
,
os
.
O_RDWR
|
os
.
O_TRUNC
|
os
.
O_CREATE
,
os
.
FileMode
(
0
o
766
))
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
cmd/sidecar/tool.go
View file @
b587b9f6
...
@@ -106,5 +106,5 @@ var toolCMD = cli.Command{
...
@@ -106,5 +106,5 @@ var toolCMD = cli.Command{
},
},
}
}
//key.json -> user private key|-> id
//
key.json -> user private key|-> id
// |-> address
// |-> address
internal/app/sidecar.go
View file @
b587b9f6
...
@@ -36,6 +36,7 @@ type App struct {
...
@@ -36,6 +36,7 @@ type App struct {
manger
internal
.
Launcher
manger
internal
.
Launcher
apiServer
*
api
.
Server
apiServer
*
api
.
Server
managerPort
*
appchain
.
Manager
}
}
// NewSidecar instantiates sidecar instance.
// NewSidecar instantiates sidecar instance.
...
@@ -43,7 +44,7 @@ func NewSidecar(repoRoot string, config *repo.Config) (internal.Launcher, error)
...
@@ -43,7 +44,7 @@ func NewSidecar(repoRoot string, config *repo.Config) (internal.Launcher, error)
store
,
err
:=
leveldb
.
New
(
filepath
.
Join
(
config
.
RepoRoot
,
"store"
))
store
,
err
:=
leveldb
.
New
(
filepath
.
Join
(
config
.
RepoRoot
,
"store"
))
tool
.
Asset
(
err
)
tool
.
Asset
(
err
)
logger
:=
loggers
.
Logger
(
loggers
.
App
)
logger
:=
loggers
.
Logger
(
loggers
.
App
)
//TODO add bls sign
//
TODO add bls sign
privateKey
,
err
:=
repo
.
LoadPrivateKey
(
repoRoot
)
privateKey
,
err
:=
repo
.
LoadPrivateKey
(
repoRoot
)
tool
.
Asset
(
err
)
tool
.
Asset
(
err
)
addr
,
err
:=
privateKey
.
PublicKey
()
.
Address
()
addr
,
err
:=
privateKey
.
PublicKey
()
.
Address
()
...
@@ -64,7 +65,7 @@ func NewSidecar(repoRoot string, config *repo.Config) (internal.Launcher, error)
...
@@ -64,7 +65,7 @@ func NewSidecar(repoRoot string, config *repo.Config) (internal.Launcher, error)
// TODO hub client
// TODO hub client
// privateKey DH
// privateKey DH
cryptor
:=
txcrypto
.
NewCryptor
(
nil
,
appchainMgr
,
privateKey
)
cryptor
:=
txcrypto
.
NewCryptor
(
nil
,
appchainMgr
,
privateKey
)
managerPort
:=
appchain
.
NewManager
(
store
,
clients
,
cryptor
,
logger
)
managerPort
:=
appchain
.
NewManager
(
clients
,
cryptor
,
logger
)
r
.
Adds
(
managerPort
.
Ports
())
r
.
Adds
(
managerPort
.
Ports
())
rule
:=
rulemgr
.
New
(
store
,
loggers
.
Logger
(
loggers
.
RuleMgr
))
rule
:=
rulemgr
.
New
(
store
,
loggers
.
Logger
(
loggers
.
RuleMgr
))
mg
,
err
:=
manager
.
NewManager
(
addr
.
String
(),
pm
,
appchainMgr
,
rule
,
loggers
.
Logger
(
loggers
.
Manager
))
mg
,
err
:=
manager
.
NewManager
(
addr
.
String
(),
pm
,
appchainMgr
,
rule
,
loggers
.
Logger
(
loggers
.
Manager
))
...
@@ -79,6 +80,7 @@ func NewSidecar(repoRoot string, config *repo.Config) (internal.Launcher, error)
...
@@ -79,6 +80,7 @@ func NewSidecar(repoRoot string, config *repo.Config) (internal.Launcher, error)
config
:
config
,
config
:
config
,
manger
:
mg
,
manger
:
mg
,
apiServer
:
apiServer
,
apiServer
:
apiServer
,
managerPort
:
managerPort
,
},
nil
},
nil
}
}
...
@@ -88,6 +90,10 @@ func (s *App) Start() error {
...
@@ -88,6 +90,10 @@ func (s *App) Start() error {
return
err
return
err
}
}
if
err
:=
s
.
managerPort
.
Start
();
err
!=
nil
{
return
err
}
return
s
.
manger
.
Start
()
return
s
.
manger
.
Start
()
}
}
...
@@ -96,5 +102,10 @@ func (s *App) Stop() error {
...
@@ -96,5 +102,10 @@ func (s *App) Stop() error {
if
err
:=
s
.
apiServer
.
Stop
();
err
!=
nil
{
if
err
:=
s
.
apiServer
.
Stop
();
err
!=
nil
{
return
err
return
err
}
}
if
err
:=
s
.
managerPort
.
Stop
();
err
!=
nil
{
return
err
}
return
s
.
manger
.
Stop
()
return
s
.
manger
.
Stop
()
}
}
internal/appchain/appchain.go
View file @
b587b9f6
...
@@ -34,8 +34,8 @@ type appChain struct {
...
@@ -34,8 +34,8 @@ type appChain struct {
msgCh
chan
*
pb
.
Message
msgCh
chan
*
pb
.
Message
}
}
func
NewPort
(
client
plugins
.
Client
,
cryptor
txcrypto
.
Cryptor
,
logger
logrus
.
FieldLogger
)
port
.
Port
{
func
newAppchain
(
ctx
context
.
Context
,
client
plugins
.
Client
,
cryptor
txcrypto
.
Cryptor
,
logger
logrus
.
FieldLogger
)
*
appChain
{
ctx
,
cancel
:=
context
.
WithCancel
(
c
ontext
.
Background
()
)
ctx
,
cancel
:=
context
.
WithCancel
(
c
tx
)
return
&
appChain
{
return
&
appChain
{
client
:
client
,
client
:
client
,
cryptor
:
cryptor
,
cryptor
:
cryptor
,
...
@@ -47,10 +47,10 @@ func NewPort(client plugins.Client, cryptor txcrypto.Cryptor, logger logrus.Fiel
...
@@ -47,10 +47,10 @@ func NewPort(client plugins.Client, cryptor txcrypto.Cryptor, logger logrus.Fiel
}
}
}
}
func
NewPorts
(
clients
[]
plugins
.
Client
,
cryptor
txcrypto
.
Cryptor
,
logger
logrus
.
FieldLogger
)
[]
port
.
Port
{
func
newAppchains
(
ctx
context
.
Context
,
clients
[]
plugins
.
Client
,
cryptor
txcrypto
.
Cryptor
,
logger
logrus
.
FieldLogger
)
[]
*
appChain
{
var
ps
[]
port
.
Port
var
ps
[]
*
appChain
for
_
,
c
:=
range
clients
{
for
_
,
c
:=
range
clients
{
p
:=
NewPort
(
c
,
cryptor
,
logger
)
p
:=
newAppchain
(
ctx
,
c
,
cryptor
,
logger
)
ps
=
append
(
ps
,
p
)
ps
=
append
(
ps
,
p
)
}
}
...
@@ -247,6 +247,10 @@ func (a *appChain) Start() error {
...
@@ -247,6 +247,10 @@ func (a *appChain) Start() error {
// Stop implements Monitor
// Stop implements Monitor
func
(
a
*
appChain
)
Stop
()
error
{
func
(
a
*
appChain
)
Stop
()
error
{
err
:=
a
.
client
.
Stop
()
if
err
!=
nil
{
return
err
}
a
.
cancel
()
a
.
cancel
()
a
.
logger
.
Info
(
"Monitor stopped"
)
a
.
logger
.
Info
(
"Monitor stopped"
)
return
nil
return
nil
...
...
internal/appchain/manager.go
View file @
b587b9f6
...
@@ -3,7 +3,6 @@ package appchain
...
@@ -3,7 +3,6 @@ package appchain
import
(
import
(
"context"
"context"
"github.com/meshplus/bitxhub-kit/storage"
"github.com/sirupsen/logrus"
"github.com/sirupsen/logrus"
"gitlab.33.cn/link33/sidecar/internal/port"
"gitlab.33.cn/link33/sidecar/internal/port"
...
@@ -14,43 +13,45 @@ import (
...
@@ -14,43 +13,45 @@ import (
type
Manager
struct
{
type
Manager
struct
{
ctx
context
.
Context
ctx
context
.
Context
cancel
context
.
CancelFunc
g
*
tool
.
Group
g
*
tool
.
Group
clients
[]
plugins
.
Client
appChains
[]
*
appChain
store
storage
.
Storage
cryptor
txcrypto
.
Cryptor
logger
logrus
.
FieldLogger
}
}
func
NewManager
(
store
storage
.
Storage
,
clients
[]
plugins
.
Client
,
cryptor
txcrypto
.
Cryptor
,
logger
logrus
.
FieldLogger
)
*
Manager
{
func
NewManager
(
clients
[]
plugins
.
Client
,
cryptor
txcrypto
.
Cryptor
,
logger
logrus
.
FieldLogger
)
*
Manager
{
g
,
ctx
:=
tool
.
WithContext
(
context
.
Background
())
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
g
,
_
:=
tool
.
WithContext
(
ctx
)
return
&
Manager
{
return
&
Manager
{
ctx
:
ctx
,
ctx
:
ctx
,
cancel
:
cancel
,
g
:
g
,
g
:
g
,
clients
:
clients
,
appChains
:
newAppchains
(
ctx
,
clients
,
cryptor
,
logger
),
store
:
store
,
cryptor
:
cryptor
,
logger
:
logger
,
}
}
}
}
func
(
m
*
Manager
)
Start
()
error
{
func
(
m
*
Manager
)
Start
()
error
{
for
_
,
client
:=
range
m
.
client
s
{
for
_
,
appChain
:=
range
m
.
appChain
s
{
m
.
g
.
Go
(
func
()
error
{
m
.
g
.
Go
(
func
()
error
{
return
client
.
Start
()
return
appChain
.
Start
()
})
})
}
}
return
m
.
g
.
Wait
()
return
m
.
g
.
Wait
()
}
}
func
(
m
*
Manager
)
Stop
()
error
{
func
(
m
*
Manager
)
Stop
()
error
{
for
_
,
client
:=
range
m
.
client
s
{
for
_
,
appChain
:=
range
m
.
appChain
s
{
m
.
g
.
Go
(
func
()
error
{
m
.
g
.
Go
(
func
()
error
{
return
client
.
Stop
()
return
appChain
.
Stop
()
})
})
}
}
m
.
cancel
()
return
m
.
g
.
Wait
()
return
m
.
g
.
Wait
()
}
}
func
(
m
*
Manager
)
Ports
()
[]
port
.
Port
{
func
(
m
*
Manager
)
Ports
()
[]
port
.
Port
{
return
NewPorts
(
m
.
clients
,
m
.
cryptor
,
m
.
logger
)
var
ports
[]
port
.
Port
for
_
,
appChain
:=
range
m
.
appChains
{
ports
=
append
(
ports
,
appChain
)
}
return
ports
}
}
internal/appchain/port.go
View file @
b587b9f6
...
@@ -47,7 +47,7 @@ func (a *appChain) Send(msg *pb.Message) (*pb.Message, error) {
...
@@ -47,7 +47,7 @@ func (a *appChain) Send(msg *pb.Message) (*pb.Message, error) {
return
nil
,
errors
.
New
(
"ibtp wrong"
)
return
nil
,
errors
.
New
(
"ibtp wrong"
)
}
}
if
ibtp
.
Type
==
pb
.
IBTP_RECEIPT_FAILURE
||
pb
.
IBTP_RECEIPT_SUCCESS
==
ibtp
.
Type
{
if
ibtp
.
Type
==
pb
.
IBTP_RECEIPT_FAILURE
||
pb
.
IBTP_RECEIPT_SUCCESS
==
ibtp
.
Type
{
//TODO 默认路由
//
TODO 默认路由
ix
:=
pb
.
IBTPX
{
ix
:=
pb
.
IBTPX
{
Ibtp
:
ibtp
,
Ibtp
:
ibtp
,
Mode
:
repo
.
DirectMode
,
Mode
:
repo
.
DirectMode
,
...
...
internal/lite/direct_lite/lite.go
View file @
b587b9f6
...
@@ -2,8 +2,7 @@ package direct_lite
...
@@ -2,8 +2,7 @@ package direct_lite
import
"gitlab.33.cn/link33/sidecar/model/pb"
import
"gitlab.33.cn/link33/sidecar/model/pb"
type
MockLite
struct
{
type
MockLite
struct
{}
}
func
(
lite
*
MockLite
)
Start
()
error
{
func
(
lite
*
MockLite
)
Start
()
error
{
return
nil
return
nil
...
...
internal/lite/hub_lite/header.go
View file @
b587b9f6
...
@@ -74,7 +74,6 @@ func (lite *HubLite) syncBlock() {
...
@@ -74,7 +74,6 @@ func (lite *HubLite) syncBlock() {
return
nil
return
nil
},
strategy
.
Wait
(
1
*
time
.
Second
))
},
strategy
.
Wait
(
1
*
time
.
Second
))
if
err
!=
nil
{
if
err
!=
nil
{
lite
.
logger
.
Panic
(
err
)
lite
.
logger
.
Panic
(
err
)
}
}
...
...
internal/router/router.go
View file @
b587b9f6
...
@@ -243,7 +243,7 @@ func (r *router) sign(ibtpx *pb.IBTPX) error {
...
@@ -243,7 +243,7 @@ func (r *router) sign(ibtpx *pb.IBTPX) error {
if
ok
{
if
ok
{
sign
:=
p
.
SignByte
(
ibtpx
.
FrontPart
())
sign
:=
p
.
SignByte
(
ibtpx
.
FrontPart
())
if
len
(
ibtpx
.
RouteSign
)
>
0
&&
ibtpx
.
RouteSign
[
0
]
!=
""
{
if
len
(
ibtpx
.
RouteSign
)
>
0
&&
ibtpx
.
RouteSign
[
0
]
!=
""
{
var
aggSign
=
bls
.
Sign
{}
aggSign
:
=
bls
.
Sign
{}
if
err
:=
aggSign
.
DeserializeHexStr
(
ibtpx
.
RouteSign
[
0
]);
err
!=
nil
{
if
err
:=
aggSign
.
DeserializeHexStr
(
ibtpx
.
RouteSign
[
0
]);
err
!=
nil
{
return
err
return
err
}
}
...
@@ -255,7 +255,7 @@ func (r *router) sign(ibtpx *pb.IBTPX) error {
...
@@ -255,7 +255,7 @@ func (r *router) sign(ibtpx *pb.IBTPX) error {
}
}
ibtpx
.
RouteSign
[
0
]
=
sign
.
SerializeToHexStr
()
ibtpx
.
RouteSign
[
0
]
=
sign
.
SerializeToHexStr
()
}
}
//TODO append publicKey
//
TODO append publicKey
ibtpx
.
RouteSign
=
append
(
ibtpx
.
RouteSign
,
p
.
GetPublicKey
()
.
SerializeToHexStr
())
ibtpx
.
RouteSign
=
append
(
ibtpx
.
RouteSign
,
p
.
GetPublicKey
()
.
SerializeToHexStr
())
}
else
{
}
else
{
hash
:=
ibtpx
.
Hash
()
hash
:=
ibtpx
.
Hash
()
...
@@ -297,7 +297,7 @@ func (r *router) aggVerify(ibtpx *pb.IBTPX) bool {
...
@@ -297,7 +297,7 @@ func (r *router) aggVerify(ibtpx *pb.IBTPX) bool {
}
}
pks
:=
&
blseth
.
PublicKey
{}
pks
:=
&
blseth
.
PublicKey
{}
for
_
,
val
:=
range
ibtpx
.
RouteSign
[
1
:
]
{
for
_
,
val
:=
range
ibtpx
.
RouteSign
[
1
:
]
{
var
pub
=
&
blseth
.
PublicKey
{}
pub
:
=
&
blseth
.
PublicKey
{}
_
=
pub
.
DeserializeHexStr
(
val
)
_
=
pub
.
DeserializeHexStr
(
val
)
pks
.
Add
(
pub
)
pks
.
Add
(
pub
)
}
}
...
...
internal/txcrypto/cryptor.go
View file @
b587b9f6
...
@@ -64,7 +64,7 @@ func (d *cryptor) getDesKey(address string, mode string) (crypto.SymmetricKey, e
...
@@ -64,7 +64,7 @@ func (d *cryptor) getDesKey(address string, mode string) (crypto.SymmetricKey, e
}
}
}
}
if
mode
==
repo
.
RelayMode
{
if
mode
==
repo
.
RelayMode
{
//TODO fix bug
//
TODO fix bug
rp
,
err
:=
d
.
client
.
InvokeBVMContract
(
constant
.
AppchainMgrContractAddr
.
Address
(),
"GetPubKeyByChainID"
,
nil
,
rpcx
.
String
(
address
))
rp
,
err
:=
d
.
client
.
InvokeBVMContract
(
constant
.
AppchainMgrContractAddr
.
Address
(),
"GetPubKeyByChainID"
,
nil
,
rpcx
.
String
(
address
))
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
...
model/pb/ibtpx_test.go
View file @
b587b9f6
...
@@ -44,7 +44,7 @@ func TestSign(t *testing.T) {
...
@@ -44,7 +44,7 @@ func TestSign(t *testing.T) {
assert
.
True
(
t
,
testVerify
(
p
,
ibtpx
))
assert
.
True
(
t
,
testVerify
(
p
,
ibtpx
))
t
.
Log
(
ibtpx
.
RouteSign
[
0
])
t
.
Log
(
ibtpx
.
RouteSign
[
0
])
//create other private key
//
create other private key
otherPrivateKey
,
err
:=
bls
.
GenerateKeyPair
(
bls
.
BlsEth
)
otherPrivateKey
,
err
:=
bls
.
GenerateKeyPair
(
bls
.
BlsEth
)
assert
.
Nil
(
t
,
err
)
assert
.
Nil
(
t
,
err
)
assert
.
NotNil
(
t
,
otherPrivateKey
)
assert
.
NotNil
(
t
,
otherPrivateKey
)
...
@@ -68,7 +68,7 @@ func TestSign(t *testing.T) {
...
@@ -68,7 +68,7 @@ func TestSign(t *testing.T) {
func
testSign
(
p
*
bls
.
PrivateKey
,
ibtpx
*
IBTPX
)
error
{
func
testSign
(
p
*
bls
.
PrivateKey
,
ibtpx
*
IBTPX
)
error
{
sign
:=
p
.
SignByte
(
ibtpx
.
FrontPart
())
sign
:=
p
.
SignByte
(
ibtpx
.
FrontPart
())
if
len
(
ibtpx
.
RouteSign
)
>
0
&&
ibtpx
.
RouteSign
[
0
]
!=
""
{
if
len
(
ibtpx
.
RouteSign
)
>
0
&&
ibtpx
.
RouteSign
[
0
]
!=
""
{
var
aggSign
=
bls
.
Sign
{}
aggSign
:
=
bls
.
Sign
{}
if
err
:=
aggSign
.
DeserializeHexStr
(
ibtpx
.
RouteSign
[
0
]);
err
!=
nil
{
if
err
:=
aggSign
.
DeserializeHexStr
(
ibtpx
.
RouteSign
[
0
]);
err
!=
nil
{
return
err
return
err
}
}
...
@@ -80,7 +80,7 @@ func testSign(p *bls.PrivateKey, ibtpx *IBTPX) error {
...
@@ -80,7 +80,7 @@ func testSign(p *bls.PrivateKey, ibtpx *IBTPX) error {
}
}
ibtpx
.
RouteSign
[
0
]
=
sign
.
SerializeToHexStr
()
ibtpx
.
RouteSign
[
0
]
=
sign
.
SerializeToHexStr
()
}
}
//TODO append publicKey
//
TODO append publicKey
ibtpx
.
RouteSign
=
append
(
ibtpx
.
RouteSign
,
p
.
GetPublicKey
()
.
SerializeToHexStr
())
ibtpx
.
RouteSign
=
append
(
ibtpx
.
RouteSign
,
p
.
GetPublicKey
()
.
SerializeToHexStr
())
return
nil
return
nil
}
}
...
@@ -106,7 +106,7 @@ func testAggVerify(ibtpx *IBTPX) bool {
...
@@ -106,7 +106,7 @@ func testAggVerify(ibtpx *IBTPX) bool {
}
}
pks
:=
&
blseth
.
PublicKey
{}
pks
:=
&
blseth
.
PublicKey
{}
for
_
,
val
:=
range
ibtpx
.
RouteSign
[
1
:
]
{
for
_
,
val
:=
range
ibtpx
.
RouteSign
[
1
:
]
{
var
pub
=
&
blseth
.
PublicKey
{}
pub
:
=
&
blseth
.
PublicKey
{}
_
=
pub
.
DeserializeHexStr
(
val
)
_
=
pub
.
DeserializeHexStr
(
val
)
pks
.
Add
(
pub
)
pks
.
Add
(
pub
)
}
}
...
@@ -116,33 +116,33 @@ func testAggVerify(ibtpx *IBTPX) bool {
...
@@ -116,33 +116,33 @@ func testAggVerify(ibtpx *IBTPX) bool {
}
}
}
}
//1、签名是我签的,防伪证明。
//
1、签名是我签的,防伪证明。
//2、所有的各个不同人的签名又能聚合在一起。压缩签名。(线性压缩)
//
2、所有的各个不同人的签名又能聚合在一起。压缩签名。(线性压缩)
//3、通过聚合签名(压缩签名),也能验证是我签过名。
//
3、通过聚合签名(压缩签名),也能验证是我签过名。
//4、签名身份被替换。无法做到抵赖(修改签名本身)。
//
4、签名身份被替换。无法做到抵赖(修改签名本身)。
//5、私自追加签名。无法被感知(串改)。
//
5、私自追加签名。无法被感知(串改)。
//6、选择最少的那个。
//
6、选择最少的那个。
//解决以上问题,就可以了。
//
解决以上问题,就可以了。
//简单经济模型:
//
简单经济模型:
//1、发送者提供资金(起始点);
//
1、发送者提供资金(起始点);
//2、路由者获得奖励(中间点);
//
2、路由者获得奖励(中间点);
//3、接收者作为结速点(中间点);
//
3、接收者作为结速点(中间点);
//4、中继链裁决方分配(裁决)。
//
4、中继链裁决方分配(裁决)。
//裁决方案:奖励金额最大、路由节点最少、速度最快方案裁决。
//
裁决方案:奖励金额最大、路由节点最少、速度最快方案裁决。
//不同私钥对各自公钥的证明可以聚合。
//
不同私钥对各自公钥的证明可以聚合。
//不同私钥对不同消息的证明可以聚合。
//
不同私钥对不同消息的证明可以聚合。
//不同私钥对不同消息的证明可以聚合。
//
不同私钥对不同消息的证明可以聚合。
//不同私钥对相同消息的证明可以聚合。
//
不同私钥对相同消息的证明可以聚合。
//相同私钥对不同消息的证明可以聚合。
//
相同私钥对不同消息的证明可以聚合。
//无证书聚合签名方案
//
无证书聚合签名方案
//不同私钥对各自公钥的证明可以聚合。
//
不同私钥对各自公钥的证明可以聚合。
//不同私钥对不同消息的证明可以聚合。
//
不同私钥对不同消息的证明可以聚合。
//不同私钥对不同消息的证明可以聚合。
//
不同私钥对不同消息的证明可以聚合。
//不同私钥对相同消息的证明可以聚合。
//
不同私钥对相同消息的证明可以聚合。
//相同私钥对不同消息的证明可以聚合。
//
相同私钥对不同消息的证明可以聚合。
//无证书聚合签名方案
//
无证书聚合签名方案
model/pb/message.pb.go
View file @
b587b9f6
...
@@ -35,7 +35,7 @@ const (
...
@@ -35,7 +35,7 @@ const (
Message_APPCHAIN_GET
Message_Type
=
4
Message_APPCHAIN_GET
Message_Type
=
4
Message_INTERCHAIN_META_GET
Message_Type
=
5
Message_INTERCHAIN_META_GET
Message_Type
=
5
Message_RULE_DEPLOY
Message_Type
=
6
Message_RULE_DEPLOY
Message_Type
=
6
//异步完成
//
异步完成
Message_IBTP_GET
Message_Type
=
7
Message_IBTP_GET
Message_Type
=
7
Message_IBTP_SEND
Message_Type
=
8
Message_IBTP_SEND
Message_Type
=
8
Message_IBTP_RECEIPT_SEND
Message_Type
=
9
Message_IBTP_RECEIPT_SEND
Message_Type
=
9
...
...
pkg/crypto/bls/bls_test.go
View file @
b587b9f6
...
@@ -159,15 +159,15 @@ func TestBlsAggregateVerify(t *testing.T) {
...
@@ -159,15 +159,15 @@ func TestBlsAggregateVerify(t *testing.T) {
t
.
Log
(
sign3
.
VerifyPop
(
pub3
))
t
.
Log
(
sign3
.
VerifyPop
(
pub3
))
assert
.
True
(
t
,
sign
.
Verify
(
pub
,
m
))
assert
.
True
(
t
,
sign
.
Verify
(
pub
,
m
))
//assert.True(t, sign.VerifyPop(pub1))
//
assert.True(t, sign.VerifyPop(pub1))
t
.
Log
(
sec
.
GetPop
()
.
SerializeToHexStr
())
t
.
Log
(
sec
.
GetPop
()
.
SerializeToHexStr
())
t
.
Log
(
sec
.
GetPop
()
.
SerializeToHexStr
())
t
.
Log
(
sec
.
GetPop
()
.
SerializeToHexStr
())
assert
.
False
(
t
,
sec
.
GetPop
()
.
VerifyPop
(
pub1
))
assert
.
False
(
t
,
sec
.
GetPop
()
.
VerifyPop
(
pub1
))
assert
.
False
(
t
,
sec
.
GetPop
()
.
VerifyPop
(
pub
))
assert
.
False
(
t
,
sec
.
GetPop
()
.
VerifyPop
(
pub
))
//assert.True(t,sec.GetPop().VerifyPop(pub))
//
assert.True(t,sec.GetPop().VerifyPop(pub))
assert
.
True
(
t
,
sec1
.
GetPop
()
.
VerifyPop
(
pub1
))
//Verify self public key
assert
.
True
(
t
,
sec1
.
GetPop
()
.
VerifyPop
(
pub1
))
//
Verify self public key
assert
.
False
(
t
,
sign
.
Verify
(
pub1
,
m
))
assert
.
False
(
t
,
sign
.
Verify
(
pub1
,
m
))
assert
.
False
(
t
,
sign
.
Verify
(
sec
.
GetPublicKey
(),
m
))
assert
.
False
(
t
,
sign
.
Verify
(
sec
.
GetPublicKey
(),
m
))
...
@@ -251,7 +251,6 @@ func TestAggregate(t *testing.T) {
...
@@ -251,7 +251,6 @@ func TestAggregate(t *testing.T) {
if
!
bls
.
VerifyPairing
(
aggSign
,
hashPt
,
pub
)
{
if
!
bls
.
VerifyPairing
(
aggSign
,
hashPt
,
pub
)
{
t
.
Errorf
(
"aggregate2"
)
t
.
Errorf
(
"aggregate2"
)
}
}
}
}
func
TestIsSign
(
t
*
testing
.
T
)
{
func
TestIsSign
(
t
*
testing
.
T
)
{
...
@@ -317,7 +316,7 @@ func TestHash(t *testing.T) {
...
@@ -317,7 +316,7 @@ func TestHash(t *testing.T) {
sig2
:=
sec
.
SignHash
(
h
)
sig2
:=
sec
.
SignHash
(
h
)
t
.
Log
(
sig1
.
SerializeToHexStr
())
t
.
Log
(
sig1
.
SerializeToHexStr
())
t
.
Log
(
sig2
.
SerializeToHexStr
())
t
.
Log
(
sig2
.
SerializeToHexStr
())
//TODO fix bug?
//
TODO fix bug?
if
sig1
.
IsEqual
(
sig2
)
{
if
sig1
.
IsEqual
(
sig2
)
{
t
.
Errorf
(
"SignHash"
)
t
.
Errorf
(
"SignHash"
)
}
}
...
...
pkg/validator/validatorlib/complex_policy.go
View file @
b587b9f6
...
@@ -4,6 +4,7 @@ package validatorlib
...
@@ -4,6 +4,7 @@ package validatorlib
//
//
// extern int32_t fabric_validate_v14(void *context, long long proof_ptr, long long validator_ptr, long long payload_ptr);
// extern int32_t fabric_validate_v14(void *context, long long proof_ptr, long long validator_ptr, long long payload_ptr);
import
"C"
import
"C"
import
(
import
(
"unsafe"
"unsafe"
...
...
pkg/validator/validatorlib/ecdsa.go
View file @
b587b9f6
...
@@ -4,6 +4,7 @@ package validatorlib
...
@@ -4,6 +4,7 @@ package validatorlib
//
//
// extern int32_t ecdsa_verify(void *context, long long sig_ptr, long long digest_ptr, long long pubkey_ptr, int32_t opt);
// extern int32_t ecdsa_verify(void *context, long long sig_ptr, long long digest_ptr, long long pubkey_ptr, int32_t opt);
import
"C"
import
"C"
import
(
import
(
"bytes"
"bytes"
"crypto"
"crypto"
...
...
pkg/validator/validatorlib/fabric_validation.go
View file @
b587b9f6
...
@@ -2,9 +2,10 @@ package validatorlib
...
@@ -2,9 +2,10 @@ package validatorlib
import
(
import
(
"fmt"
"fmt"
"gitlab.33.cn/link33/sidecar/pkg/json"
"strings"
"strings"
"gitlab.33.cn/link33/sidecar/pkg/json"
"github.com/gogo/protobuf/proto"
"github.com/gogo/protobuf/proto"
mb
"github.com/hyperledger/fabric-protos-go/msp"
mb
"github.com/hyperledger/fabric-protos-go/msp"
"github.com/hyperledger/fabric-protos-go/peer"
"github.com/hyperledger/fabric-protos-go/peer"
...
...
pkg/validator/wasm_validator.go
View file @
b587b9f6
...
@@ -2,10 +2,11 @@ package validator
...
@@ -2,10 +2,11 @@ package validator
import
(
import
(
"fmt"
"fmt"
"gitlab.33.cn/link33/sidecar/pkg/json"
"strconv"
"strconv"
"sync"
"sync"
"gitlab.33.cn/link33/sidecar/pkg/json"
"github.com/gogo/protobuf/proto"
"github.com/gogo/protobuf/proto"
"github.com/meshplus/bitxhub-kit/types"
"github.com/meshplus/bitxhub-kit/types"
"github.com/sirupsen/logrus"
"github.com/sirupsen/logrus"
...
...
pkg/validator/wasm_validator_test.go
View file @
b587b9f6
package
validator
package
validator
import
(
import
(
"gitlab.33.cn/link33/sidecar/pkg/json"
"fmt"
"fmt"
"io/ioutil"
"io/ioutil"
"strconv"
"strconv"
"sync"
"sync"
"testing"
"testing"
"gitlab.33.cn/link33/sidecar/pkg/json"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
"gitlab.33.cn/link33/sidecar/model/pb"
"gitlab.33.cn/link33/sidecar/model/pb"
...
...
pkg/wasm/wasm.go
View file @
b587b9f6
...
@@ -2,10 +2,11 @@ package wasm
...
@@ -2,10 +2,11 @@ package wasm
import
(
import
(
"fmt"
"fmt"
"gitlab.33.cn/link33/sidecar/pkg/json"
"strconv"
"strconv"
"sync"
"sync"
"gitlab.33.cn/link33/sidecar/pkg/json"
"github.com/gogo/protobuf/proto"
"github.com/gogo/protobuf/proto"
"github.com/meshplus/bitxhub-kit/types"
"github.com/meshplus/bitxhub-kit/types"
"github.com/wasmerio/go-ext-wasm/wasmer"
"github.com/wasmerio/go-ext-wasm/wasmer"
...
...
pkg/wasm/wasm_test.go
View file @
b587b9f6
package
wasm
package
wasm
import
(
import
(
"gitlab.33.cn/link33/sidecar/pkg/json"
"fmt"
"fmt"
"io/ioutil"
"io/ioutil"
"sync"
"sync"
"testing"
"testing"
"gitlab.33.cn/link33/sidecar/pkg/json"
"github.com/meshplus/bitxhub-kit/types"
"github.com/meshplus/bitxhub-kit/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/assert"
"github.com/wasmerio/go-ext-wasm/wasmer"
"github.com/wasmerio/go-ext-wasm/wasmer"
...
...
tool/tool.go
View file @
b587b9f6
...
@@ -72,11 +72,11 @@ func Exist(path string) bool {
...
@@ -72,11 +72,11 @@ func Exist(path string) bool {
// https://github.com/bluele/gcache
// https://github.com/bluele/gcache
// https://github.com/goburrow/cache
// https://github.com/goburrow/cache
//Scan git repos (or files) for secrets using regex and entropy 🔑
//
Scan git repos (or files) for secrets using regex and entropy 🔑
//https://github.com/zricethezav/gitleaks
//
https://github.com/zricethezav/gitleaks
//https://github.com/casbin/casbin
//
https://github.com/casbin/casbin
//https://github.com/casbin/casbin
//
https://github.com/casbin/casbin
//https://github.com/casbin/casbin
//
https://github.com/casbin/casbin
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