Erlang에서 ed25519를 사용하여 서명/검증

19507 단어 Erlangcryptotech
Erlang의 crypto 모듈에서 "ed25519"키 쌍을 생성하고 이 쌍을 사용하여 서명하고 검증합니다.
Erlang/OTP 24 [RELEASE CANDIDATE 2] [erts-12.0] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]

Eshell V12.0  (abort with ^G)
1> {PubKey, PrivKey} = crypto:generate_key(eddsa, ed25519).
{<<184,46,247,95,51,237,199,16,53,26,179,236,67,32,216,
   166,215,236,97,90,244,28,24,161,239,6,82,99,...>>,
 <<86,122,18,144,17,142,65,238,204,99,8,74,168,240,94,215,
   203,73,2,77,229,177,94,126,185,252,190,...>>}
2> {Algorithm, CryptoKey} = {eddsa, [PrivKey, ed25519]}.
{eddsa,[<<86,122,18,144,17,142,65,238,204,99,8,74,168,240,
          94,215,203,73,2,77,229,177,94,126,185,252,...>>,
        ed25519]}
3> DigestType = sha384.
sha384
4> PlainText = <<"abcd">>.
<<"abcd">>
5> Options = [].
[]
6> Signature = crypto:sign(Algorithm, DigestType, PlainText, CryptoKey, Options).
<<116,140,19,21,30,207,166,59,163,84,8,42,166,29,125,229,
  60,207,82,101,211,157,57,170,95,33,27,234,162,...>>
7> {Algorithm, CryptoKey1} = {eddsa, [PubKey, ed25519]}.
{eddsa,[<<184,46,247,95,51,237,199,16,53,26,179,236,67,32,
          216,166,215,236,97,90,244,28,24,161,239,6,...>>,
        ed25519]}
8> crypto:verify(Algorithm, DigestType, PlainText, Signature, CryptoKey1, Options).
true

좋은 웹페이지 즐겨찾기