Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Action signature hashes (anti-tampering) #8

Closed
grrowl opened this issue Nov 28, 2016 · 3 comments
Closed

Action signature hashes (anti-tampering) #8

grrowl opened this issue Nov 28, 2016 · 3 comments

Comments

@grrowl
Copy link
Owner

grrowl commented Nov 28, 2016

I've released a Component-based userland solution. It generates an ed25519 privateKey on mount, and passes down the functions signMessage, verifyMessage and generateKey to its children as props.

  • [pro] Totally userland, enables flexibility in signing, validating, etc.
  • [con] Can't invalidate actions which fail validation at the scuttlebutt level.
    • Which means invalid actions may fail at a reducer level, but still be communicated to peers
    • We'd either introduce latency to communicating actions to peers, or replay potentially invalid messages ASAP.
  • [fact] It takes about 1ms to sign a message, but about 6ms to verify the signature.
    • That's too slow for synchronous validation. Might be within the realm for redux-scuttlebutt to async validate
    • How far do we take this? on start we may receive 1000s of actions.
    • We could play the action immediately, and asynchronously validate actions from a queue, remove the invalid actions from history
    • ...and only replay validated actions?

What would be the perfect API for this feature? Does it belong in redux-scuttlebutt or does it make sense as an auxiliary module?

@grrowl
Copy link
Owner Author

grrowl commented Nov 28, 2016

Add verifyAsync option

  • expose option verifyAsync: function (action, cb)
    • cb(true): verified message
    • cb(false): invalid message, remove it from _updates.
  • expose option verifyStrict: bool to withhold unverified messages from replaying to peers
    • it will probably still have to influence the logical clock. we can't roll it back.
  • [wish] allow dispatching before validation, even when verifyStrict is false
    • we'll have to increment the logical clock, even for invalid actions; or play the message with a made-up logical timestamp
    • if we're strictly validating actions, they shouldn't ever increment the logical clock

questions

  • on cb(true), do we replay that action with meta.@@signature/VERIFIED: true
    • orderedHistory says yes: keeps all history states in line with the latest reality
  • on cb(false), pretend like that action never happened.
    • if verifyStrict, simply drop it from _updates
    • if not verifyStrict, remove it from history
    • seems like this gets in the way of the _updates/orderedHistory merge work

@grrowl
Copy link
Owner Author

grrowl commented Dec 5, 2016

Related discussion, "Why syncing actions instead of data model?"

There's also a bit of talk about CRDTs which don't really require the time travel functionality we've implemented, but they're not hurt by it. Currently, an action like ADD_MESSAGE can simply return state.concat(message) (that is, push it onto the state array) and even outdated/old actions from remote peers will be inserted at the correct position in the array.

@grrowl
Copy link
Owner Author

grrowl commented Jan 8, 2017

With dispatcher options verifyAsync and signAsync added, message signing and validation can be enabled by other modules (such as the in-progress redux-signatures)

@grrowl grrowl mentioned this issue Jan 8, 2017
@grrowl grrowl closed this as completed Jan 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant