Skip to content

Commit fb27bcf

Browse files
committed
set default metadata encryption to flat
1 parent 965194a commit fb27bcf

File tree

4 files changed

+33
-23
lines changed

4 files changed

+33
-23
lines changed

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,17 +136,19 @@ async fn main() -> anyhow::Result<()> {
136136
```rust
137137
use fula_client::{Config, EncryptedClient, EncryptionConfig};
138138

139+
// FlatNamespace mode is default - complete structure hiding!
140+
// Server sees only random CID-like hashes (QmX7a8f3e2d1...)
139141
let encryption = EncryptionConfig::new();
140142
let client = EncryptedClient::new(
141143
Config::new("http://localhost:9000"),
142144
encryption,
143145
)?;
144146

145-
// Data is encrypted before upload
146-
client.put_object_encrypted("bucket", "secret.txt", b"sensitive data").await?;
147+
// Data encrypted with FlatNamespace - server cannot see folder structure
148+
client.put_object_flat("bucket", "/photos/vacation/beach.jpg", data, None).await?;
147149

148-
// Data is decrypted after download
149-
let data = client.get_object_decrypted("bucket", "secret.txt").await?;
150+
// List files from encrypted PrivateForest index
151+
let files = client.list_files_from_forest("bucket").await?;
150152
```
151153

152154
### Large File Uploads
@@ -255,7 +257,8 @@ cargo run --example flat_namespace_demo
255257

256258
### Key Management
257259

258-
- Generate keys locally using `EncryptionConfig::new()`
260+
- Generate keys locally using `EncryptionConfig::new()` (uses FlatNamespace by default)
261+
- Complete structure hiding - server cannot see folder/file relationships
259262
- Export/backup secret keys securely
260263
- Lost keys = lost data (no recovery possible)
261264

crates/fula-client/src/encryption.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,18 @@ pub struct EncryptionConfig {
2929
}
3030

3131
impl EncryptionConfig {
32-
/// Create with a new random key (metadata privacy enabled by default)
32+
/// Create a new encryption config with random keys
33+
/// Metadata privacy is ENABLED by default with FlatNamespace mode (RECOMMENDED)
34+
///
35+
/// FlatNamespace provides complete structure hiding:
36+
/// - Storage keys look like random CID-style hashes
37+
/// - No prefixes or structure hints visible to server
38+
/// - Server cannot determine folder structure or parent/child relationships
3339
pub fn new() -> Self {
3440
Self {
3541
key_manager: Arc::new(KeyManager::new()),
3642
metadata_privacy: true,
37-
obfuscation_mode: KeyObfuscation::DeterministicHash,
43+
obfuscation_mode: KeyObfuscation::FlatNamespace,
3844
}
3945
}
4046

@@ -64,12 +70,12 @@ impl EncryptionConfig {
6470
}
6571
}
6672

67-
/// Create from an existing secret key
73+
/// Create from an existing secret key (uses FlatNamespace by default)
6874
pub fn from_secret_key(secret: fula_crypto::keys::SecretKey) -> Self {
6975
Self {
7076
key_manager: Arc::new(KeyManager::from_secret_key(secret)),
7177
metadata_privacy: true,
72-
obfuscation_mode: KeyObfuscation::DeterministicHash,
78+
obfuscation_mode: KeyObfuscation::FlatNamespace,
7379
}
7480
}
7581

docs/website/sdk.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,10 @@ <h3>What's Protected</h3>
245245

246246
<h3>Obfuscation Modes</h3>
247247
<ul>
248-
<li><strong>DeterministicHash</strong> - Same path → same key (default)</li>
248+
<li><strong>FlatNamespace (Default)</strong> - Complete structure hiding, maximum privacy</li>
249+
<li><strong>DeterministicHash</strong> - Same path → same key</li>
249250
<li><strong>RandomUuid</strong> - Random key per upload</li>
250251
<li><strong>PreserveStructure</strong> - Keep folders, hash filenames</li>
251-
<li><strong>FlatNamespace</strong> - Complete structure hiding (RECOMMENDED)</li>
252252
</ul>
253253
</div>
254254
<div class="example">
@@ -258,7 +258,7 @@ <h3>Obfuscation Modes</h3>
258258
</div>
259259
<pre><code class="language-rust">use fula_client::{EncryptedClient, EncryptionConfig, KeyObfuscation, Config};
260260

261-
// Metadata privacy is ENABLED by default
261+
// FlatNamespace (maximum privacy) is ENABLED by default
262262
let encryption = EncryptionConfig::new();
263263

264264
// Or customize the obfuscation mode

docs/website/security.html

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,13 +1125,13 @@ <h3>How It Works</h3>
11251125
<h3>Key Obfuscation Modes</h3>
11261126
<div class="modes-grid">
11271127
<div class="mode-card recommended">
1128-
<h4>🌟 FlatNamespace (RECOMMENDED)</h4>
1128+
<h4>🌟 FlatNamespace (DEFAULT)</h4>
11291129
<p>Complete structure hiding. Server sees only random CID-like hashes. Inspired by WNFS and Peergos.</p>
11301130
<code>/photos/beach.jpg → QmX7a8f3e2d1c9b4a5</code>
11311131
<small>No prefixes, no structure hints. Directory tree stored in encrypted PrivateForest index.</small>
11321132
</div>
11331133
<div class="mode-card">
1134-
<h4>DeterministicHash (Default)</h4>
1134+
<h4>DeterministicHash</h4>
11351135
<p>Same file path → Same storage key. Allows retrieval without local index.</p>
11361136
<code>/photos/beach.jpg → e/a7c3f9b2e8d14a6f</code>
11371137
</div>
@@ -1153,8 +1153,8 @@ <h3>Code Example</h3>
11531153
<div class="code-snippet">
11541154
<pre>use fula_client::{EncryptedClient, EncryptionConfig, KeyObfuscation};
11551155

1156-
// RECOMMENDED: FlatNamespace for complete structure hiding
1157-
let config = EncryptionConfig::new_flat_namespace();
1156+
// DEFAULT: FlatNamespace for complete structure hiding
1157+
let encryption = EncryptionConfig::new(); // FlatNamespace by default!
11581158
let client = EncryptedClient::new(config, encryption)?;
11591159

11601160
// Upload - server sees: QmX7a8f3e2d1c9b4a5e6f7d8...
@@ -1166,18 +1166,19 @@ <h3>Code Example</h3>
11661166
// Server sees NOTHING about your folder structure!
11671167

11681168
// ─────────────────────────────────────────────────────────
1169-
// Alternative modes:
1169+
// Alternative modes (for specific use cases):
11701170
// ─────────────────────────────────────────────────────────
11711171

1172-
// Default: deterministic hashing (reveals 'e/' prefix)
1173-
let config = EncryptionConfig::new();
1172+
// DeterministicHash - same path = same key, no local index needed
1173+
let encryption = EncryptionConfig::new()
1174+
.with_obfuscation_mode(KeyObfuscation::DeterministicHash);
11741175

1175-
// Customize obfuscation mode
1176-
let config = EncryptionConfig::new()
1176+
// PreserveStructure - keeps folder paths visible
1177+
let encryption = EncryptionConfig::new()
11771178
.with_obfuscation_mode(KeyObfuscation::PreserveStructure);
11781179

1179-
// Disable metadata privacy (not recommended)
1180-
let config = EncryptionConfig::new_without_privacy();
1180+
// Disable metadata privacy entirely (not recommended)
1181+
let encryption = EncryptionConfig::new_without_privacy();
11811182

11821183
// Get full metadata including original filename
11831184
let info = client.get_object_with_private_metadata(bucket, storage_key).await?;

0 commit comments

Comments
 (0)