Add correct length numbers to Lexer regexes for multihashes

This commit is contained in:
Netscape Navigator 2020-04-02 07:58:57 -05:00
parent 57a5630659
commit 4f33b42f63
4 changed files with 11 additions and 11 deletions

View File

@ -39,13 +39,14 @@ Eg: `pigeon identity show` becomes `./pigeon-cli show`.
- [X] Fix the diagram in the spec document
- [X] Validate inputs for `Draft#[]=`.
- [X] Put all the [HEADER, string, FOOTER].join("") nonsense into Pigeon::Helpers
- [ ] Don't allow carriage return in `kind` or `string` keys. Write a test for this.
- [ ] Why are blob multihashes in hex rather than b64?
- [ ] Ensure all disks writes perform verification!
- [ ] Change all the `{40,90}` values in ::Lexer to real length values
- [X] Use raw SHA256 hashes for blob multihashes, not hex.
- [X] Change all the `{40,90}` values in ::Lexer to real length values
- [ ] Rename (RemoteIdentity|LocalIdentity)#public_key to #multihash for consistency with other types.
- [ ] Rename `message find` to `message read`, since other finders return a multihash.
- [ ] Don't allow carriage return in `kind` or `string` keys. Write a test for this.
- [ ] Create regexes in ::Lexer using strings and Regexp.new() for cleaner regexes.
- [ ] pigeon message find-all for peer feed. I will need to add index for `author => message_count`
- [ ] Ensure all disks writes perform verification!
- [ ] Implement pigeon message find-all for peer feed. I will need to add index for `author => message_count`
- [ ] refactor `Bundle.create` to use `message find-all`.
- [ ] add parsers and validators for all CLI inputs
- [ ] Remove all `.current` "singletons" / hacks

View File

@ -3,11 +3,11 @@ module Pigeon
attr_reader :bundle_string, :scanner, :tokens
# TODO: Change all the `{40,90}` values in ::Lexer to real values
# TODO: Create regexes using string and Regexp.new() for cleaner regexes.
FEED_VALUE = /@.{43,45}.ed25519/
DEPTH_COUNT = /\d{1,7}/
MESG_VALUE = /%.{40,90}.sha256/
BLOB_VALUE = /&.{40,90}.sha256/
NULL_VALUE = /NONE/
FEED_VALUE = /@.{44}\.ed25519/
MESG_VALUE = /%.{43}\.sha256/
BLOB_VALUE = /&.{43}\.sha256/
STRG_VALUE = /".{1,64}"/
B64LIKE = /[a-zA-Z0-9_\-=]{1,64}/
ALL_VALUES = [

View File

@ -41,7 +41,7 @@ module Pigeon
end
def multihash
sha256 = Base64.urlsafe_encode64(Digest::SHA256.hexdigest(self.render))
sha256 = Base64.urlsafe_encode64(Digest::SHA256.digest(self.render))
"#{MESSAGE_SIGIL}#{sha256}#{BLOB_FOOTER}"
end

View File

@ -67,10 +67,9 @@ module Pigeon
end
def set_blob(data)
raw_digest = Digest::SHA256.hexdigest(data)
raw_digest = Digest::SHA256.digest(data)
b64_digest = Base64.urlsafe_encode64(raw_digest)
multihash = [BLOB_SIGIL, b64_digest, BLOB_FOOTER].join("")
write { store[BLOB_NS][multihash] = data }
multihash