Giter VIP home page Giter VIP logo

Comments (2)

vba2000 avatar vba2000 commented on June 2, 2024 1

Thanks. We will consider your wish.

from wavesgui.

username1565 avatar username1565 commented on June 2, 2024

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

from wavesgui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.