Documentation
¶
Index ¶
- type Key
- type KeyRecord
- type KeyRepository
- type KeyType
- type SimpleKeyRepository
- func (r *SimpleKeyRepository) Delete(ctx *context.AgentContext, id string) error
- func (r *SimpleKeyRepository) FindById(ctx *context.AgentContext, id string) (*KeyRecord, error)
- func (r *SimpleKeyRepository) FindByPublicKey(ctx *context.AgentContext, publicKey []byte) (*KeyRecord, error)
- func (r *SimpleKeyRepository) GetAll(ctx *context.AgentContext) ([]*KeyRecord, error)
- func (r *SimpleKeyRepository) Save(ctx *context.AgentContext, record *KeyRecord) error
- type StorageKeyRepository
- func (r *StorageKeyRepository) Delete(ctx *agentcontext.AgentContext, id string) error
- func (r *StorageKeyRepository) FindById(ctx *agentcontext.AgentContext, id string) (*KeyRecord, error)
- func (r *StorageKeyRepository) FindByPublicKey(ctx *agentcontext.AgentContext, publicKey []byte) (*KeyRecord, error)
- func (r *StorageKeyRepository) GetAll(ctx *agentcontext.AgentContext) ([]*KeyRecord, error)
- func (r *StorageKeyRepository) Save(ctx *agentcontext.AgentContext, record *KeyRecord) error
- type WalletService
- func (w *WalletService) CreateKey(keyType KeyType) (*Key, error)
- func (w *WalletService) DeleteKey(keyId string) error
- func (w *WalletService) FindKeyByPublicKey(publicKey []byte) (*Key, error)
- func (w *WalletService) GenerateNonce(length int) ([]byte, error)
- func (w *WalletService) GenerateRandomBytes(length int) ([]byte, error)
- func (w *WalletService) GetKey(keyId string) (*Key, error)
- func (w *WalletService) GetPublicKey(keyId string) ([]byte, error)
- func (w *WalletService) ListKeys() ([]*Key, error)
- func (w *WalletService) Sign(keyId string, data []byte) ([]byte, error)
- func (w *WalletService) Verify(keyId string, data []byte, signature []byte) (bool, error)
- func (w *WalletService) VerifyWithPublicKey(publicKey []byte, data []byte, signature []byte) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Key ¶
type Key struct {
Id string `json:"id"`
Type KeyType `json:"type"`
PublicKey []byte `json:"publicKey"`
PrivateKey []byte `json:"privateKey,omitempty"`
CreatedAt string `json:"createdAt"`
}
Key represents a cryptographic key
type KeyRecord ¶
type KeyRecord struct {
*storage.BaseRecord
Key *Key `json:"key"`
}
KeyRecord represents a stored key record
type KeyRepository ¶
type KeyRepository interface {
Save(ctx *context.AgentContext, record *KeyRecord) error
FindById(ctx *context.AgentContext, id string) (*KeyRecord, error)
FindByPublicKey(ctx *context.AgentContext, publicKey []byte) (*KeyRecord, error)
Delete(ctx *context.AgentContext, id string) error
GetAll(ctx *context.AgentContext) ([]*KeyRecord, error)
}
KeyRepository interface for key storage
type SimpleKeyRepository ¶
type SimpleKeyRepository struct {
// contains filtered or unexported fields
}
SimpleKeyRepository provides an in-memory key repository for development
func NewSimpleKeyRepository ¶
func NewSimpleKeyRepository() *SimpleKeyRepository
NewSimpleKeyRepository creates a new in-memory key repository
func (*SimpleKeyRepository) Delete ¶
func (r *SimpleKeyRepository) Delete(ctx *context.AgentContext, id string) error
func (*SimpleKeyRepository) FindById ¶
func (r *SimpleKeyRepository) FindById(ctx *context.AgentContext, id string) (*KeyRecord, error)
func (*SimpleKeyRepository) FindByPublicKey ¶
func (r *SimpleKeyRepository) FindByPublicKey(ctx *context.AgentContext, publicKey []byte) (*KeyRecord, error)
func (*SimpleKeyRepository) GetAll ¶
func (r *SimpleKeyRepository) GetAll(ctx *context.AgentContext) ([]*KeyRecord, error)
func (*SimpleKeyRepository) Save ¶
func (r *SimpleKeyRepository) Save(ctx *context.AgentContext, record *KeyRecord) error
type StorageKeyRepository ¶
type StorageKeyRepository struct {
// contains filtered or unexported fields
}
StorageKeyRepository stores KeyRecord via core/storage
func NewStorageKeyRepository ¶
func NewStorageKeyRepository(storage storage.StorageService) *StorageKeyRepository
func (*StorageKeyRepository) Delete ¶
func (r *StorageKeyRepository) Delete(ctx *agentcontext.AgentContext, id string) error
func (*StorageKeyRepository) FindById ¶
func (r *StorageKeyRepository) FindById(ctx *agentcontext.AgentContext, id string) (*KeyRecord, error)
func (*StorageKeyRepository) FindByPublicKey ¶
func (r *StorageKeyRepository) FindByPublicKey(ctx *agentcontext.AgentContext, publicKey []byte) (*KeyRecord, error)
func (*StorageKeyRepository) GetAll ¶
func (r *StorageKeyRepository) GetAll(ctx *agentcontext.AgentContext) ([]*KeyRecord, error)
func (*StorageKeyRepository) Save ¶
func (r *StorageKeyRepository) Save(ctx *agentcontext.AgentContext, record *KeyRecord) error
type WalletService ¶
type WalletService struct {
// contains filtered or unexported fields
}
WalletService handles key management and cryptographic operations
func NewWalletService ¶
func NewWalletService(ctx *context.AgentContext, repository KeyRepository) *WalletService
NewWalletService creates a new wallet service
func (*WalletService) CreateKey ¶
func (w *WalletService) CreateKey(keyType KeyType) (*Key, error)
CreateKey generates a new key of the specified type
func (*WalletService) DeleteKey ¶
func (w *WalletService) DeleteKey(keyId string) error
DeleteKey deletes a key by ID
func (*WalletService) FindKeyByPublicKey ¶
func (w *WalletService) FindKeyByPublicKey(publicKey []byte) (*Key, error)
FindKeyByPublicKey finds a key by its public key
func (*WalletService) GenerateNonce ¶
func (w *WalletService) GenerateNonce(length int) ([]byte, error)
GenerateNonce generates a random nonce
func (*WalletService) GenerateRandomBytes ¶
func (w *WalletService) GenerateRandomBytes(length int) ([]byte, error)
GenerateRandomBytes generates random bytes
func (*WalletService) GetKey ¶
func (w *WalletService) GetKey(keyId string) (*Key, error)
GetKey retrieves a key by ID
func (*WalletService) GetPublicKey ¶
func (w *WalletService) GetPublicKey(keyId string) ([]byte, error)
GetPublicKey retrieves just the public key portion
func (*WalletService) ListKeys ¶
func (w *WalletService) ListKeys() ([]*Key, error)
ListKeys returns all keys
func (*WalletService) Sign ¶
func (w *WalletService) Sign(keyId string, data []byte) ([]byte, error)
Sign signs data with the specified key
func (*WalletService) VerifyWithPublicKey ¶
func (w *WalletService) VerifyWithPublicKey(publicKey []byte, data []byte, signature []byte) bool
VerifyWithPublicKey verifies a signature with a public key directly