Hard code int size bits

This commit is contained in:
Agost Biro 2024-06-05 23:33:32 +02:00
parent fe3419b898
commit a1b78e0949
No known key found for this signature in database
2 changed files with 8 additions and 8 deletions

View File

@ -6,14 +6,16 @@ import (
//go:generate ./generate.sh
const intSizeBits = uint16(2048)
// WesolowskiSolve Solve and prove with the Wesolowski VDF using the given parameters.
// Outputs the concatenated solution and proof (in this order).
func WesolowskiSolve(intSizeBits uint16, challenge []uint8, difficulty uint64) []uint8 {
func WesolowskiSolve(challenge []uint8, difficulty uint64) []uint8 {
return generated.WesolowskiSolve(intSizeBits, challenge, difficulty)
}
// WesolowskiVerify Verify with the Wesolowski VDF using the given parameters.
// `allegedSolution` is the output of `WesolowskiSolve`.
func WesolowskiVerify(intSizeBits uint16, challenge []uint8, difficulty uint64, allegedSolution []uint8) bool {
func WesolowskiVerify(challenge []uint8, difficulty uint64, allegedSolution []uint8) bool {
return generated.WesolowskiVerify(intSizeBits, challenge, difficulty, allegedSolution)
}

View File

@ -7,8 +7,6 @@ import (
"testing"
)
const intSizeBits = uint16(2048)
func getChallenge(seed string) [32]byte {
return sha3.Sum256([]byte(seed))
}
@ -16,8 +14,8 @@ func getChallenge(seed string) [32]byte {
func TestProveVerify(t *testing.T) {
difficulty := uint64(10000)
challenge := getChallenge("TestProveVerify")
solution := vdf.WesolowskiSolve(intSizeBits, challenge[:], difficulty)
isOk := vdf.WesolowskiVerify(intSizeBits, challenge[:], difficulty, solution)
solution := vdf.WesolowskiSolve(challenge[:], difficulty)
isOk := vdf.WesolowskiVerify(challenge[:], difficulty, solution)
if !isOk {
t.Fatalf("Verification failed")
}
@ -28,7 +26,7 @@ func TestProveRustVerifyNekro(t *testing.T) {
challenge := getChallenge("TestProveRustVerifyNekro")
for i := 0; i < 100; i++ {
solution := vdf.WesolowskiSolve(intSizeBits, challenge[:], uint64(difficulty))
solution := vdf.WesolowskiSolve(challenge[:], uint64(difficulty))
nekroVdf := nekrovdf.New(uint32(difficulty), challenge)
isOk := nekroVdf.Verify([516]byte(solution))
if !isOk {
@ -46,7 +44,7 @@ func TestProveNekroVerifyRust(t *testing.T) {
nekroVdf := nekrovdf.New(uint32(difficulty), challenge)
nekroVdf.Execute()
proof := nekroVdf.GetOutput()
isOk := vdf.WesolowskiVerify(intSizeBits, challenge[:], uint64(difficulty), proof[:])
isOk := vdf.WesolowskiVerify(challenge[:], uint64(difficulty), proof[:])
if !isOk {
t.Fatalf("Verification failed")
}