mirror of
https://source.quilibrium.com/quilibrium/ceremonyclient.git
synced 2024-12-26 00:25:17 +00:00
Add nekryptology compatibility tests
This commit is contained in:
parent
81dd7550af
commit
fe3419b898
11
vdf/go.mod
11
vdf/go.mod
@ -1,3 +1,12 @@
|
||||
module "source.quilibrium.com/quilibrium/cermonyclient/vdf"
|
||||
module source.quilibrium.com/quilibrium/cermonyclient/vdf
|
||||
|
||||
go 1.20
|
||||
|
||||
// A necessary hack until source.quilibrium.com is open to all
|
||||
replace source.quilibrium.com/quilibrium/monorepo/nekryptology => ../nekryptology
|
||||
|
||||
require (
|
||||
golang.org/x/crypto v0.24.0 // indirect
|
||||
golang.org/x/sys v0.21.0 // indirect
|
||||
source.quilibrium.com/quilibrium/monorepo/nekryptology v0.0.0-00010101000000-000000000000 // indirect
|
||||
)
|
||||
|
4
vdf/go.sum
Normal file
4
vdf/go.sum
Normal file
@ -0,0 +1,4 @@
|
||||
golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI=
|
||||
golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM=
|
||||
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
|
||||
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
@ -1,17 +1,55 @@
|
||||
package vdf_test
|
||||
|
||||
import (
|
||||
"golang.org/x/crypto/sha3"
|
||||
"source.quilibrium.com/quilibrium/cermonyclient/vdf"
|
||||
nekrovdf "source.quilibrium.com/quilibrium/monorepo/nekryptology/pkg/vdf"
|
||||
"testing"
|
||||
)
|
||||
|
||||
const intSizeBits = uint16(2048)
|
||||
const difficulty = uint64(10000)
|
||||
|
||||
func getChallenge(seed string) [32]byte {
|
||||
return sha3.Sum256([]byte(seed))
|
||||
}
|
||||
|
||||
func TestProveVerify(t *testing.T) {
|
||||
solution := vdf.WesolowskiSolve(intSizeBits, []byte{0x01, 0x02, 0x03}, difficulty)
|
||||
isOk := vdf.WesolowskiVerify(intSizeBits, []byte{0x01, 0x02, 0x03}, difficulty, solution)
|
||||
difficulty := uint64(10000)
|
||||
challenge := getChallenge("TestProveVerify")
|
||||
solution := vdf.WesolowskiSolve(intSizeBits, challenge[:], difficulty)
|
||||
isOk := vdf.WesolowskiVerify(intSizeBits, challenge[:], difficulty, solution)
|
||||
if !isOk {
|
||||
t.Errorf("WesolowskiVerify failed")
|
||||
t.Fatalf("Verification failed")
|
||||
}
|
||||
}
|
||||
|
||||
func TestProveRustVerifyNekro(t *testing.T) {
|
||||
difficulty := 100
|
||||
challenge := getChallenge("TestProveRustVerifyNekro")
|
||||
|
||||
for i := 0; i < 100; i++ {
|
||||
solution := vdf.WesolowskiSolve(intSizeBits, challenge[:], uint64(difficulty))
|
||||
nekroVdf := nekrovdf.New(uint32(difficulty), challenge)
|
||||
isOk := nekroVdf.Verify([516]byte(solution))
|
||||
if !isOk {
|
||||
t.Fatalf("Verification failed")
|
||||
}
|
||||
challenge = sha3.Sum256(solution)
|
||||
}
|
||||
}
|
||||
|
||||
func TestProveNekroVerifyRust(t *testing.T) {
|
||||
difficulty := 100
|
||||
challenge := getChallenge("TestProveNekroVerifyRust")
|
||||
|
||||
for i := 0; i < 100; i++ {
|
||||
nekroVdf := nekrovdf.New(uint32(difficulty), challenge)
|
||||
nekroVdf.Execute()
|
||||
proof := nekroVdf.GetOutput()
|
||||
isOk := vdf.WesolowskiVerify(intSizeBits, challenge[:], uint64(difficulty), proof[:])
|
||||
if !isOk {
|
||||
t.Fatalf("Verification failed")
|
||||
}
|
||||
challenge = sha3.Sum256(proof[:])
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user