Pigeon::Message was holding on to too many drafting responsibilities.
It also was possible for the local identity to inadvertantly author
malformed messages. This is because local messages were not passed
through the ::Lexer / ::Parser and thereby did not receive the same
scrutiny of remote messages.
To avoid security problems later, and for additional security,
I will only allow messages to be saved *after* passing through the
lexer/parser. This means moving much of Pigeon::Message's logic
into Pigeon::Draft.
Observe the messages below:
=== BEGIN SAMPLE
author @sqTnBVTpnkzptZ2Ek7U7IfBKbQdWfe4HfsBd-9fcyDg=.ed25519
kind unit_test
prev NONE
depth 0
description:"Message number 1"
signature oBZcedW6JFqWVVqVHSjKeJWzd2uQtkBi2ATtF9meLzwrgf59DcjFQ5n0W6ZcCQkCSCpXECoBwF8BdnPej9XCBw==.sig.ed25519
author @sqTnBVTpnkzptZ2Ek7U7IfBKbQdWfe4HfsBd-9fcyDg=.ed25519
kind unit_test
prev oBZcedW6JFqWVVqVHSjKeJWzd2uQtkBi2ATtF9meLzwrgf59DcjFQ5n0W6ZcCQkCSCpXECoBwF8BdnPej9XCBw==.sig.ed25519
depth 1
description:"Message number 2"
signature MB52WQfouTRP_cKHnaMR8iL0EEXFDWrKghBbC8DQ_QxKzS8PFDSXCxbZFr2bfEbCzBrd_bCxP1q9uK4ndQwkCQ==.sig.ed25519
author @sqTnBVTpnkzptZ2Ek7U7IfBKbQdWfe4HfsBd-9fcyDg=.ed25519
kind unit_test
prev MB52WQfouTRP_cKHnaMR8iL0EEXFDWrKghBbC8DQ_QxKzS8PFDSXCxbZFr2bfEbCzBrd_bCxP1q9uK4ndQwkCQ==.sig.ed25519
depth 2
description:"Message number 3"
signature jEIN2yYSWmg-fnontgoZQS3Cw7KJIzhxuH6Gz-bE5pRat9zjP6vFJOlbNjADif_sPTxdye-kZdy52gTspDmdBw==.sig.ed25519
=== END EXAMPLE
Notice that the `signature` is identical to the `prev` value.
This is wrong.
The signature value is fine as it is, but the `prev` value needs to be a traditional message.
That is to say it should be a URL safe base64 string that starts with a "%" character.
You can't just copy/paste the signature like that.
For more info visit:
https://spec.scuttlebutt.nz/feed/datatypes.html#multihash-encodinghttps://spec.scuttlebutt.nz/print.html#json-encoding
Currently, it is not working correctly.
Take a look at scratchpad.sh. The `prev:` values are wrong.
It is probably as simple as updating local indexes when
Pigeon::Storage#save_message is called. Re run the indexes
at that time. Or heck, add a map/reduce ability?