github.com/Finschia/ostracon@v1.1.5/crypto/ed25519/internal/r2ishiguro/vrf.go (about) 1 package r2ishiguro 2 3 import ( 4 "github.com/Finschia/r2ishiguro_vrf/go/vrf_ed25519" 5 ) 6 7 const ( 8 ProofSize = 81 9 ) 10 11 func Verify(publicKey []byte, proof []byte, message []byte) (bool, []byte) { 12 isValid, err := vrf_ed25519.ECVRF_verify(publicKey, proof, message) 13 if err != nil || !isValid { 14 return false, nil 15 } 16 17 hash, err := ProofToHash(proof) 18 if err != nil { 19 return false, nil 20 } 21 22 return true, hash 23 } 24 25 func ProofToHash(proof []byte) ([]byte, error) { 26 // validate proof with ECVRF_decode_proof 27 _, _, _, err := vrf_ed25519.ECVRF_decode_proof(proof) 28 if err != nil { 29 return nil, err 30 } 31 return vrf_ed25519.ECVRF_proof2hash(proof), nil 32 }