Pages:
Author

Topic: Presentation of my ECC Calculator (Read 940 times)

full member
Activity: 161
Merit: 168
April 23, 2021, 03:23:18 AM
#28
How to use this program?
Did developer have video show hot to use?


If I find the time, I'll make a video. Unfortunately, my English is very poor and I am not a video professional. I would be very happy from someone else who would like to make a video of the program :-)
member
Activity: 406
Merit: 45
April 22, 2021, 10:26:47 PM
#27
How to use this program?
Did developer have video show hot to use?
member
Activity: 313
Merit: 34
April 22, 2021, 05:15:15 PM
#26
can some ecc expert write about Point addition / Point concatenate

https://bitcointalk.org/index.php?topic=5332526.new#new

waiting your expert views
legendary
Activity: 1914
Merit: 2071
April 13, 2020, 12:15:15 PM
#25

I use 32 groups of 255 points = 8160 precomputed points.
How do you think, if use 16 groups 65,535 points (1 048 576 points) will it be faster? Only 15 additions will be required.

I think it would be slower, the table would be in RAM and not in some faster cpu's cache.
sr. member
Activity: 443
Merit: 350
April 13, 2020, 12:06:59 PM
#24
-snip-
I represent every private key in binary, I split that number in 32 pieces (each piece has 256/32=8 bit -> 255 elements) and I compute only 32-1 = 31 group additions (instead of 256) for each key. No doubling.
-snip-
I split a 256 bit key in 32 pieces of 8 bit and I compute 31 additions.

Thank you very much! Very good approach!

I have tested already with 256 precomputed powers of two (so performed 255 additions) - for 10k random private keys I need 7.13 seconds (1400 per second) compared to 16 seconds (625 per second) without precomputed table. More than 2 times improvement.

I beleive that with your approach the speed will be faster. Not sure but seems that if I need only 31 additions instead of 255, the speed should be faster by 255/31 = 8 times, so for 10k I will need less than 1 second (11k per second).

I use 32 groups of 255 points = 8160 precomputed points.
How do you think, if use 16 groups 65,535 points (1 048 576 points) will it be faster? Only 15 additions will be required.
legendary
Activity: 1914
Merit: 2071
April 13, 2020, 11:07:54 AM
#23

-snip-
I use a precomputed table of multiples of G.

I did not use any precomputed multiples of G.
Do you use just 256 precomupted points for powers of two (2^0, 2^1, 2^2, 2^3, 2^4, ... 2^255) and later represent every private key number in binary and make scalar additions of precomputed points? If no, how much is your precomupted table and what kind of points include?


If you precompute only the powers of two, you avoid only the doublings. It is like you split your binary key in 256 pieces, each piece in this case is a particular point and then you perform 255 additions between these points.
But if you split 256 in 128/64/32/16/8 parts and you precompute every key in these "parts" (in these cases each part has more than 1 point) you can lower the number of additions.

I use 32 groups of 255 points = 8160 precomputed points.

I represent every private key in binary, I split that number in 32 pieces (each piece has 256/32=8 bit -> 255 elements) and I compute only 32-1 = 31 group additions (instead of 256) for each key. No doubling.

Just for example, if you have a 32 bit key:

key = 10101010101000001111111101000010

split in 4 pieces of 32/4=8 bits:

(10101010)*2^24 + (10100000)*2^16 + (11111111)*2^8 + (01000010)

Then I need to do only 3 additions, if I have precomputed this table (a line for each piece):

Code:
00000001  00000010 00000011  …   11111111

  2^0       2*2^0    3*2^0   …    255*2^0       --> one of these is (01000010)

  2^8       2*2^8    3*2^8   …    255*2^8       --> one of these is (11111111)*2^8

2^(2*8)  2*2^(2*8)  3*2^(2*8) . 255*2^(2*8)    --> one of these is (10100000)*2^16

2^(3*8)  2*2^(3*8)  3*2^(3*8) . 255*2^(3*8)    -->  one of these is (10101010)*2^24

Each line has 255 elements because you don't need the (00000000) element.


For a 256 bit key, this is the precomputed table (32 lines * 255 elements = 8160):
Code:
2^0 , 2*2^0,  3*2^0, … , 255*2^0

2^8,  2*2^8,  3*2^8, …,  255*2^8    

2^(2*8),  2*2^(2*8), 3*2^(2*8) , .., 255*2^(2*8)

2^(3*8),  2*2^(3*8), 3*2^(3*8) , .., 255*2^(3*8)

2^(4*8),  2*2^(4*8), 3*2^(4*8) , .., 255*2^(4*8)

2^(5*8),  2*2^(5*8), 3*2^(5*8) , .., 255*2^(5*8)



2^(31*8),  2*2^(31*8), 3*2^(31*8) , .., 255*2^(31*8)


I split a 256 bit key in 32 pieces of 8 bit and I compute 31 additions.
full member
Activity: 161
Merit: 168
April 13, 2020, 10:41:45 AM
#22
-snip-
I use a precomputed table of multiples of G.

I did not use any precomputed multiples of G.
Do you use just 256 precomupted points for powers of two (2^0, 2^1, 2^2, 2^3, 2^4, ... 2^255) and later represent every private key number in binary and make scalar additions of precomputed points? If no, how much is your precomupted table and what kind of points include?


https://github.com/MrMaxweII/Secp256k1-Calculator/blob/master/EXPList.java
sr. member
Activity: 443
Merit: 350
April 13, 2020, 10:32:28 AM
#21
-snip-
I use a precomputed table of multiples of G.

I did not use any precomputed multiples of G.
Do you use just 256 precomupted points for powers of two (2^0, 2^1, 2^2, 2^3, 2^4, ... 2^255) and later represent every private key number in binary and make scalar additions of precomputed points? If no, how much is your precomupted table and what kind of points include?
legendary
Activity: 1914
Merit: 2071
April 13, 2020, 08:49:30 AM
#20
However for the subsequent multiplications for numbers from 1 up to 10,000 (not random) it needed 0.6 seconds for all 10k multiplications.

Consecutive keys:

210k keys per sec; with some optimizations: 800k per sec.
full member
Activity: 161
Merit: 168
April 13, 2020, 05:35:39 AM
#19
I use my self-written library Secp256k1: https://github.com/MrMaxweII/Secp256k1

One of the main reasons for your code being slow is that you are using BigInteger, or more precisely an arbitrary length integer. The implementation of BigInteger is also known to be not-optimized which contributed to it being slow.
Optimization of BigInteger itself could help increase speed by a factor of 5 to 10.
Replacing it with a fixed length integer increases the speed by a factor of 20.
Replacing methods such as Add, Subtract, Multiply,... with their modular alternatives (AddMod, MultMod,...) increases the speed by a factor of 10.

There are some more ideas I'm currently exploring that would optimize ECC further. I've actually started a topic about optimization here 4 month ago but didn't receive any reply so the ideas are kinda on pause right now.

That's exactly the case! Thanks for the feedback.
I know that too, but I didn't mean to change that.
Programming my own data type is a lot of work for me and I have other projects I'm working on. I am currently programming a block explorer that uses the LevelDB database from the Bitcoin Core.
Using BigInteger is the easiest way to start.
If someone knows, provides or programs a suitable data type in Java for this 32 byte data, it would be great and I would then incorporate this into my libraries and into this program.
Of course, the required modular operations for this data type must then be provided. I still can't assess how difficult that would be.
legendary
Activity: 1039
Merit: 2783
Bitcoin and C♯ Enthusiast
April 13, 2020, 03:40:54 AM
#18
If you want to share your ideas …

The other ideas were mostly language related (C#) which is why I didn't mention them. For instance I've been experimenting with the new feature added in recent C# versions called ref structs. A ref readonly struct has been a successful optimization too.
Another idea was playing around with underlying integer type (UInt32 versus UInt64) and to use 32-bit or half of a UInt64 which later I found an article explaining an optimization for Curve25519 which uses radix 251 representation instead.

Basically I've started the optimization from the lowest part which is the integer type and all the basic arithmetic.
If there is interest, I could start a topic and share my findings when I'm done optimizing ECC in near future.
legendary
Activity: 1914
Merit: 2071
April 13, 2020, 03:18:43 AM
#17
There are some more ideas I'm currently exploring that would optimize ECC further. I've actually started a topic about optimization here 4 month ago but didn't receive any reply so the ideas are kinda on pause right now.

If you want to share your ideas …

Optimizing field operations is the first thing, in particular way
a) "mod p" after multiplication
b) inversion operation

Optimizing scalar multiplication (group operation) is another step.
legendary
Activity: 1039
Merit: 2783
Bitcoin and C♯ Enthusiast
April 13, 2020, 02:59:22 AM
#16
I use my self-written library Secp256k1: https://github.com/MrMaxweII/Secp256k1

One of the main reasons for your code being slow is that you are using BigInteger, or more precisely an arbitrary length integer. The implementation of BigInteger is also known to be not-optimized which contributed to it being slow.
Optimization of BigInteger itself could help increase speed by a factor of 5 to 10.
Replacing it with a fixed length integer increases the speed by a factor of 20.
Replacing methods such as Add, Subtract, Multiply,... with their modular alternatives (AddMod, MultMod,...) increases the speed by a factor of 10.

There are some more ideas I'm currently exploring that would optimize ECC further. I've actually started a topic about optimization here 4 month ago but didn't receive any reply so the ideas are kinda on pause right now.
legendary
Activity: 1914
Merit: 2071
April 13, 2020, 02:17:43 AM
#15
What kind of CPU do you use?
Intel Xeon CPU E3-1505M v6 3.00 GHz, a mobile cpu and my laptop is 3 years old.


I tested the code under Ubuntu, and it needs 16 seconds to perform 10k scalar multiplications for 10k random private keys, so it is 620-630 per second. However for the subsequent multiplications for numbers from 1 up to 10,000 (not random) it needed 0.6 seconds for all 10k multiplications.

I use a precomputed table of multiples of G.
sr. member
Activity: 443
Merit: 350
April 12, 2020, 09:02:03 PM
#14
-snip-
I have a python code that performs over 4300 scalar multiplications per second (about 2800 if I don't use the invert function from gmpy2).
-snip-

What kind of CPU do you use?
I tested the code under Ubuntu, and it needs 16 seconds to perform 10k scalar multiplications for 10k random private keys, so it is 620-630 per second. However for the subsequent multiplications for numbers from 1 up to 10,000 (not random) it needed 0.6 seconds for all 10k multiplications.
legendary
Activity: 1914
Merit: 2071
April 12, 2020, 02:28:13 PM
#13
I'm just starting my Ubuntu to test it there ...

My PC Lenovo has a very high resolution:

Code:
xdpyinfo | grep dimensions
  dimensions:    3840x2160 pixels (1016x571 millimeters)

Could you print out a screen?

https://i.imgur.com/A9frh8p.png
full member
Activity: 161
Merit: 168
April 12, 2020, 02:05:11 PM
#12
I'm just starting my Ubuntu to test it there ...

My PC Lenovo has a very high resolution:

Code:
xdpyinfo | grep dimensions
  dimensions:    3840x2160 pixels (1016x571 millimeters)

Could you print out a screen?
legendary
Activity: 1914
Merit: 2071
April 12, 2020, 01:51:03 PM
#11
I'm just starting my Ubuntu to test it there ...

My PC Lenovo has a very high resolution:

Code:
xdpyinfo | grep dimensions
  dimensions:    3840x2160 pixels (1016x571 millimeters)
full member
Activity: 161
Merit: 168
April 12, 2020, 01:44:17 PM
#10
An X coordinate "65366546543536537574373456456" is not on the SECP256k1 curve. So this is an input error.
If you enter coordinates explicitly, the points must lie on the curve.

I'm just starting my Ubuntu to test it there ...

So under Linux (Ubuntu) the font size is a bit larger, so that the input fields are a bit too short to display the whole number.
But the cursor can be moved in the input field with the arrow keys and the numbers then scroll to the right or left.
This at least enables input and output. Even if it's not nice, admittedly.
The GUI was created under Windows. There all fields are the right size. I'm sorry if it is different on Linux.
With my next update, I will improve that.
legendary
Activity: 1914
Merit: 2071
April 12, 2020, 01:29:26 PM
#9
1) on my pc (Ubuntu 17.04) I get a windows too small; how to resize it?

2)
Scalar
653646536547337543

Vector
x
65366546543536537574373456456

If I click on the first 'y' I get '0', If I click on the second one I get 'fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f', it is a bug?
Pages:
Jump to: