diff --git a/src/SUMMARY.md b/src/SUMMARY.md index b846a45..82d096d 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -5,7 +5,7 @@ # Developer Guide - [Development](development/README.md) - [Understanding the Design Goals](development/design/README.md) - - [Actor System]() + - [Actor System](development/design/actor.md) - [Security Features](development/design/security.md) - [Microkernel](development/design/kernel.md) - [GUI](development/design/gui.md) diff --git a/src/development/design/actor.md b/src/development/design/actor.md index acc5c4c..ac9a063 100644 --- a/src/development/design/actor.md +++ b/src/development/design/actor.md @@ -1,4 +1,81 @@ # Actor System +```admonish question title="Why?" +**Actors** work as an abstraction over data storage and messaging. +It allows for all systems *(GUI, Programs, etc.)* to work together, and rely on the same features. +It reduces work of implementation, and all implementations can use the functions. +``` + +## Features +- Petnames +- **OCAP** security +- **HMAC** message verification + +```rust +// Different possible types of actors (more to be added) +enum ActorType { + GUI(Widget), + ProgramInterface, +} + +// Possible states an actor can be in +enum ActorState { + Receive, + Send, + Work, + Idle, +} + +// Cryptographic keypair +struct KeyPair { + privkey: u128, + pubkey: u128, +} + +// The actor itself +struct Actor { + petname: Option, // Human-meaningful petname (explored further down) + uuid: Uuid, // Unique identifier + namespace: Uuid, // Parent namespace of this actor + actor_type: ActorType, + state: ActorState, + keys: Option, // Cryptographic keypair + creation_date: DateTime, + modified_date: DateTime, + data: Option, // Optional data of the generic D type +} + +impl Actor { + fn new(namespace: Uuid, a_type: ActorType) -> Self { + Actor { + petname: None, + uuid: Uuid::new(), + namespace: namespace, + actor_type: a_type, + state: ActorState::Idle, + keys: None, + creation_date:: now(), + modified_date: now(), + data: None, + } + }; +} + +impl KeyPair { + fn generate_keypair(&mut self) -> Self; + fn get_pubkey(&self) -> u128; + fn sign(&self, &[u8]) -> Result<&[u8], Error>; + fn verify_signature(&[u8], u128) -> Result<(), Error>; +} + +trait FilesystemInterface { // Interfacing with the filesystem + fn read(&mut self) -> Result<(), Error>; // Read the data from the disk into the Actor using the Uuid as a search key + fn write(&self) -> Result<(), Error>; // Write the data to the disk using the Uuid as a key +} + +trait DataInterface { // Necessary data functions + fn to_bytes(&self) -> Result<&[u8], Error>; // Convert the data into a byte array +} +``` ## OCAP **TODO**