mirror of
https://source.quilibrium.com/quilibrium/ceremonyclient.git
synced 2024-12-25 16:15:17 +00:00
58456c1057
* feat: IPC for wesolowski * update self peer info * remove digests and signatures * add new binaries and digests * Signatory #13 added * Signatory #4 added (#231) * added sig.6 files (#232) * Signatory #9 added (#233) * Added signatories #1, #2, #3, #5, #8, #12, #14, #15, #16, #17 * remove binaries, release ready --------- Co-authored-by: 0xOzgur <29779769+0xOzgur@users.noreply.github.com> Co-authored-by: Demipoet <161999657+demipoet@users.noreply.github.com> Co-authored-by: Freekers <1370857+Freekers@users.noreply.github.com>
42 lines
1.3 KiB
Go
42 lines
1.3 KiB
Go
package crypto_test
|
|
|
|
import (
|
|
"bytes"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"go.uber.org/zap"
|
|
"source.quilibrium.com/quilibrium/monorepo/node/crypto"
|
|
)
|
|
|
|
func TestMasterProve(t *testing.T) {
|
|
l, _ := zap.NewProduction()
|
|
w := crypto.NewWesolowskiFrameProver(l)
|
|
m, err := w.CreateMasterGenesisFrame([]byte{
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
}, bytes.Repeat([]byte{0x00}, 516), 10000)
|
|
assert.NoError(t, err)
|
|
|
|
next, err := w.ProveMasterClockFrame(m, time.Now().UnixMilli(), 10000)
|
|
assert.NoError(t, err)
|
|
err = w.VerifyMasterClockFrame(next)
|
|
assert.NoError(t, err)
|
|
}
|
|
|
|
func TestChallengeProof(t *testing.T) {
|
|
l, _ := zap.NewProduction()
|
|
w := crypto.NewWesolowskiFrameProver(l)
|
|
now := time.Now().UnixMilli()
|
|
proofs, nextSkew, err := w.CalculateChallengeProof([]byte{0x01, 0x02, 0x03}, 0, 120000, now)
|
|
assert.NoError(t, err)
|
|
assert.True(t, w.VerifyChallengeProof([]byte{0x01, 0x02, 0x03}, now, 100000, [][]byte{proofs}))
|
|
now = time.Now().UnixMilli()
|
|
proofs, _, err = w.CalculateChallengeProof([]byte{0x01, 0x02, 0x03}, 0, nextSkew*12/10, now)
|
|
assert.NoError(t, err)
|
|
assert.True(t, w.VerifyChallengeProof([]byte{0x01, 0x02, 0x03}, now, nextSkew, [][]byte{proofs}))
|
|
}
|