@adelos/sdk 0.1.12 → 0.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -128,7 +128,8 @@ ed.etc.sha512Sync = (...m) => {
128
128
  var encoder = new TextEncoder();
129
129
  var toScalar = (bytes) => {
130
130
  const cleanBytes = bytes.length === 64 ? bytes.slice(0, 32) : bytes;
131
- return ed.etc.mod(BigInt("0x" + bytesToHex(cleanBytes)), ed.CURVE.n);
131
+ const reversed = Uint8Array.from(cleanBytes).reverse();
132
+ return ed.etc.mod(BigInt("0x" + bytesToHex(reversed)), ed.CURVE.n);
132
133
  };
133
134
  function generateEphemeralKeypair() {
134
135
  const secretKey = ed.utils.randomPrivateKey();
@@ -200,9 +201,11 @@ async function signWithScalar(message, scalarBytes) {
200
201
  content.set(pubBytes, RBytes.length);
201
202
  content.set(message, RBytes.length + pubBytes.length);
202
203
  const hram = (0, import_sha512.sha512)(content);
203
- const k = ed.etc.mod(BigInt("0x" + bytesToHex(hram)), ed.CURVE.n);
204
+ const hramReversed = Uint8Array.from(hram).reverse();
205
+ const k = ed.etc.mod(BigInt("0x" + bytesToHex(hramReversed)), ed.CURVE.n);
204
206
  const S = ed.etc.mod(rScalar + k * scalar, ed.CURVE.n);
205
- const SBytes = hexToBytes(S.toString(16).padStart(64, "0"));
207
+ const sHexPadded = S.toString(16).padStart(64, "0");
208
+ const SBytes = hexToBytes(sHexPadded).reverse();
206
209
  const signature = new Uint8Array(64);
207
210
  signature.set(RBytes);
208
211
  signature.set(SBytes, 32);
package/dist/index.mjs CHANGED
@@ -78,7 +78,8 @@ ed.etc.sha512Sync = (...m) => {
78
78
  var encoder = new TextEncoder();
79
79
  var toScalar = (bytes) => {
80
80
  const cleanBytes = bytes.length === 64 ? bytes.slice(0, 32) : bytes;
81
- return ed.etc.mod(BigInt("0x" + bytesToHex(cleanBytes)), ed.CURVE.n);
81
+ const reversed = Uint8Array.from(cleanBytes).reverse();
82
+ return ed.etc.mod(BigInt("0x" + bytesToHex(reversed)), ed.CURVE.n);
82
83
  };
83
84
  function generateEphemeralKeypair() {
84
85
  const secretKey = ed.utils.randomPrivateKey();
@@ -150,9 +151,11 @@ async function signWithScalar(message, scalarBytes) {
150
151
  content.set(pubBytes, RBytes.length);
151
152
  content.set(message, RBytes.length + pubBytes.length);
152
153
  const hram = sha512(content);
153
- const k = ed.etc.mod(BigInt("0x" + bytesToHex(hram)), ed.CURVE.n);
154
+ const hramReversed = Uint8Array.from(hram).reverse();
155
+ const k = ed.etc.mod(BigInt("0x" + bytesToHex(hramReversed)), ed.CURVE.n);
154
156
  const S = ed.etc.mod(rScalar + k * scalar, ed.CURVE.n);
155
- const SBytes = hexToBytes(S.toString(16).padStart(64, "0"));
157
+ const sHexPadded = S.toString(16).padStart(64, "0");
158
+ const SBytes = hexToBytes(sHexPadded).reverse();
156
159
  const signature = new Uint8Array(64);
157
160
  signature.set(RBytes);
158
161
  signature.set(SBytes, 32);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adelos/sdk",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "description": "Adelos Protocol SDK - Privacy Stealth Transfers on Solana",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",