vm

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 16, 2026 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Session states
	SessionPending = "pending"
	SessionActive  = "active"
	SessionExpired = "expired"
	SessionClosed  = "closed"
)
View Source
const Name = "sessionvm"

Name is the human-readable name for this VM

Variables

View Source
var VMID = ids.ID{'s', 'e', 's', 's', 'i', 'o', 'n', 'v', 'm'}

VMID is the unique identifier for SessionVM Base58: 2ZbQaVuXHtT7vfJt8FmWEQKAT4NgtPqWEZHg5m3tUvEiSMnQNt

Functions

This section is empty.

Types

type Channel

type Channel struct {
	ID           ids.ID    `json:"id"`
	Name         string    `json:"name"`
	Owner        ids.ID    `json:"owner"`
	Members      []ids.ID  `json:"members"`
	Created      time.Time `json:"created"`
	MessageCount uint64    `json:"messageCount"`
}

Channel represents a multi-party communication channel

type CloseSessionArgs

type CloseSessionArgs struct {
	SessionID string `json:"sessionId"`
}

CloseSessionArgs are the arguments for CloseSession

type CloseSessionReply

type CloseSessionReply struct {
	Success bool `json:"success"`
}

CloseSessionReply is the reply for CloseSession

type Config

type Config struct {
	SessionTTL    int64  `json:"sessionTTL"` // Seconds
	MaxMessages   int    `json:"maxMessages"`
	MaxChannels   int    `json:"maxChannels"`
	RetentionDays int    `json:"retentionDays"`
	IDPrefix      string `json:"idPrefix"` // Post-quantum session ID prefix
}

Config holds SessionVM configuration

type CreateSessionArgs

type CreateSessionArgs struct {
	Participants []string `json:"participants"`
	PublicKeys   []string `json:"publicKeys"` // Hex-encoded ML-KEM public keys
}

CreateSessionArgs are the arguments for CreateSession

type CreateSessionReply

type CreateSessionReply struct {
	SessionID string `json:"sessionId"`
	Expires   int64  `json:"expires"`
}

CreateSessionReply is the reply for CreateSession

type Factory

type Factory struct{}

Factory creates new SessionVM instances

func (*Factory) New

func (f *Factory) New(logger log.Logger) (*VM, error)

New returns a new instance of the SessionVM

type GetSessionArgs

type GetSessionArgs struct {
	SessionID string `json:"sessionId"`
}

GetSessionArgs are the arguments for GetSession

type GetSessionReply

type GetSessionReply struct {
	Session *Session `json:"session"`
}

GetSessionReply is the reply for GetSession

type HealthArgs

type HealthArgs struct{}

HealthArgs are the arguments for Health

type HealthReply

type HealthReply struct {
	Healthy  bool `json:"healthy"`
	Sessions int  `json:"sessions"`
	Channels int  `json:"channels"`
	Pending  int  `json:"pending"`
}

HealthReply is the reply for Health

type Message

type Message struct {
	ID         ids.ID    `json:"id"`
	SessionID  ids.ID    `json:"sessionId"`
	Sender     ids.ID    `json:"sender"`
	Ciphertext []byte    `json:"ciphertext"` // Encrypted with session key
	Signature  []byte    `json:"signature"`  // ML-DSA signature
	Timestamp  time.Time `json:"timestamp"`
	Sequence   uint64    `json:"sequence"`
}

Message represents an encrypted message within a session

type SendMessageArgs

type SendMessageArgs struct {
	SessionID  string `json:"sessionId"`
	Sender     string `json:"sender"`
	Ciphertext string `json:"ciphertext"` // Hex-encoded encrypted message
	Signature  string `json:"signature"`  // Hex-encoded ML-DSA signature
}

SendMessageArgs are the arguments for SendMessage

type SendMessageReply

type SendMessageReply struct {
	MessageID string `json:"messageId"`
	Sequence  uint64 `json:"sequence"`
}

SendMessageReply is the reply for SendMessage

type Service

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

Service provides RPC methods for the SessionVM

func (*Service) CloseSession

func (s *Service) CloseSession(r *http.Request, args *CloseSessionArgs, reply *CloseSessionReply) error

CloseSession closes a session

func (*Service) CreateSession

func (s *Service) CreateSession(r *http.Request, args *CreateSessionArgs, reply *CreateSessionReply) error

CreateSession creates a new encrypted session

func (*Service) GetSession

func (s *Service) GetSession(r *http.Request, args *GetSessionArgs, reply *GetSessionReply) error

GetSession returns session details

func (*Service) Health

func (s *Service) Health(r *http.Request, args *HealthArgs, reply *HealthReply) error

Health returns the health status

func (*Service) SendMessage

func (s *Service) SendMessage(r *http.Request, args *SendMessageArgs, reply *SendMessageReply) error

SendMessage sends an encrypted message within a session

type Session

type Session struct {
	ID           ids.ID            `json:"id"`
	Participants []ids.ID          `json:"participants"`
	PublicKeys   [][]byte          `json:"publicKeys"` // PQ public keys (ML-KEM)
	ChannelID    ids.ID            `json:"channelId"`
	Created      time.Time         `json:"created"`
	Expires      time.Time         `json:"expires"`
	Status       string            `json:"status"`
	Metadata     map[string]string `json:"metadata"`
}

Session represents an encrypted communication session

type VM

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

VM implements the SessionVM

func (*VM) CloseSession

func (vm *VM) CloseSession(sessionID ids.ID) error

CloseSession closes a session

func (*VM) CreateHandlers

func (vm *VM) CreateHandlers(ctx context.Context) (map[string]http.Handler, error)

CreateHandlers returns the HTTP handlers for this VM

func (*VM) CreateSession

func (vm *VM) CreateSession(participants []ids.ID, publicKeys [][]byte) (*Session, error)

CreateSession creates a new encrypted session

func (*VM) GetSession

func (vm *VM) GetSession(sessionID ids.ID) (*Session, error)

GetSession returns a session by ID

func (*VM) HealthCheck

func (vm *VM) HealthCheck(ctx context.Context) (interface{}, error)

HealthCheck returns the health status of the VM

func (*VM) Initialize

func (vm *VM) Initialize(logger log.Logger, configBytes []byte) error

Initialize initializes the VM

func (*VM) SendMessage

func (vm *VM) SendMessage(sessionID ids.ID, sender ids.ID, ciphertext, signature []byte) (*Message, error)

SendMessage sends an encrypted message within a session

func (*VM) Shutdown

func (vm *VM) Shutdown(ctx context.Context) error

Shutdown shuts down the VM

Jump to

Keyboard shortcuts

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