Module libp2p_crypto

Data Types

ecdh_fun()


ecdh_fun() = fun((pubkey()) -> binary())

enacl_privkey()


enacl_privkey() = <<_:256>>

enacl_pubkey()


enacl_pubkey() = <<_:256>>

key_map()


key_map() = #{secret => privkey(), public => pubkey()}

key_type()


key_type() = ecc_compact | ed25519

privkey()


privkey() = {ecc_compact, ecc_compact:private_key()} | {ed25519, enacl_privkey()}

pubkey()


pubkey() = {ecc_compact, ecc_compact:public_key()} | {ed25519, enacl_pubkey()}

pubkey_bin()


pubkey_bin() = <<_:8, _:_*8>>

sig_fun()


sig_fun() = fun((binary()) -> binary())

Function Index

b58_to_bin/1
b58_to_pubkey/1
b58_to_version_bin/1
bin_to_b58/1
bin_to_b58/2
bin_to_pubkey/1
generate_keys/1Generate keys suitable for a swarm.
keys_from_bin/1
keys_to_bin/1
load_keys/1Load the private key from a pem encoded given filename.
mk_ecdh_fun/1
mk_sig_fun/1
p2p_to_pubkey_bin/1
pubkey_bin_to_p2p/1
pubkey_to_b58/1
pubkey_to_bin/1
save_keys/2Store the given keys in a file.
verify/3Verifies a digital signature, using sha256.

Function Details

b58_to_bin/1


b58_to_bin(Str::string()) -> binary()


b58_to_pubkey/1


b58_to_pubkey(Str::string()) -> pubkey()


b58_to_version_bin/1


b58_to_version_bin(Str::string()) -> {Version::non_neg_integer(), binary()}


bin_to_b58/1


bin_to_b58(Bin::binary()) -> string()


bin_to_b58/2


bin_to_b58(Version::non_neg_integer(), Bin::binary()) -> string()


bin_to_pubkey/1


bin_to_pubkey(X1::pubkey_bin()) -> pubkey()


generate_keys/1


generate_keys(X1::key_type()) -> key_map()


Generate keys suitable for a swarm. The returned private and public key has the attribute that the public key is a compressable public key.

keys_from_bin/1


keys_from_bin(X1::binary()) -> key_map()


keys_to_bin/1


keys_to_bin(X1::key_map()) -> binary()


load_keys/1


load_keys(FileName::string()) -> {ok, key_map()} | {error, term()}


Load the private key from a pem encoded given filename. Returns the private and extracted public key stored in the file or an error if any occorred.

mk_ecdh_fun/1


mk_ecdh_fun(X1::privkey()) -> ecdh_fun()


mk_sig_fun/1


mk_sig_fun(X1::privkey()) -> sig_fun()


p2p_to_pubkey_bin/1


p2p_to_pubkey_bin(Str::string()) -> pubkey_bin()


pubkey_bin_to_p2p/1


pubkey_bin_to_p2p(PubKey::pubkey_bin()) -> string()


pubkey_to_b58/1


pubkey_to_b58(PubKey::pubkey()) -> string()


pubkey_to_bin/1


pubkey_to_bin(X1::pubkey()) -> pubkey_bin()


save_keys/2


save_keys(KeysMap::key_map(), FileName::string()) -> ok | {error, term()}


Store the given keys in a file. See @see key_folder/1 for a utility function that returns a name and location for the keys that are relative to the swarm data folder.

verify/3


verify(Bin::binary(), Signature::binary(), X3::pubkey()) -> boolean()


Verifies a digital signature, using sha256.