session_key

package
v0.0.46 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CallKernelOperation = iota
	DelegateCallKernelOperation
)
View Source
const (
	ValidatorApprovedStruct = "ValidatorApproved(bytes4 sig,uint256 validatorData,address executor,bytes enableData)"
	DomainStruct            = "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
	KernelDomainName        = "Kernel"
	KernelDomainVersion     = "0.2.2"
	KernelEnableDataLength  = 20 + 32 + 6 + 6 + 20 + 32
)
View Source
const ECDSAValidatorAddress = "0xd9AB5096a832b9ce79914329DAEE236f8Eea0390"

Kernel v2.2

View Source
const (
	KernelEnableSigOffset = 4 + 6 + 6 + 20 + 20 + 32 + KernelEnableDataLength + 32
)
View Source
const SessionKeyValidatorAddress = "0x5C06CE2b673fD5E6e56076e40DD46aB67f5a72A5"

Kernel v2.4

Variables

View Source
var (
	KernelExecuteSig      = [4]byte(smart_wallet.KernelExecuteABI.Methods["execute"].ID)
	KernelExecuteBatchSig = [4]byte(smart_wallet.KernelExecuteABI.Methods["executeBatch"].ID)
)

Functions

func NewEthClient

func NewEthClient(rpcURLString string) (*ethclient.Client, error)

func NewPermissionTree

func NewPermissionTree(permissions []Permission) (*mt.MerkleTree, error)

func PackEnableValidatorSignature

func PackEnableValidatorSignature(enableData []byte, validator, executor common.Address, digestSig signer.Signature) []byte

func PackUseSessionKeySignature

func PackUseSessionKeySignature(sessionKey common.Address, sessionKeySig signer.Signature, kernelPermissions []kernelPermission, proofs []mt.Proof) ([]byte, error)

Types

type Client

type Client interface {
	// GetEnableDataDigest returns the hash of the enable session data, which is used to validate the session key.
	//
	// Parameters:
	// - kernelAddress: the address of the kernel contract
	// - sessionKey: the address of session key
	//
	// Returns:
	// - the hash of the enable session data
	GetEnableDataDigest(kernelAddress, sessionKey common.Address) ([]byte, error)

	// GetEnablingUserOpSigner returns a user operation signer that signs the user operation
	// with the session key and the enable signature.
	//
	// Parameters:
	// - sessionSigner: the session key signer
	// - enableSig: the signature of the enable session data
	//
	// Returns:
	// - a user operation signer function
	// - an error if the signer could not be created
	GetEnablingUserOpSigner(sessionSigner signer.Signer, enableSig signer.Signature) userop.Signer

	// GetUserOpSigner returns a user operation signer that signs the user operation with the session key.
	//
	// Parameters:
	// - sessionSigner: the session key signer
	//
	// Returns:
	// - a user operation signer function
	// - an error if the signer could not be created
	GetUserOpSigner(sessionSigner signer.Signer) userop.Signer
}

func NewClient

func NewClient(config Config) (Client, error)

type Config

type Config struct {
	ProviderURL                string
	ExecuteInBatch             bool
	SessionKeyValidAfter       uint64
	SessionKeyValidUntil       uint64
	SessionKeyValidatorAddress common.Address
	ExecutorAddress            common.Address
	PaymasterAddress           common.Address
	Permissions                []Permission
}

type ParamCondition

type ParamCondition uint8
const (
	EqualParamCondition ParamCondition = iota
	GreaterThanParamCondition
	LessThanParamCondition
	GreaterEqualParamCondition
	LessEqualParamCondition
	NotEqualParamCondition
)

type ParamRule

type ParamRule struct {
	Condition ParamCondition `json:"condition"`
	Param     [32]byte       `json:"param"`
}

type Permission

type Permission struct {
	Target      common.Address `json:"target"`
	FunctionABI abi.Method     `json:"functionABI"`
	ValueLimit  *big.Int       `json:"valueLimit"`
	// NOTE: in the current implementation each function parameter can have only one verification rule.
	// This also means that to specify rule to only second parameter, the rule for the first parameter can NOT be omitted.
	Rules []ParamRule `json:"rules"`
}

type SessionData

type SessionData struct {
	SessionKey common.Address
	ValidAfter time.Time
	ValidUntil time.Time

	// should be generated from the list of permissions
	MerkleRoot []byte

	// address(0) means accept userOp without paymaster,
	// address(1) means reject userOp with paymaster,
	// other address means accept userOp with paymaster with the address
	Paymaster common.Address

	// `SessionKeyValidator.nonces.lastNonce++` -> used in permissionKey to track executions
	Nonce *big.Int
}

func UnpackEnableData

func UnpackEnableData(signature []byte) (SessionData, error)

func (SessionData) PackEnableData

func (sd SessionData) PackEnableData() []byte

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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