packers

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: 34 Imported by: 6

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 MediaTypeAuthEncryptedMessage iden3comm.MediaType = "application/iden3comm-auth-encrypted-json"

MediaTypeAuthEncryptedMessage is media type for auth encrypted message

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

MediaTypeEncryptedMessage is media type for encrypted 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 (
	// ES256KRALG Algorithm for ECDSA using secp256k1 curve and recovery id
	ES256KRALG = jwa.NewSignatureAlgorithm("ES256K-R")
)
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,
	dr DidDocumentResolverFunc,
) *AnoncryptPacker

NewAnoncryptPacker returns new anon packers

func (*AnoncryptPacker) GetSupportedProfiles added in v2.10.0

func (p *AnoncryptPacker) GetSupportedProfiles() []string

GetSupportedProfiles gets packer envelope (supported profiles) with options

func (*AnoncryptPacker) IsProfileSupported added in v2.10.0

func (p *AnoncryptPacker) IsProfileSupported(profile string) bool

IsProfileSupported checks if profile is supported by packer

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               jwk.Key
	Recipients                 []AnoncryptRecipients
	ContentEncryptionAlgorithm string
	iden3comm.PackerParams
}

AnoncryptPackerParams is params for anoncrypt packer

type AnoncryptRecipients added in v2.11.5

type AnoncryptRecipients struct {
	DID    string
	JWKAlg string
}

AnoncryptRecipients is recipient info for anoncrypt packer

type AuthcryptPacker added in v2.11.5

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

AuthcryptPacker is packer for auth encryption / decryption

func NewAuthcryptPacker added in v2.11.5

func NewAuthcryptPacker(pubKeyResolver, privKeyResolver KeyResolverHandlerFunc) *AuthcryptPacker

NewAuthcryptPacker returns new auth packers Param pubKeyResolver is used to resolve public keys by key id Param privKeyResolver is used to resolve private keys by key id

func (*AuthcryptPacker) GetSupportedProfiles added in v2.11.5

func (p *AuthcryptPacker) GetSupportedProfiles() []string

GetSupportedProfiles returns supported profiles by packer

func (*AuthcryptPacker) IsProfileSupported added in v2.11.5

func (p *AuthcryptPacker) IsProfileSupported(profile string) bool

IsProfileSupported checks if profile is supported by packer

func (*AuthcryptPacker) MediaType added in v2.11.5

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

MediaType for iden3comm

func (*AuthcryptPacker) Pack added in v2.11.5

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

Pack returns packed message to transport envelope Notice: this functionality is in beta and can be deleted or be non-backward compatible in the future releases.

func (*AuthcryptPacker) Unpack added in v2.11.5

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

Unpack returns unpacked message from transport envelope Notice: this functionality is in beta and can be deleted or be non-backward compatible in the future releases.

type AuthcryptPackerParams added in v2.11.5

type AuthcryptPackerParams struct {
	SenderKeyID    string
	RecipientKeyID string
	iden3comm.PackerParams
}

AuthcryptPackerParams is params for authcrypt packer

type DIDResolverHandlerFunc

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

DIDResolverHandlerFunc resolves did

func (DIDResolverHandlerFunc) Resolve

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

type DataPreparerHandlerFunc

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

DataPreparerHandlerFunc registers the handler function for inputs preparation.

func (DataPreparerHandlerFunc) Prepare

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

Prepare function is responsible to call provided handler for inputs preparation

type DefaultZKPUnpackerOption added in v2.8.0

type DefaultZKPUnpackerOption func(*defaultZKPUnpacker)

DefaultZKPUnpackerOption is a function that sets the default ZKP unpacker options

func WithAuthVerifyDelay added in v2.8.0

func WithAuthVerifyDelay(delay time.Duration) DefaultZKPUnpackerOption

WithAuthVerifyDelay sets the delay for the auth verification

type DidDocumentResolverFunc added in v2.11.5

type DidDocumentResolverFunc func(ctx context.Context, did string, opts *services.ResolverOpts) (*document.DidResolution, error)

DidDocumentResolverFunc resolves did document by did

func (DidDocumentResolverFunc) Resolve added in v2.11.5

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

type JWSPacker

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

JWSPacker is packer that use jws

func NewJWSPacker

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

NewJWSPacker creates new jws packer instance

func (*JWSPacker) GetSupportedProfiles added in v2.10.0

func (p *JWSPacker) GetSupportedProfiles() []string

GetSupportedProfiles gets packer envelope (supported profiles) with options

func (*JWSPacker) IsProfileSupported added in v2.10.0

func (p *JWSPacker) IsProfileSupported(profile string) bool

IsProfileSupported checks if profile is supported by packer

func (*JWSPacker) MediaType

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

MediaType for iden3comm that returns MediaTypeSignedMessage

func (*JWSPacker) Pack

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

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) GetSupportedProfiles added in v2.10.0

func (p *PlainMessagePacker) GetSupportedProfiles() []string

GetSupportedProfiles gets packer envelope (supported profiles) with options

func (*PlainMessagePacker) IsProfileSupported added in v2.10.0

func (p *PlainMessagePacker) IsProfileSupported(profile string) bool

IsProfileSupported checks if profile is supported by packer

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

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

ProvingParams packer parameters for ZKP generation

func NewProvingParams

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

NewProvingParams defines the ZK proving parameters for ZKP generation

type SignerResolverHandlerFunc

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

SignerResolverHandlerFunc resolves signer

func (SignerResolverHandlerFunc) Resolve

Resolve function return signer by kid

type SigningParams

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

SigningParams packer parameters for jws generation

func NewSigningParams

func NewSigningParams() SigningParams

NewSigningParams defines the signing parameters for jws generation

func (*SigningParams) Verify

func (s *SigningParams) Verify() error

Verify checks if signing params are valid

type VerificationHandlerFunc

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

VerificationHandlerFunc registers the handler function for state verification.

func (VerificationHandlerFunc) Verify

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

Verify function is responsible to call provided handler for outputs verification

type VerificationParams

type VerificationParams struct {
	Key            []byte
	VerificationFn VerificationHandlerFunc
}

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

func NewVerificationParams

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
	// contains filtered or unexported fields
}

ZKPPacker is packer that use JWZ

func DefaultMultiKeyZKPUnpacker deprecated added in v2.11.3

func DefaultMultiKeyZKPUnpacker(verificationKeys map[jwz.ProvingMethodAlg][]byte, resolvers map[int]eth.Resolver, opts ...DefaultZKPUnpackerOption) *ZKPPacker

Deprecated: use NewDefaultZKPUnpacker instead. DefaultMultiKeyZKPUnpacker creates a default ZKP unpacker with the provided verification keys and resolvers

func DefaultZKPUnpacker deprecated added in v2.8.0

func DefaultZKPUnpacker(verificationKey []byte, resolvers map[int]eth.Resolver, opts ...DefaultZKPUnpackerOption) *ZKPPacker

Deprecated: use NewDefaultZKPUnpacker instead. DefaultZKPUnpacker creates a default ZKP unpacker with the provided verification key and resolvers

func NewDefaultZKPUnpacker added in v2.12.1

func NewDefaultZKPUnpacker(verificationKeys map[jwz.ProvingMethodAlg][]byte, resolvers map[int]driver.Resolver, opts ...DefaultZKPUnpackerOption) *ZKPPacker

NewDefaultZKPUnpacker creates a default ZKP unpacker with the provided verification keys and resolvers

func NewZKPPacker

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

NewZKPPacker creates new zkp packer instance

func (*ZKPPacker) GetSupportedProfiles added in v2.10.0

func (p *ZKPPacker) GetSupportedProfiles() []string

GetSupportedProfiles gets packer envelope (supported profiles) with options

func (*ZKPPacker) IsProfileSupported added in v2.10.0

func (p *ZKPPacker) IsProfileSupported(profile string) bool

IsProfileSupported checks if profile is supported by packer

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         *w3c.DID
	ProvingMethodAlg jwz.ProvingMethodAlg
	iden3comm.PackerParams
}

ZKPPackerParams is params for zkp packer

Directories

Path Synopsis
providers
bjj
jwe

Jump to

Keyboard shortcuts

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