Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Commit

Permalink
*: fix for dedis/protobuf
Browse files Browse the repository at this point in the history
  • Loading branch information
tharvik committed Dec 19, 2019
1 parent f85e1fd commit 1e74e21
Show file tree
Hide file tree
Showing 35 changed files with 436 additions and 264 deletions.
16 changes: 9 additions & 7 deletions cmd/client/survey.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,13 @@ func surveyRun(c *cli.Context) error {

query := libdrynx.Query{
Operation: operation,
Ranges: []*[]int64{}, // range for each output of operation
Proofs: int(0), // 0 == no proof, 1 == proof, 2 == optimized proof
Ranges: []*libdrynx.Int64List{}, // range for each output of operation
Proofs: int(0), // 0 == no proof, 1 == proof, 2 == optimized proof
Obfuscation: false,
DiffP: libdrynx.QueryDiffP{ // differential privacy
LapMean: 0.0, LapScale: 0.0, NoiseListSize: 0, Quanta: 0.0, Scale: 0},
IVSigs: libdrynx.QueryIVSigs{
InputValidationSigs: make([]*[]libdrynx.PublishSignatureBytes, 0),
InputValidationSigs: make([]*libdrynx.PublishSignatureBytesList, 0),
InputValidationSize1: 0,
InputValidationSize2: 0,
},
Expand All @@ -192,20 +192,22 @@ func surveyRun(c *cli.Context) error {
_, aggregations, err := client.SendSurveyQuery(libdrynx.SurveyQuery{
SurveyID: *conf.Survey.Name,
RosterServers: roster,
ServerToDP: map[string]*[]onet_network.ServerIdentity{ // map CN to DPs
roster.List[0].String(): &[]onet_network.ServerIdentity{*roster.List[1], *roster.List[2]}},
ServerToDP: map[string]*libdrynx.ServerIdentityList{ // map CN to DPs
roster.List[0].String(): &libdrynx.ServerIdentityList{Content: []onet_network.ServerIdentity{*roster.List[1], *roster.List[2]}},
roster.List[1].String(): &libdrynx.ServerIdentityList{Content: []onet_network.ServerIdentity{*roster.List[2], *roster.List[0]}},
roster.List[2].String(): &libdrynx.ServerIdentityList{Content: []onet_network.ServerIdentity{*roster.List[0], *roster.List[1]}}},
IDtoPublic: map[string]kyber.Point{ // map CN|DP|VN to pub key
roster.List[0].String(): roster.List[0].Public,
roster.List[1].String(): roster.List[1].Public,
roster.List[2].String(): roster.List[2].Public},

Query: query,

Threshold: 0,
AggregationProofThreshold: 0,
ObfuscationProofThreshold: 0,
RangeProofThreshold: 0,
KeySwitchingProofThreshold: 0,

Query: query,
})
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions data/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type DataToVerify struct {
}

//CreateRandomGoodTestData only creates valid proofs
func CreateRandomGoodTestData(roster *onet.Roster, pub kyber.Point, ps []*[]libdrynx.PublishSignatureBytes, ranges []*[]int64, nbrProofs int) DataToVerify {
func CreateRandomGoodTestData(roster *onet.Roster, pub kyber.Point, ps []*libdrynx.PublishSignatureBytesList, ranges []*libdrynx.Int64List, nbrProofs int) DataToVerify {
var secKey = bn256.NewSuiteG1().Scalar().Pick(random.New())
var entityPub = bn256.NewSuiteG1().Point().Mul(secKey, bn256.NewSuiteG1().Point().Base())
var tab1 = []int64{1, 2, 3, 6}
Expand Down Expand Up @@ -92,7 +92,7 @@ func CreateRandomGoodTestData(roster *onet.Roster, pub kyber.Point, ps []*[]libd
for i := 0; i < len(roster.List); i++ {
signatures[i] = make([]libdrynx.PublishSignature, len(ranges))
for j := 0; j < len(ranges); j++ {
signatures[i][j] = libdrynxrange.PublishSignatureBytesToPublishSignatures((*ps[i])[j])
signatures[i][j] = libdrynxrange.PublishSignatureBytesToPublishSignatures((*ps[i]).Content[j])
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/encoding/cosim.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func EncodeCosimWithProofs(rijs, riks []int64, pubKey kyber.Point, sigs [][]libd
go func(i int, v int64) {
defer wg.Done()
//input range validation proof
createProofs[i] = libdrynxrange.CreateProof{Sigs: libdrynxrange.ReadColumn(sigs, i), U: (*lu[i])[0], L: (*lu[i])[1], Secret: v, R: resultRandomRS[i], CaPub: pubKey, Cipher: resultEncrypteds[i]}
createProofs[i] = libdrynxrange.CreateProof{Sigs: libdrynxrange.ReadColumn(sigs, i), U: (*lu[i]).Content[0], L: (*lu[i]).Content[1], Secret: v, R: resultRandomRS[i], CaPub: pubKey, Cipher: resultEncrypteds[i]}
}(i, v)
}
libunlynx.EndParallelize(wg)
Expand Down
4 changes: 2 additions & 2 deletions lib/encoding/cosim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func TestEncodeDecodeCosimWithProofs(t *testing.T) {
l := int64(10)
ps := make([][]libdrynx.PublishSignature, 2)

ranges := make([]*[]int64, len(resultClear))
ranges := make([]*libdrynx.Int64List, len(resultClear))
ps[0] = make([]libdrynx.PublishSignature, len(resultClear))
ps[1] = make([]libdrynx.PublishSignature, len(resultClear))
ys := make([][]kyber.Point, 2)
Expand All @@ -109,7 +109,7 @@ func TestEncodeDecodeCosimWithProofs(t *testing.T) {
ps[1][i] = libdrynxrange.PublishSignatureBytesToPublishSignatures(libdrynxrange.InitRangeProofSignature(u))
ys[0][i] = ps[0][i].Public
ys[1][i] = ps[1][i].Public
ranges[i] = &[]int64{u, l}
ranges[i] = &libdrynx.Int64List{Content: []int64{u, l}}
}

yss := make([][]kyber.Point, len(resultClear))
Expand Down
10 changes: 5 additions & 5 deletions lib/encoding/encode_decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

// Encode takes care of computing the query result and encode it for all possible operations.
func Encode(datas [][]int64, pubKey kyber.Point, signatures [][]libdrynx.PublishSignature, ranges []*[]int64, operation libdrynx.Operation) ([]libunlynx.CipherText, []int64, []libdrynxrange.CreateProof) {
func Encode(datas [][]int64, pubKey kyber.Point, signatures [][]libdrynx.PublishSignature, ranges []*libdrynx.Int64List, operation libdrynx.Operation) ([]libunlynx.CipherText, []int64, []libdrynxrange.CreateProof) {

clearResponse := make([]int64, 0)
encryptedResponse := make([]libunlynx.CipherText, 0)
Expand All @@ -21,7 +21,7 @@ func Encode(datas [][]int64, pubKey kyber.Point, signatures [][]libdrynx.Publish
tmpEncryptedResponse := &libunlynx.CipherText{}
tmpPrfs := make([]libdrynxrange.CreateProof, 0)
if withProofs {
tmpEncryptedResponse, clearResponse, tmpPrfs = EncodeSumWithProofs(datas[0], pubKey, signatures[0], (*ranges[0])[1], (*ranges[0])[0])
tmpEncryptedResponse, clearResponse, tmpPrfs = EncodeSumWithProofs(datas[0], pubKey, signatures[0], (*ranges[0]).Content[1], (*ranges[0]).Content[0])
} else {
tmpEncryptedResponse, clearResponse = EncodeSum(datas[0], pubKey)
}
Expand Down Expand Up @@ -89,7 +89,7 @@ func Encode(datas [][]int64, pubKey kyber.Point, signatures [][]libdrynx.Publish

if withProofs {
prf := libdrynxrange.CreateProof{}
cipher, clear, prf = EncodeBitANDWithProof(booleanBit, pubKey, signatures[0], (*ranges[0])[1], (*ranges[0])[0])
cipher, clear, prf = EncodeBitANDWithProof(booleanBit, pubKey, signatures[0], (*ranges[0]).Content[1], (*ranges[0]).Content[0])
createPrf = []libdrynxrange.CreateProof{prf}
} else {
cipher, clear = EncodeBitAND(booleanBit, pubKey)
Expand All @@ -108,7 +108,7 @@ func Encode(datas [][]int64, pubKey kyber.Point, signatures [][]libdrynx.Publish

if withProofs {
prf := libdrynxrange.CreateProof{}
cipher, clear, prf = EncodeBitOrWithProof(booleanBit, pubKey, signatures[0], (*ranges[0])[1], (*ranges[0])[0])
cipher, clear, prf = EncodeBitOrWithProof(booleanBit, pubKey, signatures[0], (*ranges[0]).Content[1], (*ranges[0]).Content[0])
createPrf = []libdrynxrange.CreateProof{prf}
} else {
cipher, clear = EncodeBitOr(booleanBit, pubKey)
Expand Down Expand Up @@ -230,7 +230,7 @@ func Decode(ciphers []libunlynx.CipherText, secKey kyber.Scalar, operation libdr

// EncodeForFloat encodes floating points
func EncodeForFloat(xData [][]float64, yData []int64, lrParameters libdrynx.LogisticRegressionParameters, pubKey kyber.Point,
signatures [][]libdrynx.PublishSignature, ranges []*[]int64, operation string) ([]libunlynx.CipherText, []int64, []libdrynxrange.CreateProof) {
signatures [][]libdrynx.PublishSignature, ranges []*libdrynx.Int64List, operation string) ([]libunlynx.CipherText, []int64, []libdrynxrange.CreateProof) {

clearResponse := make([]int64, 0)
encryptedResponse := make([]libunlynx.CipherText, 0)
Expand Down
2 changes: 1 addition & 1 deletion lib/encoding/frequency_count.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func EncodeFreqCountWithProofs(input []int64, min int64, max int64, pubKey kyber
go func(i int, v int64) {
defer wg1.Done()
//input range validation proof
createRangeProof[i] = libdrynxrange.CreateProof{Sigs: libdrynxrange.ReadColumn(sigs, i), U: (*lu[i])[0], L: (*lu[i])[1], Secret: v, R: r[i], CaPub: pubKey, Cipher: ciphertextTuples[i]}
createRangeProof[i] = libdrynxrange.CreateProof{Sigs: libdrynxrange.ReadColumn(sigs, i), U: (*lu[i]).Content[0], L: (*lu[i]).Content[1], Secret: v, R: r[i], CaPub: pubKey, Cipher: ciphertextTuples[i]}
}(i, v)
}
libunlynx.EndParallelize(wg1)
Expand Down
6 changes: 3 additions & 3 deletions lib/encoding/frequency_count_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func TestEncodeDecodeFrequencyCountWithProofs(t *testing.T) {
l := int64(10)
ps := make([][]libdrynx.PublishSignature, 2)

ranges := make([]*[]int64, len(expect))
ranges := make([]*libdrynx.Int64List, len(expect))
ps[0] = make([]libdrynx.PublishSignature, len(expect))
ps[1] = make([]libdrynx.PublishSignature, len(expect))
ys := make([][]kyber.Point, 2)
Expand All @@ -77,7 +77,7 @@ func TestEncodeDecodeFrequencyCountWithProofs(t *testing.T) {
ps[1][i] = libdrynxrange.PublishSignatureBytesToPublishSignatures(libdrynxrange.InitRangeProofSignature(u))
ys[0][i] = ps[0][i].Public
ys[1][i] = ps[1][i].Public
ranges[i] = &[]int64{u, l}
ranges[i] = &libdrynx.Int64List{Content: []int64{u, l}}
}

yss := make([][]kyber.Point, len(expect))
Expand All @@ -93,7 +93,7 @@ func TestEncodeDecodeFrequencyCountWithProofs(t *testing.T) {
result := libdrynxencoding.DecodeFreqCount(resultEncrypted, secKey)

for i := 0; int64(i) <= max-min; i++ {
assert.True(t, libdrynxrange.RangeProofVerification(libdrynxrange.CreatePredicateRangeProofForAllServ(prf[i]), (*ranges[i])[0], (*ranges[i])[1], yss[i], pubKey))
assert.True(t, libdrynxrange.RangeProofVerification(libdrynxrange.CreatePredicateRangeProofForAllServ(prf[i]), (*ranges[i]).Content[0], (*ranges[i]).Content[1], yss[i], pubKey))
}
assert.Equal(t, expect, result)

Expand Down
4 changes: 2 additions & 2 deletions lib/encoding/linear_regression_dims.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func EncodeLinearRegressionDims(input1 [][]int64, input2 []int64, pubKey kyber.P
}

//EncodeLinearRegressionDimsWithProofs implements a d-dimensional linear regression algorithm on the query results with range proofs
func EncodeLinearRegressionDimsWithProofs(input1 [][]int64, input2 []int64, pubKey kyber.Point, sigs [][]libdrynx.PublishSignature, lu []*[]int64) ([]libunlynx.CipherText, []int64, []libdrynxrange.CreateProof) {
func EncodeLinearRegressionDimsWithProofs(input1 [][]int64, input2 []int64, pubKey kyber.Point, sigs [][]libdrynx.PublishSignature, lu []*libdrynx.Int64List) ([]libunlynx.CipherText, []int64, []libdrynxrange.CreateProof) {
//sum the Xs and their squares, the Ys and the product of every pair of X and Y
sumXj := int64(0)
sumY := int64(0)
Expand Down Expand Up @@ -98,7 +98,7 @@ func EncodeLinearRegressionDimsWithProofs(input1 [][]int64, input2 []int64, pubK
go func(i int, v int64) {
defer wg.Done()
//input range validation proof
createProofs[i] = libdrynxrange.CreateProof{Sigs: libdrynxrange.ReadColumn(sigs, i), U: (*lu[i])[0], L: (*lu[i])[1], Secret: v, R: r[i], CaPub: pubKey, Cipher: CiphertextTuple[i]}
createProofs[i] = libdrynxrange.CreateProof{Sigs: libdrynxrange.ReadColumn(sigs, i), U: (*lu[i]).Content[0], L: (*lu[i]).Content[1], Secret: v, R: r[i], CaPub: pubKey, Cipher: CiphertextTuple[i]}
}(i, v)
}
libunlynx.EndParallelize(wg)
Expand Down
4 changes: 2 additions & 2 deletions lib/encoding/linear_regression_dims_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ func TestEncodeDecodeLinearRegressionDimsWithProofs(t *testing.T) {
u[i] = 2
l2[i] = 8
}
ranges := make([]*[]int64, lenCiphertext)
ranges := make([]*libdrynx.Int64List, lenCiphertext)
ps := make([][]libdrynx.PublishSignature, 2)
ps[0] = make([]libdrynx.PublishSignature, lenCiphertext)
ps[1] = make([]libdrynx.PublishSignature, lenCiphertext)
Expand All @@ -250,7 +250,7 @@ func TestEncodeDecodeLinearRegressionDimsWithProofs(t *testing.T) {
ps[1][i] = libdrynxrange.PublishSignatureBytesToPublishSignatures(libdrynxrange.InitRangeProofSignature(u[i]))
ys[0][i] = ps[0][i].Public
ys[1][i] = ps[1][i].Public
ranges[i] = &[]int64{u[i], l2[i]}
ranges[i] = &libdrynx.Int64List{Content: []int64{u[i], l2[i]}}
}

yss := make([][]kyber.Point, lenCiphertext)
Expand Down
4 changes: 2 additions & 2 deletions lib/encoding/logistic_regression.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ type CipherAndRandom struct {
}

// EncodeLogisticRegressionWithProofs computes and encrypts the data provider's coefficients for logistic regression with range proofs
func EncodeLogisticRegressionWithProofs(xData [][]float64, yData []int64, lrParameters libdrynx.LogisticRegressionParameters, pubKey kyber.Point, sigs [][]libdrynx.PublishSignature, lu []*[]int64) ([]libunlynx.CipherText, []int64, []libdrynxrange.CreateProof) {
func EncodeLogisticRegressionWithProofs(xData [][]float64, yData []int64, lrParameters libdrynx.LogisticRegressionParameters, pubKey kyber.Point, sigs [][]libdrynx.PublishSignature, lu []*libdrynx.Int64List) ([]libunlynx.CipherText, []int64, []libdrynxrange.CreateProof) {

d := lrParameters.NbrFeatures
n := getTotalNumberApproxCoefficients(d, lrParameters.K)
Expand Down Expand Up @@ -194,7 +194,7 @@ func EncodeLogisticRegressionWithProofs(xData [][]float64, yData []int64, lrPara
go func(i int, v int64) {
defer wg1.Done()
//input range validation proof
createRangeProof[i] = libdrynxrange.CreateProof{Sigs: libdrynxrange.ReadColumn(sigs, i), U: (*lu[i])[0], L: (*lu[i])[1], Secret: v, R: encryptedAggregatedApproxCoefficients[i].r, CaPub: pubKey, Cipher: encryptedAggregatedApproxCoefficients[i].C}
createRangeProof[i] = libdrynxrange.CreateProof{Sigs: libdrynxrange.ReadColumn(sigs, i), U: (*lu[i]).Content[0], L: (*lu[i]).Content[1], Secret: v, R: encryptedAggregatedApproxCoefficients[i].r, CaPub: pubKey, Cipher: encryptedAggregatedApproxCoefficients[i].C}
}(i, v)
}
libunlynx.EndParallelize(wg1)
Expand Down
6 changes: 3 additions & 3 deletions lib/encoding/logistic_regression_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ func TestEncodeDecodeLogisticRegressionWithProofs(t *testing.T) {
l := int64(10)
ps := make([][]libdrynx.PublishSignature, 2)

ranges := make([]*[]int64, 30)
ranges := make([]*libdrynx.Int64List, 30)
ps[0] = make([]libdrynx.PublishSignature, 30)
ps[1] = make([]libdrynx.PublishSignature, 30)
ys := make([][]kyber.Point, 2)
Expand All @@ -701,7 +701,7 @@ func TestEncodeDecodeLogisticRegressionWithProofs(t *testing.T) {
ps[1][i] = libdrynxrange.PublishSignatureBytesToPublishSignatures(libdrynxrange.InitRangeProofSignature(u))
ys[0][i] = ps[0][i].Public
ys[1][i] = ps[1][i].Public
ranges[i] = &[]int64{u, l}
ranges[i] = &libdrynx.Int64List{Content: []int64{u, l}}
}

yss := make([][]kyber.Point, 30)
Expand All @@ -717,7 +717,7 @@ func TestEncodeDecodeLogisticRegressionWithProofs(t *testing.T) {
resultEncrypted, _, prf := libdrynxencoding.EncodeLogisticRegressionWithProofs(X, y, lrParameters, pubKey, ps, ranges)
result := libdrynxencoding.DecodeLogisticRegression(resultEncrypted, privKey, lrParameters)

assert.True(t, libdrynxrange.RangeProofVerification(libdrynxrange.CreatePredicateRangeProofForAllServ(prf[0]), (*ranges[0])[0], (*ranges[0])[1], yss[0], pubKey))
assert.True(t, libdrynxrange.RangeProofVerification(libdrynxrange.CreatePredicateRangeProofForAllServ(prf[0]), (*ranges[0]).Content[0], (*ranges[0]).Content[1], yss[0], pubKey))

// no equality because expected weights were computed in clear
// todo: consider computed weights using encrypted approx coefficients
Expand Down
4 changes: 2 additions & 2 deletions lib/encoding/mean.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func EncodeMean(input []int64, pubKey kyber.Point) ([]libunlynx.CipherText, []in
}

// EncodeMeanWithProofs computes the mean of query results with the proof of range
func EncodeMeanWithProofs(input []int64, pubKey kyber.Point, sigs [][]libdrynx.PublishSignature, lu []*[]int64) ([]libunlynx.CipherText, []int64, []libdrynxrange.CreateProof) {
func EncodeMeanWithProofs(input []int64, pubKey kyber.Point, sigs [][]libdrynx.PublishSignature, lu []*libdrynx.Int64List) ([]libunlynx.CipherText, []int64, []libdrynxrange.CreateProof) {
//sum the local DP's query results
sum := int64(0)
for _, el := range input {
Expand Down Expand Up @@ -48,7 +48,7 @@ func EncodeMeanWithProofs(input []int64, pubKey kyber.Point, sigs [][]libdrynx.P
go func(i int, v int64) {
defer wg1.Done()
//input range validation proof
createProofs[i] = libdrynxrange.CreateProof{Sigs: libdrynxrange.ReadColumn(sigs, i), U: (*lu[i])[0], L: (*lu[i])[1], Secret: v, R: resultRandomR[i], CaPub: pubKey, Cipher: resultEncrypted[i]}
createProofs[i] = libdrynxrange.CreateProof{Sigs: libdrynxrange.ReadColumn(sigs, i), U: (*lu[i]).Content[0], L: (*lu[i]).Content[1], Secret: v, R: resultRandomR[i], CaPub: pubKey, Cipher: resultEncrypted[i]}
}(i, v)
}
libunlynx.EndParallelize(wg1)
Expand Down
4 changes: 2 additions & 2 deletions lib/encoding/mean_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestEncodeDecodeMeanWithProofs(t *testing.T) {

ps := make([][]libdrynx.PublishSignature, 2)

ranges := make([]*[]int64, 2)
ranges := make([]*libdrynx.Int64List, 2)
ps[0] = make([]libdrynx.PublishSignature, 2)
ps[1] = make([]libdrynx.PublishSignature, 2)
ys := make([][]kyber.Point, 2)
Expand All @@ -62,7 +62,7 @@ func TestEncodeDecodeMeanWithProofs(t *testing.T) {
ps[1][i] = libdrynxrange.PublishSignatureBytesToPublishSignatures(libdrynxrange.InitRangeProofSignature(u[i]))
ys[0][i] = ps[0][i].Public
ys[1][i] = ps[1][i].Public
ranges[i] = &[]int64{u[i], l[i]}
ranges[i] = &libdrynx.Int64List{Content: []int64{u[i], l[i]}}
}

yss := make([][]kyber.Point, 2)
Expand Down
8 changes: 4 additions & 4 deletions lib/encoding/min_max.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
//Note: min and max are such that all values are in the range [min, max], i.e. max (min) is the largest (smallest) possible value the attribute in question can take

//EncodeMinWithProofs encodes the local min
func EncodeMinWithProofs(input []int64, max int64, min int64, pubKey kyber.Point, sigs [][]libdrynx.PublishSignature, lu []*[]int64) ([]libunlynx.CipherText, []int64, []libdrynxrange.CreateProof) {
func EncodeMinWithProofs(input []int64, max int64, min int64, pubKey kyber.Point, sigs [][]libdrynx.PublishSignature, lu []*libdrynx.Int64List) ([]libunlynx.CipherText, []int64, []libdrynxrange.CreateProof) {
//compute the local min
localMin := input[0]
for _, v := range input {
Expand All @@ -33,7 +33,7 @@ func EncodeMinWithProofs(input []int64, max int64, min int64, pubKey kyber.Point
}
tmp := &libunlynx.CipherText{}
if sigs != nil {
tmp, cleartextTuples[i-min], proofsTuples[i-min] = EncodeBitOrWithProof(val, pubKey, libdrynxrange.ReadColumn(sigs, int(i-min)), (*lu[i-min])[1], (*lu[i-min])[0])
tmp, cleartextTuples[i-min], proofsTuples[i-min] = EncodeBitOrWithProof(val, pubKey, libdrynxrange.ReadColumn(sigs, int(i-min)), (*lu[i-min]).Content[1], (*lu[i-min]).Content[0])
} else {
tmp, cleartextTuples[i-min] = EncodeBitOr(val, pubKey)
}
Expand Down Expand Up @@ -84,7 +84,7 @@ func EncodeMax(input []int64, max int64, min int64, pubKey kyber.Point) ([]libun
}

//EncodeMaxWithProofs encodes the local max
func EncodeMaxWithProofs(input []int64, max int64, min int64, pubKey kyber.Point, sigs [][]libdrynx.PublishSignature, lu []*[]int64) ([]libunlynx.CipherText, []int64, []libdrynxrange.CreateProof) {
func EncodeMaxWithProofs(input []int64, max int64, min int64, pubKey kyber.Point, sigs [][]libdrynx.PublishSignature, lu []*libdrynx.Int64List) ([]libunlynx.CipherText, []int64, []libdrynxrange.CreateProof) {
//compute the local max
localMax := input[0]
for _, v := range input {
Expand All @@ -107,7 +107,7 @@ func EncodeMaxWithProofs(input []int64, max int64, min int64, pubKey kyber.Point
}
tmp := &libunlynx.CipherText{}
if sigs != nil {
tmp, cleartextTuples[i-min], proofsTuples[i-min] = EncodeBitANDWithProof(val, pubKey, libdrynxrange.ReadColumn(sigs, int(i-min)), (*lu[i-min])[1], (*lu[i-min])[0])
tmp, cleartextTuples[i-min], proofsTuples[i-min] = EncodeBitANDWithProof(val, pubKey, libdrynxrange.ReadColumn(sigs, int(i-min)), (*lu[i-min]).Content[1], (*lu[i-min]).Content[0])
} else {
tmp, cleartextTuples[i-min] = EncodeBitAND(val, pubKey)
}
Expand Down
4 changes: 2 additions & 2 deletions lib/encoding/min_max_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func TestEncodeDecodeMinMaxWithProofs(t *testing.T) {

ps := make([][]libdrynx.PublishSignature, 2)

ranges := make([]*[]int64, globalMax-globalMin+1)
ranges := make([]*libdrynx.Int64List, globalMax-globalMin+1)
ps[0] = make([]libdrynx.PublishSignature, globalMax-globalMin+1)
ps[1] = make([]libdrynx.PublishSignature, globalMax-globalMin+1)
ys := make([][]kyber.Point, 2)
Expand All @@ -89,7 +89,7 @@ func TestEncodeDecodeMinMaxWithProofs(t *testing.T) {
ps[1][i] = libdrynxrange.PublishSignatureBytesToPublishSignatures(libdrynxrange.InitRangeProofSignature(u))
ys[0][i] = ps[0][i].Public
ys[1][i] = ps[1][i].Public
ranges[i] = &[]int64{u, l}
ranges[i] = &libdrynx.Int64List{Content: []int64{u, l}}
}

yss := make([][]kyber.Point, globalMax-globalMin+1)
Expand Down
Loading

0 comments on commit 1e74e21

Please sign in to comment.