WavesGUI icon indicating copy to clipboard operation
WavesGUI copied to clipboard

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

Open username1565 opened this issue 6 years ago • 2 comments

А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.

username1565 avatar Aug 29 '19 10:08 username1565

Thanks. We will consider your wish.

vba2000 avatar Sep 06 '19 13:09 vba2000

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

username1565 avatar Oct 02 '19 17:10 username1565