Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linked multi query #67

Merged
merged 14 commits into from
Feb 22, 2024
Merged

Linked multi query #67

merged 14 commits into from
Feb 22, 2024

Conversation

volodymyr-basiuk
Copy link
Contributor

No description provided.

auth.go Outdated Show resolved Hide resolved
auth.go Outdated Show resolved Hide resolved
auth.go Outdated Show resolved Hide resolved
auth.go Outdated

if pubSignals.LinkID != nil && groupID != 0 {
if existingLinks, exists := groupIDToLinkIDMap[groupID]; exists {
linkIDMap := map[string]*big.Int{"linkID": pubSignals.LinkID, "requestID": new(big.Int).SetUint64(uint64(proofResponse.ID))}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is better to do a private struct with LinkID and requestID fields

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

pubsignals/common.go Outdated Show resolved Hide resolved
pubsignals/common.go Outdated Show resolved Hide resolved
pubsignals/common.go Show resolved Hide resolved
pubsignals/common.go Show resolved Hide resolved
pubsignals/common.go Show resolved Hide resolved
pubsignals/common.go Show resolved Hide resolved
@volodymyr-basiuk volodymyr-basiuk changed the title WIP: Linked multi query Linked multi query Feb 21, 2024
auth.go Outdated
if err != nil {
return err
}
groupID := query.GroupID
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

auth.go Outdated
@@ -394,11 +473,48 @@ func (v *Verifier) VerifyAuthResponse(
return err
}

if response.From == "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved

auth.go Outdated
if groupID == 0 {
return nil
}
if linkID != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else {
if linkID == nil
throw err
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -18,7 +18,7 @@ type StateResolver interface {

// Verifier is interface for verification of public signals of zkp
type Verifier interface {
VerifyQuery(ctx context.Context, query Query, schemaLoader ld.DocumentLoader, verifiablePresentation json.RawMessage, circuitParams map[string]interface{}, opts ...VerifyOpt) error
VerifyQuery(ctx context.Context, query Query, schemaLoader ld.DocumentLoader, verifiablePresentation json.RawMessage, circuitParams map[string]interface{}, opts ...VerifyOpt) (CircuitOutputs, error)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. CircuitVerificationResult
    1. LinkID *big.Int

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 145 to 150
if propertyQuery.OperatorValue != nil {
if !IsValidOperation(datatype, propertyQuery.Operator) {
operatorName, _ := getKeyByValue(circuits.QueryOperators, propertyQuery.Operator)
return nil, fmt.Errorf("invalid operation '%s' for field type '%s'", operatorName, datatype)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

common for merklize / non-merklize

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

}
}

query.Values, err = transformQueryValueToBigInts(ctx, propertyQuery.OperatorValue, datatype)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

common for merklize / non-merklize

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


func transformQueryValueToBigInts(_ context.Context, value any, ldType string) (out []*big.Int, err error) {
out = make([]*big.Int, 64)
for i := 0; i < 64; i++ {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverted

if !queriesMetadata[i].MerklizedSchema {
merklizedSchema = big.NewInt(0)
}
queryHash, err := poseidon.Hash([]*big.Int{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move to separate function

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved

if err != nil {
return err
if len(queriesMetadata) > 1 {
if queriesMetadata[0].FieldName == queriesMetadata[1].FieldName {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


var metadata QueryMetadata

if len(queriesMetadata) == 1 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check if 0 is poosible

Copy link
Contributor Author

@volodymyr-basiuk volodymyr-basiuk Feb 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

possible,
then it will return nil on this check -
if metadata.Operator == circuits.NOOP { return nil }

there is also a test for this case `TestVerifyAuthResponseWithEmptyReq`

@vmidyllic vmidyllic merged commit 20d50f1 into main Feb 22, 2024
3 checks passed
@vmidyllic vmidyllic deleted the feature/linked-multi-query branch February 22, 2024 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants