Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
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
plugin
Commits
e4dacdad
Commit
e4dacdad
authored
Apr 26, 2020
by
madengji
Committed by
33cn
Jun 29, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bls sign commit part 2
parent
65ef1844
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
60 deletions
+0
-60
paracommitmsg.go
plugin/consensus/para/paracommitmsg.go
+0
-60
No files found.
plugin/consensus/para/paracommitmsg.go
View file @
e4dacdad
...
@@ -19,8 +19,6 @@ import (
...
@@ -19,8 +19,6 @@ import (
"bytes"
"bytes"
"math/big"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common/crypto"
"github.com/33cn/chain33/common/crypto"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
...
@@ -980,61 +978,3 @@ func (client *commitMsgClient) isSelfConsEnable(height int64) bool {
...
@@ -980,61 +978,3 @@ func (client *commitMsgClient) isSelfConsEnable(height int64) bool {
return
false
return
false
}
}
//to repeat get prikey's hash until in range of bls's private key
func
getBlsPriKey
(
key
[]
byte
)
*
g2pubs
.
SecretKey
{
var
newKey
[
common
.
Sha256Len
]
byte
copy
(
newKey
[
:
],
key
[
:
])
for
{
plog
.
Info
(
"para commit getBlsPriKey"
,
"keys"
,
common
.
ToHex
(
newKey
[
:
]))
secret
:=
g2pubs
.
DeserializeSecretKey
(
newKey
)
if
nil
!=
secret
.
GetFRElement
()
{
serial
:=
secret
.
Serialize
()
plog
.
Info
(
"para commit getBlsPriKey"
,
"final keys"
,
common
.
ToHex
(
serial
[
:
]),
"string"
,
secret
.
String
())
return
secret
}
copy
(
newKey
[
:
],
common
.
Sha256
(
newKey
[
:
]))
}
}
func
(
client
*
commitMsgClient
)
blsSign
(
commits
[]
*
pt
.
ParacrossCommitAction
)
error
{
nodeStr
,
err
:=
client
.
getNodeGroupAddrs
()
if
err
!=
nil
||
len
(
nodeStr
)
<=
0
{
plog
.
Info
(
"bls sign"
,
"nodestr"
,
nodeStr
,
"err"
,
err
)
return
types
.
ErrInvalidParam
}
nodes
:=
strings
.
Split
(
nodeStr
,
","
)
bitMap
,
remains
:=
setAddrsBitMap
(
nodes
,
[]
string
{
client
.
authAccount
})
if
len
(
remains
)
>
0
{
plog
.
Error
(
"bls sign addrs remains"
,
"remains"
,
remains
,
"nodestr"
,
nodeStr
,
"bitmap"
,
bitMap
,
"nodes"
,
nodes
)
}
if
remains
[
client
.
authAccount
]
{
plog
.
Error
(
"bls sign addrs miss setmap"
,
"auth"
,
client
.
authAccount
,
"remains"
,
remains
)
return
types
.
ErrInvalidParam
}
for
_
,
cmt
:=
range
commits
{
data
:=
types
.
Encode
(
cmt
.
Status
)
plog
.
Debug
(
"blsign msg"
,
"data"
,
common
.
ToHex
(
data
),
"height"
,
cmt
.
Status
.
Height
,
"map"
,
bitMap
)
sign
:=
g2pubs
.
Sign
(
data
,
client
.
blsPriKey
)
.
Serialize
()
cmt
.
Bls
=
&
pt
.
ParacrossCommitBlsInfo
{
Sign
:
sign
[
:
],
Addrs
:
bitMap
}
}
return
nil
}
//设置nodes范围内的bitmap,如果addrs在node不存在,也不设置,返回未命中的addrs
func
setAddrsBitMap
(
nodes
,
addrs
[]
string
)
([]
byte
,
map
[
string
]
bool
)
{
rst
:=
big
.
NewInt
(
0
)
addrsMap
:=
make
(
map
[
string
]
bool
)
for
_
,
n
:=
range
addrs
{
addrsMap
[
n
]
=
true
}
for
i
,
a
:=
range
nodes
{
if
_
,
exist
:=
addrsMap
[
a
];
exist
{
rst
.
SetBit
(
rst
,
i
,
1
)
delete
(
addrsMap
,
a
)
}
}
return
rst
.
Bytes
(),
addrsMap
}
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