diff --git a/Makefile b/Makefile index 294ecaed..ba95534e 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ .PHONY: test_gotest test_gotest: - go test -v -timeout=0 ./... + go test -timeout=0 ./... .PHONY: test_examples test_examples: diff --git a/drlwe/drlwe_test.go b/drlwe/drlwe_test.go index 58d74d0b..70187c39 100644 --- a/drlwe/drlwe_test.go +++ b/drlwe/drlwe_test.go @@ -15,7 +15,7 @@ import ( "github.com/tuneinsight/lattigo/v4/utils" ) -var nbParties = int(10) +var nbParties = int(5) var flagParamString = flag.String("params", "", "specify the test cryptographic parameters as a JSON string. Overrides -short and -long.") @@ -153,9 +153,11 @@ func testKeySwitching(testCtx *testContext, t *testing.T) { cks := make([]*CKSProtocol, nbParties) + sigmaSmudging := 8 * rlwe.DefaultSigma + for i := range cks { if i == 0 { - cks[i] = NewCKSProtocol(params, rlwe.DefaultSigma) + cks[i] = NewCKSProtocol(params, sigmaSmudging) } else { cks[i] = cks[0].ShallowCopy() } @@ -194,7 +196,8 @@ func testKeySwitching(testCtx *testContext, t *testing.T) { // [-as + e] + [as] ringQ.MulCoeffsMontgomeryAndAdd(ksCiphertext.Value[1], skOutIdeal.Value.Q, ksCiphertext.Value[0]) ringQ.InvNTT(ksCiphertext.Value[0], ksCiphertext.Value[0]) - log2Bound := bits.Len64(3 * uint64(math.Floor(rlwe.DefaultSigma*6)) * uint64(params.N())) + + log2Bound := bits.Len64(uint64(nbParties) * uint64(math.Floor(sigmaSmudging*6)) * uint64(params.N())) require.GreaterOrEqual(t, log2Bound, ringQ.Log2OfInnerSum(ksCiphertext.Value[0].Level(), ksCiphertext.Value[0])) }) @@ -209,10 +212,12 @@ func testPublicKeySwitching(testCtx *testContext, t *testing.T) { skOut, pkOut := testCtx.kgen.GenKeyPair() + sigmaSmudging := 8 * rlwe.DefaultSigma + pcks := make([]*PCKSProtocol, nbParties) for i := range pcks { if i == 0 { - pcks[i] = NewPCKSProtocol(params, rlwe.DefaultSigma) + pcks[i] = NewPCKSProtocol(params, sigmaSmudging) } else { pcks[i] = pcks[0].ShallowCopy() } @@ -244,7 +249,9 @@ func testPublicKeySwitching(testCtx *testContext, t *testing.T) { // [-as + e] + [as] ringQ.MulCoeffsMontgomeryAndAdd(ksCiphertext.Value[1], skOut.Value.Q, ksCiphertext.Value[0]) ringQ.InvNTT(ksCiphertext.Value[0], ksCiphertext.Value[0]) - log2Bound := bits.Len64(3 * uint64(math.Floor(rlwe.DefaultSigma*6)) * uint64(params.N())) + + log2Bound := bits.Len64(uint64(nbParties) * uint64(math.Floor(sigmaSmudging*6)) * uint64(params.N())) + require.GreaterOrEqual(t, log2Bound+5, ringQ.Log2OfInnerSum(ksCiphertext.Value[0].Level(), ksCiphertext.Value[0])) })