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

Import libsodium (Algorand's VRF lib) into Tendermint #12

Merged
merged 3 commits into from
Jan 14, 2020

Conversation

torao
Copy link
Contributor

@torao torao commented Jan 9, 2020

This PR on #1, #2 allows us to call the library libsodium implemented in C from within the Tendermint project. This contains golang functions that are equivalent to the VRF functions defined in libsodium.

Note that the libsodium used in this PR is a cryptography library of the same name with VRF capability (IRFT Draft 3) added by Algorand. The original libsodium does not contain a VRF.

In a newly checked out environment, libsodium must be built and installed before compiling golang.

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

This PR is a renewed version of #4 with accumulated commits and rebases.

@torao torao added the C: enhancement Classification: New feature or its request, or improvement in maintainability of code label Jan 9, 2020
@torao torao added this to the Evolve Leader Election into VRF milestone Jan 9, 2020
@torao torao self-assigned this Jan 9, 2020
@@ -0,0 +1,125 @@
// This vrf package makes the VRF API in Algorand's libsodium C library available to golang.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about adding our license comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we need to decide on a license declaration for our new files. I'll save it as another discussion ticket.


const OUTPUTBYTES = uint32(C.crypto_vrf_OUTPUTBYTES)

const PRIMITIVE = C.crypto_vrf_PRIMITIVE
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about collecting all similar constant values like below?

const (
	PUBLICKEYBYTES = uint32(C.crypto_vrf_PUBLICKEYBYTES)
	SECRETKEYBYTES = uint32(C.crypto_vrf_SECRETKEYBYTES)
	SEEDBYTES = uint32(C.crypto_vrf_SEEDBYTES)
	PROOFBYTES = uint32(C.crypto_vrf_PROOFBYTES)
	OUTPUTBYTES = uint32(C.crypto_vrf_OUTPUTBYTES)
	PRIMITIVE = C.crypto_vrf_PRIMITIVE
)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it seems better readability. I'll fix it.

return newOutput(op), nil
}

type Output [OUTPUTBYTES]byte
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to move topside, because it is easy to understand that the constant and property values is collected and are existed topside than functions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix it.

@torao torao mentioned this pull request Jan 10, 2020
Copy link
Member

@zemyblue zemyblue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@egonspace egonspace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@torao
Copy link
Contributor Author

torao commented Jan 14, 2020

all green

@torao torao merged commit 3402565 into master Jan 14, 2020
@torao torao deleted the feature/import_libsodium branch June 22, 2020 10:20
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

Successfully merging this pull request may close these issues.

4 participants