initial implementation
better use of pattern matching + remove debug print
code cleanup
implement key/nonce check
WIP (TODO: typesafe frames)