@neuraiproject/neurai-sign-esp32 0.8.0 → 0.8.1
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/README.md +14 -0
- package/dist/NeuraiSignESP32.global.js +9 -4
- package/dist/browser.js +9 -4
- package/dist/index.cjs +9 -4
- package/dist/index.js +9 -4
- package/dist/react-native.js +9 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -958,6 +958,20 @@ ArduinoJson parser was checked on the host up to MAX_MONEY; this does not replac
|
|
|
958
958
|
an on-device signing and display check of the firmware installed on your ESP32.
|
|
959
959
|
No global bigint JSON serializer is required.
|
|
960
960
|
|
|
961
|
+
## Upgrading to 0.8.1
|
|
962
|
+
|
|
963
|
+
React Native (Hermes): Buffer methods are no longer called on `subarray()`
|
|
964
|
+
results. Under Hermes a subarray of the bundled Buffer is a plain `Uint8Array`,
|
|
965
|
+
whose `toString("hex")` is not hex:
|
|
966
|
+
|
|
967
|
+
- reading the firmware's minimal PSBT refused a valid device answer as "a PSBT
|
|
968
|
+
for a different transaction";
|
|
969
|
+
- the DePIN device identity could not read the `s` value of a device signature
|
|
970
|
+
(`derSignatureToRecoverable`, message signatures), and failed.
|
|
971
|
+
|
|
972
|
+
`src/psbt-device.test.ts` and `src/depin-identity.test.ts` run those paths with
|
|
973
|
+
Hermes' `subarray`.
|
|
974
|
+
|
|
961
975
|
## Upgrading to 0.8.0
|
|
962
976
|
|
|
963
977
|
The PSBT helpers no longer use bitcoinjs-lib's `Psbt`: they are built on the
|
|
@@ -11038,10 +11038,12 @@ var NeuraiSignESP32Bundle = (function () {
|
|
|
11038
11038
|
entries.push({ key, value: readBytes(valueLen.value) });
|
|
11039
11039
|
}
|
|
11040
11040
|
};
|
|
11041
|
+
// A copy: under Hermes a subarray of the bundled Buffer is a plain Uint8Array,
|
|
11042
|
+
// without toString("hex") / readUInt32LE.
|
|
11041
11043
|
const readBytes = (length) => {
|
|
11042
11044
|
if (offset + length > buffer.length)
|
|
11043
11045
|
throw new Error("Format Error: Unexpected End of PSBT");
|
|
11044
|
-
const bytes = buffer.subarray(offset, offset + length);
|
|
11046
|
+
const bytes = bufferExports.Buffer.from(buffer.subarray(offset, offset + length));
|
|
11045
11047
|
offset += length;
|
|
11046
11048
|
return bytes;
|
|
11047
11049
|
};
|
|
@@ -11057,7 +11059,7 @@ var NeuraiSignESP32Bundle = (function () {
|
|
|
11057
11059
|
const partialSig = [];
|
|
11058
11060
|
for (const { key, value } of readMap()) {
|
|
11059
11061
|
if (key[0] === PSBT_IN_PARTIAL_SIG && key.length > 1) {
|
|
11060
|
-
partialSig.push({ pubkeyHex: key.
|
|
11062
|
+
partialSig.push({ pubkeyHex: key.toString("hex", 1), signatureHex: value.toString("hex") });
|
|
11061
11063
|
}
|
|
11062
11064
|
else if (key.length === 1 && key[0] === PSBT_IN_SIGHASH_TYPE && value.length === 4) {
|
|
11063
11065
|
if (value.readUInt32LE(0) !== input.sighashType) {
|
|
@@ -17047,7 +17049,9 @@ var NeuraiSignESP32Bundle = (function () {
|
|
|
17047
17049
|
if (signature$1.length !== 64) {
|
|
17048
17050
|
throw new DepinDeviceIdentityError("INVALID_DEVICE_SIGNATURE", `Compact signature must be 64 bytes; got ${signature$1.length}`);
|
|
17049
17051
|
}
|
|
17050
|
-
|
|
17052
|
+
// Not subarray(32).toString("hex"): under Hermes that subarray is a plain
|
|
17053
|
+
// Uint8Array, whose toString is not hex.
|
|
17054
|
+
const s = BigInt(`0x${signature$1.toString("hex", 32)}`);
|
|
17051
17055
|
if (s === 0n || s >= SECP256K1_ORDER) {
|
|
17052
17056
|
throw new DepinDeviceIdentityError("INVALID_DEVICE_SIGNATURE", "The device returned a signature with an invalid s scalar");
|
|
17053
17057
|
}
|
|
@@ -17059,7 +17063,8 @@ var NeuraiSignESP32Bundle = (function () {
|
|
|
17059
17063
|
}
|
|
17060
17064
|
function compactToDer(compact) {
|
|
17061
17065
|
const encoded = bufferExports.Buffer.from(signature.encode(compact, 0x01));
|
|
17062
|
-
|
|
17066
|
+
// A copy, so it is a Buffer under Hermes too (a subarray there is a plain Uint8Array).
|
|
17067
|
+
return bufferExports.Buffer.from(encoded.subarray(0, encoded.length - 1));
|
|
17063
17068
|
}
|
|
17064
17069
|
function assertOperationCount(value) {
|
|
17065
17070
|
if (!Number.isSafeInteger(value) || value < 0) {
|
package/dist/browser.js
CHANGED
|
@@ -11035,10 +11035,12 @@ function applyMinimalDevicePsbt(originalPsbtBase64, signedPsbtBase64) {
|
|
|
11035
11035
|
entries.push({ key, value: readBytes(valueLen.value) });
|
|
11036
11036
|
}
|
|
11037
11037
|
};
|
|
11038
|
+
// A copy: under Hermes a subarray of the bundled Buffer is a plain Uint8Array,
|
|
11039
|
+
// without toString("hex") / readUInt32LE.
|
|
11038
11040
|
const readBytes = (length) => {
|
|
11039
11041
|
if (offset + length > buffer.length)
|
|
11040
11042
|
throw new Error("Format Error: Unexpected End of PSBT");
|
|
11041
|
-
const bytes = buffer.subarray(offset, offset + length);
|
|
11043
|
+
const bytes = bufferExports.Buffer.from(buffer.subarray(offset, offset + length));
|
|
11042
11044
|
offset += length;
|
|
11043
11045
|
return bytes;
|
|
11044
11046
|
};
|
|
@@ -11054,7 +11056,7 @@ function applyMinimalDevicePsbt(originalPsbtBase64, signedPsbtBase64) {
|
|
|
11054
11056
|
const partialSig = [];
|
|
11055
11057
|
for (const { key, value } of readMap()) {
|
|
11056
11058
|
if (key[0] === PSBT_IN_PARTIAL_SIG && key.length > 1) {
|
|
11057
|
-
partialSig.push({ pubkeyHex: key.
|
|
11059
|
+
partialSig.push({ pubkeyHex: key.toString("hex", 1), signatureHex: value.toString("hex") });
|
|
11058
11060
|
}
|
|
11059
11061
|
else if (key.length === 1 && key[0] === PSBT_IN_SIGHASH_TYPE && value.length === 4) {
|
|
11060
11062
|
if (value.readUInt32LE(0) !== input.sighashType) {
|
|
@@ -17044,7 +17046,9 @@ function derToCompactLowS(derHex) {
|
|
|
17044
17046
|
if (signature$1.length !== 64) {
|
|
17045
17047
|
throw new DepinDeviceIdentityError("INVALID_DEVICE_SIGNATURE", `Compact signature must be 64 bytes; got ${signature$1.length}`);
|
|
17046
17048
|
}
|
|
17047
|
-
|
|
17049
|
+
// Not subarray(32).toString("hex"): under Hermes that subarray is a plain
|
|
17050
|
+
// Uint8Array, whose toString is not hex.
|
|
17051
|
+
const s = BigInt(`0x${signature$1.toString("hex", 32)}`);
|
|
17048
17052
|
if (s === 0n || s >= SECP256K1_ORDER) {
|
|
17049
17053
|
throw new DepinDeviceIdentityError("INVALID_DEVICE_SIGNATURE", "The device returned a signature with an invalid s scalar");
|
|
17050
17054
|
}
|
|
@@ -17056,7 +17060,8 @@ function derToCompactLowS(derHex) {
|
|
|
17056
17060
|
}
|
|
17057
17061
|
function compactToDer(compact) {
|
|
17058
17062
|
const encoded = bufferExports.Buffer.from(signature.encode(compact, 0x01));
|
|
17059
|
-
|
|
17063
|
+
// A copy, so it is a Buffer under Hermes too (a subarray there is a plain Uint8Array).
|
|
17064
|
+
return bufferExports.Buffer.from(encoded.subarray(0, encoded.length - 1));
|
|
17060
17065
|
}
|
|
17061
17066
|
function assertOperationCount(value) {
|
|
17062
17067
|
if (!Number.isSafeInteger(value) || value < 0) {
|
package/dist/index.cjs
CHANGED
|
@@ -11037,10 +11037,12 @@ function applyMinimalDevicePsbt(originalPsbtBase64, signedPsbtBase64) {
|
|
|
11037
11037
|
entries.push({ key, value: readBytes(valueLen.value) });
|
|
11038
11038
|
}
|
|
11039
11039
|
};
|
|
11040
|
+
// A copy: under Hermes a subarray of the bundled Buffer is a plain Uint8Array,
|
|
11041
|
+
// without toString("hex") / readUInt32LE.
|
|
11040
11042
|
const readBytes = (length) => {
|
|
11041
11043
|
if (offset + length > buffer.length)
|
|
11042
11044
|
throw new Error("Format Error: Unexpected End of PSBT");
|
|
11043
|
-
const bytes = buffer.subarray(offset, offset + length);
|
|
11045
|
+
const bytes = bufferExports.Buffer.from(buffer.subarray(offset, offset + length));
|
|
11044
11046
|
offset += length;
|
|
11045
11047
|
return bytes;
|
|
11046
11048
|
};
|
|
@@ -11056,7 +11058,7 @@ function applyMinimalDevicePsbt(originalPsbtBase64, signedPsbtBase64) {
|
|
|
11056
11058
|
const partialSig = [];
|
|
11057
11059
|
for (const { key, value } of readMap()) {
|
|
11058
11060
|
if (key[0] === PSBT_IN_PARTIAL_SIG && key.length > 1) {
|
|
11059
|
-
partialSig.push({ pubkeyHex: key.
|
|
11061
|
+
partialSig.push({ pubkeyHex: key.toString("hex", 1), signatureHex: value.toString("hex") });
|
|
11060
11062
|
}
|
|
11061
11063
|
else if (key.length === 1 && key[0] === PSBT_IN_SIGHASH_TYPE && value.length === 4) {
|
|
11062
11064
|
if (value.readUInt32LE(0) !== input.sighashType) {
|
|
@@ -17046,7 +17048,9 @@ function derToCompactLowS(derHex) {
|
|
|
17046
17048
|
if (signature$1.length !== 64) {
|
|
17047
17049
|
throw new DepinDeviceIdentityError("INVALID_DEVICE_SIGNATURE", `Compact signature must be 64 bytes; got ${signature$1.length}`);
|
|
17048
17050
|
}
|
|
17049
|
-
|
|
17051
|
+
// Not subarray(32).toString("hex"): under Hermes that subarray is a plain
|
|
17052
|
+
// Uint8Array, whose toString is not hex.
|
|
17053
|
+
const s = BigInt(`0x${signature$1.toString("hex", 32)}`);
|
|
17050
17054
|
if (s === 0n || s >= SECP256K1_ORDER) {
|
|
17051
17055
|
throw new DepinDeviceIdentityError("INVALID_DEVICE_SIGNATURE", "The device returned a signature with an invalid s scalar");
|
|
17052
17056
|
}
|
|
@@ -17058,7 +17062,8 @@ function derToCompactLowS(derHex) {
|
|
|
17058
17062
|
}
|
|
17059
17063
|
function compactToDer(compact) {
|
|
17060
17064
|
const encoded = bufferExports.Buffer.from(signature.encode(compact, 0x01));
|
|
17061
|
-
|
|
17065
|
+
// A copy, so it is a Buffer under Hermes too (a subarray there is a plain Uint8Array).
|
|
17066
|
+
return bufferExports.Buffer.from(encoded.subarray(0, encoded.length - 1));
|
|
17062
17067
|
}
|
|
17063
17068
|
function assertOperationCount(value) {
|
|
17064
17069
|
if (!Number.isSafeInteger(value) || value < 0) {
|
package/dist/index.js
CHANGED
|
@@ -11035,10 +11035,12 @@ function applyMinimalDevicePsbt(originalPsbtBase64, signedPsbtBase64) {
|
|
|
11035
11035
|
entries.push({ key, value: readBytes(valueLen.value) });
|
|
11036
11036
|
}
|
|
11037
11037
|
};
|
|
11038
|
+
// A copy: under Hermes a subarray of the bundled Buffer is a plain Uint8Array,
|
|
11039
|
+
// without toString("hex") / readUInt32LE.
|
|
11038
11040
|
const readBytes = (length) => {
|
|
11039
11041
|
if (offset + length > buffer.length)
|
|
11040
11042
|
throw new Error("Format Error: Unexpected End of PSBT");
|
|
11041
|
-
const bytes = buffer.subarray(offset, offset + length);
|
|
11043
|
+
const bytes = bufferExports.Buffer.from(buffer.subarray(offset, offset + length));
|
|
11042
11044
|
offset += length;
|
|
11043
11045
|
return bytes;
|
|
11044
11046
|
};
|
|
@@ -11054,7 +11056,7 @@ function applyMinimalDevicePsbt(originalPsbtBase64, signedPsbtBase64) {
|
|
|
11054
11056
|
const partialSig = [];
|
|
11055
11057
|
for (const { key, value } of readMap()) {
|
|
11056
11058
|
if (key[0] === PSBT_IN_PARTIAL_SIG && key.length > 1) {
|
|
11057
|
-
partialSig.push({ pubkeyHex: key.
|
|
11059
|
+
partialSig.push({ pubkeyHex: key.toString("hex", 1), signatureHex: value.toString("hex") });
|
|
11058
11060
|
}
|
|
11059
11061
|
else if (key.length === 1 && key[0] === PSBT_IN_SIGHASH_TYPE && value.length === 4) {
|
|
11060
11062
|
if (value.readUInt32LE(0) !== input.sighashType) {
|
|
@@ -17044,7 +17046,9 @@ function derToCompactLowS(derHex) {
|
|
|
17044
17046
|
if (signature$1.length !== 64) {
|
|
17045
17047
|
throw new DepinDeviceIdentityError("INVALID_DEVICE_SIGNATURE", `Compact signature must be 64 bytes; got ${signature$1.length}`);
|
|
17046
17048
|
}
|
|
17047
|
-
|
|
17049
|
+
// Not subarray(32).toString("hex"): under Hermes that subarray is a plain
|
|
17050
|
+
// Uint8Array, whose toString is not hex.
|
|
17051
|
+
const s = BigInt(`0x${signature$1.toString("hex", 32)}`);
|
|
17048
17052
|
if (s === 0n || s >= SECP256K1_ORDER) {
|
|
17049
17053
|
throw new DepinDeviceIdentityError("INVALID_DEVICE_SIGNATURE", "The device returned a signature with an invalid s scalar");
|
|
17050
17054
|
}
|
|
@@ -17056,7 +17060,8 @@ function derToCompactLowS(derHex) {
|
|
|
17056
17060
|
}
|
|
17057
17061
|
function compactToDer(compact) {
|
|
17058
17062
|
const encoded = bufferExports.Buffer.from(signature.encode(compact, 0x01));
|
|
17059
|
-
|
|
17063
|
+
// A copy, so it is a Buffer under Hermes too (a subarray there is a plain Uint8Array).
|
|
17064
|
+
return bufferExports.Buffer.from(encoded.subarray(0, encoded.length - 1));
|
|
17060
17065
|
}
|
|
17061
17066
|
function assertOperationCount(value) {
|
|
17062
17067
|
if (!Number.isSafeInteger(value) || value < 0) {
|
package/dist/react-native.js
CHANGED
|
@@ -11035,10 +11035,12 @@ function applyMinimalDevicePsbt(originalPsbtBase64, signedPsbtBase64) {
|
|
|
11035
11035
|
entries.push({ key, value: readBytes(valueLen.value) });
|
|
11036
11036
|
}
|
|
11037
11037
|
};
|
|
11038
|
+
// A copy: under Hermes a subarray of the bundled Buffer is a plain Uint8Array,
|
|
11039
|
+
// without toString("hex") / readUInt32LE.
|
|
11038
11040
|
const readBytes = (length) => {
|
|
11039
11041
|
if (offset + length > buffer.length)
|
|
11040
11042
|
throw new Error("Format Error: Unexpected End of PSBT");
|
|
11041
|
-
const bytes = buffer.subarray(offset, offset + length);
|
|
11043
|
+
const bytes = bufferExports.Buffer.from(buffer.subarray(offset, offset + length));
|
|
11042
11044
|
offset += length;
|
|
11043
11045
|
return bytes;
|
|
11044
11046
|
};
|
|
@@ -11054,7 +11056,7 @@ function applyMinimalDevicePsbt(originalPsbtBase64, signedPsbtBase64) {
|
|
|
11054
11056
|
const partialSig = [];
|
|
11055
11057
|
for (const { key, value } of readMap()) {
|
|
11056
11058
|
if (key[0] === PSBT_IN_PARTIAL_SIG && key.length > 1) {
|
|
11057
|
-
partialSig.push({ pubkeyHex: key.
|
|
11059
|
+
partialSig.push({ pubkeyHex: key.toString("hex", 1), signatureHex: value.toString("hex") });
|
|
11058
11060
|
}
|
|
11059
11061
|
else if (key.length === 1 && key[0] === PSBT_IN_SIGHASH_TYPE && value.length === 4) {
|
|
11060
11062
|
if (value.readUInt32LE(0) !== input.sighashType) {
|
|
@@ -17044,7 +17046,9 @@ function derToCompactLowS(derHex) {
|
|
|
17044
17046
|
if (signature$1.length !== 64) {
|
|
17045
17047
|
throw new DepinDeviceIdentityError("INVALID_DEVICE_SIGNATURE", `Compact signature must be 64 bytes; got ${signature$1.length}`);
|
|
17046
17048
|
}
|
|
17047
|
-
|
|
17049
|
+
// Not subarray(32).toString("hex"): under Hermes that subarray is a plain
|
|
17050
|
+
// Uint8Array, whose toString is not hex.
|
|
17051
|
+
const s = BigInt(`0x${signature$1.toString("hex", 32)}`);
|
|
17048
17052
|
if (s === 0n || s >= SECP256K1_ORDER) {
|
|
17049
17053
|
throw new DepinDeviceIdentityError("INVALID_DEVICE_SIGNATURE", "The device returned a signature with an invalid s scalar");
|
|
17050
17054
|
}
|
|
@@ -17056,7 +17060,8 @@ function derToCompactLowS(derHex) {
|
|
|
17056
17060
|
}
|
|
17057
17061
|
function compactToDer(compact) {
|
|
17058
17062
|
const encoded = bufferExports.Buffer.from(signature.encode(compact, 0x01));
|
|
17059
|
-
|
|
17063
|
+
// A copy, so it is a Buffer under Hermes too (a subarray there is a plain Uint8Array).
|
|
17064
|
+
return bufferExports.Buffer.from(encoded.subarray(0, encoded.length - 1));
|
|
17060
17065
|
}
|
|
17061
17066
|
function assertOperationCount(value) {
|
|
17062
17067
|
if (!Number.isSafeInteger(value) || value < 0) {
|