Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it possible to call a VRF API implemented in Algorand's libsodium #1

Closed
torao opened this issue Nov 15, 2019 · 3 comments
Closed
Assignees
Labels
C: enhancement Classification: New feature or its request, or improvement in maintainability of code

Comments

@torao
Copy link
Contributor

torao commented Nov 15, 2019

Use libsodium (used by Algorand) for VRF. It's an extension of the original security library jedisc1/libsodium to include VRF functionality.

The libsodium is implemented in C and should be called via cgo from Tendermint.

The header file sodium.h is required to use constants and functions in libsodium from Golang. Therefore, I'll place github.com/algorithm/libsodium on crypto/vrf/internal/vrf/libsodium
(with git submodule), according to other packages, such as crypto/secp256k, which is part of Tendermint.

Additionally, we must also compile and install the library before we use it.

@torao torao added the C: enhancement Classification: New feature or its request, or improvement in maintainability of code label Nov 15, 2019
@torao torao added this to the Evolve Leader Election into VRF milestone Nov 15, 2019
@torao torao self-assigned this Nov 15, 2019
@torao
Copy link
Contributor Author

torao commented Nov 15, 2019

This modification will require libsodium to be installed before building Tendermint, as follows:

$ cd crypto/vrf/internal/vrf/libsodium
$ ./autoconf.sh
$ ./configure
$ make && make check
$ sudo make install

The symbols crypto_vrf_* will then be visible on libsodium.a,

$ nm /usr/local/lib/libsodium.a | grep vrf
/usr/local/lib/libsodium.a(libsodium_la-crypto_vrf.o):
U _crypto_vrf_ietfdraft03_is_valid_key
U _crypto_vrf_ietfdraft03_keypair
...

and can be called from golang.

package main

/*
#cgo CFLAGS: -I./internal/vrf/libsodium/src/libsodium/include
#cgo LDFLAGS: -lsodium
#include <sodium.h>
*/
import "C"
import "fmt"

func main(){
  fmt.Printf("public key bytes: %d\n", C.crypto_vrf_publickeybytes())
}

@torao
Copy link
Contributor Author

torao commented Nov 19, 2019

push on branch feature/integrate_libsodium.

@torao
Copy link
Contributor Author

torao commented Dec 13, 2019

To be taken over to PR # 4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: enhancement Classification: New feature or its request, or improvement in maintainability of code
Projects
None yet
Development

No branches or pull requests

1 participant