Bitcoin Forum
April 28, 2024, 06:31:21 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: « 1 ... 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 [1586] 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 ... 2557 »
  Print  
Author Topic: NXT :: descendant of Bitcoin - Updated Information  (Read 2761529 times)
fmiboy
Full Member
***
Offline Offline

Activity: 189
Merit: 100


View Profile
February 10, 2014, 05:46:54 PM
 #31701

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!
1714329081
Hero Member
*
Offline Offline

Posts: 1714329081

View Profile Personal Message (Offline)

Ignore
1714329081
Reply with quote  #2

1714329081
Report to moderator
1714329081
Hero Member
*
Offline Offline

Posts: 1714329081

View Profile Personal Message (Offline)

Ignore
1714329081
Reply with quote  #2

1714329081
Report to moderator
"Governments are good at cutting off the heads of a centrally controlled networks like Napster, but pure P2P networks like Gnutella and Tor seem to be holding their own." -- Satoshi
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714329081
Hero Member
*
Offline Offline

Posts: 1714329081

View Profile Personal Message (Offline)

Ignore
1714329081
Reply with quote  #2

1714329081
Report to moderator
1714329081
Hero Member
*
Offline Offline

Posts: 1714329081

View Profile Personal Message (Offline)

Ignore
1714329081
Reply with quote  #2

1714329081
Report to moderator
Damelon
Legendary
*
Offline Offline

Activity: 1092
Merit: 1010



View Profile
February 10, 2014, 05:49:40 PM
 #31702



Somehow I think BCNext is Glurmo.

Member of the Nxt Foundation | Donations: NXT-D6K7-MLY6-98FM-FLL5T
Join Nxt Slack! https://nxtchat.herokuapp.com/
Founder of Blockchain Workspace | Personal Site & Blog
nakaone
Hero Member
*****
Offline Offline

Activity: 742
Merit: 500


View Profile
February 10, 2014, 05:49:53 PM
 #31703

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
lophie
Hero Member
*****
Offline Offline

Activity: 924
Merit: 1001

Unlimited Free Crypto


View Profile
February 10, 2014, 05:51:04 PM
 #31704

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.

Will take me a while to climb up again, But where is a will, there is a way...
BloodyRookie
Hero Member
*****
Offline Offline

Activity: 687
Merit: 500


View Profile
February 10, 2014, 05:57:10 PM
 #31705

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. x<h)
2) 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<=v<q.
If -128<v[31]<0 then a (positive) multiple of the group order is added 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<=v<q.
In the other case x<h making v=x-h negativ (we had an underflow) and thus its highest bit is set, i.e. -128<v[31]<0. In that case we are causing an overflow by adding a suitable multiple of the group order which compensates the underflow and will again have 0<=v<q.
Sounds 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<=v<q. The rest of sign() is the same es before. Nothing 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.

Nothing Else Matters
NEM: NALICE-LGU3IV-Y4DPJK-HYLSSV-YFFWYS-5QPLYE-ZDJJ
NXT: 11095639652683007953
brooklynbtc
Sr. Member
****
Offline Offline

Activity: 336
Merit: 250

AKA jefdiesel


View Profile
February 10, 2014, 06:00:01 PM
 #31706

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



SN
S   U   P   E   R    N   E   T
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀   
Uniting cryptocurrencies, Rewarding talent, Sharing benefits..

Blockchain Technology.

opticalcarrier
Full Member
***
Offline Offline

Activity: 238
Merit: 100



View Profile
February 10, 2014, 06:05:12 PM
Last edit: February 10, 2014, 06:15:46 PM by opticalcarrier
 #31707

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?
smartwart
Full Member
***
Offline Offline

Activity: 171
Merit: 100


View Profile
February 10, 2014, 06:05:20 PM
 #31708

thx BloodyRookie, very good explaied!!!

NxT: 13574045486980287597
fmiboy
Full Member
***
Offline Offline

Activity: 189
Merit: 100


View Profile
February 10, 2014, 06:12:38 PM
 #31709

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

great, thanks!

what do you mean? I believe all tables are editable (you can copy data from). You can "watch account" by adding any account number and label it.

it is also possible to play around with account that you don't own, just add to watch list and see what assets that account holds.
Though, you won't be able to transfer/issue/place order/cancel order unless you have passphrase.
gimre
Legendary
*
Offline Offline

Activity: 866
Merit: 1002



View Profile WWW
February 10, 2014, 06:18:44 PM
 #31710

Wall of text.

Astonishing work. I could never explain it in such simple and elegant way.
Kudos to you, sir!

NemusExMāchinā
Catapult docs: https://docs.symbol.dev
github: https://github.com/symbol
brooklynbtc
Sr. Member
****
Offline Offline

Activity: 336
Merit: 250

AKA jefdiesel


View Profile
February 10, 2014, 06:26:53 PM
 #31711

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

great, thanks!

what do you mean? I believe all tables are editable (you can copy data from). You can "watch account" by adding any account number and label it.

it is also possible to play around with account that you don't own, just add to watch list and see what assets that account holds.
Though, you won't be able to transfer/issue/place order/cancel order unless you have passphrase.


if i right click, i get the dropdown boxes, bid, etc, and if i double click, I can select all but then when all selected, there is no more right click, and cmd-c doesnt work

SN
S   U   P   E   R    N   E   T
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀   
Uniting cryptocurrencies, Rewarding talent, Sharing benefits..

Blockchain Technology.

brooklynbtc
Sr. Member
****
Offline Offline

Activity: 336
Merit: 250

AKA jefdiesel


View Profile
February 10, 2014, 06:30:10 PM
 #31712

and also, CNY/NXT is higher than USD/NXT..  and more volume than bter and dgex combined on BTC

here comes CHINA!

SN
S   U   P   E   R    N   E   T
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀   
Uniting cryptocurrencies, Rewarding talent, Sharing benefits..

Blockchain Technology.

Come-from-Beyond
Legendary
*
Offline Offline

Activity: 2142
Merit: 1009

Newbie


View Profile
February 10, 2014, 06:35:32 PM
 #31713

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

also

please do not try to increase the support to remove mining fees, at least not just yet...Mining makes more people run more nodes thereby securing the network, no matter their intent...unless project kharon is ready and implemented


Innovative ideas are nice but radical proposals are great
BUT PLEASE KEEP NXT PURE TO ITS FUNDAMENT SOCIAL CONTRACT

More people should comment on this link to let their opinion be known:

https://bitcointalk.org/index.php?topic=458036.0

I didn't say that I'm going to add reversable transactions. We also can't make Nxt an inflationary coin. And forging fees can't be removed completely.
brooklynbtc
Sr. Member
****
Offline Offline

Activity: 336
Merit: 250

AKA jefdiesel


View Profile
February 10, 2014, 06:35:42 PM
 #31714

NXT account got hacked. 34200 NXT stolen from my account

account number, password and what version app were you using?

Where did you download it from?


SN
S   U   P   E   R    N   E   T
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀   
Uniting cryptocurrencies, Rewarding talent, Sharing benefits..

Blockchain Technology.

brooklynbtc
Sr. Member
****
Offline Offline

Activity: 336
Merit: 250

AKA jefdiesel


View Profile
February 10, 2014, 06:43:09 PM
 #31715

NXT account got hacked. 34200 NXT stolen from my account

account number, password and what version app were you using?

Where did you download it from?



acc number is 8616845891998500989. I was using 0.5.11. I downloaded it from official NXT website

did you log in to any remote NRS? any app? any faucet?

SN
S   U   P   E   R    N   E   T
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀   
Uniting cryptocurrencies, Rewarding talent, Sharing benefits..

Blockchain Technology.

brooklynbtc
Sr. Member
****
Offline Offline

Activity: 336
Merit: 250

AKA jefdiesel


View Profile
February 10, 2014, 06:44:38 PM
 #31716

NXT account got hacked. 34200 NXT stolen from my account

account number, password and what version app were you using?

Where did you download it from?



acc number is 8616845891998500989. I was using 0.5.11. I downloaded it from official NXT website

it shows you transferred them to your account at 10.02.2014 17:41:39
and they left 2 minutes later?
 
where did they come from? did you buy them?

SN
S   U   P   E   R    N   E   T
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀   
Uniting cryptocurrencies, Rewarding talent, Sharing benefits..

Blockchain Technology.

FrictionlessCoin
Legendary
*
Offline Offline

Activity: 868
Merit: 1000


Cryptotalk.org - Get paid for every post!


View Profile
February 10, 2014, 06:46:19 PM
 #31717

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. x<h)
2) 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<=v<q.
If -128<v[31]<0 then a (positive) multiple of the group order is added 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<=v<q.
In the other case x<h making v=x-h negativ (we had an underflow) and thus its highest bit is set, i.e. -128<v[31]<0. In that case we are causing an overflow by adding a suitable multiple of the group order which compensates the underflow and will again have 0<=v<q.
Sounds 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<=v<q. The rest of sign() is the same es before. Nothing 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.

bloody details!

Join the NEX team and you will be bloody rewarded!

 
                                . ██████████.
                              .████████████████.
                           .██████████████████████.
                        -█████████████████████████████
                     .██████████████████████████████████.
                  -█████████████████████████████████████████
               -███████████████████████████████████████████████
           .-█████████████████████████████████████████████████████.
        .████████████████████████████████████████████████████████████
       .██████████████████████████████████████████████████████████████.
       .██████████████████████████████████████████████████████████████.
       ..████████████████████████████████████████████████████████████..
       .   .██████████████████████████████████████████████████████.
       .      .████████████████████████████████████████████████.

       .       .██████████████████████████████████████████████
       .    ██████████████████████████████████████████████████████
       .█████████████████████████████████████████████████████████████.
        .███████████████████████████████████████████████████████████
           .█████████████████████████████████████████████████████
              .████████████████████████████████████████████████
                   ████████████████████████████████████████
                      ██████████████████████████████████
                          ██████████████████████████
                             ████████████████████
                               ████████████████
                                   █████████
.CryptoTalk.org.|.MAKE POSTS AND EARN BTC!.🏆
Come-from-Beyond
Legendary
*
Offline Offline

Activity: 2142
Merit: 1009

Newbie


View Profile
February 10, 2014, 06:47:04 PM
 #31718

it shows you transferred them to your account at 10.02.2014 17:41:39
and they left 2 minutes later?
 
where did they come from? did you buy them?

I bet passphrase is very weak.
brooklynbtc
Sr. Member
****
Offline Offline

Activity: 336
Merit: 250

AKA jefdiesel


View Profile
February 10, 2014, 06:48:34 PM
 #31719

it shows you transferred them to your account at 10.02.2014 17:41:39
and they left 2 minutes later?
 
where did they come from? did you buy them?

I bet passphrase is very weak.

cfb look at blockchain

34026 in from an account with no other trans than 34678 in from an account with no other trans but 35300 in etcc...

   11007046523210455619   34,026

from

    14496421013728271997   34,678

from

        2242568923119713955   35,330

with always a second payout of 650



http://87.230.14.1/nxt/nxt.cgi?action=100

wierd shit

it goes back 10 account plus, all the same thing, with 650 siphoned off each, and all the 650s go to

http://87.230.14.1/nxt/nxt.cgi?action=3000&acc=14343293611098709683

WTF IS THIS??

HEY LOOK AT THE TRANSACTIONS

SN
S   U   P   E   R    N   E   T
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀   
Uniting cryptocurrencies, Rewarding talent, Sharing benefits..

Blockchain Technology.

xyzzyx
Sr. Member
****
Offline Offline

Activity: 490
Merit: 250


I don't really come from outer space.


View Profile
February 10, 2014, 06:50:36 PM
 #31720

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

I agree, HFT is not impossible if you discard the delay between blocks.

"An awful lot of code is being written ... in languages that aren't very good by people who don't know what they're doing." -- Barbara Liskov
Pages: « 1 ... 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 [1586] 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 ... 2557 »
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!