diff --git a/README.md b/README.md index 421dee1..c01792a 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,8 @@ Eg: `pigeon identity show` becomes `./pigeon-cli show`. - [X] Implement pigeon message find-all for peer feed. I will need to add index for `author => message_count` - [X] Switch to Crockford base32- Simplifies support for legacy systems. Easy to implement. - [X] Fix `scratchpad.sh` to use Base32 - - [ ] Rename (RemoteIdentity|LocalIdentity)#public_key to #multihash for consistency with other types. + - [X] Rename (RemoteIdentity|LocalIdentity)#public_key to #multihash for consistency with other types. + - [ ] Fix diagram in spec doc - [ ] refactor `Bundle.create` to use `message find-all`. - [ ] Need a way of importing / exporting a feeds blobs. (see "Bundle Brainstorming" below) - [ ] Need a way of adding peers messages / gossip to bundles. (see "Bundle Brainstorming" below) diff --git a/dist/pigeon.rb b/dist/pigeon.rb index 27a3309..340edd7 100644 --- a/dist/pigeon.rb +++ b/dist/pigeon.rb @@ -117,7 +117,7 @@ module Pigeon def self.verify_string(identity, string_signature, string) binary_signature = decode_multihash(string_signature) - string_key = identity.public_key + string_key = identity.multihash binary_key = decode_multihash(string_key) verify_key = Ed25519::VerifyKey.new(binary_key) diff --git a/dist/pigeon/bundle.rb b/dist/pigeon/bundle.rb index eaea79f..f60c0b8 100644 --- a/dist/pigeon/bundle.rb +++ b/dist/pigeon/bundle.rb @@ -6,7 +6,7 @@ module Pigeon author = Pigeon::LocalIdentity.current range = (0...last).to_a content = range - .map { |depth| s.get_message_by_depth(author.public_key, depth) } + .map { |depth| s.get_message_by_depth(author.multihash, depth) } .map { |multihash| s.find_message(multihash) } .map { |message| message.render } .join(BUNDLE_MESSAGE_SEPARATOR) diff --git a/dist/pigeon/local_identity.rb b/dist/pigeon/local_identity.rb index 1c65513..2dab4d1 100644 --- a/dist/pigeon/local_identity.rb +++ b/dist/pigeon/local_identity.rb @@ -30,11 +30,11 @@ module Pigeon @private_key ||= Helpers.b32_encode(@seed) end - def public_key + def multihash bytes = @signing_key.verify_key.to_bytes b64 = Helpers.b32_encode(bytes) - @public_key ||= [IDENTITY_SIGIL, b64, IDENTITY_FOOTER].join("") + @multihash ||= [IDENTITY_SIGIL, b64, IDENTITY_FOOTER].join("") end def sign(string) diff --git a/dist/pigeon/message.rb b/dist/pigeon/message.rb index db46272..b34dcd0 100644 --- a/dist/pigeon/message.rb +++ b/dist/pigeon/message.rb @@ -12,9 +12,9 @@ module Pigeon author = LocalIdentity.current depth = Pigeon::Storage .current - .get_message_count_for(author.public_key) - count = store.get_message_count_for(author.public_key) - prev = store.get_message_by_depth(author.public_key, count - 1) + .get_message_count_for(author.multihash) + count = store.get_message_count_for(author.multihash) + prev = store.get_message_by_depth(author.multihash, count - 1) msg = self.new(author: author, kind: draft.kind, body: draft.body, @@ -65,8 +65,8 @@ module Pigeon end def verify_depth_prev_and_depth - count = store.get_message_count_for(author.public_key) - expected_prev = store.get_message_by_depth(author.public_key, count - 1) || Pigeon::EMPTY_MESSAGE + count = store.get_message_count_for(author.multihash) + expected_prev = store.get_message_by_depth(author.multihash, count - 1) || Pigeon::EMPTY_MESSAGE assert("depth", count, depth) assert("prev", prev, expected_prev) end diff --git a/dist/pigeon/message_serializer.rb b/dist/pigeon/message_serializer.rb index c01e4ce..34f7b1f 100644 --- a/dist/pigeon/message_serializer.rb +++ b/dist/pigeon/message_serializer.rb @@ -21,7 +21,7 @@ module Pigeon private def do_render(template) - author = message.author.public_key + author = message.author.multihash body = message.body depth = message.depth kind = message.kind diff --git a/dist/pigeon/remote_identity.rb b/dist/pigeon/remote_identity.rb index 1d4a111..1af4516 100644 --- a/dist/pigeon/remote_identity.rb +++ b/dist/pigeon/remote_identity.rb @@ -6,10 +6,10 @@ module Pigeon # help us maintain our sanity when the Gem's API # changes. class RemoteIdentity - attr_reader :public_key + attr_reader :multihash def initialize(multihash) - @public_key = multihash + @multihash = multihash end end end diff --git a/dist/pigeon/storage.rb b/dist/pigeon/storage.rb index 8c4c655..6bdba39 100644 --- a/dist/pigeon/storage.rb +++ b/dist/pigeon/storage.rb @@ -136,7 +136,7 @@ module Pigeon end def insert_and_update_index(message) - pub_key = message.author.public_key + pub_key = message.author.multihash # STEP 1: Update MESG_NS, the main storage spot. store[MESG_NS][message.multihash] = message diff --git a/kitchen_sink.sh b/kitchen_sink.sh old mode 100644 new mode 100755 diff --git a/pigeon-cli b/pigeon-cli index c16dc68..8070851 100755 --- a/pigeon-cli +++ b/pigeon-cli @@ -32,13 +32,13 @@ module Pigeon end kp = Pigeon::LocalIdentity.new() kp.save! - puts kp.public_key + puts kp.multihash end desc "show", "Prints your identiy string to STDOUT" def show - puts Pigeon::LocalIdentity.current.public_key + puts Pigeon::LocalIdentity.current.multihash end end @@ -138,7 +138,7 @@ module Pigeon desc "find-all", "Find a pigeon message in the local DB" - def find_all(author = Pigeon::LocalIdentity.current.public_key) + def find_all(author = Pigeon::LocalIdentity.current.multihash) # TODO: Ability to find-all messages by author ID puts Pigeon::Storage .current @@ -151,7 +151,7 @@ module Pigeon def last me = Pigeon::LocalIdentity.current store = Pigeon::Storage.current - multihash = store.get_message_by_depth(me.public_key, store.message_count - 1) + multihash = store.get_message_by_depth(me.multihash, store.message_count - 1) puts multihash end end @@ -166,7 +166,7 @@ module Pigeon _) ( Peers: #{Pigeon::Storage.current.all_peers.count} / ) Blocked: #{Pigeon::Storage.current.all_blocks.count} /_,' / Logs: #{Pigeon::Storage.current.message_count} - \\ / Ident: #{Pigeon::LocalIdentity.current.public_key} + \\ / Ident: #{Pigeon::LocalIdentity.current.multihash} ===m" "m=== " end diff --git a/spec/pigeon/draft_spec.rb b/spec/pigeon/draft_spec.rb index 8aa163e..8b7941b 100644 --- a/spec/pigeon/draft_spec.rb +++ b/spec/pigeon/draft_spec.rb @@ -25,7 +25,7 @@ RSpec.describe Pigeon::Draft do ].join("\n") it "renders a message" do - pk = Pigeon::LocalIdentity.current.public_key + pk = Pigeon::LocalIdentity.current.multihash actual = message.render expected = MSG.gsub("___", pk) expect(actual).to start_with(expected) diff --git a/spec/pigeon/lexer_spec.rb b/spec/pigeon/lexer_spec.rb index 0210758..fab22f9 100644 --- a/spec/pigeon/lexer_spec.rb +++ b/spec/pigeon/lexer_spec.rb @@ -139,7 +139,7 @@ RSpec.describe Pigeon::Lexer do h end - expect(hash[:AUTHOR]).to eq(message.author.public_key) + expect(hash[:AUTHOR]).to eq(message.author.multihash) expect(hash[:BODY]).to eq(message.body) expect(hash[:DEPTH]).to eq(message.depth) expect(hash[:KIND]).to eq(message.kind) diff --git a/spec/pigeon/local_identity_spec.rb b/spec/pigeon/local_identity_spec.rb index 46c965a..78df260 100644 --- a/spec/pigeon/local_identity_spec.rb +++ b/spec/pigeon/local_identity_spec.rb @@ -17,7 +17,7 @@ RSpec.describe Pigeon::LocalIdentity do it "generates a pair from a seed" do x = "@XSZY1ME6QMA5BBSJ8QSDJCSG6EVDTCKYNMV221SB7B2NZR5K09J0.ed25519" - expect(kp.public_key).to eq(x) + expect(kp.multihash).to eq(x) y = "2PRTG7F13HWF1HPW9FF9NDSYGSQS5VXQ2WMZY0A510J64AE9G840" expect(kp.private_key).to eq(y) end diff --git a/spec/pigeon/message_spec.rb b/spec/pigeon/message_spec.rb index e1ad35a..f922123 100644 --- a/spec/pigeon/message_spec.rb +++ b/spec/pigeon/message_spec.rb @@ -54,7 +54,7 @@ RSpec.describe Pigeon::Message do "", "signature __SIGNATURE__", ].join("\n") - .gsub("__AUTHOR__", message.author.public_key) + .gsub("__AUTHOR__", message.author.multihash) .gsub("__SIGNATURE__", message.signature) expect(actual).to eq(expected) end diff --git a/spec/pigeon/storage_spec.rb b/spec/pigeon/storage_spec.rb index 19d474f..b175dfb 100644 --- a/spec/pigeon/storage_spec.rb +++ b/spec/pigeon/storage_spec.rb @@ -52,7 +52,7 @@ RSpec.describe Pigeon::Storage do it "finds all authored by a particular feed" do ingested_messages = Pigeon::Bundle.ingest("./spec/fixtures/normal.bundle") - author = ingested_messages.first.author.public_key + author = ingested_messages.first.author.multihash actual_messages = Pigeon::Storage.current.find_all(author) search_results = Pigeon::Storage.current.find_all(author) end @@ -67,10 +67,10 @@ RSpec.describe Pigeon::Storage do "e" => Pigeon::Storage.current.set_blob(File.read("./logo.png")), }), Pigeon::Helpers.create_message("g", { - "me_myself_and_i" => Pigeon::LocalIdentity.current.public_key, + "me_myself_and_i" => Pigeon::LocalIdentity.current.multihash, }), ] - me = Pigeon::LocalIdentity.current.public_key + me = Pigeon::LocalIdentity.current.multihash results = Pigeon::Storage.current.find_all(me) expect(results.length).to eq(3) expect(msgs[0].multihash).to eq(results[0]) diff --git a/spec/pigeon/template_spec.rb b/spec/pigeon/template_spec.rb index 4d92bdf..b03a33e 100644 --- a/spec/pigeon/template_spec.rb +++ b/spec/pigeon/template_spec.rb @@ -12,7 +12,7 @@ RSpec.describe Pigeon::MessageSerializer do EXPECTED_DRAFT = TOP_HALF + BOTTOM_HALF class FakeLocalIdentity - def self.public_key + def self.multihash "FAKE_AUTHOR" end end