wallet

package
v0.0.0-...-b078ce1 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

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

func NewKeyRecord

func NewKeyRecord(key *Key) *KeyRecord

NewKeyRecord creates a new key record

func (*KeyRecord) Clone

func (r *KeyRecord) Clone() storage.Record

Implement Clone to satisfy storage.Record and preserve key data

func (*KeyRecord) FromJSON

func (r *KeyRecord) FromJSON(data []byte) error

func (*KeyRecord) ToJSON

func (r *KeyRecord) ToJSON() ([]byte, error)

Implement storage.Record JSON methods for full serialization

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 KeyType

type KeyType string

KeyType represents supported key types

const (
	KeyTypeEd25519 KeyType = "Ed25519"
	KeyTypeX25519  KeyType = "X25519"
)

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 (*StorageKeyRepository) FindById

func (*StorageKeyRepository) FindByPublicKey

func (r *StorageKeyRepository) FindByPublicKey(ctx *agentcontext.AgentContext, publicKey []byte) (*KeyRecord, error)

func (*StorageKeyRepository) GetAll

func (*StorageKeyRepository) Save

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) Verify

func (w *WalletService) Verify(keyId string, data []byte, signature []byte) (bool, error)

Verify verifies a signature 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

Jump to

Keyboard shortcuts

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