From 4111aed599e9cbafc6ae00dc44e53846e82b3e95 Mon Sep 17 00:00:00 2001 From: Ujjwal Sharma Date: Thu, 25 Mar 2021 14:41:55 +0530 Subject: [PATCH] src: include warning in the secret file --- src/keypair.rs | 11 ++++++++++- src/warning.txt | 15 +++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 src/warning.txt diff --git a/src/keypair.rs b/src/keypair.rs index d2fc5d7..e2efee4 100644 --- a/src/keypair.rs +++ b/src/keypair.rs @@ -59,7 +59,16 @@ impl SSBKeypair for Keypair { } else { let mut csprng = OsRng {}; let keypair = Keypair::generate(&mut csprng); - std::fs::write(path, keypair.to_json().pretty(2)).unwrap(); + let keypair_json = keypair.to_json(); + std::fs::write( + path, + format!( + include_str!("warning.txt"), + keys = keypair_json.pretty(2), + id = keypair_json["id"] + ), + ) + .unwrap(); keypair } } diff --git a/src/warning.txt b/src/warning.txt new file mode 100644 index 0000000..901621b --- /dev/null +++ b/src/warning.txt @@ -0,0 +1,15 @@ +# WARNING: Never show this to anyone. +# WARNING: Never edit it or use it on multiple devices at once. +# +# This is your SECRET, it gives you magical powers. With your secret you can +# sign your messages so that your friends can verify that the messages came +# from you. If anyone learns your secret, they can use it to impersonate you. +# +# If you use this secret on more than one device you will create a fork and +# your friends will stop replicating your content. +# +{keys} +# +# The only part of this file that's safe to share is your public name: +# +# {id}