48 lines
1.9 KiB
Java
48 lines
1.9 KiB
Java
import swiss.qpq.gajumaru.core.crypto.*;
|
|
import swiss.qpq.gajumaru.core.encoding.*;
|
|
import swiss.qpq.gajumaru.core.data.*;
|
|
import swiss.qpq.gajumaru.core.tools.*;
|
|
import java.util.Arrays;
|
|
|
|
public class TestRunner {
|
|
public static void main(String[] args) {
|
|
try {
|
|
if (args.length == 0) {
|
|
System.out.println("Usage: java TestRunner <command> <input>");
|
|
return;
|
|
}
|
|
|
|
String cmd = args[0];
|
|
switch (cmd) {
|
|
case "keccak":
|
|
byte[] kInput = CryptoUtils.hexToBin(args[1]);
|
|
System.out.println(CryptoUtils.binToHex(Keccak256.hash(kInput)));
|
|
break;
|
|
case "blake2b":
|
|
byte[] bInput = CryptoUtils.hexToBin(args[1]);
|
|
System.out.println(CryptoUtils.binToHex(Blake2b.hash(bInput)));
|
|
break;
|
|
case "ak_encode":
|
|
byte[] akInput = CryptoUtils.hexToBin(args[1]);
|
|
System.out.println(ApiEncoder.encode(ApiEncoder.Type.ACCOUNT_PUBKEY, akInput));
|
|
break;
|
|
case "ed25519_pub":
|
|
byte[] seed = CryptoUtils.hexToBin(args[1]);
|
|
System.out.println(CryptoUtils.binToHex(Ed25519.publicKey(seed)));
|
|
break;
|
|
case "id_serialize":
|
|
int tag = Integer.parseInt(args[1]);
|
|
byte[] val = CryptoUtils.hexToBin(args[2]);
|
|
Id id = new Id(Id.Tag.fromValue(tag), val);
|
|
System.out.println(CryptoUtils.binToHex(id.serialize()));
|
|
break;
|
|
default:
|
|
System.out.println("Unknown command: " + cmd);
|
|
}
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
System.exit(1);
|
|
}
|
|
}
|
|
}
|