Skip to content

Instantly share code, notes, and snippets.

View mikekelly's full-sized avatar

Mike Kelly mikekelly

View GitHub Profile
-module(compress_ecdsa_publickey).
-export([compress_ecdsa_publickey/1, test/0]).
compress_ecdsa_publickey(UncompressedPublicKey) ->
%% To binary
UncompressedPublicKeyBin = binary:decode_hex(list_to_binary(UncompressedPublicKey)),
%% Check that the uncompressed public key is valid
case size(UncompressedPublicKeyBin) of
65 ->
%% Remove the prefix (first byte) from the public key