Running ente locally

published:

updated:

tags: [ #ente, #open source ]

ente is a suite of utilities with an emphasis on transparency and privacy. It is also open source.

In this post, I'm going to outline my process of setting up and running the applications locally. I encourage you to help support this business by getting a subscription, but I still find it interesting to experiment and undderstand how the applications work.

Using the Docker images

The manual covers some steps for getting started using docker here. Since I am running WSL on Windows with NixOS, I couldn't use that with docker (maybe I'm not doing it right). In any case, I installed debian and used it to launch:

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ente/ente/main/server/quickstart.sh)"

This worked and I was able to launch the Photos app locally pretty easily. But, I found that to launch other supported apps (Auth, Locker), you need to enable these commented sections in compose.yml

 web:
    image: ghcr.io/ente/web
    ports:
      - 3000:3000 # Photos web app
      # - 3001:3001 # Accounts
      - 3002:3002 # Public albums
      # - 3003:3003 # Auth
      # - 3004:3004 # Cast
      # - 3005:3005 # Share
      # - 3006:3006 # Embed
      # - 3008:3008 # Paste
      # - 3009:3009 # Locker
      # - 3010:3010 # Memories

Overall seecurity architecture

Ente follows an end-to-end encryption model described here. This applies to all data stored on the servers, whether photos or other documents.

I won't go into the details covered by the architecture page, but at a high level:

  • When a user signs up as a user, the client app generates a master key (call it MK) for the account.
  • An ecryption key (call it EK) is deriveed from the user's chosen password, and is generated by using Argon2.
  • Then MK and EK are used to derive an encrypted master key (call it EMK), which is what is stored on the server (not the source MK). This uses XSalsa20.
  • When using the account from a second device, the EMK and password are used to decrypt, which yields the master key.

libsodium is used for the client-side encryption as noted here.

Running Auth

The server can be run enabling the port 3003 in compose.yml. But the server is not used to generate the codes. For One-time Pincode (OTP) generation, you need to run the mobile or desktop apps. These are Flutter apps whose main library implementationn exists in a common library.

The top-level README.md mentions that in order to build from source you need Flutter and Rust.

How TOTP is generated

from the sourcee here

String getOTP(Code code) {
  if (code.type == Type.steam || code.issuer.toLowerCase() == 'steam') {
    return _getSteamCode(code);
  }
  if (code.type == Type.hotp) {
    return _getHOTPCode(code);
  }
  return otp.OTP.generateTOTPCodeString(
    getSanitizedSecret(code.secret),
    millisecondsSinceEpoch(),
    length: code.digits,
    interval: code.period,
    algorithm: _getAlgorithm(code),
    isGoogle: true,
  );
}

So, ente primarily leverages the totp package which is implements RFC 6238: TOTP: Time-Based One-Time Password Algorithm. This package is also used by Google Authenticator and some others.

For SteamOS, it looks like the steam_totp package is used. I didn't know what [SteamGuard](https://help. steampowered.com/en/faqs/view/06B0-26E6-2CF8-254C) was and had to look it up.

For a deeper dive into how TOTP actually works, Henrik has a good post.

References

  1. Building from source
  2. Overall server architecture