packers

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2023 License: Apache-2.0, MIT Imports: 22 Imported by: 5

Documentation

Overview

Package packers defines core 3 protocol packers: anoncrypt, plain and zkp

Index

Constants

View Source
const (
	JSONWebKey2020                    verificationType = "JsonWebKey2020"
	EcdsaSecp256k1VerificationKey2019 verificationType = "EcdsaSecp256k1VerificationKey2019"
	EcdsaSecp256k1RecoveryMethod2020  verificationType = "EcdsaSecp256k1RecoveryMethod2020"
	EddsaBJJVerificationKey           verificationType = "EddsaBJJVerificationKey"
)

List of supported verification types

View Source
const MediaTypeEncryptedMessage iden3comm.MediaType = "application/iden3comm-encrypted-json"

MediaTypeEncryptedMessage is media type for ecnrypted message

View Source
const MediaTypePlainMessage iden3comm.MediaType = "application/iden3comm-plain-json"

MediaTypePlainMessage is media type for plain message

View Source
const MediaTypeSignedMessage iden3comm.MediaType = "application/iden3comm-signed-json"

MediaTypeSignedMessage is media type for jws

View Source
const MediaTypeZKPMessage iden3comm.MediaType = "application/iden3-zkp-json"

MediaTypeZKPMessage is media type for jwz

Variables

View Source
var ErrorVerificationMethodNotFound = errors.New("specified verification method not found")

ErrorVerificationMethodNotFound is return where no verification method found for specified kid

Functions

This section is empty.

Types

type AnoncryptPacker

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

AnoncryptPacker is packer for anon encryption / decryption

func NewAnoncryptPacker

func NewAnoncryptPacker(kr KeyResolverHandlerFunc) *AnoncryptPacker

NewAnoncryptPacker returns new anon packers

func (*AnoncryptPacker) MediaType

func (p *AnoncryptPacker) MediaType() iden3comm.MediaType

MediaType for iden3comm

func (*AnoncryptPacker) Pack

func (p *AnoncryptPacker) Pack(payload []byte, params iden3comm.PackerParams) ([]byte, error)

Pack returns packed message to transport envelope

func (*AnoncryptPacker) Unpack

func (p *AnoncryptPacker) Unpack(envelope []byte) (*iden3comm.BasicMessage, error)

Unpack returns unpacked message from transport envelope

type AnoncryptPackerParams

type AnoncryptPackerParams struct {
	RecipientKey *jose.JSONWebKey
	iden3comm.PackerParams
}

AnoncryptPackerParams is params for anoncrypt packer

type DIDResolverHandlerFunc added in v1.1.0

type DIDResolverHandlerFunc func(did string) (*verifiable.DIDDocument, error)

DIDResolverHandlerFunc resolves did

func (DIDResolverHandlerFunc) Resolve added in v1.1.0

Resolve function is responsible to call provided handler for resolve did document

type DataPreparerHandlerFunc added in v1.0.0

type DataPreparerHandlerFunc func(hash []byte, id *core.DID, circuitID circuits.CircuitID) ([]byte, error)

DataPreparerHandlerFunc registers the handler function for inputs preparation.

func (DataPreparerHandlerFunc) Prepare added in v1.0.0

func (f DataPreparerHandlerFunc) Prepare(hash []byte, id *core.DID, circuitID circuits.CircuitID) ([]byte, error)

Prepare function is responsible to call provided handler for inputs preparation

type JWSPacker added in v1.1.0

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

JWSPacker is packer that use jws

func NewJWSPacker added in v1.1.0

func NewJWSPacker(
	didResolverHandler DIDResolverHandlerFunc,
	signerResolverHandlerFunc SignerResolverHandlerFunc,
) *JWSPacker

NewJWSPacker creates new jws packer instance

func (*JWSPacker) MediaType added in v1.1.0

func (p *JWSPacker) MediaType() iden3comm.MediaType

MediaType for iden3comm that returns MediaTypeSignedMessage

func (*JWSPacker) Pack added in v1.1.0

func (p *JWSPacker) Pack(
	payload []byte, params iden3comm.PackerParams) ([]byte, error)

Pack returns packed message to transport envelope with a zero knowledge proof in JWS full serialized format

func (*JWSPacker) Unpack added in v1.1.0

func (p *JWSPacker) Unpack(envelope []byte) (*iden3comm.BasicMessage, error)

Unpack returns unpacked message from transport envelope with verification of signature

type KeyResolverHandlerFunc

type KeyResolverHandlerFunc func(keyID string) (key interface{}, err error)

KeyResolverHandlerFunc resolve private key by key id

func (KeyResolverHandlerFunc) Resolve

func (kr KeyResolverHandlerFunc) Resolve(keyID string) (key interface{}, err error)

Resolve function is responsible to call provided handler for recipient private key resolve

type PlainMessagePacker

type PlainMessagePacker struct {
}

PlainMessagePacker is simple packer that doesn't use encryption / encoding

func (*PlainMessagePacker) MediaType

func (p *PlainMessagePacker) MediaType() iden3comm.MediaType

MediaType for iden3comm

func (*PlainMessagePacker) Pack

func (p *PlainMessagePacker) Pack(payload []byte, _ iden3comm.PackerParams) ([]byte, error)

Pack returns packed message to transport envelope

func (*PlainMessagePacker) Unpack

func (p *PlainMessagePacker) Unpack(envelope []byte) (*iden3comm.BasicMessage, error)

Unpack returns unpacked message from transport envelope

type PlainPackerParams

type PlainPackerParams struct {
	iden3comm.PackerParams
}

PlainPackerParams is params for plain packer

type ProvingParams added in v1.0.0

type ProvingParams struct {
	DataPreparer DataPreparerHandlerFunc
	ProvingKey   []byte
	Wasm         []byte
}

ProvingParams packer parameters for ZKP generation

func NewProvingParams added in v1.0.0

func NewProvingParams(dataPreparer DataPreparerHandlerFunc, provingKey, wasm []byte) ProvingParams

NewProvingParams defines the ZK proving parameters for ZKP generation

type SignerResolverHandlerFunc added in v1.1.0

type SignerResolverHandlerFunc func(kid string) (crypto.Signer, error)

SignerResolverHandlerFunc resolves signer

func (SignerResolverHandlerFunc) Resolve added in v1.1.0

Resolve function return signer by kid

type SigningParams added in v1.1.0

type SigningParams struct {
	Alg    jwa.SignatureAlgorithm
	KID    string
	DIDDoc *verifiable.DIDDocument
	iden3comm.PackerParams
}

SigningParams packer parameters for jws generation

func NewSigningParams added in v1.1.0

func NewSigningParams() SigningParams

NewSigningParams defines the signing parameters for jws generation

func (*SigningParams) Verify added in v1.1.0

func (s *SigningParams) Verify() error

Verify checks if signing params are valid

type StateVerificationFunc

type StateVerificationFunc func(id circuits.CircuitID, pubsignals []string) error

StateVerificationFunc must verify pubsignals for circuit id

type VerificationHandlerFunc added in v1.0.0

type VerificationHandlerFunc func(id circuits.CircuitID, pubsignals []string) error

VerificationHandlerFunc registers the handler function for state verification.

func (VerificationHandlerFunc) Verify added in v1.0.0

func (f VerificationHandlerFunc) Verify(id circuits.CircuitID, pubsignals []string) error

Verify function is responsible to call provided handler for outputs verification

type VerificationParams added in v1.0.0

type VerificationParams struct {
	Key            []byte
	VerificationFn VerificationHandlerFunc
}

VerificationParams defined the verification function and the verification key for ZKP full verification

func NewVerificationParams added in v1.0.0

func NewVerificationParams(key []byte, verifier VerificationHandlerFunc) VerificationParams

NewVerificationParams creates new verification params

type ZKPPacker

type ZKPPacker struct {
	Prover       map[jwz.ProvingMethodAlg]ProvingParams
	Verification map[jwz.ProvingMethodAlg]VerificationParams
}

ZKPPacker is packer that use JWZ

func NewZKPPacker

func NewZKPPacker(provingParams map[jwz.ProvingMethodAlg]ProvingParams,
	verification map[jwz.ProvingMethodAlg]VerificationParams) *ZKPPacker

NewZKPPacker creates new zkp packer instance

func (*ZKPPacker) MediaType

func (p *ZKPPacker) MediaType() iden3comm.MediaType

MediaType for iden3comm that returns MediaTypeZKPMessage

func (*ZKPPacker) Pack

func (p *ZKPPacker) Pack(payload []byte, params iden3comm.PackerParams) ([]byte, error)

Pack returns packed message to transport envelope with a zero knowledge proof in JWZ full serialized format

func (*ZKPPacker) Unpack

func (p *ZKPPacker) Unpack(envelope []byte) (*iden3comm.BasicMessage, error)

Unpack returns unpacked message from transport envelope with verification of zeroknowledge proof

type ZKPPackerParams

type ZKPPackerParams struct {
	SenderID         *core.DID
	ProvingMethodAlg jwz.ProvingMethodAlg
	iden3comm.PackerParams
}

ZKPPackerParams is params for zkp packer

Directories

Path Synopsis
providers
bjj

Jump to

Keyboard shortcuts

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