FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JavaDataStructures/ECC/PrivateKey.java at master · benaich/JavaDataStructures · GitHub
benaich
/
JavaDataStructures
Public
Notifications
You must be signed in to change notification settings
Fork
7
Star
2
Code
Issues
0
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
JavaDataStructures
/
ECC
/
PrivateKey.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
61 lines (50 loc) · 1.57 KB
Breadcrumbs
JavaDataStructures
/
ECC
/
PrivateKey.java
Copy path
File metadata and controls
61 lines (50 loc) · 1.57 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
package
ECC
;
import
java
.
math
.
BigInteger
;
import
java
.
nio
.
charset
.
StandardCharsets
;
import
java
.
nio
.
file
.
Files
;
import
java
.
nio
.
file
.
Paths
;
import
java
.
util
.
List
;
/**
* The private key of the El Gamal Elliptic Curve Cryptography.
*
* The key consists of: c, the elliptic curve used in the calculations, k is the
* private key, a randomly-generated integer, satisfying 1 <= k < p-1.
*/
public
class
PrivateKey
{
private
EllipticCurve
c
;
private
BigInteger
k
;
public
PrivateKey
(
EllipticCurve
c
,
BigInteger
k
) {
this
.
c
=
c
;
this
.
k
=
k
;
}
public
PrivateKey
(
String
pathFile
) {
try
{
List
<
String
>
lines
=
Files
.
readAllLines
(
Paths
.
get
(
pathFile
),
StandardCharsets
.
UTF_8
);
BigInteger
a
=
new
BigInteger
(
lines
.
get
(
0
),
16
);
BigInteger
b
=
new
BigInteger
(
lines
.
get
(
1
),
16
);
BigInteger
p
=
new
BigInteger
(
lines
.
get
(
2
),
16
);
BigInteger
g1
=
new
BigInteger
(
lines
.
get
(
3
),
16
);
BigInteger
g2
=
new
BigInteger
(
lines
.
get
(
4
),
16
);
BigInteger
k
=
new
BigInteger
(
lines
.
get
(
5
),
16
);
EllipticCurve
eC
=
new
EllipticCurve
(
a
,
b
,
p
,
new
Point
(
g1
,
g2
));
this
.
c
=
eC
;
this
.
k
=
k
;
}
catch
(
Exception
e
) {
}
}
public
void
setCurve
(
EllipticCurve
c
) {
this
.
c
=
c
;
}
public
EllipticCurve
getCurve
() {
return
c
;
}
public
void
setKey
(
BigInteger
k
) {
this
.
k
=
k
;
}
public
BigInteger
getKey
() {
return
k
;
}
public
Point
getBasePoint
() {
return
c
.
getBasePoint
();
}
}
Back
|
FazBrowse Home
|
New Git URL