Documentation
¶
Index ¶
- Constants
- Variables
- func CalculateQueryHash(values []*big.Int, schemaHash *big.Int, slotIndex int, operator int, ...) (*big.Int, error)
- func IsValidOperation(typ string, op int) bool
- func RegisterVerifier(id circuits.CircuitID, t reflect.Type)
- type AtomicQueryMTPV2
- func (c *AtomicQueryMTPV2) VerifyIDOwnership(sender string, requestID *big.Int) error
- func (c *AtomicQueryMTPV2) VerifyQuery(ctx context.Context, query Query, schemaLoader ld.DocumentLoader, ...) (CircuitVerificationResult, error)
- func (c *AtomicQueryMTPV2) VerifyStates(ctx context.Context, stateResolvers map[string]StateResolver, ...) error
- type AtomicQuerySigV2
- func (c *AtomicQuerySigV2) VerifyIDOwnership(sender string, requestID *big.Int) error
- func (c *AtomicQuerySigV2) VerifyQuery(ctx context.Context, query Query, schemaLoader ld.DocumentLoader, ...) (CircuitVerificationResult, error)
- func (c *AtomicQuerySigV2) VerifyStates(ctx context.Context, stateResolvers map[string]StateResolver, ...) error
- type AtomicQueryV3
- func (c *AtomicQueryV3) VerifyIDOwnership(sender string, requestID *big.Int) error
- func (c *AtomicQueryV3) VerifyQuery(ctx context.Context, query Query, schemaLoader ld.DocumentLoader, ...) (CircuitVerificationResult, error)
- func (c *AtomicQueryV3) VerifyStates(ctx context.Context, stateResolvers map[string]StateResolver, ...) error
- type AuthV2
- func (c *AuthV2) VerifyIDOwnership(sender string, challenge *big.Int) error
- func (c *AuthV2) VerifyQuery(_ context.Context, _ Query, _ ld.DocumentLoader, _ json.RawMessage, ...) (CircuitVerificationResult, error)
- func (c *AuthV2) VerifyStates(ctx context.Context, stateResolvers map[string]StateResolver, ...) error
- type CircuitOutputs
- type CircuitVerificationResult
- type LinkedMultiQuery
- func (c *LinkedMultiQuery) VerifyIDOwnership(_ string, _ *big.Int) error
- func (c *LinkedMultiQuery) VerifyQuery(ctx context.Context, query Query, schemaLoader ld.DocumentLoader, ...) (CircuitVerificationResult, error)
- func (c *LinkedMultiQuery) VerifyStates(_ context.Context, _ map[string]StateResolver, _ ...VerifyOpt) error
- type PropertyQuery
- type Query
- type QueryMetadata
- type StateResolver
- type Verifier
- type VerifyConfig
- type VerifyOpt
Constants ¶
const ParamNameNullifierSessionID = "nullifierSessionId"
ParamNameNullifierSessionID is a nullifier session id - specific circuit param for V3 to generate nullifier
const ParamNameVerifierDID = "verifierDid"
ParamNameVerifierDID is a verifier did - specific circuit param for V3, but can be utilized by other circuits
const PathToSubjectType = "https://www.w3.org/2018/credentials#credentialSubject"
PathToSubjectType path to description of subject type.
Variables ¶
var ( errors.New("issuer not exists in query access list") // ErrSchemaID proof was created for different schema. ErrSchemaID = errors.New("proof was generated for another schema") // ErrRequestOperator proof was created for different query. ErrRequestOperator = errors.New("proof was generated for another query operator") // ErrValuesSize proof was created for different values. ErrValuesSize = errors.New("query asked proof about more values") // ErrInvalidValues proof was created for different values. ErrInvalidValues = errors.New("proof was generated for another values") // ErrNegativeValue only positive integers allowed. ErrNegativeValue = errors.New("negative values not supported") )ErrUnavailableIssuer =
var ( // ErrGlobalStateIsNotValid invalid global state id. ErrGlobalStateIsNotValid = errors.New("global state is not valid") // ErrIssuerClaimStateIsNotValid declares that issuer state is invalid. ErrIssuerClaimStateIsNotValid = errors.New("issuer state is not valid") // ErrIssuerNonRevocationClaimStateIsNotValid declares that issuer non-revocation state is invalid. ErrIssuerNonRevocationClaimStateIsNotValid = errors.New("issuer state for non-revocation proofs is not valid") // ErrProofGenerationOutdated declares that generated proof is outdated. ErrProofGenerationOutdated = errors.New("generated proof is outdated") // ErrWronProofType declares that query proof type doesn't match circuit proof type ErrWronProofType = errors.New("invalid proof type") )
Functions ¶
func CalculateQueryHash ¶ added in v2.2.0
func CalculateQueryHash( values []*big.Int, schemaHash *big.Int, slotIndex int, operator int, claimPathKey *big.Int, isMerklized bool, ) (*big.Int, error)
CalculateQueryHash calculates query hash
func IsValidOperation ¶ added in v2.2.0
IsValidOperation checks if operation and type are supported.
func RegisterVerifier ¶
RegisterVerifier is factory for public signals init. This is done during init() in the method's implementation
Types ¶
type AtomicQueryMTPV2 ¶
type AtomicQueryMTPV2 struct {
circuits.AtomicQueryMTPV2PubSignals
}
AtomicQueryMTPV2 is a wrapper for circuits.AtomicQueryMTPV2PubSignals.
func (*AtomicQueryMTPV2) VerifyIDOwnership ¶
func (c *AtomicQueryMTPV2) VerifyIDOwnership(sender string, requestID *big.Int) error
VerifyIDOwnership returns error if ownership id wasn't verified in circuit.
func (*AtomicQueryMTPV2) VerifyQuery ¶
func (c *AtomicQueryMTPV2) VerifyQuery( ctx context.Context, query Query, schemaLoader ld.DocumentLoader, verifiablePresentation json.RawMessage, _ map[string]interface{}, opts ...VerifyOpt, ) (CircuitVerificationResult, error)
VerifyQuery checks whether the proof matches the query.
func (*AtomicQueryMTPV2) VerifyStates ¶
func (c *AtomicQueryMTPV2) VerifyStates(ctx context.Context, stateResolvers map[string]StateResolver, opts ...VerifyOpt) error
VerifyStates verifies user state and issuer claim issuance state in the smart contract.
type AtomicQuerySigV2 ¶
type AtomicQuerySigV2 struct {
circuits.AtomicQuerySigV2PubSignals
}
AtomicQuerySigV2 is a wrapper for circuits.AtomicQuerySigV2PubSignals.
func (*AtomicQuerySigV2) VerifyIDOwnership ¶
func (c *AtomicQuerySigV2) VerifyIDOwnership(sender string, requestID *big.Int) error
VerifyIDOwnership returns error if ownership id wasn't verified in circuit.
func (*AtomicQuerySigV2) VerifyQuery ¶
func (c *AtomicQuerySigV2) VerifyQuery( ctx context.Context, query Query, schemaLoader ld.DocumentLoader, verifiablePresentation json.RawMessage, _ map[string]interface{}, opts ...VerifyOpt, ) (CircuitVerificationResult, error)
VerifyQuery verifies query for atomic query mtp circuit.
func (*AtomicQuerySigV2) VerifyStates ¶
func (c *AtomicQuerySigV2) VerifyStates(ctx context.Context, stateResolvers map[string]StateResolver, opts ...VerifyOpt) error
VerifyStates verifies user state and issuer auth claim state in the smart contract.
type AtomicQueryV3 ¶ added in v2.1.0
type AtomicQueryV3 struct {
circuits.AtomicQueryV3PubSignals
}
AtomicQueryV3 is a wrapper for circuits.AtomicQueryV3PubSignals.
func (*AtomicQueryV3) VerifyIDOwnership ¶ added in v2.1.0
func (c *AtomicQueryV3) VerifyIDOwnership(sender string, requestID *big.Int) error
VerifyIDOwnership returns error if ownership id wasn't verified in circuit.
func (*AtomicQueryV3) VerifyQuery ¶ added in v2.1.0
func (c *AtomicQueryV3) VerifyQuery( ctx context.Context, query Query, schemaLoader ld.DocumentLoader, verifiablePresentation json.RawMessage, params map[string]interface{}, opts ...VerifyOpt, ) (CircuitVerificationResult, error)
VerifyQuery verifies query for atomic query V3 circuit.
func (*AtomicQueryV3) VerifyStates ¶ added in v2.1.0
func (c *AtomicQueryV3) VerifyStates(ctx context.Context, stateResolvers map[string]StateResolver, opts ...VerifyOpt) error
VerifyStates verifies user state and issuer auth claim state in the smart contract.
type AuthV2 ¶
type AuthV2 struct {
circuits.AuthV2PubSignals
}
AuthV2 is a wrapper for circuits.AuthV2PubSignals.
func (*AuthV2) VerifyIDOwnership ¶
VerifyIDOwnership returns error if ownership id wasn't verified in circuit.
func (*AuthV2) VerifyQuery ¶
func (c *AuthV2) VerifyQuery( _ context.Context, _ Query, _ ld.DocumentLoader, _ json.RawMessage, _ map[string]interface{}, _ ...VerifyOpt) (CircuitVerificationResult, error)
VerifyQuery is not implemented for authV2 circuit.
func (*AuthV2) VerifyStates ¶
func (c *AuthV2) VerifyStates(ctx context.Context, stateResolvers map[string]StateResolver, opts ...VerifyOpt) error
VerifyStates verify AuthV2 tests.
type CircuitOutputs ¶
type CircuitOutputs struct { IssuerID *core.ID ClaimSchema core.SchemaHash SlotIndex int Operator int Value []*big.Int Timestamp int64 Merklized int ClaimPathKey *big.Int ClaimPathNotExists int ValueArraySize int IsRevocationChecked int // V3 NEW LinkID *big.Int VerifierID *core.ID NullifierSessionID *big.Int OperatorOutput *big.Int Nullifier *big.Int ProofType int }
CircuitOutputs pub signals from circuit.
type CircuitVerificationResult ¶ added in v2.2.0
CircuitVerificationResult struct for verification result.
type LinkedMultiQuery ¶ added in v2.2.0
type LinkedMultiQuery struct {
circuits.LinkedMultiQueryPubSignals
}
LinkedMultiQuery is a wrapper for circuits.LinkedMultiQueryPubSignals.
func (*LinkedMultiQuery) VerifyIDOwnership ¶ added in v2.2.0
func (c *LinkedMultiQuery) VerifyIDOwnership(_ string, _ *big.Int) error
VerifyIDOwnership returns error if ownership id wasn't verified in circuit.
func (*LinkedMultiQuery) VerifyQuery ¶ added in v2.2.0
func (c *LinkedMultiQuery) VerifyQuery( ctx context.Context, query Query, schemaLoader ld.DocumentLoader, vp json.RawMessage, _ map[string]interface{}, _ ...VerifyOpt, ) (CircuitVerificationResult, error)
VerifyQuery verifies query for linked multi query 10 circuit.
func (*LinkedMultiQuery) VerifyStates ¶ added in v2.2.0
func (c *LinkedMultiQuery) VerifyStates(_ context.Context, _ map[string]StateResolver, _ ...VerifyOpt) error
VerifyStates verifies user state and issuer auth claim state in the smart contract.
type PropertyQuery ¶ added in v2.2.0
PropertyQuery struct
func ParseCredentialSubject ¶ added in v2.2.0
func ParseCredentialSubject(_ context.Context, credentialSubject any) (out []PropertyQuery, err error)
ParseCredentialSubject parse credential subject and return array of property queries
type Query ¶
type Query struct { AllowedIssuers []string `json:"allowedIssuers"` CredentialSubject map[string]interface{} `json:"credentialSubject,omitempty"` Context string `json:"context"` Type string `json:"type"` ClaimID string `json:"claimId,omitempty"` SkipClaimRevocationCheck bool `json:"skipClaimRevocationCheck,omitempty"` ProofType string `json:"proofType"` GroupID int `json:"groupId"` }
Query represents structure for query to atomic circuit.
func (Query) Check ¶
func (q Query) Check( ctx context.Context, loader ld.DocumentLoader, pubSig *CircuitOutputs, verifiablePresentation json.RawMessage, circuitID circuits.CircuitID, opts ...VerifyOpt, ) error
Check checks if proof was created for this query. Would be good to use ctx for external http requests, but current interfaces doesn't allow to do it. Left it for future.
type QueryMetadata ¶ added in v2.2.0
type QueryMetadata struct { PropertyQuery SlotIndex int Values []*big.Int Path *merklize.Path ClaimPathKey *big.Int Datatype string MerklizedSchema bool }
QueryMetadata struct describe query metadata
func ParseQueriesMetadata ¶ added in v2.2.0
func ParseQueriesMetadata(ctx context.Context, credentialType, ldContextJSON string, credentialSubject map[string]interface{}, options merklize.Options) (out []QueryMetadata, err error)
ParseQueriesMetadata parse credential subject and return array of query metadata
func ParseQueryMetadata ¶ added in v2.2.0
func ParseQueryMetadata(ctx context.Context, propertyQuery PropertyQuery, ldContextJSON, credentialType string, options merklize.Options) (query *QueryMetadata, err error)
ParseQueryMetadata parse property query and return query metadata
type StateResolver ¶
type StateResolver interface { Resolve(ctx context.Context, id *big.Int, state *big.Int) (*state.ResolvedState, error) ResolveGlobalRoot(ctx context.Context, state *big.Int) (*state.ResolvedState, error) }
StateResolver is a state resolver interface
type Verifier ¶
type Verifier interface { VerifyQuery(ctx context.Context, query Query, schemaLoader ld.DocumentLoader, verifiablePresentation json.RawMessage, circuitParams map[string]interface{}, opts ...VerifyOpt) (CircuitVerificationResult, error) VerifyStates(ctx context.Context, resolvers map[string]StateResolver, opts ...VerifyOpt) error VerifyIDOwnership(userIdentifier string, challenge *big.Int) error circuits.PubSignalsUnmarshaller }
Verifier is interface for verification of public signals of zkp
func GetVerifier ¶
GetVerifier return specific public signals verifier
type VerifyConfig ¶
type VerifyConfig struct { // is the period of time that a revoked state remains valid. AcceptedStateTransitionDelay time.Duration AcceptedProofGenerationDelay time.Duration AllowExpiredMessages *bool }
VerifyConfig verifiers options.
type VerifyOpt ¶
type VerifyOpt func(v *VerifyConfig)
VerifyOpt sets options.
func WithAcceptedProofGenerationDelay ¶
WithAcceptedProofGenerationDelay sets the delay of the proof generation.
func WithAcceptedStateTransitionDelay ¶
WithAcceptedStateTransitionDelay sets the delay of the revoked state.
func WithAllowExpiredMessages ¶ added in v2.6.0
WithAllowExpiredMessages sets the allow expired messages option.