-
Notifications
You must be signed in to change notification settings - Fork 0
Fix/readme #14
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
base: main
Are you sure you want to change the base?
Fix/readme #14
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
## Introduction | ||
|
||
This repository is an SDK for connecting external services with Rarimo passport | ||
verification system that may be used in back-end services. Its main purpose is | ||
verification and voting systems that may be used in back-end services. Its main purpose is | ||
providing a convenient methods that can be used in any system without deep | ||
introduction in the Rarimo system structure. | ||
|
||
|
@@ -20,16 +20,16 @@ import ( | |
) | ||
|
||
func main() { | ||
rv := root.NewVerifier(contractCaller, reqTimeout) | ||
passportVerifier := root.NewPoseidonSMTVerifier(rpcURL, contractAddress, reqTimeout) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not general usage. Add headers: Passport, Voting, etc. |
||
|
||
v, err := kit.NewVerifier( | ||
kit.PassportVerification, | ||
nil, | ||
kit.WithProofType(kit.GeneralPassport), | ||
kit.WithVerificationKeyFile("key.json"), | ||
kit.WithEventID("304358862882731539112827930982999386691702727710421481944329166126417129570"), | ||
kit.WithAgeAbove(18), | ||
kit.WithCitizenships("UKR"), | ||
kit.WithIdentityVerifier(rv), | ||
kit.WithPassportRootVerifier(passportVerifier), | ||
kit.WithIdentitiesCounter(0), | ||
kit.WithIdentitiesCreationTimestampLimit(1847321000), | ||
) | ||
|
@@ -44,20 +44,55 @@ func main() { | |
} | ||
``` | ||
|
||
```go | ||
package main | ||
|
||
import ( | ||
kit "github.com/rarimo/zkverifier-kit" | ||
"github.com/rarimo/zkverifier-kit/root" | ||
) | ||
|
||
func main() { | ||
pollVerifier := root.NewProposalSMTVerifier(rpcURL, reqTimeout) | ||
|
||
v, err := kit.NewVerifier( | ||
nil, | ||
kit.WithProofType(kit.PollParticipation), | ||
kit.WithVerificationKeyFile("key.json"), | ||
kit.WithEventID("304358862882731539112827930982999386691702727710421481944329166126417129570"), | ||
) | ||
if err != nil { | ||
// ... | ||
} | ||
// data is an abstract event data that you expect to be in proof | ||
err = v.VerifyProof(proof, | ||
kit.WithPollParticipationEventID(pollEventID) , | ||
kit.WithPollRootVerifier(v.WithContract(pollContract))) | ||
if err != nil { | ||
// ... | ||
} | ||
} | ||
``` | ||
Let's break this down. | ||
|
||
### Configurable root verifier | ||
|
||
Firstly, you instantiate identity root verifier, which will verify the | ||
`IdStateRoot` public signal with contract call. You can refer to our | ||
generated contract bindings in [poseidonsmt](internal/poseidonsmt) package. | ||
generated contract bindings in [poseidonsmt](internal/poseidonsmt) and [proposalsmt](internal/proposalsmt) package. | ||
However, maybe, you would like to create the verifier from config map. | ||
|
||
Here is configuration sample that you should have in `config.yaml` of your app: | ||
```yaml | ||
root_verifier: | ||
rpc: https://your-rpc | ||
contract: 0x... | ||
verifier: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add examples of using config. It might be either ProvideVerifier() with specified Type or custom initialization without Provider. |
||
allowed_age: 18 | ||
allowed_identity_timestamp: 1715698750 | ||
poseidonsmt_root_verifier: | ||
rpc: evm_rpc_url | ||
contract: poseidon_smt_contract_address | ||
request_timeout: 10s | ||
proposalsmt_root_verifier: | ||
rpc: evm_rpc_url | ||
request_timeout: 10s | ||
``` | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,9 @@ type VerifyOptions struct { | |
partEventID string | ||
// voteVerifier - verifies root in PollParticipation proof type | ||
voteVerifier root.Verifier | ||
// skipExpirationCheck - specifies whether to check the expiration date. | ||
// Used for tests only | ||
skipExpirationCheck bool | ||
} | ||
|
||
// VerifyOption type alias for function that may add new values to VerifyOptions structure. | ||
|
@@ -166,6 +169,12 @@ func WithPollRootVerifier(v root.Verifier) VerifyOption { | |
} | ||
} | ||
|
||
func withSkipExpirationCheck(check bool) VerifyOption { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. comment that it's only for tests, or make it exported and describe a use case |
||
return func(opts *VerifyOptions) { | ||
opts.skipExpirationCheck = check | ||
} | ||
} | ||
|
||
// mergeOptions collects all parameters together and fills VerifyOptions struct | ||
// with it, overwriting existing values | ||
func mergeOptions(withDefaults bool, opts VerifyOptions, options ...VerifyOption) VerifyOptions { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.