👏🎉 Message verification works on the Golang version! Hooray!
This commit is contained in:
parent
3068b474ed
commit
d930e68e53
|
@ -20,14 +20,13 @@ Email `contact@vaporsfot.xyz` if you have any questions.
|
||||||
* Writing a BNF grammar for message parsing
|
* Writing a BNF grammar for message parsing
|
||||||
* Test coverage increases
|
* Test coverage increases
|
||||||
* Manual QA of features and edge cases
|
* Manual QA of features and edge cases
|
||||||
|
* Providing constructive feedback on documentation
|
||||||
* Cross-compiling windows binaries
|
* Cross-compiling windows binaries
|
||||||
* General Golang help (I am a Golang novice- project structure could be improved)
|
* General Golang help (I am a Golang novice- project structure could be improved)
|
||||||
* Security auditing and vulnerability discovery. Please send security concerns to `contact@vaporsoft.xyz`.
|
* Security auditing and vulnerability discovery. Please send security concerns to `contact@vaporsoft.xyz` privately.
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
|
|
||||||
**CURRENT TASK:** Write a message parser.
|
|
||||||
|
|
||||||
- [ ] Add a real testing lib to DRY things up.
|
- [ ] Add a real testing lib to DRY things up.
|
||||||
- [ ] Get a good CI system going? Run tests at PR time, provide prebuilt binaries, prevent coverage slips, etc..
|
- [ ] Get a good CI system going? Run tests at PR time, provide prebuilt binaries, prevent coverage slips, etc..
|
||||||
- [ ] Add a `transact()` helper to ensure all transactions are closed out.
|
- [ ] Add a `transact()` helper to ensure all transactions are closed out.
|
||||||
|
@ -38,8 +37,8 @@ Email `contact@vaporsfot.xyz` if you have any questions.
|
||||||
|
|
||||||
|Done?|Noun |Verb | Flag / arg 1 | Flag 2 |
|
|Done?|Noun |Verb | Flag / arg 1 | Flag 2 |
|
||||||
|-----|------------|-----------|---------------|-----------|
|
|-----|------------|-----------|---------------|-----------|
|
||||||
| |blob |remove | mhash | |
|
|
||||||
| |bundle |ingest | | |
|
| |bundle |ingest | | |
|
||||||
|
| |blob |remove | mhash | |
|
||||||
| |message |show | message mhash | |
|
| |message |show | message mhash | |
|
||||||
| |message |find | --all | |
|
| |message |find | --all | |
|
||||||
| |message |find | --last | |
|
| |message |find | --last | |
|
||||||
|
|
|
@ -21,6 +21,10 @@ func B32Decode(input string) []byte {
|
||||||
return output
|
return output
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func decodeMhash(input string) []byte {
|
||||||
|
return []byte(B32Decode(input[5:]))
|
||||||
|
}
|
||||||
|
|
||||||
func validateMhash(input string) string {
|
func validateMhash(input string) string {
|
||||||
arry := strings.Split(input, ".")
|
arry := strings.Split(input, ".")
|
||||||
if len(arry) != 2 {
|
if len(arry) != 2 {
|
||||||
|
|
|
@ -119,13 +119,17 @@ func parseBody(state *parserState) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseFooter(state *parserState) {
|
func parseFooter(state *parserState) {
|
||||||
|
t := state.scanner.Text()
|
||||||
|
chunks := strings.Split(t, " ")
|
||||||
|
state.buffer.signature = chunks[1]
|
||||||
state.mode = parsingDone
|
state.mode = parsingDone
|
||||||
err := verifyShallow(&state.buffer)
|
err := verifyShallow(&state.buffer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
state.results = append(state.results, state.buffer)
|
|
||||||
state.buffer = pigeonMessage{}
|
|
||||||
panicf("Message verification failed for %s. %s", state.buffer.signature, err)
|
panicf("Message verification failed for %s. %s", state.buffer.signature, err)
|
||||||
}
|
}
|
||||||
|
state.results = append(state.results, state.buffer)
|
||||||
|
state.buffer.body = []pigeonBodyItem{}
|
||||||
|
state.buffer = pigeonMessage{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func maybeContinue(state *parserState) {
|
func maybeContinue(state *parserState) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/ed25519"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
@ -69,8 +70,18 @@ func validateBodyValue(value *string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func validateSignature(_topHalf string, _b32signature string) error {
|
func validateSignature(message *pigeonMessage, topHalf string) error {
|
||||||
return errors.New("WIP")
|
asciiSignature := message.signature
|
||||||
|
signature := []byte(B32Decode(asciiSignature))
|
||||||
|
publicKey := decodeMhash(message.author)
|
||||||
|
ok := ed25519.Verify(publicKey, []byte(topHalf), signature)
|
||||||
|
|
||||||
|
if ok {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
error := fmt.Sprintf("Can't verify message %s", message.signature)
|
||||||
|
return errors.New(error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func verifyBodyItem(bodyItem *pigeonBodyItem) error {
|
func verifyBodyItem(bodyItem *pigeonBodyItem) error {
|
||||||
|
@ -113,6 +124,6 @@ func verifyShallow(message *pigeonMessage) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer.Write([]byte("\n"))
|
buffer.Write([]byte("\n"))
|
||||||
validateSignature(buffer.String(), message.signature)
|
validateSignature(message, buffer.String())
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue