FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
bitcore/test/test.Key.node.js at master · deckar01/bitcore · GitHub
deckar01
/
bitcore
Public
forked from
bitpay/bitcore
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
bitcore
/
test
/
test.Key.node.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
81 lines (72 loc) · 2.62 KB
Breadcrumbs
bitcore
/
test
/
test.Key.node.js
Copy path
File metadata and controls
81 lines (72 loc) · 2.62 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
var
chai
=
chai
||
require
(
'chai'
)
;
var
bitcore
=
bitcore
||
require
(
'../bitcore'
)
;
var
coinUtil
=
coinUtil
||
bitcore
.
util
;
var
buffertools
=
require
(
'buffertools'
)
;
var
should
=
chai
.
should
(
)
;
var
assert
=
chai
.
assert
;
var
Key
=
bitcore
.
Key
;
//addUncompressed is a node-only interface feature
if
(
typeof
process
!==
'undefined'
&&
process
.
versions
)
{
describe
(
'#Key.node'
,
function
(
)
{
describe
(
'#addUncompressed'
,
function
(
)
{
it
(
'should exist'
,
function
(
)
{
should
.
exist
(
Key
.
addUncompressed
)
;
}
)
;
it
(
'should add two uncompressed public keys'
,
function
(
)
{
var
key1
=
Key
.
generateSync
(
)
;
key1
.
compressed
=
false
;
var
key2
=
Key
.
generateSync
(
)
;
key2
.
compressed
=
false
;
var
pubkey1
=
key1
.
public
;
var
pubkey2
=
key2
.
public
;
var
pubkey
=
Key
.
addUncompressed
(
pubkey1
,
pubkey2
)
;
pubkey
.
length
.
should
.
equal
(
65
)
;
}
)
;
it
(
'a + b should equal b + a'
,
function
(
)
{
var
key1
=
Key
.
generateSync
(
)
;
key1
.
compressed
=
false
;
var
key2
=
Key
.
generateSync
(
)
;
key2
.
compressed
=
false
;
var
pubkey1
=
key1
.
public
;
var
pubkey2
=
key2
.
public
;
var
r1
=
Key
.
addUncompressed
(
pubkey1
,
pubkey2
)
;
var
r2
=
Key
.
addUncompressed
(
pubkey2
,
pubkey1
)
;
r1
.
toString
(
'hex'
)
.
should
.
equal
(
r2
.
toString
(
'hex'
)
)
;
}
)
;
it
(
'should be able to add these two public keys without error'
,
function
(
)
{
var
key1
=
new
Key
(
)
;
key1
.
private
=
coinUtil
.
sha256
(
"first "
+
3
)
;
key1
.
compressed
=
false
;
key1
.
regenerateSync
(
)
;
var
key2
=
new
Key
(
)
;
key2
.
private
=
coinUtil
.
sha256
(
"second "
+
3
)
;
key2
.
compressed
=
false
;
key2
.
regenerateSync
(
)
;
var
pubkey1
=
key1
.
public
;
var
pubkey2
=
key2
.
public
;
var
pubkey
=
Key
.
addUncompressed
(
pubkey1
,
pubkey2
)
;
pubkey
.
length
.
should
.
equal
(
65
)
;
var
key
=
new
Key
(
)
;
key
.
public
=
pubkey
;
assert
(
key
.
public
!==
null
)
;
}
)
;
}
)
;
describe
(
'node only Key functionality'
,
function
(
)
{
it
(
'should not fail when called as Key() without "new"'
,
function
(
)
{
var
key
=
Key
(
)
;
should
.
exist
(
key
)
;
}
)
;
it
(
'should not fail when called as Key() without "new" with some args'
,
function
(
)
{
var
key
=
Key
(
1
,
2
,
3
,
4
,
5
)
;
should
.
exist
(
key
)
;
}
)
;
it
(
'should have correct properties when called with Key() without "new"'
,
function
(
)
{
var
key
=
Key
(
)
;
key
.
compressed
.
should
.
equal
(
true
)
;
should
.
not
.
exist
(
key
.
public
)
;
should
.
not
.
exist
(
key
.
private
)
;
should
.
exist
(
key
)
;
}
)
;
}
)
;
}
)
;
}
Back
|
FazBrowse Home
|
New Git URL