Skip to content

Hamstory/pyvrf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is a very simple wrapper around algorand forked libsodium with vrf.

Install libsodium of algorand

$ git clone https://github.com/algorand/libsodium
$ cd libsodium
$ ./autogen.sh
$ make && make check
$ sudo make install 

Install pyvrf

$ git clone https://github.com/hamstory/pyvrf
$ cd pyvrf
$ pip install .

VRF constants

pyvrf.crypto_vrf_secretkeybytes     # 64
pyvrf.crypto_vrf_publickeybytes     # 32
pyvrf.crypto_vrf_seedbytes          # 32
pyvrf.crypto_vrf_proofbytes         # 80
pyvrf.crypto_vrf_outputbytes        # 64

Note that secret key is 64 byte. Here, secret key consists of seed(32byte) + public key(32byte).

Example

import pyvrf

pk, sk = pyvrf.crypto_vrf_keypair()
print(pk.hex())
print(sk.hex())

More usages are in tests/test_pyvrf.py

VRF functions

crypto_vrf_keypair()

Internally generates a random seed and generates a secret key and a public key.

crypto_vrf_keypair_from_seed(seed: bytes)

Creates a secret key and a public key with the given random seed.

crypto_vrf_is_valid_key(pk: bytes)

Ensure that the public key is a valid key.

crypto_vrf_prove(sk: bytes, message: bytes)

Create a proof with a secret key and a message.

crypto_vrf_proof_to_hash(proof: bytes)

Use the generated proof to get a random hash. This function does not validate the proof. To verify and get the random hash, you should use the crypto_vrf_verify function.

crypto_vrf_verify(pk: bytes, proof: bytes, message: bytes)

Verify the proof with the message, public key and get the random hash coming out of the proof.

crypto_vrf_sk_to_pk(sk: bytes)

Get the public key from the secret key

crypto_vrf_sk_to_seed(sk: bytes)

Get the seed from the secret key

About

python wrapper of vrf included libsodium

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages