Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/helium/erlang-tc
Erlang NIF for threshold_crypto
https://github.com/helium/erlang-tc
Last synced: 5 days ago
JSON representation
Erlang NIF for threshold_crypto
- Host: GitHub
- URL: https://github.com/helium/erlang-tc
- Owner: helium
- License: apache-2.0
- Created: 2021-01-09T10:17:07.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-09-16T21:49:43.000Z (about 3 years ago)
- Last Synced: 2024-10-29T08:41:46.789Z (15 days ago)
- Language: Erlang
- Size: 1.86 MB
- Stars: 5
- Watchers: 24
- Forks: 7
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
erlang_tc
=====Erlang bindings for [threshold_crypto](https://github.com/poanetwork/threshold_crypto).
**NOTE**: We advise _not_ to use the `erlang_tc` module directly, preferably use the submodules for performing various threshold cryptography functions.
Usage
-----Verfy basic secret key usage.
```erlang
1> SK0 = tc_secret_key:random().
#Ref<0.989752667.1337851906.91190>
2> SK1 = tc_secret_key:random().
#Ref<0.989752667.1337851906.91197>
3> PK0 = tc_secret_key:public_key(SK0).
#Ref<0.989752667.1337851906.91209>
4> MSG0 = <<"real news">>.
<<"real news">>
5> MSG1 = <<"fake news">>.
<<"fake news">>
6> %% correct
6> tc_pubkey:verify(PK0, tc_secret_key:sign(SK0, MSG0), MSG0).
true
7> %% wrong key
7> tc_pubkey:verify(PK0, tc_secret_key:sign(SK1, MSG0), MSG0).
false
8> %% wrong msg
8> tc_pubkey:verify(PK0, tc_secret_key:sign(SK0, MSG1), MSG0).
false
```Build
-----$ make
Test
-----$ make test