pubsignals

package
v1.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 11, 2023 License: Apache-2.0, MIT Imports: 19 Imported by: 1

Documentation

Index

Constants

View Source
const PathToSubjectType = "https://www.w3.org/2018/credentials#credentialSubject"

PathToSubjectType path to description of subject type.

Variables

View Source
var (
	// ErrUnavailableIssuer issuer from proof not allowed.
	ErrUnavailableIssuer = 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 anther values")
	// ErrNegativeValue only positive integers allowed.
	ErrNegativeValue = errors.New("negative values not supported")
)
View Source
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")
)

Functions

func IDFromUnknownDID added in v1.2.2

func IDFromUnknownDID(did string) core.ID

IDFromUnknownDID returns ID from did with unsupported by go-iden3-core did method type is set to [255,255] hash alg is sha256

func RegisterVerifier

func RegisterVerifier(id circuits.CircuitID, t reflect.Type)

RegisterVerifier is factory for public signals init. This is done during init() in the method's implementation

Types

type AtomicQueryMTPV2 added in v1.0.0

type AtomicQueryMTPV2 struct {
	circuits.AtomicQueryMTPV2PubSignals
}

AtomicQueryMTPV2 is a wrapper for circuits.AtomicQueryMTPV2PubSignals.

func (*AtomicQueryMTPV2) VerifyIDOwnership added in v1.0.0

func (c *AtomicQueryMTPV2) VerifyIDOwnership(sender string, requestID *big.Int) error

VerifyIDOwnership returns error if ownership id wasn't verified in circuit.

func (*AtomicQueryMTPV2) VerifyQuery added in v1.0.0

func (c *AtomicQueryMTPV2) VerifyQuery(
	ctx context.Context,
	query Query,
	schemaLoader loaders.SchemaLoader,
	verifiablePresentation json.RawMessage,
	opts ...VerifyOpt,
) error

VerifyQuery checks whether the proof matches the query.

func (*AtomicQueryMTPV2) VerifyStates added in v1.0.0

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 added in v1.0.0

type AtomicQuerySigV2 struct {
	circuits.AtomicQuerySigV2PubSignals
}

AtomicQuerySigV2 is a wrapper for circuits.AtomicQuerySigV2PubSignals.

func (*AtomicQuerySigV2) VerifyIDOwnership added in v1.0.0

func (c *AtomicQuerySigV2) VerifyIDOwnership(sender string, requestID *big.Int) error

VerifyIDOwnership returns error if ownership id wasn't verified in circuit.

func (*AtomicQuerySigV2) VerifyQuery added in v1.0.0

func (c *AtomicQuerySigV2) VerifyQuery(
	ctx context.Context,
	query Query,
	schemaLoader loaders.SchemaLoader,
	verifiablePresentation json.RawMessage,
	opts ...VerifyOpt,
) error

VerifyQuery verifies query for atomic query mtp circuit.

func (*AtomicQuerySigV2) VerifyStates added in v1.0.0

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 AuthV2 added in v1.0.0

type AuthV2 struct {
	circuits.AuthV2PubSignals
}

AuthV2 is a wrapper for circuits.AuthV2PubSignals.

func (*AuthV2) VerifyIDOwnership added in v1.0.0

func (c *AuthV2) VerifyIDOwnership(sender string, challenge *big.Int) error

VerifyIDOwnership returns error if ownership id wasn't verified in circuit.

func (*AuthV2) VerifyQuery added in v1.0.0

func (c *AuthV2) VerifyQuery(
	_ context.Context,
	_ Query,
	_ loaders.SchemaLoader,
	_ json.RawMessage,
	_ ...VerifyOpt) error

VerifyQuery is not implemented for authV2 circuit.

func (*AuthV2) VerifyStates added in v1.0.0

func (c *AuthV2) VerifyStates(ctx context.Context, stateResolvers map[string]StateResolver, opts ...VerifyOpt) error

VerifyStates verify AuthV2 tests.

type CircuitOutputs added in v1.0.0

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
}

CircuitOutputs pub signals from circuit.

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"`
}

Query represents structure for query to atomic circuit.

func (Query) Check added in v1.0.0

func (q Query) Check(
	ctx context.Context,
	loader loaders.SchemaLoader,
	pubSig *CircuitOutputs,
	verifiablePresentation json.RawMessage,
	opts ...VerifyOpt,
) error

Check checks if proof was created for this query.

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 loaders.SchemaLoader, verifiablePresentation json.RawMessage, opts ...VerifyOpt) 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

func GetVerifier(id circuits.CircuitID) (Verifier, error)

GetVerifier return specific public signals verifier

type VerifyConfig added in v1.0.0

type VerifyConfig struct {
	// contains filtered or unexported fields
}

VerifyConfig verifiers options.

type VerifyOpt added in v1.0.0

type VerifyOpt func(v *VerifyConfig)

VerifyOpt sets options.

func WithAcceptedProofGenerationDelay added in v1.2.3

func WithAcceptedProofGenerationDelay(duration time.Duration) VerifyOpt

WithAcceptedProofGenerationDelay sets the delay of the proof generation.

func WithAcceptedStateTransitionDelay added in v1.0.0

func WithAcceptedStateTransitionDelay(duration time.Duration) VerifyOpt

WithAcceptedStateTransitionDelay sets the delay of the revoked state.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL