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

Add sign and verify for personal messages #33

Merged
merged 5 commits into from
May 22, 2018

Conversation

davidyuk
Copy link
Member

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

@@ -87,6 +87,19 @@ function verify (str, signature, publicKey) {
return nacl.sign.detached.verify(new Uint8Array(str), signature, publicKey)
}

const personalMessageToBinary = (message) => {
Copy link
Contributor

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 consts 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)
Copy link
Contributor

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove newline

Copy link
Member Author

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.

@davidyuk davidyuk force-pushed the feature/personal-messages branch from 65fb0f5 to 293bba1 Compare May 17, 2018 08:01
Copy link
Contributor

@outergod outergod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@outergod outergod force-pushed the feature/personal-messages branch from 293bba1 to 816ceb3 Compare May 22, 2018 10:17
@outergod outergod merged commit 38c5e82 into develop May 22, 2018
@outergod outergod deleted the feature/personal-messages branch May 22, 2018 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants