Bitcoin Forum
December 05, 2016, 12:32:06 PM *
News: To be able to use the next phase of the beta forum software, please ensure that your email address is correct/functional.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: The shortest elliptic curve library!  (Read 1582 times)
grondilu
Legendary
*
Offline Offline

Activity: 1134


View Profile
June 08, 2012, 12:35:25 PM
 #1

I wrote this dc library for elliptic curve arithmetics on secp256k1:

Code:
I16iFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2Fsp
7sb0sa483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8
79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798lp*+sG
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141soilpsm
[[_1*lm1-*lm%q]Std0>tlm%Lts#]s%[_1*l%x]s_[+l%x]s+[*l%x]s*[-l%x]s-[Smdd
l%x-lm/rl%xLms#]s~[l%xsclmsd1su0sv0sr1st[q]SQ[lc0=Qldlcl~xlcsdscsqlrlq
lu*-ltlqlv*-lulvstsrsvsulXx]dSXxLXs#LQs#lrl%x]sI[lpSm[+q]S0d0=0lpl~xsy
dsxd*3*lal+x2ly*lIx*l%xdsld*2lx*l-xdlxrl-xlll*xlyl-xrlp*+Lms#L0s#]sD[lp
Sm[+q]S0[2;AlDxq]Sdd0=0rd0=0d2:Alp~1:A0:Ad2:Blp~1:B0:B2;A2;B=d[0q]Sx2;A
0;B1;Bl_xrlm*+=x0;A0;Bl-xlIxdsi1;A1;Bl-xl*xdsld*0;Al-x0;Bl-xd0;Arl-xll
l*x1;Al-xrlp*+L0s#Lds#Lxs#Lms#]sA[rs.0r[rl.lAxr]SP[q]sQ[d0!<Qd2%1=P2/l.
lDxs.lLx]dSLxs#LPs#LQs#]sM

It does addition and multiplication of any point.

Examples:

Doubling the subgroup generator (G):
Code:
$ dc "$THE_ABOVE_CODE  lG lDx lm~f"

Multiplying G by a large number stored in shell variable n:
Code:
$ dc "$THE_ABOVE_CODE $n lG lMx lm~f"


An so on (the macro for addition is in register 'A').

1480941126
Hero Member
*
Offline Offline

Posts: 1480941126

View Profile Personal Message (Offline)

Ignore
1480941126
Reply with quote  #2

1480941126
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
grondilu
Legendary
*
Offline Offline

Activity: 1134


View Profile
June 12, 2012, 12:00:20 PM
 #2


A bit shorter, and with better alignment (64 characters):

Code:
I16i7sb0sa[[_1*lm1-*lm%q]Std0>tlm%Lts#]s%[Smddl%x-lm/rl%xLms#]s~
483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8
79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798
2 100^d14551231950B75FC4402DA1732FC9BEBF-so1000003D1-ddspsm*+sGi
[_1*l%x]s_[+l%x]s+[*l%x]s*[-l%x]s-[l%xsclmsd1su0sv0sr1st[q]SQ[lc
0=Qldlcl~xlcsdscsqlrlqlu*-ltlqlv*-lulvstsrsvsulXx]dSXxLXs#LQs#lr
l%x]sI[lpSm[+q]S0d0=0lpl~xsydsxd*3*lal+x2ly*lIx*l%xdsld*2lx*l-xd
lxrl-xlll*xlyl-xrlp*+Lms#L0s#]sD[lpSm[+q]S0[2;AlDxq]Sdd0=0rd0=0d
2:Alp~1:A0:Ad2:Blp~1:B0:B2;A2;B=d[0q]Sx2;A0;B1;Bl_xrlm*+=x0;A0;B
l-xlIxdsi1;A1;Bl-xl*xdsld*0;Al-x0;Bl-xd0;Arl-xlll*x1;Al-xrlp*+L0
s#Lds#Lxs#Lms#]sA[rs.0r[rl.lAxr]SP[q]sQ[d0!<Qd2%1=P2/l.lDxs.lLx]
dSLxs#LPs#LQs#]sM
Gavin Andresen
Legendary
*
qt
Offline Offline

Activity: 1652


Chief Scientist


View Profile WWW
June 12, 2012, 12:48:43 PM
 #3

You're a crazy-man.  Crazy in a good way... ever do any APL programming?

How often do you get the chance to work on a potentially world-changing project?
grondilu
Legendary
*
Offline Offline

Activity: 1134


View Profile
June 12, 2012, 01:00:24 PM
 #4

You're a crazy-man.  Crazy in a good way...ever do any APL programming?

 Cheesy
No, but I'll check it out Smiley
ribuck
Donator
Legendary
*
Offline Offline

Activity: 826


View Profile
June 12, 2012, 01:54:37 PM
 #5

Here's my attempt:

elliptic-curve-in-dc-0.2.8

*original source is here
piotr_n
Legendary
*
Offline Offline

Activity: 1498


aka tonikt


View Profile WWW
June 15, 2012, 05:26:35 PM
 #6

it's amazing! Smiley

Check out gocoin - my original project of a bitcoin client written in Go, with some unique features.
PGP fingerprint: AB9E A551 E262 A87A 13BB  9059 1BE7 B545 CDF3 FD0E
deepceleron
Legendary
*
Offline Offline

Activity: 1470



View Profile WWW
June 16, 2012, 04:00:43 AM
 #7

Next up: offline Bitcoin transaction generator written in AWK...

Boussac
Legendary
*
Offline Offline

Activity: 1173


e-ducat.fr


View Profile WWW
June 18, 2012, 05:13:06 PM
 #8

Here's my attempt:

elliptic-curve-in-dc-0.2.8

*original source is here

I like those curves too  Cheesy but Grondilu is the grand master

2112
Legendary
*
Offline Offline

Activity: 1708



View Profile
June 18, 2012, 10:43:40 PM
 #9

You're a crazy-man.  Crazy in a good way... ever do any APL programming?


Aaah, APL. The write-only programming language.
Speaking of APL: someone had alredy posted an EC math library in the J programming language, the descendant of APL.

Here's the link:

https://bitcointalk.org/index.php?topic=35518.msg439736#msg439736

It may not be shorter, but it is clearly on par with dc.

Please comment, critique, criticize or ridicule BIP 2112: https://bitcointalk.org/index.php?topic=54382.0
Long-term mining prognosis: https://bitcointalk.org/index.php?topic=91101.0
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!