key

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package kchain provides the K-Chain (KMS) adapter for the DAG indexer. Handles distributed key management, threshold signatures, and post-quantum algorithms.

Index

Constants

View Source
const (
	// DefaultPort for K-Chain indexer API
	DefaultPort = 4900
	// DefaultDatabase name
	DefaultDatabase = "explorer_kchain"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

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

Adapter implements the DAG adapter interface for K-Chain

func New

func New(rpcEndpoint string) *Adapter

New creates a new K-Chain adapter

func (*Adapter) GetKeyByID

func (a *Adapter) GetKeyByID(ctx context.Context, id string) (*Key, error)

GetKeyByID fetches a specific key by ID

func (*Adapter) GetKeysByAlgorithm

func (a *Adapter) GetKeysByAlgorithm(ctx context.Context, store storage.Store, algorithm string, limit, offset int) ([]Key, error)

GetKeysByAlgorithm returns keys filtered by algorithm

func (*Adapter) GetPostQuantumKeys

func (a *Adapter) GetPostQuantumKeys(ctx context.Context, store storage.Store, limit, offset int) ([]Key, error)

GetPostQuantumKeys returns all post-quantum keys

func (*Adapter) GetRecentVertices

func (a *Adapter) GetRecentVertices(ctx context.Context, limit int) ([]json.RawMessage, error)

GetRecentVertices fetches recent vertices from K-Chain RPC

func (*Adapter) GetStats

func (a *Adapter) GetStats(ctx context.Context, store storage.Store) (map[string]interface{}, error)

GetStats returns K-Chain specific statistics using unified storage

func (*Adapter) GetThresholdKeys

func (a *Adapter) GetThresholdKeys(ctx context.Context, store storage.Store, limit, offset int) ([]Key, error)

GetThresholdKeys returns all threshold keys (threshold > 1)

func (*Adapter) GetVertexByID

func (a *Adapter) GetVertexByID(ctx context.Context, id string) (json.RawMessage, error)

GetVertexByID fetches a specific vertex by ID

func (*Adapter) InitSchema

func (a *Adapter) InitSchema(ctx context.Context, store storage.Store) error

InitSchema creates K-Chain specific database tables using unified storage

func (*Adapter) ListAlgorithms

func (a *Adapter) ListAlgorithms(ctx context.Context) ([]Algorithm, error)

ListAlgorithms fetches supported algorithms

func (*Adapter) ListKeys

func (a *Adapter) ListKeys(ctx context.Context, algorithm, status string, offset, limit int) ([]Key, error)

ListKeys fetches all keys from K-Chain

func (*Adapter) ParseVertex

func (a *Adapter) ParseVertex(data json.RawMessage) (*dag.Vertex, error)

ParseVertex parses K-Chain vertex data

func (*Adapter) StoreEncryptionRequest

func (a *Adapter) StoreEncryptionRequest(ctx context.Context, store storage.Store, req EncryptionRequest) error

StoreEncryptionRequest stores an encryption request

func (*Adapter) StoreKey

func (a *Adapter) StoreKey(ctx context.Context, store storage.Store, k Key) error

StoreKey stores a key

func (*Adapter) StoreKeyOperation

func (a *Adapter) StoreKeyOperation(ctx context.Context, store storage.Store, op KeyOperation) error

StoreKeyOperation stores a key operation

func (*Adapter) StoreSignatureRequest

func (a *Adapter) StoreSignatureRequest(ctx context.Context, store storage.Store, req SignatureRequest) error

StoreSignatureRequest stores a signature request

func (*Adapter) StoreVertex

func (a *Adapter) StoreVertex(ctx context.Context, store storage.Store, v *dag.Vertex) error

StoreVertex stores vertex data

func (*Adapter) UpdateExtendedStats

func (a *Adapter) UpdateExtendedStats(ctx context.Context, store storage.Store) error

UpdateExtendedStats updates K-Chain specific statistics

type Algorithm

type Algorithm struct {
	Name             string   `json:"name"`
	Type             string   `json:"type"`
	SecurityLevel    int      `json:"securityLevel"`
	KeySize          int      `json:"keySize"`
	SignatureSize    int      `json:"signatureSize"`
	PostQuantum      bool     `json:"postQuantum"`
	ThresholdSupport bool     `json:"thresholdSupport"`
	Description      string   `json:"description"`
	Standards        []string `json:"standards"`
}

Algorithm represents a supported cryptographic algorithm

type AlgorithmType

type AlgorithmType string

AlgorithmType represents cryptographic algorithm categories

const (
	AlgorithmTypeKeyExchange AlgorithmType = "key-exchange"
	AlgorithmTypeSigning     AlgorithmType = "signing"
	AlgorithmTypeEncryption  AlgorithmType = "encryption"
)

type EncryptionRequest

type EncryptionRequest struct {
	ID        string    `json:"id"`
	KeyID     string    `json:"keyId"`
	Requester string    `json:"requester"`
	DataSize  int64     `json:"dataSize"`
	Success   bool      `json:"success"`
	Timestamp time.Time `json:"timestamp"`
}

EncryptionRequest represents an encryption operation

type Key

type Key struct {
	ID          string    `json:"id"`
	Name        string    `json:"name"`
	Algorithm   string    `json:"algorithm"`
	KeyType     string    `json:"keyType"`
	PublicKey   string    `json:"publicKey"`
	Threshold   int       `json:"threshold"`
	TotalShares int       `json:"totalShares"`
	CreatedAt   time.Time `json:"createdAt"`
	UpdatedAt   time.Time `json:"updatedAt"`
	Status      KeyStatus `json:"status"`
	Tags        []string  `json:"tags"`
}

Key represents a distributed cryptographic key

type KeyOperation

type KeyOperation struct {
	ID           string    `json:"id"`
	KeyID        string    `json:"keyId"`
	Operation    string    `json:"operation"` // create, rotate, revoke, delete
	Initiator    string    `json:"initiator"`
	Participants []string  `json:"participants"`
	Success      bool      `json:"success"`
	Error        string    `json:"error,omitempty"`
	Timestamp    time.Time `json:"timestamp"`
}

KeyOperation represents a key lifecycle operation

type KeyStatus

type KeyStatus string

KeyStatus represents key lifecycle state

const (
	KeyStatusActive   KeyStatus = "active"
	KeyStatusInactive KeyStatus = "inactive"
	KeyStatusRotating KeyStatus = "rotating"
	KeyStatusRevoked  KeyStatus = "revoked"
	KeyStatusPending  KeyStatus = "pending"
)

type SignatureRequest

type SignatureRequest struct {
	ID          string    `json:"id"`
	KeyID       string    `json:"keyId"`
	Signers     []string  `json:"signers"`
	MessageHash string    `json:"messageHash"`
	Algorithm   string    `json:"algorithm"`
	Success     bool      `json:"success"`
	Timestamp   time.Time `json:"timestamp"`
}

SignatureRequest represents a signing operation

Jump to

Keyboard shortcuts

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