Coverage Summary for Class: GenNodeKeyId (co.rsk)
Class |
Class, %
|
Method, %
|
Line, %
|
GenNodeKeyId |
0%
(0/1)
|
0%
(0/2)
|
0%
(0/19)
|
1 /*
2 * This file is part of RskJ
3 * Copyright (C) 2017 RSK Labs Ltd.
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19
20 package co.rsk;
21
22 import org.ethereum.crypto.ECKey;
23 import org.ethereum.crypto.HashUtil;
24 import org.ethereum.util.ByteUtil;
25
26 import java.nio.charset.StandardCharsets;
27
28 /**
29 * Created by ajlopez on 3/9/2016.
30 * Don't modify
31 */
32 public class GenNodeKeyId {
33 public static void main(String[] args) {
34 String generator = "";
35
36 if (args.length > 0) {
37 generator = args[0];
38 }
39
40 ECKey key;
41 if (generator.equals("")) {
42 key = new ECKey();
43 } else {
44 key = ECKey.fromPrivate(HashUtil.keccak256(generator.getBytes(StandardCharsets.UTF_8)));
45 }
46
47 String keybytes = ByteUtil.toHexString(key.getPrivKeyBytes());
48 String pubkeybytes = ByteUtil.toHexString(key.getPubKey());
49 String compressedpubkeybytes = ByteUtil.toHexString(key.getPubKey(true));
50 String address = ByteUtil.toHexString(key.getAddress());
51 String nodeid = ByteUtil.toHexString(key.getNodeId());
52
53 System.out.println('{');
54 System.out.println(" \"privateKey\": \"" + keybytes + "\",");
55 System.out.println(" \"publicKey\": \"" + pubkeybytes + "\",");
56 System.out.println(" \"publicKeyCompressed\": \"" + compressedpubkeybytes + "\",");
57 System.out.println(" \"address\": \"" + address + "\",");
58 System.out.println(" \"nodeId\": \"" + nodeid + "\"");
59 System.out.println('}');
60 }
61 }