A cryptographically secure file storage and sharing system built in Go, featuring military-grade encryption, digital signatures, and zero-trust architecture.
Built with cryptographic best practices and zero-trust principles
All files encrypted with AES-256 before storage. Keys never leave your device.
Share files with cryptographically signed invitations and fine-grained access control.
HMAC authentication ensures tamper detection for all stored data.
Instantly revoke access with automatic re-encryption of all file content.
Files stored as encrypted linked lists for O(1) append operations.
Argon2 key derivation and PKI-based user authentication.
A layered security architecture with cryptographic primitives at every level
Handles user registration, authentication, and key management with RSA and DSA key pairs.
Encrypted linked-list structure for efficient file storage and retrieval with per-node encryption.
Cryptographically secure invitation system with digital signatures and access control.
HMAC integrity protection and encrypt-then-MAC pattern throughout the entire system.
Complete API documentation for all operations
func InitUser(username string, password string) (*User, error)
Creates a new user account with secure key generation and encrypted storage.
// Create a new user
user, err := InitUser("alice", "securePassword123")
if err != nil {
log.Fatal("Failed to create user:", err)
}
fmt.Println("User created:", user.Username)
func GetUser(username string, password string) (*User, error)
Authenticates and retrieves an existing user from encrypted storage.
// Authenticate existing user
user, err := GetUser("alice", "securePassword123")
if err != nil {
log.Fatal("Authentication failed:", err)
}
fmt.Println("Logged in as:", user.Username)
func (userdata *User) StoreFile(filename string, content []byte) error
Stores a new file or overwrites existing file with encrypted content.
// Store encrypted file
content := []byte("Secret document content")
err := user.StoreFile("document.txt", content)
if err != nil {
log.Fatal("Failed to store file:", err)
}
fmt.Println("File stored securely")
func (userdata *User) LoadFile(filename string) ([]byte, error)
Retrieves and decrypts file content with automatic integrity verification.
// Load and decrypt file
content, err := user.LoadFile("document.txt")
if err != nil {
log.Fatal("Failed to load file:", err)
}
fmt.Println("File content:", string(content))
func (userdata *User) AppendToFile(filename string, content []byte) error
Efficiently appends content to existing file in O(1) time complexity.
// Efficiently append to file
newContent := []byte("\nAdditional content")
err := user.AppendToFile("document.txt", newContent)
if err != nil {
log.Fatal("Failed to append:", err)
}
fmt.Println("Content appended successfully")
func (userdata *User) CreateInvitation(filename string, recipientUsername string) (uuid.UUID, error)
Creates cryptographically secure invitation to share file access.
// Share file with another user
inviteUUID, err := alice.CreateInvitation("document.txt", "bob")
if err != nil {
log.Fatal("Failed to create invitation:", err)
}
fmt.Println("Invitation created:", inviteUUID)
func (userdata *User) AcceptInvitation(senderUsername string, invitationPtr uuid.UUID, filename string) error
Accepts invitation and adds shared file to user's namespace with verification.
// Accept shared file invitation
err := bob.AcceptInvitation("alice", inviteUUID, "shared-doc.txt")
if err != nil {
log.Fatal("Failed to accept invitation:", err)
}
fmt.Println("File access granted")
func (userdata *User) RevokeAccess(filename string, recipientUsername string) error
Revokes user access with complete re-encryption (owner only).
// Revoke user's access to file
err := alice.RevokeAccess("document.txt", "bob")
if err != nil {
log.Fatal("Failed to revoke access:", err)
}
fmt.Println("Access revoked successfully")
Defense-in-depth with multiple layers of cryptographic protection
Cannot read, modify, or meaningfully corrupt stored data
Cannot access files without proper authorization
Cannot intercept or modify invitations in transit
Multiple security layers: encryption + HMAC + signatures
All data verified before use, no implicit trust
Users access only explicitly shared files
Unique keys for each operation and file
Revocation renders old keys permanently useless
All errors reject access, no unsafe fallbacks
Quick setup and installation guide
git clone https://github.com/mananb77/file-sharing-system.git
cd file-sharing-system
go mod download
cd client_test
go test -v
import "github.com/mananb77/file-sharing-system/client"
// Create user
user, _ := client.InitUser("alice", "password123")
// Store file
user.StoreFile("secret.txt", []byte("confidential data"))
// Load file
content, _ := user.LoadFile("secret.txt")