Documentation
¶
Index ¶
- func Decrypt(key, ciphertext []byte) ([]byte, error)
- func DeriveKey(passphrase string, salt []byte) []byte
- func Encrypt(key, plaintext []byte) ([]byte, error)
- func GenerateSalt() ([]byte, error)
- type Conflict
- type DiffOp
- type EncryptedEngine
- func (ee *EncryptedEngine) DecryptFile(ciphertext []byte) ([]byte, error)
- func (ee *EncryptedEngine) DecryptThreadEntries(entries []*store.ThreadEntry) ([]*store.ThreadEntry, error)
- func (ee *EncryptedEngine) EncryptFile(plaintext []byte) ([]byte, error)
- func (ee *EncryptedEngine) EncryptThreadEntries(entries []*store.ThreadEntry) ([]*store.ThreadEntry, error)
- type Engine
- func (e *Engine) ApplyDiffs(diffs []FileDiff, getContent func(path string) ([]byte, error)) error
- func (e *Engine) BuildLocalManifest() (*Manifest, error)
- func (e *Engine) ExportThreadEntries(since time.Time) ([]*store.ThreadEntry, error)
- func (e *Engine) ImportThreadEntries(entries []*store.ThreadEntry) error
- func (e *Engine) MergeThreadEntries(remote []*store.ThreadEntry) (int, error)
- type FileDiff
- type FileEntry
- type KeyFile
- type KeyStore
- type Manifest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type EncryptedEngine ¶
type EncryptedEngine struct {
Engine *Engine
Key []byte // 32-byte symmetric key (unlocked from KeyStore)
}
EncryptedEngine wraps Engine with E2E encryption.
func (*EncryptedEngine) DecryptFile ¶
func (ee *EncryptedEngine) DecryptFile(ciphertext []byte) ([]byte, error)
DecryptFile decrypts data encrypted by EncryptFile.
func (*EncryptedEngine) DecryptThreadEntries ¶
func (ee *EncryptedEngine) DecryptThreadEntries(entries []*store.ThreadEntry) ([]*store.ThreadEntry, error)
DecryptThreadEntries decrypts entries encrypted by EncryptThreadEntries. Returns new copies; the originals are not modified.
func (*EncryptedEngine) EncryptFile ¶
func (ee *EncryptedEngine) EncryptFile(plaintext []byte) ([]byte, error)
EncryptFile encrypts plaintext file content.
func (*EncryptedEngine) EncryptThreadEntries ¶
func (ee *EncryptedEngine) EncryptThreadEntries(entries []*store.ThreadEntry) ([]*store.ThreadEntry, error)
EncryptThreadEntries encrypts the Summary and UserInput fields of thread entries. Returns new copies; the originals are not modified.
type Engine ¶
func (*Engine) ApplyDiffs ¶
func (*Engine) BuildLocalManifest ¶
func (*Engine) ExportThreadEntries ¶
func (*Engine) ImportThreadEntries ¶
func (e *Engine) ImportThreadEntries(entries []*store.ThreadEntry) error
func (*Engine) MergeThreadEntries ¶
func (e *Engine) MergeThreadEntries(remote []*store.ThreadEntry) (int, error)
MergeThreadEntries merges remote thread entries into the local store. Deduplicates by (task_id, wing_id, timestamp) triple. Entries without task_id use (wing_id, timestamp, summary) for dedup. Returns count of entries imported.
type FileDiff ¶
func DiffManifests ¶
DiffManifests compares two manifests by SHA256 hash. Files in remote but not local = add. Files with different hash = update. Files in local but not remote are left alone (additive only, no deletes).
type KeyFile ¶
type KeyFile struct {
Salt []byte `yaml:"salt"`
EncryptedKey []byte `yaml:"encrypted_key"`
KeyHash string `yaml:"key_hash"`
CreatedAt int64 `yaml:"created_at"`
}
KeyFile is the on-disk format for the encryption key material.
type KeyStore ¶
type KeyStore struct {
Dir string // ~/.wingthing/
}
KeyStore manages encryption keys for sync.
func NewKeyStore ¶
func (*KeyStore) Init ¶
Init generates a new random symmetric key, encrypts it with the passphrase, and saves.
func (*KeyStore) IsInitialized ¶
IsInitialized checks if a keyfile exists.
type Manifest ¶
type Manifest struct {
WingID string `json:"wing_id"`
Files []FileEntry `json:"files"`
CreatedAt int64 `json:"created_at"`
}