Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nodemanager
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
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
Odysseus
nodemanager
Commits
318381ff
Commit
318381ff
authored
Mar 16, 2024
by
vicotor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update container signature verify
parent
c10dc2cd
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
9 deletions
+38
-9
taskresult.go
server/taskresult.go
+18
-9
crypto_test.go
utils/crypto_test.go
+20
-0
No files found.
server/taskresult.go
View file @
318381ff
...
@@ -77,16 +77,22 @@ func (wm *WorkerManager) computeTaskResult(worker *Worker, task *odysseus.TaskCo
...
@@ -77,16 +77,22 @@ func (wm *WorkerManager) computeTaskResult(worker *Worker, task *odysseus.TaskCo
if
len
(
signature
)
==
65
{
if
len
(
signature
)
==
65
{
signature
=
signature
[
:
64
]
signature
=
signature
[
:
64
]
}
}
pubkey
:=
utils
.
FromHex
(
string
(
task
.
ContainerPubkey
))
pubLen
:=
len
(
task
.
ContainerPubkey
)
if
len
(
pubkey
)
>
65
{
pubkey
:=
[]
byte
{}
pubkey
=
pubkey
[
:
65
]
if
pubLen
==
130
||
pubLen
==
132
{
pubkey
=
utils
.
FromHex
(
string
(
task
.
ContainerPubkey
))
}
else
if
pubLen
==
65
{
pubkey
=
task
.
ContainerPubkey
}
}
verified
:=
crypto
.
VerifySignature
(
pubkey
,
dataHash
[
:
],
signature
)
verified
:=
crypto
.
VerifySignature
(
pubkey
,
dataHash
[
:
],
signature
)
log
.
WithFields
(
log
.
Fields
{
log
.
WithFields
(
log
.
Fields
{
"containerSignatureVerify"
:
verified
,
"containerSignatureVerify"
:
verified
,
"taskkind"
:
task
.
TaskKind
,
"taskkind"
:
task
.
TaskKind
,
"containerPubkey"
:
string
(
task
.
ContainerPubkey
),
"dataHash"
:
hex
.
EncodeToString
(
dataHash
[
:
]),
"containerPubkey"
:
hex
.
EncodeToString
(
pubkey
),
"signature"
:
hex
.
EncodeToString
(
signature
),
})
.
Debug
(
"container signature verify"
)
})
.
Debug
(
"container signature verify"
)
if
!
verified
{
if
!
verified
{
// todo: handle signature verify failed
// todo: handle signature verify failed
...
@@ -182,10 +188,13 @@ func (wm *WorkerManager) standardTaskResult(worker *Worker, task *odysseus.TaskC
...
@@ -182,10 +188,13 @@ func (wm *WorkerManager) standardTaskResult(worker *Worker, task *odysseus.TaskC
if
len
(
signature
)
==
65
{
if
len
(
signature
)
==
65
{
signature
=
signature
[
:
64
]
signature
=
signature
[
:
64
]
}
}
pubkey
:=
task
.
ContainerPubkey
pubLen
:=
len
(
task
.
ContainerPubkey
)
//pubkey := utils.FromHex(string(task.ContainerPubkey))
pubkey
:=
[]
byte
{}
if
len
(
pubkey
)
>
65
{
pubkey
=
pubkey
[
:
65
]
if
pubLen
==
130
||
pubLen
==
132
{
pubkey
=
utils
.
FromHex
(
string
(
task
.
ContainerPubkey
))
}
else
if
pubLen
==
65
{
pubkey
=
task
.
ContainerPubkey
}
}
verified
:=
crypto
.
VerifySignature
(
pubkey
,
dataHash
[
:
],
signature
)
verified
:=
crypto
.
VerifySignature
(
pubkey
,
dataHash
[
:
],
signature
)
...
@@ -193,7 +202,7 @@ func (wm *WorkerManager) standardTaskResult(worker *Worker, task *odysseus.TaskC
...
@@ -193,7 +202,7 @@ func (wm *WorkerManager) standardTaskResult(worker *Worker, task *odysseus.TaskC
"containerSignatureVerify"
:
verified
,
"containerSignatureVerify"
:
verified
,
"taskkind"
:
task
.
TaskKind
,
"taskkind"
:
task
.
TaskKind
,
"dataHash"
:
hex
.
EncodeToString
(
dataHash
[
:
]),
"dataHash"
:
hex
.
EncodeToString
(
dataHash
[
:
]),
"containerPubkey"
:
hex
.
EncodeToString
(
task
.
ContainerP
ubkey
),
"containerPubkey"
:
hex
.
EncodeToString
(
p
ubkey
),
"signature"
:
hex
.
EncodeToString
(
signature
),
"signature"
:
hex
.
EncodeToString
(
signature
),
})
.
Debug
(
"container signature verify"
)
})
.
Debug
(
"container signature verify"
)
if
!
verified
{
if
!
verified
{
...
...
utils/crypto_test.go
View file @
318381ff
package
utils
package
utils
import
(
"github.com/ethereum/go-ethereum/crypto"
"github.com/magiconair/properties/assert"
"testing"
)
func
TestCombineBytes
(
t
*
testing
.
T
)
{
hash
:=
FromHex
(
"0xaa81f776e43511492b9db11894c71e7fdca3f09bd24dc1fe93f1e017e6eef947"
)
pubkey
:=
FromHex
(
"0423965c5d5b4c2fa03fe024cfbcd413db25e7c420b73bd5dccb78fada9e22d4848d32952c913ae0cdcc70efa38094dc49c05c6a0cec7e1712557050da7d7bd05a"
)
signature
:=
FromHex
(
"db2be765e420d3b67e695612a349090e9fe2446c6b7875d36a0e6268bc3619e14d24b93a5d8f7f55b9649ad3f5a636a886c480fbe6fb5c49f3b716c0ea66ea7a01"
)
if
len
(
signature
)
==
65
{
signature
=
signature
[
:
64
]
}
if
len
(
pubkey
)
>
65
{
pubkey
=
pubkey
[
:
65
]
}
verified
:=
crypto
.
VerifySignature
(
pubkey
,
hash
,
signature
)
assert
.
Equal
(
t
,
verified
,
true
)
}
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