5 type tKey32
=packed array [0..31] of byte;
6 type tKey64
=packed array [0..63] of byte;
12 (*procedure CreateSeed(out seed: tKey32);*)
13 procedure CreatekeyPair(out pub
:tPubKey
; var priv
:tPrivKey
);
14 procedure Sign(out signature
:tSig
; const message; len
:LongWord
; const pub
:tPubKey
; const priv
:tPrivKey
);
15 function Verify(const signature
:tSig
; const message; len
:LongWord
; const pub
:tPubKey
):boolean;
16 procedure SharedSecret(out shared
:tKey32
; const pub
:tPubKey
; const priv
:tPrivKey
);
25 {$L ed25519/key_exchange.o}
28 procedure ed25519_create_keypair(pub
,priv
,seed
:pointer);
30 procedure ed25519_sign(sig
,msg
:pointer; len
:LongWord
; pub
,priv
:pointer);
32 function ed25519_verify(sig
,msg
:pointer; len
:LongWord
; pub
:pointer):integer;
34 procedure ed25519_key_exchange(shared
,pub
,priv
:pointer);
37 type ge_p3
=packed array [1..160] of byte; {opaque}
38 procedure ge_scalarmult_base(h
,a
:pointer); cdecl;external;
39 procedure ge_p3_tobytes(s
, h
:pointer); cdecl;external;
41 procedure CreateKeyPair(out pub
:tPubKey
; var priv
:tPrivKey
);
44 priv
[ 0] := priv
[ 0] and 248;
45 priv
[31] := priv
[31] and 63;
46 priv
[31] := priv
[31] or 64;
47 ge_scalarmult_base(@A
, @priv
);
48 ge_p3_tobytes(@pub
, @A
);
51 procedure Sign(out signature
:tSig
; const message; len
:LongWord
; const pub
:tPubKey
; const priv
:tPrivKey
);
53 ed25519_sign(@signature
,@message,len
,@pub
,@priv
);
56 function Verify(const signature
:tSig
; const message; len
:LongWord
; const pub
:tPubKey
):boolean;
58 Verify
:=ed25519_verify(@signature
,@message,len
,@pub
)=1;
61 procedure SharedSecret(out shared
:tKey32
; const pub
:tPubKey
; const priv
:tPrivKey
);
63 ed25519_key_exchange(@shared
,@pub
,@priv
);