<page>
<title>How_to_sign_an_article</title>
<author_name>stjohn_piano</author_name>
<content>


<bold_lines>
Contents
</bold_lines>


- Prerequisites
- Setup
- Verify draft article
- Derive URI title
- Construct article filename
- Verify article filename
- Sign article
- [optional] Verify signed article




<bold_lines>
Prerequisites
</bold_lines>


- <link>
<type>hyperlink</type>
<reference>/pages/how_to_write_an_article</reference>
<text>How to write an article</text>
</link>
- <link>
<type>hyperlink</type>
<reference>/pages/how_to_generate_a_gpg_key</reference>
<text>How to generate a GPG key</text>
</link>
- <link>
<type>hyperlink</type>
<reference>/pages/how_to_upload_a_draft_article</reference>
<text>How to upload a draft article</text>
</link>




<bold_lines>
Setup
</bold_lines>


If you have worked through <link>
<type>hyperlink</type>
<reference>/pages/how_to_upload_a_draft_article</reference>
<text>How to upload a draft article</text>
</link>, you should have a work directory called "new_articles", with this directory layout:

<datablock_lines>
new_articles
- keys
-- private_keys
-- public_keys
- drafts
- edgecase_article
</datablock_lines>

edgecase_article must have been successfully installed.

Inside "private_keys", you should have your secondary private key.

Example secondary private key filename:
stjohn_piano_2_private_key.txt

Explanation: Most articles will be signed using a secondary key, which can be kept on an internet-connected machine. This is more convenient than transferring data to/from an offline machine.

Inside "drafts", you should have a new article that you are ready to sign.

<bold>Important</bold>: Check that the author name within the article is your secondary key name. E.g. "stjohn_piano_2", not "stjohn_piano". The author name must match the key.

Note: Sometimes you may want to use a primary key to sign the article (e.g. "stjohn_piano"), or a corporate key (e.g. "edgecase", "morgan_industries").

Inside the work directory, create this subdirectory:
- "signed_articles"




<bold_lines>
Verify draft article
</bold_lines>


Open a shell and change directory to the work directory.

Set a shell value for the draft filename.

<code_lines>
DRAFT_FILE_NAME=draft_1.txt
</code_lines>

<code_lines>
python3 edgecase_article/cli.py --task verify --logLevel info --verifyContent --articleFile drafts/$DRAFT_FILE_NAME
</code_lines>




<bold_lines>
Construct article filename
</bold_lines>

Construct the final article filename. The draft filename was not important, but the article filename follows specific rules.

<code_lines>
python3 edgecase_article/cli.py --task constructFilename --articleFile drafts/$DRAFT_FILE_NAME
</code_lines>

Example article filename:
2021-12-24_stjohn_piano_2_jabberwocky_by_lewis_carroll.txt

The filename consists of:
- The date in YYYY-MM-DD format. This must match the date inside the article.
- The author name. This must match the author name inside the article.
- The URI title. URI format: Lowercase, numbers, and underscores. Periods and hyphens converted to underscores. Other punctuation removed.
- A '.txt' extension.

All the sections of the filename are joined by underscores.

Change the draft article filename to this new filename.




<bold_lines>
Verify article filename.
</bold_lines>


Set a shell value for the article filename.

<code_lines>
ARTICLE_FILE_NAME=2021-12-24_stjohn_piano_2_jabberwocky_by_lewis_carroll.txt
</code_lines>

<code_lines>
python3 edgecase_article/cli.py --task verify --logLevel info --verifyFileName --articleFile drafts/$ARTICLE_FILE_NAME
</code_lines>




<bold_lines>
Sign article
</bold_lines>


<code_lines>
python3 edgecase_article/cli.py --task sign --articleFile drafts/$ARTICLE_FILE_NAME --publicKeyDir=keys/public_keys --privateKeyDir=keys/private_keys \> signed_articles/$ARTICLE_FILE_NAME
</code_lines>




<bold_lines>
[optional] Verify signed article
</bold_lines>


<code_lines>
python3 edgecase_article/cli.py --task verify --logLevel info --verifyContent --verifyFileName --articleFile signed_articles/$ARTICLE_FILE_NAME --publicKeyDir=keys/public_keys --verifySignature
</code_lines>








</content>
</page>
