Documentation
¶
Overview ¶
Package packers defines core 3 protocol packers: anoncrypt, plain and zkp
Index ¶
- Constants
- Variables
- type AnoncryptPacker
- func (p *AnoncryptPacker) GetSupportedProfiles() []string
- func (p *AnoncryptPacker) IsProfileSupported(profile string) bool
- func (p *AnoncryptPacker) MediaType() iden3comm.MediaType
- func (p *AnoncryptPacker) Pack(payload []byte, params iden3comm.PackerParams) ([]byte, error)
- func (p *AnoncryptPacker) Unpack(envelope []byte) (*iden3comm.BasicMessage, error)
- type AnoncryptPackerParams
- type AnoncryptRecipients
- type AuthcryptPacker
- func (p *AuthcryptPacker) GetSupportedProfiles() []string
- func (p *AuthcryptPacker) IsProfileSupported(profile string) bool
- func (p *AuthcryptPacker) MediaType() iden3comm.MediaType
- func (p *AuthcryptPacker) Pack(payload []byte, params iden3comm.PackerParams) ([]byte, error)
- func (p *AuthcryptPacker) Unpack(envelope []byte) (*iden3comm.BasicMessage, error)
- type AuthcryptPackerParams
- type DIDResolverHandlerFunc
- type DataPreparerHandlerFunc
- type DefaultZKPUnpackerOption
- type DidDocumentResolverFunc
- type JWSPacker
- func (p *JWSPacker) GetSupportedProfiles() []string
- func (p *JWSPacker) IsProfileSupported(profile string) bool
- func (p *JWSPacker) MediaType() iden3comm.MediaType
- func (p *JWSPacker) Pack(payload []byte, params iden3comm.PackerParams) ([]byte, error)
- func (p *JWSPacker) Unpack(envelope []byte) (*iden3comm.BasicMessage, error)
- type KeyResolverHandlerFunc
- type PlainMessagePacker
- func (p *PlainMessagePacker) GetSupportedProfiles() []string
- func (p *PlainMessagePacker) IsProfileSupported(profile string) bool
- func (p *PlainMessagePacker) MediaType() iden3comm.MediaType
- func (p *PlainMessagePacker) Pack(payload []byte, _ iden3comm.PackerParams) ([]byte, error)
- func (p *PlainMessagePacker) Unpack(envelope []byte) (*iden3comm.BasicMessage, error)
- type PlainPackerParams
- type ProvingParams
- type SignerResolverHandlerFunc
- type SigningParams
- type VerificationHandlerFunc
- type VerificationParams
- type ZKPPacker
- func DefaultMultiKeyZKPUnpacker(verificationKeys map[jwz.ProvingMethodAlg][]byte, ...) *ZKPPackerdeprecated
- func DefaultZKPUnpacker(verificationKey []byte, resolvers map[int]eth.Resolver, ...) *ZKPPackerdeprecated
- func NewDefaultZKPUnpacker(verificationKeys map[jwz.ProvingMethodAlg][]byte, ...) *ZKPPacker
- func NewZKPPacker(provingParams map[jwz.ProvingMethodAlg]ProvingParams, ...) *ZKPPacker
- func (p *ZKPPacker) GetSupportedProfiles() []string
- func (p *ZKPPacker) IsProfileSupported(profile string) bool
- func (p *ZKPPacker) MediaType() iden3comm.MediaType
- func (p *ZKPPacker) Pack(payload []byte, params iden3comm.PackerParams) ([]byte, error)
- func (p *ZKPPacker) Unpack(envelope []byte) (*iden3comm.BasicMessage, error)
- type ZKPPackerParams
Constants ¶
const ( JSONWebKey2020 verificationType = "JsonWebKey2020" EcdsaSecp256k1VerificationKey2019 verificationType = "EcdsaSecp256k1VerificationKey2019" EcdsaSecp256k1RecoveryMethod2020 verificationType = "EcdsaSecp256k1RecoveryMethod2020" EddsaBJJVerificationKey verificationType = "EddsaBJJVerificationKey" )
List of supported verification types
const MediaTypeAuthEncryptedMessage iden3comm.MediaType = "application/iden3comm-auth-encrypted-json"
MediaTypeAuthEncryptedMessage is media type for auth encrypted message
const MediaTypeEncryptedMessage iden3comm.MediaType = "application/iden3comm-encrypted-json"
MediaTypeEncryptedMessage is media type for encrypted message
const MediaTypePlainMessage iden3comm.MediaType = "application/iden3comm-plain-json"
MediaTypePlainMessage is media type for plain message
const MediaTypeSignedMessage iden3comm.MediaType = "application/iden3comm-signed-json"
MediaTypeSignedMessage is media type for jws
const MediaTypeZKPMessage iden3comm.MediaType = "application/iden3-zkp-json"
MediaTypeZKPMessage is media type for jwz
Variables ¶
var ( // ES256KRALG Algorithm for ECDSA using secp256k1 curve and recovery id ES256KRALG = jwa.NewSignatureAlgorithm("ES256K-R") )
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
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 ¶
func (f DIDResolverHandlerFunc) Resolve(did string) (*verifiable.DIDDocument, error)
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.
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
func (d DidDocumentResolverFunc) Resolve(ctx context.Context, did string, opts *services.ResolverOpts) (*document.DidResolution, error)
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
GetSupportedProfiles gets packer envelope (supported profiles) with options
func (*JWSPacker) IsProfileSupported ¶ added in v2.10.0
IsProfileSupported checks if profile is supported by packer
type KeyResolverHandlerFunc ¶
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 ¶
SignerResolverHandlerFunc resolves signer
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 ¶
VerificationHandlerFunc registers the handler function for state 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 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
GetSupportedProfiles gets packer envelope (supported profiles) with options
func (*ZKPPacker) IsProfileSupported ¶ added in v2.10.0
IsProfileSupported checks if profile is supported by packer
type ZKPPackerParams ¶
type ZKPPackerParams struct {
SenderID *w3c.DID
ProvingMethodAlg jwz.ProvingMethodAlg
iden3comm.PackerParams
}
ZKPPackerParams is params for zkp packer