Generally, with cryptosystems based on secp256k1, a private key is a secret scalar $n$—an integer $n$ in the range $0 \leq n < \ell$ where $\ell$ is the order of the group, which for secp256k1 is a little under $2^{256}$—and a public key is a point on the curve obtained by repeatedly adding a standard base point $G$ to itself $n$ times, $$[n]G = \underbrace{G + \cdots+ G}_{\text{$n$ times}}.$$ No matter how you store the private key, whether with ASN.1 DER or with ASN.1 XER gzip-compressed or with US-ASCII text PEM format, the scalar $n$ is needed to perform private-key operations like signing messages. (Some cryptosystems like Ed25519 have additional information in the private key.)
Since the scalar is typically chosen uniformly at random or near uniform, it can't be compressed. More often, compression applies to public keys or curve points: one way to look at the curve secp256k1 is roughly the set of integer solutions $(x, y)$ to the equation $$y^2 \equiv x^3 + 7 \pmod{2^{256} - 2^{32} - 977},$$ so we could represent it by two 256-bit strings $\underline x$ and $\underline y$ representing integers. But for any particular $x$ coordinate, there are only two possible $y$ coordinates (if any), so it suffices to store a 256-bit string $\underline x$ together with a single bit to determine which square root of $x^3 + 7$ is the $y$ coordinate such as the even one vs. the odd one, for a total of 257 bits—plus any encoding overhead, such as a container format's ASN.1 metadata, and the ANSI X9.62 point encoding which starts with 0x04
for an uncompressed point, 0x02
for a compressed point with even $y$, or 0x03
for a compressed point with odd $y$.
So, for a key pair $(x, y) = [n]G$, the two procedures are as follows:
- Pick $n$.
- Compute $(x, y) = [n]G$.
- Compute $y \bmod p \bmod 2$ and store the compressed key pair $(n, x, y \bmod p \bmod 2)$.
- Publish the compressed public key $(x, y \bmod p \bmod 2)$.
- Pick $n$.
- Compute $(x, y) = [n]G$.
- Store the uncompressed key pair $(n, x, y)$.
- Compute $y \bmod p \bmod 2$ and publish the compressed public key $(x, y \bmod p \bmod 2)$.
The first option stores a compressed private key; the second stores an uncompressed one. Either way, it's the same private key and public key, and the resulting compressed public key $(x, y \bmod p \bmod 2)$ has the same bit encoding no matter which path you take.