Python으로 인간을 위한 암호화 메모리 레이어를 만들었습니다
발행: (2026년 2월 8일 오전 07:43 GMT+9)
2 분 소요
원문: Dev.to
Source: Dev.to
Quick start
vault = MemoryVault(encryption_key="your-secret-key")
Capture Layer — Gets data in
지금은 수동 입력, 나중에 AI 에이전트.
Synthesis Layer — AI enrichment
요약, 패턴 탐지, 감정 분석. (v0.2에서 제공 예정)
Verification Layer — The cryptographic core
여기가 흥미로운 부분입니다.
Permanence Layer — Anchoring verified hashes
로컬 저장소, Arweave, Ethereum L2, 혹은 IPFS.
The crypto decisions I made (and why)
Key derivation: HKDF, not raw SHA‑256
첫 구현에서는 SHA‑256(master_key + purpose) 로 암호화 및 서명 키를 파생했습니다. 동작은 했지만, 진지한 암호 시스템에서는 이렇게 하지 않습니다. 그래서 HKDF(RFC 5869) 로 전환했으며, 이는 TLS 1.3 및 Signal Protocol에서 사용되는 업계 표준입니다.
from cryptography.hazmat.primitives.kdf.hkdf import HKDF
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
import os
def _derive_key(self, purpose: bytes) -> bytes:
# Example derivation using HKDF
hkdf = HKDF(
algorithm=hashes.SHA256(),
length=32,
salt=None,
info=purpose,
)
return hkdf.derive(self._master_key)
def encrypt(self, plaintext: str) -> tuple[bytes, bytes]:
nonce = os.urandom(12)
aesgcm = AESGCM(self._enc_key)
ciphertext = aesgcm.encrypt(nonce, plaintext.encode("utf-8"), None)
return ciphertext, nonce
Signing: HMAC‑SHA256
서명된 모든 데이터는 HMAC‑SHA256 로 무결성과 인증을 보장합니다.
import hmac
import hashlib
def sign(self, data: bytes) -> bytes:
return hmac.new(self._sign_key, data, hashlib.sha256).digest()
AI capture agents (v0.2)
향후 버전에서는 자동으로 항목을 캡처하고 주석을 다는 AI 에이전트를 포함할 예정입니다.
Try it
- GitHub:
- License: MIT
- Test suite: 28 tests passing
- 벤처 자본도, 토큰도 없습니다—그저 존재했으면 하는 도구일 뿐입니다.