signMessageWithoutSaltV2

WIF:
Message:

Result:


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

          /**
          * @example
          * wif = 'KzSDyrAnef6K51tfq4Hf1isBRuGTfrsFBJUWR6WiPmUassSYEFTB'
          * message = 'Hello World'
          * parameterHexString = '48656c6c6f20576f726c64'
          * lengthHex = '0b'
          * concatenatedString = '0b48656c6c6f20576f726c64'
          * serializedTransaction = '000000000e33488d4ab441dc702194e3e1cdc69d1b34a41710ee6181db1e9c21bb334188'
          * data = {
          * message: 'Hello World',
          * publicKey: '023e72b8b5a20c00dac7ac01ecd72354a2d7d64620d6615524bb18b9f5a6ca8ef4',
          * data: '1e810cc032025011df057e99245eece3b7697c27e9b482400130bab576c09f30d9f3bb4414de9ffa623241b231e81d1f089522d1520fb1fdf6c6f34cf9aac7d9'
          * }
          */
          const parameterHexString = Buffer.from(message).toString('hex');
          const lengthHex = u.num2VarInt(parameterHexString.length / 2);
          const concatenatedString = lengthHex + parameterHexString;
          let serializedTransaction = "000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000" + concatenatedString;
          serializedTransaction = u.num2hexstring(0, 4, true) + u.sha256(serializedTransaction)
          const data = {
            message: message,
            publicKey: publicKey,
            data: wallet.sign(serializedTransaction, privateKey),
          };
        

signMessageV2

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;
          let serializedTransaction = "000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000" + concatenatedString;
          serializedTransaction = u.num2hexstring(0, 4, true) + u.sha256(serializedTransaction)
          const data = {
            salt: randomSalt,
            message: message,
            publicKey: publicKey,
            data: wallet.sign(serializedTransaction, privateKey),
          };
        

verifyMessageV2

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 = "000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000" + concatenatedString;
          const signHex = u.num2hexstring(0, 4, true) + u.sha256(messageHex)
          const result = wallet.verify(signHex, data, publicKey);