title: Delete public key from Private for Private key storage with GPG
body: <p>I'm trying to make a paper based backup of a 4092 bit secret/private PGP key using a QR code generator, but the key is just too big. I'm going to go low tech here and split it into two pieces, but perhaps I don't need to. I know that when exporting the secret key, it also exports the public key embedded within it. </p>
  
  <p>Is there any way to remove the public portion of the key from that file, or prior to exporting, so that the resulting file is <em>only</em> the private key?</p>
  
  <p>I'm not certain the resulting file will be small enough still, but it is worth a shot.</p>
  
  <pre><code>D:\Users\tharding&gt;gpg --edit-key "04EAC14C"
  gpg (GnuPG) 2.0.26; Copyright (C) 2013 Free Software Foundation, Inc.
  This is free software: you are free to change and redistribute it.
  There is NO WARRANTY, to the extent permitted by law.
  
  Secret key is available.
  
  pub  4096R/04EAC14C  created: 2015-02-11  expires: never       usage: SCE
                       trust: unknown       validity: unknown
  [ unknown] (1). Timothy Harding &lt;hardingt@gmail.com&gt;
  
  gpg&gt; key 1
  No subkey with index 1
  
  gpg&gt; delkey
  You must select at least one key.
  
  gpg&gt; delkey 0
  You must select at least one key.
  </code></pre>
  
  <p>Update:
  From what I can tell, (looking at the ASCII Armored output for both the public key and the private key) it looks like they are structured this way:</p>
  
  <p><img src="https://i.stack.imgur.com/t2w6k.png" alt="GPG ASCII Armored Key File Format"></p>
  
  <p>Update 2:</p>
  
  <p>Looked at the files again, and this is what I've got, I haven't pulled out a hex editor yet to verify the non armored files, but I've found surprisingly little help online about how these key files are internally structured:</p>
  
  <pre><code>-----BEGIN PGP PUBLIC KEY BLOCK-----
  Version: 
  
  4    header chars ??
  1517 pub key chars
  4    footer chars ??
  -----END PGP PUBLIC KEY BLOCK-----
  </code></pre>
  
  <p>and</p>
  
  <pre><code>-----BEGIN PGP PRIVATE KEY BLOCK-----
  Version:
  
  4    different header chars from pub key ??
  700  pub key chars
  1772 private key chars (possibly some header/footer to do with the symmetric cipher)
  817  pub key chars (same total 1517, exact same ASCII sequence if put together)
  4    different footer chars from pub key ??
  -----END PGP PRIVATE KEY BLOCK-----
  </code></pre>
  
  <p>Update 3:
  Took a look at the binary pub/private keys and found that:</p>
  
  <ul>
  <li>public key is 1138 bytes
  
  <ul>
  <li>4 unique bytes</li>
  <li>1134 bytes found in private key as well</li>
  </ul></li>
  <li>private key is 2467 bytes
  
  <ul>
  <li>4 unique bytes</li>
  <li>524 of which are found verbatim in the public key</li>
  <li>1329 of which are unique to the private key</li>
  <li>38 bytes which are found verbatim in the public key (key name &amp; Email address)</li>
  <li>572 bytes which are found verbatim in the public key</li>
  </ul></li>
  </ul>