Bitcoin Forum
May 23, 2024, 05:28:07 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: « 1 2 3 [4] 5 »  All
  Print  
Author Topic: [ANN] Nxt Bounty for working JavaScript code that signs and verifies signatures  (Read 8353 times)
Jaguar0625 (OP)
Sr. Member
****
Offline Offline

Activity: 299
Merit: 250


View Profile
January 15, 2014, 02:12:06 PM
 #61

And for completeness, these are the numbers I see for hoax's implementation:

Code:
Javascript needs 16.6ms/getPublicKey
Javascript needs 33.8ms/sign
Javascript needs 27ms/verify

It looks like I have a lot of catching up to do :/.

NEM - nem.io
Come-from-Beyond
Legendary
*
Offline Offline

Activity: 2142
Merit: 1009

Newbie


View Profile
January 15, 2014, 03:12:14 PM
 #62

Since the Java code is producing deterministic signatures, I'm assuming you want the JavaScript port to have the same behavior?

If not, that would potentially open up other areas for optimization.

I want the same behavior.
Come-from-Beyond
Legendary
*
Offline Offline

Activity: 2142
Merit: 1009

Newbie


View Profile
January 15, 2014, 03:13:22 PM
 #63

Javascript needs 5.5ms/getPublicKey
Javascript needs 12ms/sign
Javascript needs 9.5ms/verify

So, who said that 10ms is impossible? Smiley
hoax
Newbie
*
Offline Offline

Activity: 36
Merit: 0


View Profile
January 15, 2014, 03:22:19 PM
 #64

Javascript needs 5.5ms/getPublicKey
Javascript needs 12ms/sign
Javascript needs 9.5ms/verify

So, who said that 10ms is impossible? Smiley
We talk about 1ghz core? Wink

But in overall, yes, i was too pessimistic Smiley
On my pc(core i5 2.67ghz) i now get 7.5ms(avg) for sign and 5.5ms(avg) for verify in Chrome Smiley
hoax
Newbie
*
Offline Offline

Activity: 36
Merit: 0


View Profile
January 15, 2014, 03:36:23 PM
 #65

Thanks to Jaguar0625 for tests. I just runned my latest version(on github) on them, all tests are passed Smiley
BloodyRookie
Hero Member
*****
Offline Offline

Activity: 687
Merit: 500


View Profile
January 15, 2014, 03:40:43 PM
 #66

Hmmm...chrome is indeed faster but even on a 3GHz maschine I don't get your results:

Code:
Javascript needs 12.22ms/getPublicKey
Javascript needs 26.24ms/sign
Javascript needs 21.18ms/verify

What am I doing wrong?

Nothing Else Matters
NEM: NALICE-LGU3IV-Y4DPJK-HYLSSV-YFFWYS-5QPLYE-ZDJJ
NXT: 11095639652683007953
gimre
Legendary
*
Offline Offline

Activity: 866
Merit: 1002



View Profile WWW
January 15, 2014, 03:45:25 PM
 #67

@gimre: On what kind of cpu r u testing, gimre?
laptop, i7, 2.2G

@Jaguar0625: 9.8ms/getPublicKey with javascript?

Yes, but don't worry, I ran your code too and it was faster Smiley. These are the results for your code on my machine (i am using the test js/html from your repo):
Code:
Javascript needs 5.5ms/getPublicKey
Javascript needs 12ms/sign
Javascript needs 9.5ms/verify

I suspect you're seeing slower numbers on your machine because you're testing in FireFox. AFAIK, Chrome has a faster JavaScript interpreter.

WOW, these look incredible!

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

Activity: 687
Merit: 500


View Profile
January 15, 2014, 03:50:37 PM
 #68

@hoax: I don't think your version of is_negative is compatible with the java version, or is it?
Code:
/* checks if x is "negative", requires reduced input */
function is_negative(x)
{
    return x[0] & 0xFF >= 0x80;
}


Nothing Else Matters
NEM: NALICE-LGU3IV-Y4DPJK-HYLSSV-YFFWYS-5QPLYE-ZDJJ
NXT: 11095639652683007953
hoax
Newbie
*
Offline Offline

Activity: 36
Merit: 0


View Profile
January 15, 2014, 03:59:44 PM
 #69

Hmmm...chrome is indeed faster but even on a 3GHz maschine I don't get your results:

Code:
Javascript needs 12.22ms/getPublicKey
Javascript needs 26.24ms/sign
Javascript needs 21.18ms/verify

What am I doing wrong?


Hmmm...chrome is indeed faster but even on a 3GHz maschine I don't get your results:

Code:
Javascript needs 12.22ms/getPublicKey
Javascript needs 26.24ms/sign
Javascript needs 21.18ms/verify

What am I doing wrong?

Just runned in ff26: 22ms(avg)/sign 16ms(avg)/verify.

As i can see it depends on loop count(more loops - better time) and browser wish(sometimes it do everything slower(extensions, synchronization, etc??).

We should test everything in same environment Smiley I would be appreciated if Jaguar0625 measure time for my latest version(which use rev22 math with some optimizations).

@hoax: I don't think your version of is_negative is compatible with the java version, or is it?
Code:
/* checks if x is "negative", requires reduced input */
function is_negative(x)
{
    return x[0] & 0xFF >= 0x80;
}


This check for overflow. Tested on Jaguar0625 tests(generated from Java) and get 100/100 passed, so... You can correct me if i'm wrong.

And you can remove in your sources second argument from
Code:
SHA256_write(m, m.length);
it was my copy-paste typo, sorry Sad
BloodyRookie
Hero Member
*****
Offline Offline

Activity: 687
Merit: 500


View Profile
January 15, 2014, 04:51:15 PM
 #70

@hoax: I don't think your version of is_negative is compatible with the java version, or is it?
Code:
/* checks if x is "negative", requires reduced input */
function is_negative(x)
{
    return x[0] & 0xFF >= 0x80;
}

This check for overflow. Tested on Jaguar0625 tests(generated from Java) and get 100/100 passed, so... You can correct me if i'm wrong.
Hmmm.....you didn't understand what I was trying to say, so here we go again.
Your code: is_negative(1) returns 0 (hopefully the & operator gets executed before >= operator).
Java code: is_negative(1) returns 1.

Since u use your is_negativ for both siging and verifying, it works.
But if u sign with your code and try to verify with the java code, it should fail sometimes (didn't test that but it really should fail).

Nothing Else Matters
NEM: NALICE-LGU3IV-Y4DPJK-HYLSSV-YFFWYS-5QPLYE-ZDJJ
NXT: 11095639652683007953
gimre
Legendary
*
Offline Offline

Activity: 866
Merit: 1002



View Profile WWW
January 15, 2014, 06:00:14 PM
 #71

My new results, I forgot to turn off miner when doing previous tests Wink

chrom-opera:
Code:
curveSelfTest : ok
sign time: 25.000ms
verify time: 16.000ms
sign+verify time: 41.000ms
 verified?  true
doing 20 signs
sigs20: 396.000ms
doing 20 verifies
verify20: 307.000ms
true,true,true,true,true,true,true,true,false,true,true,true,true,false,true,true,true,false,true,false

chrome:
Code:
curveSelfTest : ok
sign time: 25.000ms
verify time: 16.000ms
sign+verify time: 41.000ms
 verified?  true
doing 20 signs
sigs20: 396.000ms
doing 20 verifies
verify20: 307.000ms
true,true,true,true,true,true,true,true,false,true,true,true,true,false,true,true,true,false,true,false

I don't think I'll get to anything better than that...

Also on what data do you operate inside functions?
As I find requirement, to take input as "hex strings" quite ugly.

P.S. My sign looks more or less like this:
Code:
function crypto_sign(privKey, messageHash)
{
var pubAndS = this.c.genPubWithS(privKey);
var sess = pubAndS.s;

var x = SHA256(...);
var Y = this.c.genPub(x).key;

var h = SHA256(...);

var vh = this.c.sign(h, x, sess);
return {sig: vh, key: pubAndS.key};
}

NemusExMāchinā
Catapult docs: https://docs.symbol.dev
github: https://github.com/symbol
hoax
Newbie
*
Offline Offline

Activity: 36
Merit: 0


View Profile
January 15, 2014, 06:02:34 PM
 #72

Hmmm.....you didn't understand what I was trying to say, so here we go again.
You're right. Thank you. I've fixed it and will look at this closer again Smiley
Jaguar0625 (OP)
Sr. Member
****
Offline Offline

Activity: 299
Merit: 250


View Profile
January 16, 2014, 12:06:51 AM
 #73

We should test everything in same environment Smiley I would be appreciated if Jaguar0625 measure time for my latest version(which use rev22 math with some optimizations).

Here are the latest numbers for hoax's code:
Code:
Javascript needs 3.6ms/getPublicKey
Javascript needs 6.9ms/sign
Javascript needs 7.8ms/verify

Nice job!

NEM - nem.io
hoax
Newbie
*
Offline Offline

Activity: 36
Merit: 0


View Profile
January 16, 2014, 06:15:09 AM
 #74

We should test everything in same environment Smiley I would be appreciated if Jaguar0625 measure time for my latest version(which use rev22 math with some optimizations).

Here are the latest numbers for hoax's code:
Code:
Javascript needs 3.6ms/getPublicKey
Javascript needs 6.9ms/sign
Javascript needs 7.8ms/verify

Nice job!
Thank you Smiley
gimre
Legendary
*
Offline Offline

Activity: 866
Merit: 1002



View Profile WWW
January 16, 2014, 05:24:09 PM
 #75

Something told me, to do tests on Jaguar's test set, and glad I did, cause I've found small bug in my implementation.

Here's my code, https://github.com/gimer/curve25519nxt
inside testing.js there are some simple tests along with Jaguar's tests.

It's based on objects rather than modules.

I doubt it'll beat hoax implementation though.

Here are some numbers, from my machine.
Code:
testCurveKeygen: 764.000ms
testCurveSign: 0.000ms
testCurveVerify: 1200.000ms
testCryptoKey: 703.000ms
testCryptoSign: 1498.000ms     (~~ 15ms/sign)

Oh, PS, also api is a bit strange, I'd find it more covenient if everything passed to JS would be wrapped in typed arrays already.

NemusExMāchinā
Catapult docs: https://docs.symbol.dev
github: https://github.com/symbol
gimre
Legendary
*
Offline Offline

Activity: 866
Merit: 1002



View Profile WWW
January 17, 2014, 02:24:23 PM
 #76

We should test everything in same environment Smiley I would be appreciated if Jaguar0625 measure time for my latest version(which use rev22 math with some optimizations).

Here are the latest numbers for hoax's code:
Code:
Javascript needs 3.6ms/getPublicKey
Javascript needs 6.9ms/sign
Javascript needs 7.8ms/verify

Nice job!

Could I kindly ask you to run test also on my code?

NemusExMāchinā
Catapult docs: https://docs.symbol.dev
github: https://github.com/symbol
Jaguar0625 (OP)
Sr. Member
****
Offline Offline

Activity: 299
Merit: 250


View Profile
January 17, 2014, 11:24:33 PM
 #77

Could I kindly ask you to run test also on my code?

Are the inputs and outputs of all of your functions byte arrays?

NEM - nem.io
Jaguar0625 (OP)
Sr. Member
****
Offline Offline

Activity: 299
Merit: 250


View Profile
January 17, 2014, 11:27:45 PM
 #78

I was finally able to get rid of all the Long math and replace it from fast math functions from curve255.js and got much better results Smiley:
Code:
Javascript needs 6.9ms/getPublicKey
Javascript needs 13.4ms/sign
Javascript needs 10.7ms/verify

Still not as good as hoax's, but a lot better than my earlier numbers.

NEM - nem.io
gimre
Legendary
*
Offline Offline

Activity: 866
Merit: 1002



View Profile WWW
January 18, 2014, 10:27:35 AM
 #79

Could I kindly ask you to run test also on my code?

Are the inputs and outputs of all of your functions byte arrays?

almost, was it specified anywhere how input output should look like?

take a look at github, there's description of input output there.

NemusExMāchinā
Catapult docs: https://docs.symbol.dev
github: https://github.com/symbol
Come-from-Beyond
Legendary
*
Offline Offline

Activity: 2142
Merit: 1009

Newbie


View Profile
January 18, 2014, 10:29:17 AM
 #80

almost, was it specified anywhere how input output should look like?

Quote
- Input/output values must be strings like "8302504e4e57c6c65335289879c6915a273d3aae7bd086058e403fcd2bc18341"
Pages: « 1 2 3 [4] 5 »  All
  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!