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

Verification failed despite correct proof and message #13

Closed
torao opened this issue Jan 10, 2020 · 0 comments
Closed

Verification failed despite correct proof and message #13

torao opened this issue Jan 10, 2020 · 0 comments
Assignees
Labels
C: bug Classification: Something isn't working

Comments

@torao
Copy link
Contributor

torao commented Jan 10, 2020

Situation: To create a proof for a message using VRF prove() and when it's used the verify() with the same message, it could fail.

Caused by: a bug in passing the message from Go to C as a byte array. Specifically, it must pass an address of the array (so-called pointer or reference), but it was passed not array address but Go slice address as follows:

func Prove(privateKey *[SECRETKEYBYTES]byte, message []byte) (*[PROOFBYTES]byte, error) {
  ...
  messagePtr := (*C.uchar)(unsafe.Pointer(&message))
  if C.crypto_vrf_prove(proofPtr, privateKeyPtr, messagePtr, messageLen) != 0 {...}
}

The &message specifies not array address but slice address.

messagePrt := (*C.uchar)(unsafe.Pointer(&message[0]))
                         // or C.NULL if len(message) == 0

When proof() and verify() were using exactly the same instance of the message []byte slice, verification seemed to succeed because the contents pointed to by both addresses were equal. However, in case that the slices had the same data but different instances, it failed because the data pointed to by the slice addresses where different. This was essentially a memory access violation and could have caused a SIGSEGV.

Fixed: in PR #12 . This issue has been created to share the issue.

@torao torao added the C: bug Classification: Something isn't working label Jan 10, 2020
@torao torao added this to the Evolve Leader Election into VRF milestone Jan 10, 2020
@torao torao self-assigned this Jan 10, 2020
@torao torao closed this as completed Jan 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: bug Classification: Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant