-
Notifications
You must be signed in to change notification settings - Fork 58
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
Add sign and verify for personal messages #33
Conversation
src/utils/crypto.js
Outdated
@@ -87,6 +87,19 @@ function verify (str, signature, publicKey) { | |||
return nacl.sign.detached.verify(new Uint8Array(str), signature, publicKey) | |||
} | |||
|
|||
const personalMessageToBinary = (message) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use function
instead of assigning anonymous functions to const
s unless you have a strong reason not to, e.g. because you're assigning a function returned by another function of higher order.
test/crypto.js
Outdated
|
||
describe('sign', () => { | ||
it('should produce correct signature', () => { | ||
let s = Crypto.sign(txBinary, privateKey) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use const
instead of let
wherever possible (please disregard that old code does it wrong)
test/crypto.js
Outdated
|
||
it('should verify message with non-ASCII chars', () => { | ||
const result = Crypto.verifyPersonalMessage( | ||
messageNonASCII, messageNonASCIISignature, publicKey) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove newline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't you have any limits on line length? Usually, I'm trying not to make lines longer than 100 chars.
65fb0f5
to
293bba1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
293bba1
to
816ceb3
Compare
For the Voting app, it is necessary to implement methods for signing and verifying of personal messages. But I can't find anything that describes how this messages should be signed on Aeternity. I propose to use the approach similar to Bitcoin and Ethereum approaches.
In ethereum/go-ethereum#14794 proposed to use
varint
from Bitcoin to store message length, I suppose to implement it later in case if this whole approach is acceptable.Depends on #32