Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
A
app-hive
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Privacy statement
Keyboard shortcuts
?
What's new
6
Snippets
Groups
Projects
Show more breadcrumbs
engrave
ledger
app-hive
Commits
fd3cc020
Commit
fd3cc020
authored
2 years ago
by
Bartłomiej Górnicki
Browse files
Options
Downloads
Patches
Plain Diff
chore: additional signMessage test
parent
153c1f11
Branches
Branches containing commit
No related tags found
1 merge request
!5
1.2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/tests/signMessage.test.ts
+27
-1
27 additions, 1 deletion
test/tests/signMessage.test.ts
with
27 additions
and
1 deletion
test/tests/signMessage.test.ts
+
27
−
1
View file @
fd3cc020
...
...
@@ -2,13 +2,17 @@ import Transport from '@ledgerhq/hw-transport-node-speculos';
import
Hive
from
'
@engrave/ledger-app-hive
'
;
import
{
expect
}
from
'
chai
'
;
import
*
as
speculosButtons
from
'
../utils/speculosButtons
'
;
import
{
cryptoUtils
,
Signature
}
from
"
@hiveio/dhive
"
;
import
{
PublicKey
}
from
"
@hiveio/dhive/lib/crypto
"
;
const
prepareExpectedSignature
=
(
msg
:
string
,
expectedSignature
:
string
)
=>
({
msg
,
expectedSignature
});
describe
(
'
Sign message
'
,
async
()
=>
{
[
// short message
prepareExpectedSignature
(
'
Test
'
,
'
1f52721df9ed62bf7eb064547a3fa2443dc850e82eda7baa434c9fa1243f608155208ab694cc8e71295e593a2d4b5a33563eb4544b8d1c626f04e65951c49e2464
'
),
prepareExpectedSignature
(
'
{"msg": "This is a longer string imitating JSON"}
'
,
'
1f28bcb4ca91fdc92c407a63d297911e92814226ba79ce7803c7aaf9a1a055a2bc2e9591da1518be7f55c88317b7032a05e28bb47904c2fcc130ac9d32bfe797f5
'
),
// max length message
prepareExpectedSignature
(
'
x
'
.
repeat
(
512
),
'
2065458416d886ecc537eebb10dba459bd537fd3d651a877398d9dba38fda63ecb2412beca7e967de5f15ebc6a17b5f2d528f35ba4b7489b64a6a26dadc30ff91c
'
),
].
forEach
(
input
=>
{
it
(
`should properly sign message`
,
async
function
()
{
const
transport
=
await
Transport
.
open
({
apduPort
:
40000
,
buttonPort
:
5000
,
automationPort
:
5000
});
...
...
@@ -30,5 +34,27 @@ describe('Sign message', async () => {
}).
timeout
(
10000
)
})
it
(
'
should generate signature compatible with Hive Keychain
'
,
async
function
()
{
const
transport
=
await
Transport
.
open
({
apduPort
:
40000
,
buttonPort
:
5000
,
automationPort
:
5000
});
try
{
const
hive
=
new
Hive
(
transport
);
const
message
=
'
This is a message to sign
'
;
const
publicKey
=
await
hive
.
getPublicKey
(
`48'/13'/0'/0'/0'`
);
const
signingMsgPromise
=
hive
.
signMessage
(
message
,
`48'/13'/0'/0'/0'`
);
// accept message
await
speculosButtons
.
pressLeft
();
await
speculosButtons
.
pressLeft
();
await
speculosButtons
.
pressBoth
();
const
signature
=
await
signingMsgPromise
;
const
key
=
PublicKey
.
fromString
(
publicKey
);
const
isSignedByKey
=
key
.
verify
(
cryptoUtils
.
sha256
(
message
),
Signature
.
fromString
(
signature
));
expect
(
isSignedByKey
).
to
.
be
.
true
;
}
finally
{
await
transport
.
close
();
}
});
})
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment