Skip to content

Commit

Permalink
fix: explicitly pass arraybuffer offset and length
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewkeil committed Apr 17, 2024
1 parent 848bf90 commit acc608a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,18 @@ const bindingsPath = getBindingsPath(rootDir);

function prepareBindings(bindings) {
bindings.SecretKey.prototype.toHex = function toHex() {
return `0x${Buffer.from(this.serialize().buffer).toString("hex")}`;
const uint8 = this.serialize();
return `0x${Buffer.from(uint8.buffer, uint8.byteOffset, uint8.byteLength).toString("hex")}`;
};

bindings.PublicKey.prototype.toHex = function toHex(compress) {
return `0x${Buffer.from(this.serialize(compress).buffer).toString("hex")}`;
const uint8 = this.serialize(compress);
return `0x${Buffer.from(uint8.buffer, uint8.byteOffset, uint8.byteLength).toString("hex")}`;
};

bindings.Signature.prototype.toHex = function toHex(compress) {
return `0x${Buffer.from(this.serialize(compress).buffer).toString("hex")}`;
const uint8 = this.serialize(compress);
return `0x${Buffer.from(uint8.buffer, uint8.byteOffset, uint8.byteLength).toString("hex")}`;
};

return {
Expand Down

0 comments on commit acc608a

Please sign in to comment.