Skip to content

Commit 14d5596

Browse files
committed
updated some docs
1 parent 348126c commit 14d5596

File tree

4 files changed

+111
-4
lines changed

4 files changed

+111
-4
lines changed

crates/fula-flutter/src/api/client.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ pub fn create_encrypted_client(
6969
ObfuscationMode::Random => {
7070
enc_config.with_obfuscation_mode(fula_client::KeyObfuscation::RandomUuid)
7171
}
72+
ObfuscationMode::FlatNamespace => {
73+
enc_config.with_obfuscation_mode(fula_client::KeyObfuscation::FlatNamespace)
74+
}
75+
ObfuscationMode::PreserveStructure => {
76+
enc_config.with_obfuscation_mode(fula_client::KeyObfuscation::PreserveStructure)
77+
}
7278
};
7379

7480
let client = fula_client::EncryptedClient::new(inner_config, enc_config)?;
@@ -110,6 +116,20 @@ pub fn create_encrypted_client_with_pinning(
110116
};
111117

112118
let enc_config = enc_config.with_metadata_privacy(encryption.enable_metadata_privacy);
119+
let enc_config = match encryption.obfuscation_mode {
120+
ObfuscationMode::Deterministic => {
121+
enc_config.with_obfuscation_mode(fula_client::KeyObfuscation::DeterministicHash)
122+
}
123+
ObfuscationMode::Random => {
124+
enc_config.with_obfuscation_mode(fula_client::KeyObfuscation::RandomUuid)
125+
}
126+
ObfuscationMode::FlatNamespace => {
127+
enc_config.with_obfuscation_mode(fula_client::KeyObfuscation::FlatNamespace)
128+
}
129+
ObfuscationMode::PreserveStructure => {
130+
enc_config.with_obfuscation_mode(fula_client::KeyObfuscation::PreserveStructure)
131+
}
132+
};
113133

114134
let pinning_creds = fula_client::PinningCredentials::new(
115135
pinning.endpoint,

crates/fula-flutter/src/api/types.rs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,35 @@ impl Default for EncryptionConfig {
5656
}
5757

5858
/// Obfuscation mode for file name privacy
59+
///
60+
/// Controls how file paths are obfuscated before sending to the server.
61+
/// This affects what the server can learn about your file structure.
5962
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
6063
pub enum ObfuscationMode {
61-
/// Same input always produces same output (allows deduplication)
64+
/// Hash the key with a secret prefix (deterministic - same key = same hash)
65+
/// Allows server-side deduplication but reveals if same file uploaded twice.
66+
/// Server sees: `e/a7c3f9b2e8d14a6f` (reveals "e/" prefix)
6267
#[default]
6368
Deterministic,
64-
/// Random obfuscation (maximum privacy)
69+
/// Random UUID for each upload (non-deterministic)
70+
/// Maximum privacy but no dedup.
71+
/// Server sees: `e/random-uuid-here`
6572
Random,
73+
/// Flat namespace - complete structure hiding (RECOMMENDED)
74+
///
75+
/// Inspired by WNFS and Peergos:
76+
/// - All keys look like random CID-style hashes
77+
/// - No prefixes or structure hints
78+
/// - File tree stored in encrypted index (PrivateForest)
79+
/// - Server cannot determine folder structure, parent/child relationships
80+
///
81+
/// Server sees: `QmX7a8f3e2d1c9b4a5e6f7d8c9a0b1e2f3a4b5c6d7e8f9`
82+
FlatNamespace,
83+
/// Preserve path structure but hash filenames
84+
/// e.g., "/photos/vacation/" + hash(filename)
85+
/// Allows folder-like organization while hiding filenames.
86+
/// Server sees: `/photos/vacation/e_a7c3f9b2`
87+
PreserveStructure,
6688
}
6789

6890
/// Configuration for IPFS pinning service

docs/website/sdk.html

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -883,10 +883,11 @@ <h3>Key Features</h3>
883883
maxRetries: 3,
884884
);
885885

886+
// FlatNamespace is RECOMMENDED for maximum privacy
886887
final encConfig = EncryptionConfig(
887888
secretKey: null, // Generate new key
888889
enableMetadataPrivacy: true,
889-
obfuscationMode: ObfuscationMode.deterministic,
890+
obfuscationMode: ObfuscationMode.flatNamespace,
890891
);
891892

892893
final client = await createEncryptedClient(config, encConfig);
@@ -985,6 +986,36 @@ <h3>Key Features</h3>
985986
storageKey,
986987
acceptedShare,
987988
);</code></pre>
989+
990+
<div class="example-header">
991+
<span class="lang-label">Obfuscation Modes</span>
992+
<button class="copy-btn" onclick="copyCode(this)">Copy</button>
993+
</div>
994+
<pre><code class="language-dart">// Available obfuscation modes for metadata privacy:
995+
996+
// FlatNamespace (RECOMMENDED) - complete structure hiding
997+
// Server sees: QmX7a8f3e2d1c9b4... (CID-like hash)
998+
final encConfig = EncryptionConfig(
999+
obfuscationMode: ObfuscationMode.flatNamespace,
1000+
);
1001+
1002+
// Deterministic - same path = same hash (allows server deduplication)
1003+
// Server sees: e/a7c3f9b2e8d14a6f
1004+
final encConfig = EncryptionConfig(
1005+
obfuscationMode: ObfuscationMode.deterministic,
1006+
);
1007+
1008+
// Random - new UUID for each upload (max privacy, no dedup)
1009+
// Server sees: e/random-uuid-here
1010+
final encConfig = EncryptionConfig(
1011+
obfuscationMode: ObfuscationMode.random,
1012+
);
1013+
1014+
// PreserveStructure - keep folder paths, hash filenames only
1015+
// Server sees: /photos/vacation/e_a7c3f9b2
1016+
final encConfig = EncryptionConfig(
1017+
obfuscationMode: ObfuscationMode.preserveStructure,
1018+
);</code></pre>
9881019
</div>
9891020
</div>
9901021
</section>

packages/fula_client/README.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@ Future<void> main() async {
3737
accessToken: 'your-jwt-token',
3838
);
3939
40+
// FlatNamespace is RECOMMENDED for maximum privacy
4041
final encConfig = EncryptionConfig(
4142
enableMetadataPrivacy: true,
42-
obfuscationMode: ObfuscationMode.deterministic,
43+
obfuscationMode: ObfuscationMode.flatNamespace,
4344
);
4445
4546
final client = await createEncryptedClient(config, encConfig);
@@ -134,6 +135,39 @@ application/wasm
134135
- `createRotationManager(client)` - Create key rotation manager
135136
- `rotateBucket(client, bucket, manager)` - Rotate all keys in bucket
136137

138+
## Obfuscation Modes
139+
140+
The SDK supports 4 obfuscation modes for metadata privacy:
141+
142+
| Mode | Server Sees | Privacy Level | Use Case |
143+
|------|-------------|---------------|----------|
144+
| `flatNamespace` | `QmX7a8f3e2d1c9b4...` | **Highest** | Default, recommended |
145+
| `deterministic` | `e/a7c3f9b2e8d14a6f` | Medium | Server deduplication |
146+
| `random` | `e/random-uuid-here` | High | Max privacy, no dedup |
147+
| `preserveStructure` | `/photos/vacation/e_a7c3` | Low | Folder organization |
148+
149+
```dart
150+
// FlatNamespace (RECOMMENDED) - complete structure hiding
151+
final encConfig = EncryptionConfig(
152+
obfuscationMode: ObfuscationMode.flatNamespace,
153+
);
154+
155+
// Deterministic - same file = same hash (allows deduplication)
156+
final encConfig = EncryptionConfig(
157+
obfuscationMode: ObfuscationMode.deterministic,
158+
);
159+
160+
// Random - new UUID for each upload (maximum privacy)
161+
final encConfig = EncryptionConfig(
162+
obfuscationMode: ObfuscationMode.random,
163+
);
164+
165+
// PreserveStructure - keep folder paths, hash filenames
166+
final encConfig = EncryptionConfig(
167+
obfuscationMode: ObfuscationMode.preserveStructure,
168+
);
169+
```
170+
137171
## Documentation
138172

139173
- [Full API Documentation](https://functionland.github.io/fula-api/)

0 commit comments

Comments
 (0)