@ethersproject/bytes
Advanced tools
Comparing version 5.5.0 to 5.6.0
@@ -1,2 +0,2 @@ | ||
export declare const version = "bytes/5.5.0"; | ||
export declare const version = "bytes/5.6.0"; | ||
//# sourceMappingURL=_version.d.ts.map |
@@ -1,2 +0,2 @@ | ||
export const version = "bytes/5.5.0"; | ||
export const version = "bytes/5.6.0"; | ||
//# sourceMappingURL=_version.js.map |
@@ -23,2 +23,4 @@ export declare type Bytes = ArrayLike<number>; | ||
v: number; | ||
yParityAndS: string; | ||
compact: string; | ||
} | ||
@@ -25,0 +27,0 @@ export declare function isBytesLike(value: any): value is BytesLike; |
@@ -272,13 +272,24 @@ "use strict"; | ||
recoveryParam: 0, | ||
v: 0 | ||
v: 0, | ||
yParityAndS: "0x", | ||
compact: "0x" | ||
}; | ||
if (isBytesLike(signature)) { | ||
const bytes = arrayify(signature); | ||
if (bytes.length !== 65) { | ||
logger.throwArgumentError("invalid signature string; must be 65 bytes", "signature", signature); | ||
let bytes = arrayify(signature); | ||
// Get the r, s and v | ||
if (bytes.length === 64) { | ||
// EIP-2098; pull the v from the top bit of s and clear it | ||
result.v = 27 + (bytes[32] >> 7); | ||
bytes[32] &= 0x7f; | ||
result.r = hexlify(bytes.slice(0, 32)); | ||
result.s = hexlify(bytes.slice(32, 64)); | ||
} | ||
// Get the r, s and v | ||
result.r = hexlify(bytes.slice(0, 32)); | ||
result.s = hexlify(bytes.slice(32, 64)); | ||
result.v = bytes[64]; | ||
else if (bytes.length === 65) { | ||
result.r = hexlify(bytes.slice(0, 32)); | ||
result.s = hexlify(bytes.slice(32, 64)); | ||
result.v = bytes[64]; | ||
} | ||
else { | ||
logger.throwArgumentError("invalid signature string", "signature", signature); | ||
} | ||
// Allow a recid to be used as the v | ||
@@ -387,2 +398,4 @@ if (result.v < 27) { | ||
} | ||
result.yParityAndS = result._vs; | ||
result.compact = result.r + result.yParityAndS.substring(2); | ||
return result; | ||
@@ -389,0 +402,0 @@ } |
@@ -1,2 +0,2 @@ | ||
export declare const version = "bytes/5.5.0"; | ||
export declare const version = "bytes/5.6.0"; | ||
//# sourceMappingURL=_version.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.version = void 0; | ||
exports.version = "bytes/5.5.0"; | ||
exports.version = "bytes/5.6.0"; | ||
//# sourceMappingURL=_version.js.map |
@@ -23,2 +23,4 @@ export declare type Bytes = ArrayLike<number>; | ||
v: number; | ||
yParityAndS: string; | ||
compact: string; | ||
} | ||
@@ -25,0 +27,0 @@ export declare function isBytesLike(value: any): value is BytesLike; |
@@ -288,13 +288,24 @@ "use strict"; | ||
recoveryParam: 0, | ||
v: 0 | ||
v: 0, | ||
yParityAndS: "0x", | ||
compact: "0x" | ||
}; | ||
if (isBytesLike(signature)) { | ||
var bytes = arrayify(signature); | ||
if (bytes.length !== 65) { | ||
logger.throwArgumentError("invalid signature string; must be 65 bytes", "signature", signature); | ||
// Get the r, s and v | ||
if (bytes.length === 64) { | ||
// EIP-2098; pull the v from the top bit of s and clear it | ||
result.v = 27 + (bytes[32] >> 7); | ||
bytes[32] &= 0x7f; | ||
result.r = hexlify(bytes.slice(0, 32)); | ||
result.s = hexlify(bytes.slice(32, 64)); | ||
} | ||
// Get the r, s and v | ||
result.r = hexlify(bytes.slice(0, 32)); | ||
result.s = hexlify(bytes.slice(32, 64)); | ||
result.v = bytes[64]; | ||
else if (bytes.length === 65) { | ||
result.r = hexlify(bytes.slice(0, 32)); | ||
result.s = hexlify(bytes.slice(32, 64)); | ||
result.v = bytes[64]; | ||
} | ||
else { | ||
logger.throwArgumentError("invalid signature string", "signature", signature); | ||
} | ||
// Allow a recid to be used as the v | ||
@@ -403,2 +414,4 @@ if (result.v < 27) { | ||
} | ||
result.yParityAndS = result._vs; | ||
result.compact = result.r + result.yParityAndS.substring(2); | ||
return result; | ||
@@ -405,0 +418,0 @@ } |
{ | ||
"author": "Richard Moore <me@ricmoo.com>", | ||
"dependencies": { | ||
"@ethersproject/logger": "^5.5.0" | ||
"@ethersproject/logger": "^5.6.0" | ||
}, | ||
@@ -18,3 +18,3 @@ "description": "Bytes utility functions for ethers.", | ||
], | ||
"gitHead": "5899c8aec0600dca42d7e24fc215037aa48917f2", | ||
"gitHead": "b8cda5dffdcb688e38d7c6a0aec4c7b8b59c1af5", | ||
"keywords": [ | ||
@@ -42,5 +42,5 @@ "Ethereum", | ||
"sideEffects": false, | ||
"tarballHash": "0x1daef684cc067d9e39c56da0288767a1d0d210074513e60fac0b86d8243278fc", | ||
"tarballHash": "0xc7e0cbde21c544c2ca2ec8cb806ad1c3781ef1820c97dc24f65a9a0a96a4c5ad", | ||
"types": "./lib/index.d.ts", | ||
"version": "5.5.0" | ||
"version": "5.6.0" | ||
} |
@@ -1,1 +0,1 @@ | ||
export const version = "bytes/5.5.0"; | ||
export const version = "bytes/5.6.0"; |
@@ -49,2 +49,5 @@ "use strict"; | ||
v: number; | ||
yParityAndS: string | ||
compact: string; | ||
} | ||
@@ -332,2 +335,3 @@ | ||
export function splitSignature(signature: SignatureLike): Signature { | ||
const result = { | ||
@@ -338,16 +342,29 @@ r: "0x", | ||
recoveryParam: 0, | ||
v: 0 | ||
v: 0, | ||
yParityAndS: "0x", | ||
compact: "0x" | ||
}; | ||
if (isBytesLike(signature)) { | ||
const bytes: Uint8Array = arrayify(signature); | ||
if (bytes.length !== 65) { | ||
logger.throwArgumentError("invalid signature string; must be 65 bytes", "signature", signature); | ||
} | ||
let bytes: Uint8Array = arrayify(signature); | ||
// Get the r, s and v | ||
result.r = hexlify(bytes.slice(0, 32)); | ||
result.s = hexlify(bytes.slice(32, 64)); | ||
result.v = bytes[64]; | ||
if (bytes.length === 64) { | ||
// EIP-2098; pull the v from the top bit of s and clear it | ||
result.v = 27 + (bytes[32] >> 7); | ||
bytes[32] &= 0x7f; | ||
result.r = hexlify(bytes.slice(0, 32)); | ||
result.s = hexlify(bytes.slice(32, 64)); | ||
} else if (bytes.length === 65) { | ||
result.r = hexlify(bytes.slice(0, 32)); | ||
result.s = hexlify(bytes.slice(32, 64)); | ||
result.v = bytes[64]; | ||
} else { | ||
logger.throwArgumentError("invalid signature string", "signature", signature); | ||
} | ||
// Allow a recid to be used as the v | ||
@@ -454,2 +471,5 @@ if (result.v < 27) { | ||
result.yParityAndS = result._vs; | ||
result.compact = result.r + result.yParityAndS.substring(2); | ||
return result; | ||
@@ -456,0 +476,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
81010
1305
Updated@ethersproject/logger@^5.6.0