Author

Topic: NXT :: descendant of Bitcoin - Updated Information - page 972. (Read 2761655 times)

full member
Activity: 238
Merit: 100
Running Nxt over tor
I tried to run Nxt over tor using torsocks, but apparently this doesn't work for java. The way to tell java to use a socks proxy is to define socksProxyHost and socksProxyPort properties, in a system properties file or on the command line:

Code:
java -DsocksProxyHost=127.0.0.1 -DsocksProxyPort=9050 -Xmx1024M -jar start.jar

Replace 127.0.0.1 and 9050 with your tor host and socks port, if not default. Basically this is equivalent to the socks proxy options in the configuration of bitcoin-qt, if you use that.
You cannot use tor if you want to advertise a public IP or run a bootstrapping node, so only use it on your mining node, if you care about preserving your privacy. And you cannot hallmark a node ran behind tor, so if you are a stakeholder and want to contribute to the network stability, please consider running a separate publicly visible hallmarked node (and if you want to anonymize that one too, need to use a VPN which allows port forwarding and dynamic DNS).


this is a bit old, but I have some questions on how NRS works that is applicable to its appropriate use with tor.  How does NRS deal with DNS names that it sees in incoming requests, and for DNS names when it wants to create a new connection outbound?

These scenarios have nothing to do with hallmarking, so we can safely discard those discussions...

Lets first discuss when NRS receives a new connection from an external node:
Obviously, the IP packet itself just contains IP addresses, but what does NRS do when the external node's web.xml does not have an IP address in there, but instead has a DNS name?  Does the local NRS first query DNS, and then check to see if the IP address returned by DNS matches the IP address in the incoming IP packet?  If so, what happens if there is a mismatch?  Or does the local NRS simply read the DNS passed over JSON and think to itself "ok IP address X is claiming to be DNS name Y; thats nice, now I will still just use the IP address to respond to the external , regardless of what the DNS really resolves to."

The issue here is that if DNS is queried, then most likely the java process is doing this outside the scope of tor, resulting in leaking through your real IP address to DNS servers. ( I say most likely, I use this proxy-type setup with firefox over sshd's dynamic socks proxy, and this by default leaks to DNS; appropriate extra counter-steps must be taken)

The same thing would happen for outbound-initiated connections, whether from the seeded wellknownhosts or from learning about the DNS names from other peers - if the local node wants to query DNS before connecting, then real IP address will be leaked.

So how does NRS deal with DNS?
sr. member
Activity: 336
Merit: 250
AKA jefdiesel
slick job fmiboy!  Smiley
I mean really, seeing all these features being implemented in cool clients is just awesome  Cheesy

thanks! hopefully it has all necessary features for tomorrow AE Test...

installing OS X on VM to test and see it works properly on mac as well!

Im running it on Mavericks, seems fine. unlocked a new account, but don't have any testNXT to play with

test account wont let me copy paste the account number.. 15265031083387211287


hero member
Activity: 687
Merit: 500
There have been quite a few posts lately discussing the failure of sign() in curve25519.java. I still have the feeling that most people don't fully understand what causes this failure. So I will explain in detail below. Note that if the majority of the community thinks that curve25519.java should not be changed, that's ok for me. I don't forge with my small account so it doesn't matter to me.

Let's start by looking at an easy example to see what can go wrong:
Our coder Mr. Confusius wants to write some code that is doing modulus calculus in the field F7 (i.e. all numbers can be reduced mod 7). Since F7 contains only the numbers 0,....,6 he decides to represent each number by 4 bits and calls his class fourBitNum. So we have
0 = 0000, 1 = 0001, ..., 6 = 0110
Happy with the design he writes methods for adding, subtracting, multiplication and mod 7 reduction of those numbers:

Code:
FourBitNum add(fourBitNum a, fourBitNum b)
FourBitNum sub(fourBitNum a, fourBitNum b)
FourBitNum mul(fourBitNum a, fourBitNum b)
FourBitNum mod7(fourBitNum a)

He then tests his code by calculating 5+4 in F7. Since 5+4=9≡2 mod 7 the output should be 2:
Code:
fourBitNum a = add(fourBitNum(5), fourBitNum(4));
fourBitNum b = mod7(a);
output(b)
and the output is indeed 2 as expected. What a great coder I am, he thinks, and tests the multiplication. 5*4=20≡6 mod 7 so the output should be 6:
Code:
fourBitNum a = mul(fourBitNum(5), fourBitNum(4));
fourBitNum b = mod7(a);
output(b)
He wraps his eyes when he sees that the output is 4. ok, I'll fix that later he says to himself, let's first try the sub method. He tests 5 and 4 as input for calculating 5-4=1 mod 7 and the result is correct. However 4 and 5 as input for calculating 4-5=-1≡6 mod 7 outputs the unexpected result 1.
What the hell is wrong with his code?
In the first example of failure the result 5*4=20=10100 is to big to be held in four bits so his add method simply omits the highest bit, effectively doing a mod 16 reduction of 5*4 followed by the wanted mod 7 reduction: output = ((5*4) mod 16) mod7 = 4.
Not handling overflows always ruins the calculation.
In the second example 4-5=-1=1111 in his four bit representation. But his mod7 method expects positive input and interprets it as 15 which again means there was an unwanted mod 16 reduction, -1≡15 mod 16, and his calculation is ruined again.

The conclusion is that when doing modulus calculation it is very important to realize when numbers get too big (i.e. overflow) or too small (i.e. < 0, underflow). The coder of curve25519.java (respectively the coder of the original in c) certainly is not Mr. Confusius. But he did make some mistakes. Let's analyze the sign() method line by line:

Code:
public static final boolean sign(byte[] v, byte[] h, byte[] x, byte[] s) {
   /* v = (x - h) s  mod q */
The comment simply states what he wants to calculate. At this point h is a hash representing an arbitrary 256-bit, x is a hash that got clamped (i.e. some bits were changed) and s is the inverse of the private key k. s already has been reduced mod group order. After defining some variables that he needs for the calculation and setting all bytes in the v array to 0 the calculation begins:
Code:
i = mula_small(v, x, 0, h, 32, -1);
The name "mula_small" is deceptive, it really is a multiplication plus an addition. He calculates v = x + h * (-1). The returned value i is not used in the subsequent calculation. The author probably only used it for debugging purposes. More on that a little later.
We will leave out the next line (I will refer to this line as "strange code line")
Code:
mula_small(v, v, 0, ORDER, 32, (15-v[31])/16);
for a moment and take a look at the rest of the code first before returning to this important line.
The author continues to get to the wanted result with
Code:
mula32(tmp1, v, s, 32, 1);
Again the name "mula32" is deceptive as it really is 2 multiplications plus one addition. The line means: tmp1 = tmp1 + v * s * 1. Since v=x-h and this point we have tmp1 = (x-h)*s.
The last line that calculates something, is a mod q reduction (where q is the group order represented by the ORDER argument) which is in principle unnecessary:
Code:
divmod(tmp2, tmp1, 64, ORDER, 32);
The result is tmp2 = tmp1/ORDER as integer division and tmp1 = tmp1 mod ORDER so we finally have tmp1 = (x-h)*s mod q
The following loop copies tmp1 into v and at the same time ORs the bits of tmp1 into w. Thus w==0 <==> v==0:
Code:
for (w = 0, i = 0; i < 32; i++)
   w |= v[i] = tmp1[i];
It finally returns true if and only if v!=0 (via w!=0).
Note that sign() returns false <==> v==0 <==> (x-h)s mod q == 0 <==> x=h. Since x and h are sha256 hashes (with x only a little bit changed) we either are very unlucky) or message + s == message + Y <==> s==Y where Y is the public key of x. Again, that is very unlikely. To me, failure to produce a valid signature is just a theoretical possibility, it should not happen in real life (correct me if I am wrong).

Now will that code work? If we comment out the "strange code line" and remove the variable "i" we probably get the first version of the sign() method that the author tested. It produces in more than 60% of the cases wrong signatures. Why that? If x-h<0 then v=(x-h)s<0 and the mod q reduction will not give the expected result. The author probably was astonished and inserted the variable i in his code to check if mula_small(v, x, 0, h, 32, -1) indicates an underflow (mula_small returns -1 in this case). Once he realized the problem he tried to fix it in a super smart way by inserting the "strange code line":
Code:
  mula_small(v, v, 0, ORDER, 32, (15-v[31])/16);
With this line, he wants to kill two birds with one stone:
1) Compensate the error if there was an underflow (i.e. x2) reduce v mod q

But alas, sometimes if you think you are doing something super smart you end up doing something super stupid! It usually is better to do it in 2 steps each of which is easy to understand.
Let's see what really happens:
If 0<=v[31]<31 then 0*group order is added to v leaving v unchanged.
If 31<=v[31]<=127 then a (positive) multiple of the group order is subtracted from v to get 0<=vIf -128added to v. v is hereby crossing the 2^256 border causing an overflow.
So his idea is:
If x>=h then v=x-h is positive and thus the highest bit of v is not set, i.e. 0<=v[31]<127. In that case we reduce v by subtracting multiple of the group order ending up with 0<=vIn the other case xSounds good but actually is a bad idea!
Consider x=2^255+1 and h=1 giving v=x-h=2^255. There was no underflow in the calculation and still the highest bit of v is set causing the above algorithm to add a multiple of the group order which in turn causes an overflow und thus ruining the whole calculation.
On the other hand if x=1 and h=2^255+1 then the calculation of v is indeed causing an underflow but this time the highest bit of v is not set so the algorithm will not compensate for it and thus again ruining the calculation.

Even though the first case cannot happen (the highest bit of x is always cleared) the second case can happen and leads to failure. The probability is roughly (1/4*1/2*2^254*(2^254 + 1))/2^508 ≈ 1/8 which is close to the value gimre found with his tests.

The way I suggested to correct the error was very simply and thus easy to understand:
Since the whole calculation is within Fq, reduction mod q of any positive variable at any point of the calculation doesn't alter the result (that's a mathematical fact). After we have reduced x and h mod q and calculated v=x-h it's easy to check if v is negative by looking at the highest bit (this always works!). If it is negative, adding the group order will always result in 0<=vNothing is leaked.
For those who are complaining that parts of my code like
Code:
if ((v[31] & 0x80) != 0)
{
   mula_small(v, v , 0, ORDER, 32, 1);
}
is time dependent and therefore bad, you can easily modify it to include a fake addition which adds 0:
Code:
if ((v[31] & 0x80) != 0)
{
   mula_small(v, v , 0, ORDER, 32, 1);
}
else
{
   mula_small(v, v , 0, ORDER, 32, 0);
}
Even more, if you are complaining about code in curve25519.java to be time dependent, take a look how the inverse s=k^-1 of the private key k is calculated. It uses the extended euclidean algorithm which is time dependend too. If you have problems with that, you have to replace that part too (It can be done by using Fermat's little theorem and a Montgommery ladder).

That's it, I have nothing more to say about sign() (the post was long enough Smiley ).
I hope that those who are interested in the sign() method now have a better understanding what really happens inside of it and where is goes wrong.
hero member
Activity: 924
Merit: 1003
Unlimited Free Crypto
The point here is: 'SHOULD work on "3"' has to be proved.

Maybe, there are some negative numbers c so that (a, c') validates ALTHOUGH a is invalid. (where c' is the positive equivalent of c)
Maybe not.

So, proof of the algo as well as the code is needed.

I'm done advocating this here for a while, I can better spend my time.
I've stated it number of times, it's the implementation that's wrong, not the math. Math stays the same.
If you're interested you can go through my earlier posts.

Some interesting links:

I'm going to run NRS with patched Curve from now on.

EOT for me

Please provide the source code so we can compile and swap. By We I mean the ones who agree with you.
hero member
Activity: 742
Merit: 500
WE SHOULD START TO BUILD NXTMONEY == fixed price/value in all major currencies.

We need economists for that or u will end with eMunie-like system. I still doubt that eMunie "constant value" idea will work if people start selling EMUs.

economist here Smiley

that is the famous trilemma of fixed exchange rates in standard theory - I think it might be possible to build something like fixed exchange rates due to the fact that not monetary policy is possbile necessary, but you have to do it with extreme caution.



I can remember MSCs whitepaper suggesting something like a battery (probably a proof of isolation) for keeping values stable
legendary
Activity: 1092
Merit: 1010


Somehow I think BCNext is Glurmo.
full member
Activity: 189
Merit: 100
slick job fmiboy!  Smiley
I mean really, seeing all these features being implemented in cool clients is just awesome  Cheesy

thanks! hopefully it has all necessary features for tomorrow AE Test...

installing OS X on VM to test and see it works properly on mac as well!
legendary
Activity: 866
Merit: 1002
The point here is: 'SHOULD work on "3"' has to be proved.

Maybe, there are some negative numbers c so that (a, c') validates ALTHOUGH a is invalid. (where c' is the positive equivalent of c)
Maybe not.

So, proof of the algo as well as the code is needed.

I'm done advocating this here for a while, I can better spend my time.
I've stated it number of times, it's the implementation that's wrong, not the math. Math stays the same.
If you're interested you can go through my earlier posts.

Some interesting links:

I'm going to run NRS with patched Curve from now on.

EOT for me
sr. member
Activity: 630
Merit: 262
This account was hacked. just recently got it back
slick job fmiboy!  Smiley
I mean really, seeing all these features being implemented in cool clients is just awesome  Cheesy
full member
Activity: 189
Merit: 100
sr. member
Activity: 308
Merit: 250
Which clients are ready for AE test tomorrow?
legendary
Activity: 1806
Merit: 1038
i installed tor on my ubuntu system, can someone tell me how to make the NRS java client use tor and not the computer's default gateway?
- may be this help: https://bitcointalksearch.org/topic/m.3875933
full member
Activity: 238
Merit: 100
i installed tor on my ubuntu system, can someone tell me how to make the NRS java client use tor and not the computer's default gateway?
full member
Activity: 178
Merit: 100
So let's bury/ignore the idea with possibility of canceling transactions.

Moving on.
++
CFB please take the above statement seriously...there are certain reason why the nxt community is what it is today and why people believe in nxt. Transaction cancellation and inflationary currency is definitely not one of them...The creation of colored coins and other instruments will serve to stabilize or peg nxt at a constant verifiable value


Why inflationary? The supply of Nxt won't change. Only the supply of coloured coins on top of Nxt will rise. At least that is how i understood it.
full member
Activity: 189
Merit: 100
UPDATE: ClieNXT GUI

version 0.0.5 [code name] AE testnet

* this version solely works with testnet server http://holms.cloudapp.net:6874/
* Asset Exchange window has major features

------
Download
------
https://bitbucket.org/fmiboy/clienxt/downloads/clienxt_005.zip


------
Usage
------

* Windows users unzip the archive and run Clienxt.jar file
* Linux users unzip the archive and run in terminal ./clienxt.run &
* Mac users unzip the archive and run in terminal ./clienxt.run & (not tested, working on creating *.app file or *.pkg installer)

* Languages English, Russian only Asset Exchange window translations are missing.

NB: don't use your own accounts on "testnet"

click Unlock button to open new or existing accounts on "testnet" (unlock and watch if you have more accounts)
go to Asset Exchange window and start Trading

....

Please report bugs or feature request here: https://bitbucket.org/fmiboy/clienxt/issues?status=new&status=open
Once client is tested, we can use it tomorrow without an issue!
Translators are very much welcome! The more languages we have the more people test Asset Exchange tomorrow.

Translators can find word list in Bundle.Properties (everything right side of "=" needs translation) here: https://bitbucket.org/fmiboy/clienxt/src/0a35a05b7786b2c3cf1e69ca16c0bbd48d8f953c/src/clienxt/Bundle.properties?at=master

If you like my work, donate nxt 13792774143018875909 and thank you very much for all supports.

anyone tested client? anything missing or not working?

thanks

Im trying it now, seems ok.
I tried to issue an asset but it says my balance is zero, which it is.



thanks for report! yes, you need at least 1001 to issue an Asset!

I guess we will test it tomorrow with testcoins...

btw, who will give out testcoins for testers?
hero member
Activity: 910
Merit: 1000
Please can someone explain the answer to the theoretical question to me:

If we have the potential for 1000tps-unlimited tps
why is HFT impossible? or at least as some people have alluded to on blockchain based system? especially given the unique qualities of nxt

HFT needs fast connections, and I mean really fast (time-critial = milliseconds). Nxt is a global network which uses TCP/IP -> Slow. Also the forging node would decide which sequence of the incoming orders is 'the right'. Can't think this would work globally and fair. Nxt will only be able to handle the amount of 1000 TPS.
full member
Activity: 238
Merit: 100
Hey guys,

I just updated to 0.7.2 and it runs great. Just one question, how do I shut down the Java process? In earlier versions this happened automatically by exiting CMD window, but in 0.7.2 this is not the case. Is it the only way to go and kill the process in task manager?

Thanks

Also I just realized that if I don't go and kill the Java process next time I go to start NRS i get the error.

[2014-02-10 17:33:20.789] Error initializing Nxt servlet

How should it be properly done?
Thanks

Ctrl-C in the cmd window

Thanks but which CMD window? There is no more CMD window in 0.7.2, when you start a batch file, only nxt notepad document updates itself and that is it.. Nothing else happens..

Edit: Nevermind, I got it.. Thanks
full member
Activity: 224
Merit: 100
Hey guys,

I just updated to 0.7.2 and it runs great. Just one question, how do I shut down the Java process? In earlier versions this happened automatically by exiting CMD window, but in 0.7.2 this is not the case. Is it the only way to go and kill the process in task manager?

Thanks

Also I just realized that if I don't go and kill the Java process next time I go to start NRS i get the error.

[2014-02-10 17:33:20.789] Error initializing Nxt servlet

How should it be properly done?
Thanks

Ctrl-C in the cmd window
newbie
Activity: 36
Merit: 0
I heard on Lets Talk Bitcoin a few nights ago that the Zerocoin protocol is being developed for NXT.  Does this mean that NXT is developing a Zercoin-like protocol or have the Zerocoin developers decided to build on top of NXT?  Are the developers working together?

Neither.  A few people (including jl777) are interested in developing NXTcash, which is an implementation of Zerocoin ON TOP OF Nxt.  To date, the Zerocoin folks have not responded to overtures from these Nxt folks -- but the Zerocoin library is open-source and so they're moving ahead with it anyway.

You will hear more and more about people building things on top of Nxt.  Think of Nxt as a low-layer protocol.  Everything built on top of it is independent.  Like Nxt itself, nothing is "official" or "centralized".

The fact that Nxt can support such a diversity of applications and uses, supported by a lightweight PoS blockchain, is part of its appeal.

Thanks for clearing that up for me!
full member
Activity: 238
Merit: 100
Hey guys,

I just updated to 0.7.2 and it runs great. Just one question, how do I shut down the Java process? In earlier versions this happened automatically by exiting CMD window, but in 0.7.2 this is not the case. Is it the only way to go and kill the process in task manager?

Thanks

Also I just realized that if I don't go and kill the Java process next time I go to start NRS i get the error.

[2014-02-10 17:33:20.789] Error initializing Nxt servlet

How should it be properly done?
Thanks
Jump to: