From 2a53399b4a2bfe1aed72f906a2d554f2fcfcd9c2 Mon Sep 17 00:00:00 2001 From: Agost Biro Date: Thu, 6 Jun 2024 00:05:02 +0200 Subject: [PATCH] Use arrays in Weso interfaces --- vdf/vdf.go | 8 ++++---- vdf/vdf_test.go | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/vdf/vdf.go b/vdf/vdf.go index d6f7765..78ce931 100644 --- a/vdf/vdf.go +++ b/vdf/vdf.go @@ -10,12 +10,12 @@ 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(challenge []uint8, difficulty uint32) []uint8 { - return generated.WesolowskiSolve(intSizeBits, challenge, difficulty) +func WesolowskiSolve(challenge [32]byte, difficulty uint32) [516]byte { + return [516]byte(generated.WesolowskiSolve(intSizeBits, challenge[:], difficulty)) } // WesolowskiVerify Verify with the Wesolowski VDF using the given parameters. // `allegedSolution` is the output of `WesolowskiSolve`. -func WesolowskiVerify(challenge []uint8, difficulty uint32, allegedSolution []uint8) bool { - return generated.WesolowskiVerify(intSizeBits, challenge, difficulty, allegedSolution) +func WesolowskiVerify(challenge [32]byte, difficulty uint32, allegedSolution [516]byte) bool { + return generated.WesolowskiVerify(intSizeBits, challenge[:], difficulty, allegedSolution[:]) } diff --git a/vdf/vdf_test.go b/vdf/vdf_test.go index 4c269c3..dd3e56a 100644 --- a/vdf/vdf_test.go +++ b/vdf/vdf_test.go @@ -14,8 +14,8 @@ func getChallenge(seed string) [32]byte { func TestProveVerify(t *testing.T) { difficulty := uint32(10000) challenge := getChallenge("TestProveVerify") - solution := vdf.WesolowskiSolve(challenge[:], difficulty) - isOk := vdf.WesolowskiVerify(challenge[:], difficulty, solution) + solution := vdf.WesolowskiSolve(challenge, difficulty) + isOk := vdf.WesolowskiVerify(challenge, difficulty, solution) if !isOk { t.Fatalf("Verification failed") } @@ -26,13 +26,13 @@ func TestProveRustVerifyNekro(t *testing.T) { challenge := getChallenge("TestProveRustVerifyNekro") for i := 0; i < 100; i++ { - solution := vdf.WesolowskiSolve(challenge[:], difficulty) + solution := vdf.WesolowskiSolve(challenge, difficulty) nekroVdf := nekrovdf.New(difficulty, challenge) - isOk := nekroVdf.Verify([516]byte(solution)) + isOk := nekroVdf.Verify(solution) if !isOk { t.Fatalf("Verification failed") } - challenge = sha3.Sum256(solution) + challenge = sha3.Sum256(solution[:]) } } @@ -44,7 +44,7 @@ func TestProveNekroVerifyRust(t *testing.T) { nekroVdf := nekrovdf.New(difficulty, challenge) nekroVdf.Execute() proof := nekroVdf.GetOutput() - isOk := vdf.WesolowskiVerify(challenge[:], difficulty, proof[:]) + isOk := vdf.WesolowskiVerify(challenge, difficulty, proof) if !isOk { t.Fatalf("Verification failed") }