Files
zeekay eeaa2a1c07 fix: resolve go vet and formatting issues
- Fix go vet error in lss_bench_test.go: replace b.Fatal with panic in goroutine
- Fix go vet error in lss_test.go: remove t.Skip call from goroutine
- Apply gofmt to all files to fix formatting issues

All go vet errors and formatting issues have been resolved.
2025-08-05 17:59:18 -05:00

70 lines
1.4 KiB
Go

package zkprm
import (
"testing"
"github.com/fxamacker/cbor/v2"
"github.com/luxfi/threshold/pkg/hash"
"github.com/luxfi/threshold/pkg/paillier"
"github.com/luxfi/threshold/pkg/pool"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestPrm(t *testing.T) {
pl := pool.NewPool(0)
defer pl.TearDown()
sk := paillier.NewSecretKey(pl)
ped, lambda := sk.GeneratePedersen()
public := Public{
Aux: ped,
}
proof := NewProof(Private{
Lambda: lambda,
Phi: sk.Phi(),
P: sk.P(),
Q: sk.Q(),
}, hash.New(), public, pl)
assert.True(t, proof.Verify(public, hash.New(), pl))
out, err := cbor.Marshal(proof)
require.NoError(t, err, "failed to marshal proof")
proof2 := &Proof{}
require.NoError(t, cbor.Unmarshal(out, proof2), "failed to unmarshal proof")
out2, err := cbor.Marshal(proof2)
require.NoError(t, err, "failed to marshal 2nd proof")
proof3 := &Proof{}
require.NoError(t, cbor.Unmarshal(out2, proof3), "failed to unmarshal 2nd proof")
assert.True(t, proof3.Verify(public, hash.New(), pl))
}
var p *Proof
func BenchmarkCRT(b *testing.B) {
b.StopTimer()
pl := pool.NewPool(0)
defer pl.TearDown()
sk := paillier.NewSecretKey(pl)
ped, lambda := sk.GeneratePedersen()
public := Public{
Aux: ped,
}
private := Private{
Lambda: lambda,
Phi: sk.Phi(),
P: sk.P(),
Q: sk.Q(),
}
b.StartTimer()
for i := 0; i < b.N; i++ {
p = NewProof(private, hash.New(), public, nil)
}
}