Skip to content

Commit

Permalink
fix check
Browse files Browse the repository at this point in the history
  • Loading branch information
vmidyllic committed Dec 19, 2023
1 parent bc2f72c commit d633e39
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions pubsignals/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,33 +297,6 @@ func (q Query) validateDisclosure(ctx context.Context, pubSig *CircuitOutputs,
return errors.New("selective disclosure value is missed")
}

if !suppordSdOperator {
if pubSig.Operator != circuits.EQ {
return errors.New("selective disclosure available only for equal operation")
}

for i := 1; i < len(pubSig.Value); i++ {
if pubSig.Value[i].Cmp(big.NewInt(0)) != 0 {
return errors.New("selective disclosure not available for array of values")
}
}

} else {
if pubSig.Operator != circuits.SD {
return errors.New("invalid pub signal operator for selective disclosure")
}

if pubSig.OperatorOutput == nil || pubSig.OperatorOutput == big.NewInt(0) {
return errors.New("operator output should be not null or empty")
}

for i := 0; i < len(pubSig.Value); i++ {
if pubSig.Value[i].Cmp(big.NewInt(0)) != 0 {
return errors.New("selective disclosure values should be zero")
}
}
}

mz, err := merklize.MerklizeJSONLD(ctx,
bytes.NewBuffer(verifiablePresentation),
merklize.WithDocumentLoader(schemaLoader))
Expand Down Expand Up @@ -351,8 +324,35 @@ func (q Query) validateDisclosure(ctx context.Context, pubSig *CircuitOutputs,
return errors.Errorf("failed to hash value: %v", err)
}

if pubSig.Value[0].Cmp(mvBig) != 0 {
return errors.New("different value between proof and disclosure value")
if !suppordSdOperator {
if pubSig.Operator != circuits.EQ {
return errors.New("selective disclosure available only for equal operation")
}

for i := 1; i < len(pubSig.Value); i++ {
if pubSig.Value[i].Cmp(big.NewInt(0)) != 0 {
return errors.New("selective disclosure not available for array of values")
}
}

if pubSig.Value[0].Cmp(mvBig) != 0 {
return errors.New("different value between proof and disclosure value")
}

} else {
if pubSig.Operator != circuits.SD {
return errors.New("invalid pub signal operator for selective disclosure")
}

if pubSig.OperatorOutput == nil || pubSig.OperatorOutput.Cmp(mvBig) != 0 {
return errors.New("operator output should be equal to disclosed value")
}
for i := 0; i < len(pubSig.Value); i++ {
if pubSig.Value[i].Cmp(big.NewInt(0)) != 0 {
return errors.New("selective disclosure values should be zero")
}
}

}

return nil
Expand Down

0 comments on commit d633e39

Please sign in to comment.