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.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CantorPairing
{
classProgram
{
staticvoid Main(string[] args)
{
//
Console.Write("Start with a bitcoin address as decimal 4824855521912883454204125328393785564172057950402473856794");
Console.WriteLine("or 1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T");
Console.Write("Add a litecoin address as decimal 305531613334489417964998059632233568427215324197451409291673");
Console.WriteLine("or LaxGrwMeokoMgv5zYpv5btT4yNUB9DaiqE");
System.Diagnostics.Stopwatch sw = System.Diagnostics.Stopwatch.StartNew();
Org.BouncyCastle.Math.BigInteger btc =new Org.BouncyCastle.Math.BigInteger("4824855521912883454204125328393785564172057950402473856794");
Org.BouncyCastle.Math.BigInteger ltc =new Org.BouncyCastle.Math.BigInteger("305531613334489417964998059632233568427215324197451409291673");
Org.BouncyCastle.Math.BigInteger bigResult = CantorPair(btc, ltc);
Console.WriteLine("The cantor pairing function yields the number ", bigResult);
Org.BouncyCastle.Math.BigInteger[] pair = Reverse(bigResult);
sw.Stop();
Console.WriteLine(bigResult +" in "+ sw.ElapsedMilliseconds +"ms");
Console.WriteLine("Btc {0}", pair[0]);
Console.WriteLine("Ltc {0}", pair[1]);
Console.ReadKey();
}
staticint CantorPair(short x, short y)
{
return ((x + y) * (x + y +1)) /2+ y;
}
static Org.BouncyCastle.Math.BigInteger CantorPair(Org.BouncyCastle.Math.BigInteger x, Org.BouncyCastle.Math.BigInteger y)
{
Org.BouncyCastle.Math.BigInteger xplusy = x.Add(y);
Org.BouncyCastle.Math.BigInteger xplusyplus1 = xplusy.Add(Org.BouncyCastle.Math.BigInteger.One);
Org.BouncyCastle.Math.BigInteger inside = xplusy.Multiply(xplusyplus1);
Org.BouncyCastle.Math.BigInteger twoplusy = Org.BouncyCastle.Math.BigInteger.Two.Add(y);
return xplusy.Multiply(xplusyplus1).Divide(Org.BouncyCastle.Math.BigInteger.Two).Add(y);
}
staticshort[] Reverse(int z)
{
short[] pair =newshort[2];
int t = (int)Math.Floor((-1D+Math.Sqrt(1D+8* z)) /2D);
int x = t * (t +3) /2- z;
int y = z - t * (t +1) /2;
pair[0] = (short)x;
pair[1] = (short)y;
return pair;
}
static Org.BouncyCastle.Math.BigInteger[] Reverse(Org.BouncyCastle.Math.BigInteger z)
{
//"constants"
Org.BouncyCastle.Math.BigInteger three =new Org.BouncyCastle.Math.BigInteger("3");
Org.BouncyCastle.Math.BigInteger eight =new Org.BouncyCastle.Math.BigInteger("8");
Org.BouncyCastle.Math.BigInteger[] pair =new Org.BouncyCastle.Math.BigInteger[2];
Org.BouncyCastle.Math.BigInteger t = eight.Multiply(z).Add(Org.BouncyCastle.Math.BigInteger.One);
Byte[] tempBytes = t.ToByteArray();
Array.Reverse(tempBytes);
System.Numerics.BigInteger temp =new System.Numerics.BigInteger(tempBytes);
System.Numerics.BigInteger root = Sqrt(temp);
String root3 = root.ToString();
Org.BouncyCastle.Math.BigInteger root2 =new Org.BouncyCastle.Math.BigInteger(root3);
t = root2.Subtract(Org.BouncyCastle.Math.BigInteger.One);
t = t.Divide(Org.BouncyCastle.Math.BigInteger.Two);
Org.BouncyCastle.Math.BigInteger tplus3 = t.Add(three);
Org.BouncyCastle.Math.BigInteger tplus1 = t.Add(Org.BouncyCastle.Math.BigInteger.One);
Org.BouncyCastle.Math.BigInteger x = t.Multiply(tplus3).Divide(Org.BouncyCastle.Math.BigInteger.Two).Subtract(z); // * (t + 3) / 2 - z;
Org.BouncyCastle.Math.BigInteger y = t.Multiply(tplus1).Divide(Org.BouncyCastle.Math.BigInteger.Two); //- t * (t + 1) / 2;
y = z.Subtract(y);
pair[0] = x;
pair[1] = y;
return pair;
}
publicstatic System.Numerics.BigInteger Sqrt(System.Numerics.BigInteger n)
{
if (n ==0) return0;
if (n >0)
{
int bitLength =Convert.ToInt32(Math.Ceiling(System.Numerics.BigInteger.Log(n, 2)));
System.Numerics.BigInteger root = System.Numerics.BigInteger.One << (bitLength /2);
while (!isSqrt(n, root))
{
root += n / root;
root /=2;
}
return root;
}
thrownewArithmeticException("NaN");
}
privatestaticBoolean isSqrt(System.Numerics.BigInteger n, System.Numerics.BigInteger root)
{
System.Numerics.BigInteger lowerBound = root * root;
System.Numerics.BigInteger upperBound = (root +1) * (root +1);
return (n >= lowerBound && n < upperBound);
}
}
}