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

chore: Add optional parameter to packer.Unpack #60

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

x1m3
Copy link
Contributor

@x1m3 x1m3 commented Oct 15, 2024

This PR adds an optional parameter to packer.Unpack function and change the implementation of the the ZKKPacker unpack code to support parameter with custom AuthVerifyDelay

packers/zkp.go Outdated
@@ -30,11 +30,11 @@ func (f DataPreparerHandlerFunc) Prepare(hash []byte, id *w3c.DID, circuitID cir
}

// VerificationHandlerFunc registers the handler function for state verification.
type VerificationHandlerFunc func(id circuits.CircuitID, pubsignals []string) error
type VerificationHandlerFunc func(id circuits.CircuitID, pubsignals []string, opts ...DefaultZKPUnpackerOption) error
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Open question. Is it ok to use DefaultZKPUnpackerOption or we should create a new Option type?

Copy link
Contributor

Choose a reason for hiding this comment

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

My proposal it's add UnpackerParams in the same way how we did with PackerParams and use them instead of DefaultZKPUnpackerOption

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean the function verificationKey.VerificationFn.Verify(circuits.CircuitID(token.CircuitID), token.ZkProof.PubSignals, verifyOpts...) should accept ZKPPUnpackerParams

packers/zkp.go Outdated
}
verifications := make(map[jwz.ProvingMethodAlg]VerificationParams)
verifications[jwz.AuthV2Groth16Alg] = NewVerificationParams(verificationKey, def.defaultZkpUnpackerVerificationFn)
return NewZKPPacker(nil, verifications)
}

func (d *defaultZKPUnpacker) defaultZkpUnpackerVerificationFn(id circuits.CircuitID, pubsignals []string) error {
func (d *defaultZKPUnpacker) defaultZkpUnpackerVerificationFn(id circuits.CircuitID, pubsignals []string, opts ...DefaultZKPUnpackerOption) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

If you will remove opts from defaultZKPUnpacker, you can refactor the method to 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.

I don't think so. It is using d.resolvers inside the method body.

@ilya-korotya ilya-korotya self-requested a review November 13, 2024 10:32
use zkp unpacker params only
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