It was the Bitcointalk forum that inspired us to create Bitcointalksearch.org - Bitcointalk is an excellent site that should be the default page for anybody dealing in cryptocurrency, since it is a virtual gold-mine of data. However, our experience and user feedback led us create our site; Bitcointalk's search is slow, and difficult to get the results you need, because you need to log in first to find anything useful - furthermore, there are rate limiters for their search functionality.
The aim of our project is to create a faster website that yields more results and faster without having to create an account and eliminate the need to log in - your personal data, therefore, will never be in jeopardy since we are not asking for any of your data and you don't need to provide them to use our site with all of its capabilities.
We created this website with the sole purpose of users being able to search quickly and efficiently in the field of cryptocurrency so they will have access to the latest and most accurate information and thereby assisting the crypto-community at large.
import com.sun.net.httpserver.HttpServer;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.util.Arrays;
public class atoi {
private static final int[] INDICES = new int[729];
private static final int[] F = {0, -1, 1, 0, 1, -1, -1, 1, 0};
private static final String tryteLetters = "9abcdefghijklmnopqrstuvwxyz";
private static final int[][] tryteTrits = {
{0, 0, 0},
{1, 0, 0},
{-1, 1, 0},
{0, 1, 0},
{1, 1, 0},
{-1, -1, 1},
{0, -1, 1},
{1, -1, 1},
{-1, 0, 1},
{0, 0, 1},
{1, 0, 1},
{-1, 1, 1},
{0, 1, 1},
{1, 1, 1},
{-1, -1, -1},
{0, -1, -1},
{1, -1, -1},
{-1, 0, -1},
{0, 0, -1},
{1, 0, -1},
{-1, 1, -1},
{0, 1, -1},
{1, 1, -1},
{-1, -1, 0},
{0, -1, 0},
{1, -1, 0},
{-1, 0, 0}
};
static {
int index = 0;
for (int i = 0; i < 729; i++) {
INDICES[i] = index += index <= 364 ? 364 : -365;
}
}
private static int[] digest(final int[] message) {
final int[] state = new int[729];
System.arraycopy(message, 0, state, 0, message.length);
transform(state);
return Arrays.copyOf(state, 243);
}
private static void transform(final int[] state) {
final int[] leftPart = new int[729], rightPart = new int[729];
int index = 0;
for (int round = 9; round-- > 0; ) {
for (int i = 0; i < 729; i++) {
final int a, b;
leftPart[i] = f(a = state[index], b = state[index = INDICES[i]]);
rightPart[i] = f(b, a);
}
for (int i = 0; i < 729; i++) {
state[i] = f(leftPart[index], rightPart[index = INDICES[i]]);
}
}
}
private static int f(final int a, final int b) {
return F[a + a + a + b + 4];
}
public static void main(final String[] args) throws Exception {
final HttpServer server = HttpServer.create(new InetSocketAddress(9999), 0);
server.createContext("/", (exchange) -> {
// Fetch lowercase latin letters and '9' from the request into a seed
final StringBuilder seed = new StringBuilder();
for (final char tryteLetter : exchange.getRequestURI().getPath().toCharArray()) {
if (tryteLetters.indexOf(tryteLetter) >= 0) {
seed.append(tryteLetter);
}
}
// Check if there are exactly 81 chars in the seed
final String response;
if (seed.length() != 81) {
// Inform the user that something is wrong with their seed
response = "Seed length is " + seed.length() + ", must be 81!";
} else {
// Translate the seed chars into trits
int[] seedTrits = new int[243];
int offset = 0;
for (final char tryteLetter : seed.toString().toCharArray()) {
System.arraycopy(tryteTrits[tryteLetters.indexOf(tryteLetter)], 0, seedTrits, offset, 3);
offset += 3;
}
// Derive private key fragments from the seed
final int[][] key = new int[27][];
final int[] scratchpad = new int[seedTrits.length];
for (int i = 0; i < key.length; i++) {
System.arraycopy(i == 0 ? seedTrits : key[i - 1], 0, scratchpad, 0, scratchpad.length);
key[i] = digest(scratchpad);
}
// Truncate the private key fragments to 81 trits each
for (int i = 0; i < key.length; i++) {
key[i] = Arrays.copyOf(key[i], 81);
}
// Derive public key fragments from the private key fragments, keep them truncated to 81 trits each
for (int i = 0; i < key.length; i++) {
for (int j = 0; j < 27; j++) {
key[i] = Arrays.copyOf(digest(key[i]), 81);
}
}
// Derive a public key from the public key fragments
final int[] state = new int[729];
for (int i = 0; i < key.length; ) {
System.arraycopy(key[i++], 0, state, 0, 81);
System.arraycopy(key[i++], 0, state, 81, 81);
System.arraycopy(key[i++], 0, state, 162, 81);
transform(state);
}
// Negate the trits of the seed
for (int i = 0; i < seedTrits.length; i++) {
seedTrits[i] = -seedTrits[i];
}
// Derive a checkpointing key from the seed
for (int i = 0; i < 12 * 24 * 366; i++) {
seedTrits = digest(seedTrits);
}
// Translate the keys into text
final StringBuilder publicKey = new StringBuilder(), checkpointingKey = new StringBuilder();
for (int i = 0; i < 243; i += 3) {
int tryteValue = state[i] + state[i + 1] * 3 + state[i + 2] * 9;
if (tryteValue < 0) {
tryteValue += 27;
}
publicKey.append(tryteLetters.charAt(tryteValue));
tryteValue = seedTrits[i] + seedTrits[i + 1] * 3 + seedTrits[i + 2] * 9;
if (tryteValue < 0) {
tryteValue += 27;
}
checkpointingKey.append(tryteLetters.charAt(tryteValue));
}
// Output the keys in a format suitable for copy-pasting
response = (publicKey.toString() + "_" + checkpointingKey.toString()).toUpperCase();
}
// Send the response
exchange.sendResponseHeaders(200, response.length());
final OutputStream outputStream = exchange.getResponseBody();
outputStream.write(response.getBytes("UTF-8"));
outputStream.close();
});
server.start();
}
}