DEV Community

voluntas
voluntas

Posted on • Updated on

ed25519 と x25519 で公開鍵と秘密鍵を作る

OTP-22.3-rc2 で ed25519 に対応しました。

Erlang/OTP 23 [erts-11.0] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [hipe] [sharing-preserving]

Eshell V11.0  (abort with ^G)
1> crypto:generate_key(eddsa, ed25519).
{<<125,35,162,182,22,21,162,141,50,135,15,227,58,228,192,
   29,126,65,238,25,99,54,18,220,253,153,209,222,...>>,
 <<162,78,62,125,24,238,130,139,208,62,159,201,51,207,143,
   240,70,226,152,30,39,89,65,172,131,198,164,...>>}
2> crypto:generate_key(ecdh, x25519).
{<<240,91,161,68,198,253,253,158,164,169,36,43,229,150,53,
   196,178,35,147,54,62,156,121,213,54,156,135,231,...>>,
 <<0,171,160,172,83,207,11,26,217,171,220,241,161,245,193,
   171,32,209,157,20,7,88,248,186,231,5,219,...>>}
Enter fullscreen mode Exit fullscreen mode

戻り値は {公開鍵, 秘密鍵} です。生成される証明書両方で compute_key は実行できるので、どちらで作っても大差ないです。

Top comments (0)