I'm looking to implement a "Verify with Bitcoin-OTC" feature for my web app. The general idea is the user would prove he owns a particular account on the external site Bitcoin-OTC and my app would accept/deny him based on his rating there.
Here's how I'm thinking of implementing this:
- User provides Bitcoin-OTC username.
- My app looks up his GPG fingerprint using this bitcoin-otc gem.
- My app presents the user with his encrypted one-time password and asks him to decrypt it.
- User provides decrypted password.
- My app verifies it with the gpg everify command on Freenode and accepts/denies the user.
The part I'm struggling with is step #5. I'm doing it this way because I'm not sure Bitcoin-OTC exposes an API. I'm not sure how to programmatically communicate with the bot on their IRC channel.
Steps 1-5 are basically how a user would verify himself on the Bitcoin-OTC IRC channel except my app is acting as a middleman.
My questions are:
- How can I achieve step #5?
- Does adding my app into this flow introduce any security risks?
Edit:
I've been doing some research and I've realized I can probably just get the user to sign a message stating he owns the Bitcoin-OTC account in question.
If the message is signed with the fingerprint tied to the Bitcoin-OTC account and the signature is trusted, then can I be sure the user is who he says he is?
Here is my proposed flow in an ad-hoc Ruby script:
require 'bitcoin/otc'
account = Bitcoin::OTC::Account['mhluska']
message = Time.now.to_i.to_s + " I am the owner of username #{account.nick} on Bitcoin-OTC"
puts 'Run the following command to sign a message using your GPG fingerprint #{account.fingerprint}:'
puts "$ echo \"#{message}\" | gpg --clearsign"
puts "Paste it back here and press Ctrl+D"
$/ = "\0"
message = STDIN.gets
response = %x[echo "#{message}" | gpg --verify 2>&1]
if response.include?('Good signature')
if response.include?('This key is not certified')
puts 'Good signature but untrusted'
else
puts 'Good signature and trusted'
end
else
puts 'Bad signature'
end