signMessageWithoutSalt

WIF:
Message:

Result:


          import { wallet, u } from "@cityofzion/neon-core";

          /**
          * @example
          * wif = 'KzSDyrAnef6K51tfq4Hf1isBRuGTfrsFBJUWR6WiPmUassSYEFTB'
          * message = 'Hello World'
          * parameterHexString = '48656c6c6f20576f726c64'
          * lengthHex = '0b'
          * concatenatedString = '0b48656c6c6f20576f726c64'
          * serializedTransaction = '010001f00b48656c6c6f20576f726c640000'
          * data = {
          * message: 'Hello World',
          * publicKey: '023e72b8b5a20c00dac7ac01ecd72354a2d7d64620d6615524bb18b9f5a6ca8ef4',
          * data: '99b2ab83e9b6e64af69f29ddd056594e803e484a0aa80c6682466ce0791e8222939959d749adbf7984655aa7a8a7a7b47d215bc9b878102ffa39b3ed1ab11481'
          * }
          */
          const parameterHexString = Buffer.from(message).toString('hex');
          const lengthHex = u.num2VarInt(parameterHexString.length / 2);
          const concatenatedString = lengthHex + parameterHexString;
          const serializedTransaction = "010001f0" + concatenatedString + "0000";
          const data = {
            message: message,
            publicKey: publicKey,
            data: wallet.sign(serializedTransaction, privateKey),
          };
        

signMessage

WIF:
Message:

Result:


          import { wallet, u } from "@cityofzion/neon-core";
          import { randomBytes } from "crypto-browserify";

          const randomSalt = randomBytes(16).toString("hex");
          const targetMessage = randomSalt + message;
          const parameterHexString = Buffer.from(targetMessage).toString('hex');
          const lengthHex = u.num2VarInt(parameterHexString.length / 2);
          const concatenatedString = lengthHex + parameterHexString;
          const serializedTransaction = "010001f0" + concatenatedString + "0000";
          const data = {
            salt: randomSalt,
            message: message,
            publicKey: publicKey,
            data: wallet.sign(serializedTransaction, privateKey),
          };
        

verifyMessage

Original Message:
Salt(optional):
Data:
PublicKey:

Result:


          const message = salt + originalMessage;
          const parameterHexString = Buffer.from(message).toString('hex');
          const lengthHex = u.num2VarInt(parameterHexString.length / 2);
          const concatenatedString = lengthHex + parameterHexString;
          const messageHex = "010001f0" + concatenatedString + "0000";
          const result = wallet.verify(messageHex, data, publicKey);