mock

package
v2.13.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: Apache-2.0, MIT Imports: 24 Imported by: 0

Documentation

Overview

Package mock defines mocks for protocol testing

Index

Constants

View Source
const (
	SenderKeyIdAuthCrypt    = "sender-key-id"
	RecipientKeyIdAuthCrypt = "recipient-key-id"
)
View Source
const MockRecipientKeyID = "123456789"

MockRecipientKeyID is mocked key id for recipient

Variables

View Source
var (
	AliceDigest  = rand.New(rand.NewSource(1))
	BobDigest    = rand.New(rand.NewSource(2))
	ViktorDigest = rand.New(rand.NewSource(3))
)
View Source
var (
	PubResolverAuthCrypt = func(kid string) (interface{}, error) {
		if kid == SenderKeyIdAuthCrypt {
			return joseprimitives.Import(senderKey.PublicKey())
		}
		if kid == RecipientKeyIdAuthCrypt {
			return joseprimitives.Import(recipientKey.PublicKey())
		}
		return nil, errors.New("key not found")
	}

	PrivResolverAuthCrypt = func(kid string) (interface{}, error) {
		if kid == SenderKeyIdAuthCrypt {
			return senderKey, nil
		}
		if kid == RecipientKeyIdAuthCrypt {
			return recipientKey, nil
		}
		return nil, errors.New("key not found")
	}
)

Functions

func PrepareAuthInputs

func PrepareAuthInputs(hash []byte, _ *w3c.DID, _ circuits.CircuitID) ([]byte, error)

PrepareAuthInputs returns mocked inputs for auth circuit

func ResolveEncPrivateKey

func ResolveEncPrivateKey(keyID string) (interface{}, error)

ResolveEncPrivateKey returns mocked private key

func ResolveKeyID

func ResolveKeyID(keyID string) (jwk.Key, error)

ResolveKeyID returns mocked public key for any key ID

func ToJWK added in v2.11.5

func ToJWK(t *testing.T, key any) map[string]interface{}

func VerifyState

func VerifyState(_ circuits.CircuitID, _ []string) error

VerifyState return no error always

Types

type MockCommon added in v2.11.9

type MockCommon struct {
	MockRSA MockRSA
	MockEC  MockEC
}

func NewCommonMock added in v2.11.9

func NewCommonMock(r MockRSA, e MockEC) MockCommon

func (MockCommon) BuildDidDocWithAllKeys added in v2.11.9

func (m MockCommon) BuildDidDocWithAllKeys(t *testing.T, did string) *document.DidResolution

type MockEC added in v2.11.5

type MockEC struct {
	PrivateKey *ecdh.PrivateKey
}

func NewMockEC added in v2.11.5

func NewMockEC(t *testing.T, r io.Reader) MockEC

func (MockEC) BuildDidDocWithECKey added in v2.11.5

func (m MockEC) BuildDidDocWithECKey(t *testing.T, did string) *document.DidResolution

func (MockEC) GetJWKForPrivateKey added in v2.11.5

func (m MockEC) GetJWKForPrivateKey(t *testing.T) map[string]interface{}

func (MockEC) GetJWKForPublicKey added in v2.11.5

func (m MockEC) GetJWKForPublicKey(t *testing.T) map[string]interface{}

type MockRSA added in v2.11.5

type MockRSA struct {
	PrivateKey *rsa.PrivateKey
}

func NewMockRSA added in v2.11.5

func NewMockRSA(t *testing.T, r io.Reader) MockRSA

func (MockRSA) BuildDidDocWithRSAKey added in v2.11.5

func (m MockRSA) BuildDidDocWithRSAKey(t *testing.T, did string) *document.DidResolution

func (MockRSA) GetJWKForPrivateKey added in v2.11.5

func (m MockRSA) GetJWKForPrivateKey(t *testing.T) map[string]interface{}

func (MockRSA) GetJWKForPublicKey added in v2.11.5

func (m MockRSA) GetJWKForPublicKey(t *testing.T) map[string]interface{}

type ProvingMethodGroth16AuthV2

type ProvingMethodGroth16AuthV2 struct {
	jwz.ProvingMethodAlg
}

ProvingMethodGroth16AuthV2 proving method to avoid using of proving key and wasm files

func (*ProvingMethodGroth16AuthV2) Alg

Alg returns current zk alg

func (*ProvingMethodGroth16AuthV2) CircuitID

func (m *ProvingMethodGroth16AuthV2) CircuitID() string

CircuitID returns name of circuit

func (*ProvingMethodGroth16AuthV2) Prove

func (m *ProvingMethodGroth16AuthV2) Prove(_, _, _ []byte) (*types.ZKProof, error)

Prove generates proof using auth circuit and groth16 alg, checks that proven message hash is set as a part of circuit specific inputs

func (*ProvingMethodGroth16AuthV2) Verify

func (m *ProvingMethodGroth16AuthV2) Verify(_ []byte, _ *types.ZKProof, _ []byte) error

Verify return no error for any proof

Jump to

Keyboard shortcuts

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