Author

Topic: The shortest elliptic curve library! (Read 1838 times)

legendary
Activity: 2128
Merit: 1065
June 18, 2012, 06: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://bitcointalksearch.org/topic/m.439736

It may not be shorter, but it is clearly on par with dc.
legendary
Activity: 1220
Merit: 1015
e-ducat.fr
June 18, 2012, 01: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
legendary
Activity: 1512
Merit: 1028
June 16, 2012, 12:00:43 AM
#7
Next up: offline Bitcoin transaction generator written in AWK...
legendary
Activity: 2053
Merit: 1354
aka tonikt
June 15, 2012, 01:26:35 PM
#6
it's amazing! Smiley
donator
Activity: 826
Merit: 1039
June 12, 2012, 09:54:37 AM
#5
Here's my attempt:

elliptic-curve-in-dc-0.2.8

*original source is here
legendary
Activity: 1288
Merit: 1076
June 12, 2012, 09:00:24 AM
#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
legendary
Activity: 1652
Merit: 2216
Chief Scientist
June 12, 2012, 08:48:43 AM
#3
You're a crazy-man.  Crazy in a good way... ever do any APL programming?
legendary
Activity: 1288
Merit: 1076
June 12, 2012, 08:00:20 AM
#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!dSLxs#LPs#LQs#]sM
legendary
Activity: 1288
Merit: 1076
June 08, 2012, 08:35:25 AM
#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!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').

Jump to: