View Single Post
  #5  
Old 07-28-2007, 08:17
TmC TmC is offline
VIP
 
Join Date: Aug 2004
Posts: 330
Rept. Given: 1
Rept. Rcvd 15 Times in 9 Posts
Thanks Given: 2
Thanks Rcvd at 23 Times in 17 Posts
TmC Reputation: 15
Quote:
Originally Posted by taos
Uhmm I'm not expert in Delphi (ASM is better) but g,y are TECPoint data types.
Tecpoint is a record
:TECPoint = Record
XCoordinate, YCoordinate : TFGInt;
Infinity : Boolean;
You can manipulate TECPOINT to convert to string ( ECPointToECPointString) or reverse (ECPointStringToECPoint). TEcpoints are this y^2 = x^3 + a*x + b and they are points on a elliptic curve.
Maybe this can help you:
ECPointKMultiple(g, p, a, x, y);

'Code:
Begin
// setting up parameters
writeln('setting up EC parameters ...');
Base256StringToFGInt('222222aatzzzznnn', p);
ok := true;
While ok Do
Begin
FindPrimeGoodCurveAndPoint(p, a, b, h, n, 60, g);
IsECSuperSingular(p, a, b, ok);
If ok Then
Begin
FGIntDestroy(a);
FGIntDestroy(b);
FGIntDestroy(h);
FGIntDestroy(n);
ECPointDestroy(g);
End;
End;
Base256StringToFGInt('ergezam', x);
ECPointKMultiple(g, p, a, x, y);
Base10StringToFGInt('63557', k);
Base2StringToFGInt('1', one);
FGIntGCD(k, n, temp);
While Not (FGIntCompareAbs(one, temp) = Eq) Do
Begin
FGIntDestroy(temp);
FGIntAddBis(k, one);
FGIntGCD(k, n, temp);
End;
FGIntDestroy(temp);
FGIntDestroy(one);

// with all these precautions everything is set up for signing/verifying

T := 'A black hole is a place where God divided by zero';
writeln('Signing the following string: ', T);
ECDSASign(T, p, a, x, n, k, g, r, s);
writeln('Verifying signature...');
ECDSAVerify(T, r, s, p, a, n, g, y, ok);
If ok Then writeln('Verification complete: signature is valid') Else writeln('Signature is not valid');

FGIntDestroy(p);
FGIntDestroy(a);
FGIntDestroy(n);
FGIntDestroy(k);
FGIntDestroy(h);
FGIntDestroy(x);
ECPointDestroy(g);
ECPointDestroy(y);
readln;
'End CODE
Thanks taos, but the problem is just that one:

I should get y and g without involving x(the private key) or the entire scheme is useless since the private key is revealed and included in the program so everyone can create keys for it (etc etc)...

other helps?
Reply With Quote