mirror of
https://source.quilibrium.com/quilibrium/ceremonyclient.git
synced 2024-12-26 00:25:17 +00:00
Hard code int size bits
This commit is contained in:
parent
fe3419b898
commit
a1b78e0949
@ -6,14 +6,16 @@ import (
|
|||||||
|
|
||||||
//go:generate ./generate.sh
|
//go:generate ./generate.sh
|
||||||
|
|
||||||
|
const intSizeBits = uint16(2048)
|
||||||
|
|
||||||
// WesolowskiSolve Solve and prove with the Wesolowski VDF using the given parameters.
|
// WesolowskiSolve Solve and prove with the Wesolowski VDF using the given parameters.
|
||||||
// Outputs the concatenated solution and proof (in this order).
|
// 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)
|
return generated.WesolowskiSolve(intSizeBits, challenge, difficulty)
|
||||||
}
|
}
|
||||||
|
|
||||||
// WesolowskiVerify Verify with the Wesolowski VDF using the given parameters.
|
// WesolowskiVerify Verify with the Wesolowski VDF using the given parameters.
|
||||||
// `allegedSolution` is the output of `WesolowskiSolve`.
|
// `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)
|
return generated.WesolowskiVerify(intSizeBits, challenge, difficulty, allegedSolution)
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,6 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
const intSizeBits = uint16(2048)
|
|
||||||
|
|
||||||
func getChallenge(seed string) [32]byte {
|
func getChallenge(seed string) [32]byte {
|
||||||
return sha3.Sum256([]byte(seed))
|
return sha3.Sum256([]byte(seed))
|
||||||
}
|
}
|
||||||
@ -16,8 +14,8 @@ func getChallenge(seed string) [32]byte {
|
|||||||
func TestProveVerify(t *testing.T) {
|
func TestProveVerify(t *testing.T) {
|
||||||
difficulty := uint64(10000)
|
difficulty := uint64(10000)
|
||||||
challenge := getChallenge("TestProveVerify")
|
challenge := getChallenge("TestProveVerify")
|
||||||
solution := vdf.WesolowskiSolve(intSizeBits, challenge[:], difficulty)
|
solution := vdf.WesolowskiSolve(challenge[:], difficulty)
|
||||||
isOk := vdf.WesolowskiVerify(intSizeBits, challenge[:], difficulty, solution)
|
isOk := vdf.WesolowskiVerify(challenge[:], difficulty, solution)
|
||||||
if !isOk {
|
if !isOk {
|
||||||
t.Fatalf("Verification failed")
|
t.Fatalf("Verification failed")
|
||||||
}
|
}
|
||||||
@ -28,7 +26,7 @@ func TestProveRustVerifyNekro(t *testing.T) {
|
|||||||
challenge := getChallenge("TestProveRustVerifyNekro")
|
challenge := getChallenge("TestProveRustVerifyNekro")
|
||||||
|
|
||||||
for i := 0; i < 100; i++ {
|
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)
|
nekroVdf := nekrovdf.New(uint32(difficulty), challenge)
|
||||||
isOk := nekroVdf.Verify([516]byte(solution))
|
isOk := nekroVdf.Verify([516]byte(solution))
|
||||||
if !isOk {
|
if !isOk {
|
||||||
@ -46,7 +44,7 @@ func TestProveNekroVerifyRust(t *testing.T) {
|
|||||||
nekroVdf := nekrovdf.New(uint32(difficulty), challenge)
|
nekroVdf := nekrovdf.New(uint32(difficulty), challenge)
|
||||||
nekroVdf.Execute()
|
nekroVdf.Execute()
|
||||||
proof := nekroVdf.GetOutput()
|
proof := nekroVdf.GetOutput()
|
||||||
isOk := vdf.WesolowskiVerify(intSizeBits, challenge[:], uint64(difficulty), proof[:])
|
isOk := vdf.WesolowskiVerify(challenge[:], uint64(difficulty), proof[:])
|
||||||
if !isOk {
|
if !isOk {
|
||||||
t.Fatalf("Verification failed")
|
t.Fatalf("Verification failed")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user