Security (identity, login/keys, access control, encryption)
Purpose
The security component provides the cryptographic foundation of LibreSocial (formerly LifeSocial.KOM):
- Identity: a node's Pastry ID is the compressed 160-bit elliptic-curve public key derived from username + passphrase. There is no registration server and no trusted third party; possession of the private key is the account.
- Login/key derivation: keys are deterministically re-derived from credentials at every login, so the same username/password always yields the same node ID and the same identity.
- Access control: ACL-based, key-list style read control (per-object symmetric data key, wrapped per authorized user) plus group key management with versioned group keys, and two-level write protection (group signature + author signature with nonce) on distributed data structures.
- Encryption and signatures: hybrid cryptography everywhere — AES for bulk data, EC (ECIES/ECDSA) for key wrapping and signatures; signed storage items, signed messages, a signed join-response protocol.
The design intent, first published in 2009, was "practical security": low overhead, fine-grained ACLs on DHT-stored data, and decentralised registration/login, rather than formal or anonymity-grade security.
Current implementation (as of 2026)
Source root: Source/com.p2pframework/src/com/p2pframework/ unless noted.
Key abstraction — com.p2pframework.security
security/AsymmetricKey.java— interface:createKey(),createKey(String seed),createKeyFromCredentials(String user, String pass),encrypt/decrypt,sign/verify, plusencryptObject/decryptObject/signObject/verifyObjectforSerializablepayloads (Java serialization under the hood).security/SymmetricKey.java— interface for symmetric keys (createKey(),createKey(String seed), encrypt/decrypt of bytes and objects).security/KeyFactory.java— factory with hard-coded defaults:EC/160-bit asymmetric,AES/128-bit symmetric,SHA-1hash.newAsymmetricKey()only accepts EC at exactly 160 bits; other sizes throwKeyException. (Note: it compares algorithm names with==on strings — fragile but currently harmless because only the defaults are used.)security/KeyException.java— wrapper aroundP2PFrameworkException;security/RandomStringKey.java—SecureRandom+BigInteger(130, random).toString(32)for random key seeds.- Unit tests:
Source/com.p2pframework.unittests/src/com/p2pframework/security/AsymmetricKeyTest.java.
Elliptic-curve backend — com.p2pframework.security.ellipticcurves
ellipticcurves/ECAsymmetricKey.java(453 lines) — as of 2026 uses BouncyCastle (BouncyCastleProvider, registered as"BC"):Cipher.getInstance("ECIES", "BC")for encryption,Signature.getInstance("SHA1withECDSA", "BC")for signatures. Key generation:KeyPairGenerator.getInstance("EC", "BC")with the named curve BrainpoolP160r1 (ECNamedCurveTable.getParameterSpec("brainpoolp160r1")).- Deterministic derivation (
createKey(String keySeed)): a custom anonymousSecureRandomthat re-emits only the bytes of the seed (rotated per call) drives the generator; the seed is repeatedly re-hashed with the configured hash (SHA-1by default) until the generated point's compressed encoding starts with0x02, so the leading prefix byte can be dropped and the public point fits exactly in 160 bits.createKeyFromCredentials(user, pass)=createKey(user + password). - Header comment documents the 2026 migration "Modified by Lukas Mueller 2026 … replaced obsolete FlexiProvider with BouncyCastleProvider"; comments record that an earlier rewrite used
SecureRandom.getInstanceStrong(), which produced a fresh random key per login and silently broke login and data access; a later rewrite also stored raw BC public keys, causing aClassCastExceptioninPastryNetwork.createNodeAndBoot. ellipticcurves/ECPublicKey.java— still FlexiProvider-based: extendsde.flexiprovider.ec.keys.ECPublicKeywithBrainpoolP160r1parameters. Stores the compressed point minus the0x02/0x03prefix (byte[20]), re-adding0x02inprepare(); providestoByteArray()andtoId()→rice.pastry.Id.build(...). This class is the bridge between key material and the DHT ID space.ellipticcurves/AESSymmetricKey.java—Cipher.getInstance("AES")(provider default mode, i.e. ECB with SunJCE), default key size 128.createKey(seed)uses the same seed-replay pseudo-SecureRandomso an AES key is reproducible from its seed;createKey()uses a freshKeyGenerator. Contains built-in nanoTiming instrumentation (encryptionTime,decryptionTime, …) from the 2011/12 project-group evaluation.- Known hybrid state:
ECAsymmetricKeyis migrated to BouncyCastle, butECPublicKeyand thereforeSource/com.p2pframework/build.gradle(implementation files('lib-dist/FlexiProvider-1.7p3.signed.jar') //FIXME: find replacement library) still depend on FlexiProvider. Full de-FlexiProvider migration of the key model is not finished as of 2026.
Login, identity and node ID
Source/org.lifesocial.plugin.loginplugin/src/org/lifesocial/loginplugin/component/LoginComponent.java— OSGi@ComponentimplementingILoginPlugin.login(bootstrapHost, bootstrapPort, bindHost, bindPort, usrname, password). The password is pre-hashed locally asSHA-256(password + username)(username lower-cased, used as salt) before it reaches the framework. Login then callsframework.getNetwork().connect(user, hash)(existence-checking variant); a 2026 fix replaced the oldconnect(..., true)which silently accepted any credentials.getUserKey()exposes the session'sAsymmetricKey. Registration uses theconnect(user, pass, register=true)variant.network/freepastry/PastryNetwork.java—createNodeAndBoot(username, password): 1.userKey = new ECAsymmetricKey(username, password); 2. node ID =((ECPublicKey) userKey.getPublic()).toByteArray()(20 bytes, compressed point without prefix); password reference is then nulled; 3. Pastry node is booted withId.build(idBytes).connect(user, pass)afterwards resolvesUserManager.getUserID(ownID);ItemNotFoundException→UserNotRegisteredException; withregister=truea missing user is created viaUserManager.createUser(username, ownID).Network.getUserKey()is the framework-wide accessor.network/freepastry/PastryID.java— adapter implementing bothcom.p2pframework.network.IDandrice.p2p.commonapi.Id; wraps arice.pastry.Idand anECPublicKeyinterchangeably (IDLength = 160);IDFactory.javacachesId → PastryID(and public-key → ID) and delegates IP resolution toIPFactory.users/UserManager.java— maintains the stable-identity layer:users/ID2UserIDStorageItem.java(nodeID → userID) andusers/UserID2IDStorageItem.java(userID + index → nodeID) stored in PAST;changeIDre-publishes the mapping, so a user's immutableUserIDsurvives node-ID changes.
Access control
storage/SecureStorageItem.java— per-object hybrid envelope: the wrappedStorageItemis encrypted with an AES key (either a suppliedSecretKeyor a secret derived via the owner's private key), and the serializedAccessControlListplus ciphertext are signed with ECDSA. A 2026-era commit (6a7bb14c7) fixed rights handling: only the owner can set rights, verification always uses the owner's public key.storage/AccessControlList.java—HashMap<UserID, byte[]>: for each authorized user, the object's AES key wrapped with that user's public key.addReadRight(UserID, wrappedKey),removeReadRight,getCryptedReadKey. Read-rights only; write control lives in the DDS layer below.storage/SecureGroupDataItem.java— group variant of the same pattern.users/Group.java— group key management: history of group asymmetric key pairs (Vector<byte[]> publicKeys), and per member-subset symmetric group keys (LinkedHashMap<ArrayList<UserID>, Vector<byte[]>>) with private-key seeds; keys are transported asusers/KeyContainer.java(encrypted asymmetric-key seed + encrypted symmetric key + version numbers).users/GroupKeysRetriever.java—RemoteOperationClient(identifierGroupManagment) issuinggetPublicKey,retrieveAsymmetricGroupKey,retrieveAllGroupKeys,revokeUserRights, role operations against the group's home node; used by the DDS layer to fetch keys for decryption without holding the group locally.users/ReferingRole.java— signed (nonce + ECDSA) role reference allowing one group to be a member of another (hierarchical/nested groups); verified with the referring group's current public key.users/UserRoleManager.java,users/GroupServer.javaimplement the server side.- Revocation:
Group.revokeUserRights(...)deletes the member set's key seed/symmetric key entries and callsupdateGroupKeys(...), which generates a new group EC pair and new symmetric keys for the remaining member sets (versioned key lists). Old ciphertexts are not eagerly re-encrypted — key versions make readers skip data they can no longer decrypt (lazy-revocation semantics).
Message, DDS and join protection
message/SecureMessage.java— wraps a payloadMessage: optional AES confidentiality (sharedSecretKeyor receiver's EC public key via ECIES) and optional ECDSA signature; flagsisEncrypted/isSigned.DDS/SecureDistributedDataItem.java— DDS element envelope:encryptedStorageItem(AES),userSignature(author, write-ownership + nonce replay protection) andgroupSignature(insert permission), pluspubPrivKeyVersion/secretKeyVersion. Equality/contains()checks work on signatures without decryption, so storage nodes can answer membership queries without reading plaintext.network/freepastry/SecureJoinProtocol.java— extends FreePastry'sConsistentJoinProtocol; the join response would be sent asEncryptPRawMessagebound to the joiner's public key reconstructed from its ID (new ECPublicKey(pId.toByteArray())), tying ID to key already at join time. Current state caveat: grep over the 2026 tree shows neither class is referenced outside their own definitions — the modified Pastry node boots with the stock join protocol, so this ID/key binding at join time is dormant code, not active wiring.
Notable parameters (current code)
| Parameter | Value | Where |
|---|---|---|
| Curve | BrainpoolP160r1 | ECAsymmetricKey, ECPublicKey |
| Asymmetric algorithms | ECIES (enc), SHA1withECDSA (sig) | ECAsymmetricKey via BC |
| Node/ID space | 160 bit, compressed point without prefix byte | ECPublicKey.toByteArray, PastryNetwork |
| Seed re-hash loop | SHA-1 until compressed prefix 0x02 |
ECAsymmetricKey.createKey |
| Symmetric cipher | AES-128 (default provider mode = ECB) | AESSymmetricKey, KeyFactory |
| Credential pre-hash | SHA-256(password+username) | LoginComponent.hash |
| Random seed strings | 130-bit BigInteger, base-32 | RandomStringKey |
Design options and decision
The papers state some alternatives explicitly; for the rest the rationale below is reconstructed from the cited publications and marked as such.
- Self-sovereign key-derived identity vs. server-issued accounts (documented choice, 2009 paper): registration derives the key pair locally from username+passphrase; the public key becomes the nodeID/userID and a signed minimal profile is stored as proof-of-existence in the DHT. A central directory was rejected because the platform's premise (censorship/abuse resistance of central OSNs) forbids a trusted third party. Trade-off: login correctness depends on deterministic key derivation — the 2026 BC migration bug (
getInstanceStrong) shows the cost: any nondeterminism silently destroys the identity. - RSA-1024 vs. ECC for identity (documented revision): the 2009 system used RSA-1024 and had to widen the FreePastry ID space to 1088 bits to hold an RSA key. The 2011/12 Paderborn project group replaced this with BrainpoolP160r1: a 160-bit compressed EC public key fits FreePastry's native
Id, removing a fork-specific modification and shrinking messages/signatures; the paper trail (PG 2011/12 report, 2020 framework paper) cites exactly this. Trade-off: the 161-bit compressed point must be trimmed to 160 bits (re-hash until prefix0x02), and EC security at 160 bits (~80-bit) is weaker than modern guidance — accepted for ID-space fit; still the current state in 2026. - ACLs vs. capability lists (documented, 2009 paper): each item gets an object-specific symmetric key; copies are wrapped per authorized user in a signed key list (SharedItem → CryptedItem). Capability-based systems (Cryptree, Plutus, OceanStore are surveyed as related work) were not adopted because per-object ACLs are simpler to modify (revocation = remove an entry) and integrate with group key lists. Trade-off measured in 2009: +413 bytes per additional authorized user (~200 friends → ~84 KB, 24% relative overhead), hence group-based ACL recommended beyond that size.
- Hybrid vs. pure asymmetric encryption (documented): bulk data under AES-128, only keys under ECIES/RSA. 2009 evaluation: total overhead < 2 KB per message (1899–1911 B absolute), en/decryption ≈ 10–14 ms/8–10 ms; pure asymmetric was orders of magnitude slower. (Reconstructed:) the 2014/2017 DDS work kept this split and added GEGS — granular encryption/signature per DDS attribute — instead of encrypting whole buckets, trading per-attribute crypto operations for attribute-level access granularity.
- Eager re-encryption vs. lazy revocation (documented, 2017 LANMAN paper): removing a user would classically require re-encrypting all data (the "DDEKey problem"). The implemented scheme uses a Security Context with an Access Control Map (signed ACL entries: access right, wrapped DDEKey, signer; first entry proves authorship) and an Encryption Version parameter: revocation removes the ACE and issues a new key for new modifications only; old versions are deliberately ignored. Code counterpart: versioned symmetric/group keys and
secretKeyVersionfields. Trade-off: a revoked user retains old plaintext; forward secrecy for new data is bought cheaply. - Single-level vs. hierarchical groups (documented, 2014 paper + 2014 master's thesis): admin groups and nested groups (a group as member, depth-first key resolution) were chosen over flat ACLs for large communities;
ReferingRoleimplements cross-group role references with signatures + nonces rather than a global role server. - Integrity at the storage node (documented, 2014 paper): write protection is two-layered — bucket/group signature (who may insert) and per-element author signature + nonce (only the author may change/delete, replay-protected). Storage nodes are treated as honest-but-curious: they enforce signatures without decrypting (signed
containsinSecureDistributedDataItem). - Overlay-level protection (reconstructed): the designed
SecureJoinProtocolresponse encryption (present but not wired in the 2026 build) and the signed monitoring structures (SkyEye tree monitoring, 2016 Convex-Hull-Watchdog mitigation of malicious nodes in tree-based monitoring) show the intended posture for monitoring-adjacent security: authenticated tree links and watchdog voting on the DHT tree rather than a centralized monitor (single point of failure) or gossip (unbounded message cost, hard to attribute blame). Detailed monitoring rationale belongs to the monitoring component doc.
Technical details
Login/registration protocol (current):
1. UI/OSGi calls LoginComponent.login(...) → hash = SHA-256(password + username) (UTF-8).
2. PastryNetwork.createNodeAndBoot(user, hash) → ECAsymmetricKey(user, hash); seed = user+hash, then SHA-1-chained deterministic EC keygen on BrainpoolP160r1 until prefix 0x02; nodeID = 20-byte compressed point.
3. Boot Pastry with that ID (stock FreePastry join protocol; the optional SecureJoinProtocol variant is not wired in the current build).
4. Login path: UserManager.getUserID(ownID) must find an ID2UserIDStorageItem in PAST, else UserNotRegisteredException. Register path: UserManager.createUser(username, ownID) stores ID2UserIDStorageItem and up to N sharded UserID2IDStorageItems (userID + "_" + i).
5. Password reference is dropped after ID derivation.
Data-at-rest envelope (SecureStorageItem): ciphertext = AES-128(item); AES key stored once per authorized user as ECIES(pubKey_user) inside the serialized AccessControlList; signature = ECDSA_owner(ACL_bytes || ciphertext). Readers locate the item by ID in PAST, unwrap their AES copy, decrypt, and verify against the owner's public key (recoverable from the item ID itself via new ECPublicKey(idBytes)).
DDS write protocol (2014, implemented in DDS/): lists/trees are bucketed (bucket key = h(listName + floor(i/splitsize)), evaluated splitsize 20), mutations are remote operations executed by the bucket's home node; elements are AES-encrypted and carry both author and group ECDSA signatures with key versions; deletion inserts a DeletedDistributedItem marker and the consolidation protocol shifts it one bucket per call. SecureDistributedDataItem.verifyGroup/verifyUser implement the storage node's checks without decryption.
Group keys: Group stores key histories (indexed by version) so old ciphertexts remain attributable; member sets are ArrayList<UserID> keys into the symmetric-key map, enabling subgroup caching; GroupKeysRetriever + RemoteOperation.{getPublicKey, getEncryptedPrivateKey, getEncryptedSymmetricKey, getAllKeys, revokeUserRights, getOwnRoles, getReferingRoles, …} are the RPC surface to a group's home node.
Identity layer: UserID is stable across identity-key changes; UserManager.changeID republishes mappings; challenge/response protection of mapping items is described in the 2020 dissertation (partly outside this package).
Integration points: Framework.java exposes getKeyFactory() (created through PastryClassFactory.createKeyFactory()), though most call sites construct ECAsymmetricKey/AESSymmetricKey directly. Also: rice.freepastry (rice.pastry.Id, ConsistentJoinProtocol, PAST Id requirements), com.p2pframework.storage.past (PastryStorageItem/PastryStorageDispatcher wrap SecureStorageItem), com.p2pframework.storagedispatcher, com.p2pframework.messagedispatcher (SecureMessage transport), DDS (SecureDistributedDataItem, RemoteOperationClient), users (UserManager/Group), plugins: org.lifesocial.plugin.loginplugin (login UI flow), groups, forum, photosplugin, filestorage, messagingplugin, livechatplugin (all construct SecureStorageItem/SecureMessage through framework APIs), org.lifesocial.core.main (SecureSharedItemPayload, HashKeyBuilder for storage keys).
Weaknesses visible in current code (stated as of 2026): AES without an explicit IV/mode (ECB default); SHA-1 for signatures and seed chaining; single unsalted-round SHA-256 password pre-hash; deterministic PRNG construction for key derivation is not a KDF (no iteration count, no per-user salt beyond the username); password and key material occasionally logged (System.out.println("password= …")). These are legacy choices preserved for compatibility of existing DHT data.
Evolution and supersession
- 2007–2009 (LifeSocial.KOM): security framework defined and published at IEEE LCN 2009 — RSA-1024 identities, enlarged 1088-bit Pastry ID space, AES-128, ACL key lists, group keys. 2010 demo paper restates the same stack.
- 2011/12: the Paderborn project group created the present
com.p2pframework.security+security.ellipticcurvespackages (file headers "Created by Project Group 2011/12 University of Paderborn"): interfacesAsymmetricKey/SymmetricKey,KeyFactory, ECIES/SHA1withECDSA on BrainpoolP160r1 via FlexiProvider, 160-bit IDs matching vanilla FreePastry. This supersedes the RSA/1088-bit description of the 2009 paper; the 2012/2013 PG final reports document the switch. - 2013/14: DDS security layer (
SecureDistributedDataItem, remote-operation write protection, group key management, consolidation) built by the 2013/14 project group; described in the 2014 IEEE CTS paper, which supersedes the flat 2009 access-control description for data-structure-level control. Hierarchical communities/ACL levels added by the 2014 master's thesis (groups plugin). - 2016/2017: Convex-Hull-Watchdog (2016) adds malicious-node mitigation to the tree-based monitoring overlay (adjacent to this component). The 2017 LANMAN short paper formalises the access-control design (Security Context, Access Control Map, GEGS, lazy revocation, anonymous identities) and is the authoritative description of revocation semantics — the code implements it as versioned keys rather than the paper's full Security Context API.
- 2020: LibreSocial framework paper and dissertation describe the mature state: 160-bit ECC nodeIDs replacing RSA, stable
UserID↔ nodeID mapping via signed mapping items, device-independent login. They supersede 2009/2011 descriptions as the reference for identity handling. - 2025: revival work (setup guide, "Reviving LibreSocial" master's thesis) ports the legacy build to modern JDKs, exposing the FlexiProvider dependency as a blocker.
- 2026 (current): git history shows
./gradlew rewriteRun(OpenRewrite, Java 17) in June 2026, thena4dda2c64 "Restore old state of elliptic curve implementation"(2026-07-06) andd9ccc75b9 "Fix login, storage, OOM, album creation and getalbumlists on migrated build"(2026-07-06):ECAsymmetricKeymigrated from FlexiProvider to BouncyCastle with a re-implemented deterministic key derivation and the0x02-prefix loop;ECPublicKeyremains FlexiProvider-based andlib-dist/FlexiProvider-1.7p3.signed.jaris still a dependency (marked FIXME). Login now pre-hashes with SHA-256 and uses the existence-checkingconnect(); earlier rewrites had broken both (getInstanceStronglogin bug,ClassCastExceptionon raw BC keys, silent empty-identity login).
Related publications
- Practical Security in P2P-based Social Networks (2009)
- LifeSocial.KOM: A P2P-based Platform for Secure Online Social Networks (Demo-Paper, IEEE P2P 2010) (2010)
- LifeSocial.KOM: A Secure and P2P-based Solution for Online Social Networks (2011)
- A Distributed Framework for Social Networks — Final Report (Project Group 2011) (2011)
- A Peer-to-Peer Framework for Social Networks — Final Report (Project Group 2013/14, LifeSocial) (2014)
- Secure Distributed Data Structures for Peer-to-Peer-based Social Networks (2014)
- Distributed Access Control Mechanisms for Peer-to-Peer Networks (2014)
- Convex Hull Watchdog: Mitigation of Malicious Nodes in Tree-based P2P Monitoring Systems (2016)
- Access Control for Secure Distributed Data Structures in Distributed Hash Tables (Short Paper) (2017)
- Access Control for Secure Distributed Data Structures in Distributed Hash Tables (2017)
- LibreSocial: A peer-to-peer framework for online social networks (2020)
- Peer-to-Peer Mechanisms for Fully Decentralized, Secure and Scalable Online Social Networks (2020)
- Reviving LibreSocial: Error Fixes and a Baseline Evaluation on Modern Systems (2025)
- Running LibreSocial: A Legacy Java Project Setup Guide (2025)