Skip to content

Commit

Permalink
Redis and Flatbuffers Integration for Event Handling (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
arkavo-com authored Oct 3, 2024
1 parent f9edbe3 commit b2cd419
Show file tree
Hide file tree
Showing 6 changed files with 1,422 additions and 36 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ Cargo.lock
/etc/contracts/ev/
/etc/contracts/simple_abac/.idea/
/apple-app-site-association.json
/dump.rdb
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[package]
name = "arkavo-rs"
version = "0.7.0"
version = "0.9.0"
edition = "2021"
rust-version = "1.80.0"

[lib]
name = "nanotdf"
Expand Down Expand Up @@ -42,6 +43,8 @@ ink = "5.0.0"
jsonwebtoken = "9.3.0"
async-nats = "0.36.0"
serde_json = "1.0.128"
redis = { version = "0.27.2", features = ["tokio-comp"] }
flatbuffers = "24.3.25"

[dev-dependencies]
criterion = "0.5.1"
Expand Down
26 changes: 23 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,16 @@ Implementation of KAS from [OpenTDF specification](https://github.com/opentdf/sp
- Rust (latest stable version)
- `cargo` package manager
- NATS
- Redis

```bash
brew install nats-server
brew install nats-server redis flatbuffers
```

### Compile Flatbuffers (optional)

```shell
flatc --binary --rust idl/event.fbs
```

### Installation
Expand All @@ -35,14 +42,21 @@ brew install nats-server
cargo build
```

Release build

```shell
export RUSTFLAGS="-C target-cpu=native"
cargo build --release
```

### Running the Server

1. Ensure you have a valid EC private key in PEM format named `recipient_private_key.pem`.

```shell
openssl ecparam -genkey -name prime256v1 -noout -out recipient_private_key.pem
```

Validate
```shell
openssl ec -in recipient_private_key.pem -text -noout
Expand Down Expand Up @@ -75,6 +89,7 @@ The server can be configured using environment variables. If not set, default va
| TLS_CERT_PATH | Path to the TLS certificate file | ./fullchain.pem |
| TLS_KEY_PATH | Path to the TLS private key file | ./privkey.pem |
| KAS_KEY_PATH | Path to the KAS private key file | ./recipient_private_key.pem |
| REDIS_URL | URL for Redis connection | redis://localhost:6379 |

All file paths are relative to the current working directory where the server is run.

Expand All @@ -84,6 +99,7 @@ export TLS_CERT_PATH=/path/to/fullchain.pem
export TLS_KEY_PATH=/path/to/privkey.pem
export KAS_KEY_PATH=/path/to/recipient_private_key.pem
export NATS_URL=nats://localhost:4222
export REDIS_URL=redis://localhost:6379
export ENABLE_TIMING_LOGS=true
export RUST_LOG=info
```
Expand All @@ -101,6 +117,10 @@ environment variables or secure vaults for managing sensitive information in pro
nats-server
```

```shell
redis-server
```

#### Start backend

```shell
Expand Down Expand Up @@ -130,4 +150,4 @@ sequenceDiagram
Server ->> Server: Compute shared_secret = ECDH(server_private_key, client_public_key)
Client ->> Client: Compute shared_secret = ECDH(client_private_key, server_public_key)
Note over Client, Server: Both have the same shared_secret
```
```
Loading

0 comments on commit b2cd419

Please sign in to comment.