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

[FEATURE] Add the ability for signing and verify messages. #1610

Open
username1565 opened this issue Aug 29, 2019 · 2 comments
Open

[FEATURE] Add the ability for signing and verify messages. #1610

username1565 opened this issue Aug 29, 2019 · 2 comments
Assignees
Labels

Comments

@username1565
Copy link

username1565 commented Aug 29, 2019

Аbstract

Is your feature request related to a problem? Please describe.

No, this is not related with problem, this is a future request.

Motivation and Purposes
A clear and concise description of what the problem is. Ex. I'm always frustrated when [I cann't sign and verify messages].

** Specification**
A clear and concise description of what you want to happen. Describe alternatives you've considered
Here: https://username1565.github.io/brainwallet.github.io/#sign
I can sign the messages, by privkey.
Here,
I can verify the messages, and got the signatory address.
But... This all working only for bitcoins and altcoins, not for waves.
I see on the node there is can be possible to sign and verify messages,
using NODE REST API,
with options
post /addresses/signText/{address} or post /addresses/sign/{address}
and
post /addresses/verifyText/{address} or post /addresses/verify/{address} ,
but in this case the address of signatory - must be the node address.

Backwards Compatibility
Can your proposition affect any existing features?
Maybe, no. You can just add the separate option in waves client and waves-lite-client.
Also, will be better to you add the another menu in NODE REST API
to sign and verify the messages by seed, privkey or pubkey, for remote user, not node address.
But will be better to make this client-side, like in that brainwalletx,
and without transfer any personal info, somewhere.

Examples and Implementation
Examples of implementation in other projects?
http://brainwalletx.github.io/ this is open-source and client-side.

@vba2000
Copy link
Member

vba2000 commented Sep 6, 2019

Thanks. We will consider your wish.

@username1565
Copy link
Author

username1565 commented Oct 2, 2019

I see here: https://waveswallet.io/js/waves-lite-client-mainnet-0.5.22.js
in this https://waveswallet.io/
there is some code to sign and verify messages:

axlsign.openMessage = function(publicKey, signedMsg) {
  checkArrayTypes(signedMsg, publicKey);
  if (publicKey.length !== 32) throw new Error('wrong public key length');
  var tmp = new Uint8Array(signedMsg.length);
  var mlen = curve25519_sign_open(tmp, signedMsg, signedMsg.length, publicKey);
  if (mlen < 0) return null;
  var m = new Uint8Array(mlen);
  for (var i = 0; i < m.length; i++) m[i] = tmp[i];
  return m;
};

axlsign.sign = function(secretKey, msg, opt_random) {
  checkArrayTypes(secretKey, msg);
  if (secretKey.length !== 32) throw new Error('wrong secret key length');
  if (opt_random) {
    checkArrayTypes(opt_random);
    if (opt_random.length !== 64) throw new Error('wrong random data length');
  }
  var buf = new Uint8Array((opt_random ? 128 : 64) + msg.length);
  curve25519_sign(buf, msg, msg.length, secretKey, opt_random);
  var signature = new Uint8Array(64);
  for (var i = 0; i < signature.length; i++) signature[i] = buf[i];
  return signature;
};

axlsign.verify = function(publicKey, msg, signature) {
  checkArrayTypes(msg, signature, publicKey);
  if (signature.length !== 64) throw new Error('wrong signature length');
  if (publicKey.length !== 32) throw new Error('wrong public key length');
  var sm = new Uint8Array(64 + msg.length);
  var m = new Uint8Array(64 + msg.length);
  var i;
  for (i = 0; i < 64; i++) sm[i] = signature[i];
  for (i = 0; i < msg.length; i++) sm[i+64] = msg[i];
  return (curve25519_sign_open(m, sm, sm.length, publicKey) >= 0);
};

And

// function accepts buffer with private key and an array with dataToSign
            // returns buffer with signed data
            // 64 randoms bytes are added to the signature
            // method falls back to deterministic signatures if crypto object is not supported
            this.nonDeterministicSign = function(privateKey, dataToSign) {
                var crypto = window.crypto || window.msCrypto;
                var random;
                if (crypto) {
                    random = new Uint8Array(64);
                    crypto.getRandomValues(random);
                }

                var signature = axlsign.sign(privateKey, new Uint8Array(dataToSign), random);

                return this.base58.encode(signature);
            };

            // function accepts buffer with private key and an array with dataToSign
            // returns buffer with signed data
            this.deterministicSign = function(privateKey, dataToSign) {
                var signature = axlsign.sign(privateKey, new Uint8Array(dataToSign));

                return this.base58.encode(signature);
            };

            this.verify = function(senderPublicKey, dataToSign, signatureBytes) {
                return axlsign.verify(senderPublicKey, dataToSign, signatureBytes);
            };

And maybe this can be processed client-side.

Also, I see some scripts here: https://github.com/wavesplatform/waves-signature-generator
But this is for node.js, and I don't know how to build and install this...

P.S.: Yeap, this working with some modifications. See this issue: https://github.com/wavesplatform/Waves/issues/2625

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants