20241106 ◎

I'm hungry… I've been with 1800kcal but I'm considering increasing my calorie intake for better sustainability, but let's see.

PGP and PEP 761

PGP

What is PGP Encryption? Pretty Good Privacy Explained | Fortinet

Pretty Good Privacy (PGP) is a security program used to decrypt and encrypt email and authenticate email messages through digital signatures and file encryption.

PGP works through a combination of cryptography, data compression, and hashing techniques.

PGP uses the public key system in which every user has a unique encryption key known publicly and a private key that only they know. A message is encrypted when a user sends it to someone using their public key, then decrypted when the recipient opens it with their private key. It combines private-key and public-key cryptography and the use of symmetric and asymmetric key technology to encrypt data as it travels across networks.

The algorithm that PGP uses, which is typically the RSA algorithm, is largely considered unbreakable, which makes it ideal for encrypting files. It is particularly effective when used with a threat detection and response tool. File encryption software enables users to encrypt all of their files while removing the complexity of the encryption-decryption process.

So, PGP is a program that uses an asymmetric key algorithm (and a symmetric key algorithm after sharing a symmetric key) to encrypt files, transfer them securely, and decrypt the files.

Pretty Good Privacy (PGP) and Digital Signatures

In 1991 Phil Zimmermann, a free speech activist, and anti-nuclear pacifist developed Pretty Good Privacy (PGP), the first software available to the general public that utilized RSA (a public key cryptosystem, will discuss it later) for email encryption and signing.

It seems PGP can be also used for signing in addition to email encryption.

I’m giving up on PGP

A long term key is as secure as the minimum common denominator of your security practices over its lifetime. It’s the weak link.

Worse, long term keys patterns like collecting signatures and printing fingerprints on business cards discourage practices that would otherwise be obvious hygiene: rotating keys often, having different keys for different devices, compartmentalization. It actually encourages expanding the attack surface by making backups of the key.

Are you sure you can protect that long-term key forever? Because when an attacker decides to target you and succeeds, it won’t have access from that point forwards, but to all your past communications, too. And that’s ever more relevant.

I don’t fully understand how PGP works, but as I read the blog, it seems a long-lived encryption key is required for PGP to work.

PEP 761 - Deprecating PGP signatures for CPython artifacts

Abstract

Since Python 3.11.0, CPython has provided two verifiable digital signatures for all CPython artifacts: PGP and Sigstore.

PGP’s design requires the maintenance and protection of long-lived private keys by trusted parties. PGP’s security and ergonomics have been criticized by security practitioners for many years now, with the biggest issue being that there were few alternatives for “artifact signing” being proposed or adopted.

Sigstore’s design philosophy has focused on the ergonomics of signing and verifying and uses short-lived keys with strongly-bound human-readable identities via OpenID Connect. Sigstore has both development and adoption momentum, seeing adoption by PyPI, NPM, Homebrew, and GitHub, among other ecosystems.

This PEP proposes to move CPython to using Sigstore exclusively for signing artifacts through a deprecation and eventual discontinuance of providing PGP signatures with new release managers.

1829C. Mr. Perfectly Fine - 800

The first dirty solution I could come up with.

import math


for _ in range(int(input())):
    n: int = int(input())

    first_skill_min: int = math.inf
    second_skill_min: int = math.inf
    both_skill_min: int = math.inf
    for _ in range(n):
        mins, skills = input().split()
        mins = int(mins)
        match skills:
            case "10":
                first_skill_min = min(first_skill_min, mins)
            case "01":
                second_skill_min = min(second_skill_min, mins)
            case "11":
                both_skill_min = min(both_skill_min, mins)
            case _:
                continue

    if both_skill_min != math.inf:
        if first_skill_min != math.inf and second_skill_min != math.inf:
            print(min(both_skill_min, first_skill_min + second_skill_min))
        else:
            print(both_skill_min)
    elif first_skill_min != math.inf and second_skill_min != math.inf:
        print(first_skill_min + second_skill_min)
    else:
        print(-1)

Since the solution does not look beautiful (super subjective), and the problem is tagged as bitmask, I took time to explore more sophisticated approaches.

Codeforces Round 871 (Div. 4) Editorial

It seems that is the expected solution.


Sushi bowl 800 Pasta 500 Protein bars 500

Total 1800 kcal


MUST:

TODO:


index 20241105 20241107