Comparing version 0.1.21 to 0.1.22
{ | ||
"name": "eth-lib", | ||
"version": "0.1.21", | ||
"version": "0.1.22", | ||
"description": "Lightweight Ethereum libraries", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -58,3 +58,3 @@ const Bytes = require("./bytes"); | ||
const vrs = {v: Bytes.toNumber(vals[0]), r:vals[1].slice(2), s:vals[2].slice(2)}; | ||
const ecPublicKey = secp256k1.recoverPubKey(new Buffer(hash.slice(2), "hex"), vrs, vrs.v < 2 ? vrs.v : 1 - (vrs.v % 2)); // because odd vals mean v=0... sadly that means v=0 means v=1... I hate that | ||
const ecPublicKey = secp256k1.recoverPubKey(new Buffer(hash.slice(2), "hex"), vrs, vrs.v < 2 ? vrs.v : 1 - (vrs.v % 2)); // because odd vals mean v=0... sadly that means v=0 means v=1... I hate that | ||
const publicKey = "0x" + ecPublicKey.encode("hex", false).slice(2); | ||
@@ -80,3 +80,3 @@ const publicHash = keccak256(publicKey); | ||
const signingData = transactionSigningData(tx); | ||
const signature = makeSign(Nat.toNumber(tx.chainId || "0x1") * 2 + 35)(keccak256(signingData), privateKey); | ||
const signature = makeSign(Nat.toNumber(tx.chainId || "0x1") * 2 + 35)(keccak256(signingData), privateKey); | ||
const rawTransaction = rlp.decode(signingData).slice(0,6).concat(decodeSignature(signature)); | ||
@@ -83,0 +83,0 @@ return rlp.encode(rawTransaction); |
@@ -29,3 +29,3 @@ const A = require("./array.js"); | ||
let hex = num.toString(16); | ||
return hex.length % 2 === 0 ? "0x" + hex : "0x0" + hex ; | ||
return hex.length % 2 === 0 ? "0x" + hex : "0x0" + hex ; | ||
}; | ||
@@ -69,3 +69,3 @@ | ||
const fromNat = bn => | ||
bn === "0x0" ? "0x" : bn.length % 2 === 0 ? bn : "0x0" + bn.slice(2); | ||
bn === "0x0" ? "0x" : bn.length % 2 === 0 ? bn : "0x0" + bn.slice(2); | ||
@@ -72,0 +72,0 @@ const toNat = bn => |
@@ -17,3 +17,3 @@ const Bytes = require("./bytes"); | ||
const mid = (b64 >>> 0) & 3; | ||
return inis[ini] + mids[mid]; | ||
return inis[ini] + mids[mid]; | ||
} | ||
@@ -31,8 +31,8 @@ | ||
let b64s = [], b64; | ||
for (let i = 0, l = Math.ceil(bytes.length * 8 / 6); i < l; ++i) { | ||
let j = i / 8 * 6 | 0; | ||
for (let i = 0, l = Math.ceil(bytes.length * 8 / 6); i < l; ++i) { | ||
let j = i / 8 * 6 | 0; | ||
b64s.push | ||
( i % 4 === 0 ? (bytes[j+0] / 4 | 0) | ||
: i % 4 === 1 ? bytes[j+0] % 4 * 16 + (bytes[j+1] / 16 | 0) | ||
: i % 4 === 2 ? bytes[j+0] % 16 * 4 + (bytes[j+1] / 64 | 0) | ||
( i % 4 === 0 ? (bytes[j+0] / 4 | 0) | ||
: i % 4 === 1 ? bytes[j+0] % 4 * 16 + (bytes[j+1] / 16 | 0) | ||
: i % 4 === 2 ? bytes[j+0] % 16 * 4 + (bytes[j+1] / 64 | 0) | ||
: bytes[j+0] % 64 * 1); | ||
@@ -45,7 +45,7 @@ } | ||
let bytes = []; | ||
for (let i = 0, l = Math.floor(b64s.length * 6 / 8); i < l; ++i) { | ||
let j = i / 6 * 8 | 0; | ||
for (let i = 0, l = Math.floor(b64s.length * 6 / 8); i < l; ++i) { | ||
let j = i / 6 * 8 | 0; | ||
bytes.push | ||
( i % 3 === 0 ? b64s[j+0] % 64 * 4 + (b64s[j+1] / 16 | 0) | ||
: i % 3 === 1 ? b64s[j+0] % 16 * 16 + (b64s[j+1] / 4 | 0) | ||
( i % 3 === 0 ? b64s[j+0] % 64 * 4 + (b64s[j+1] / 16 | 0) | ||
: i % 3 === 1 ? b64s[j+0] % 16 * 16 + (b64s[j+1] / 4 | 0) | ||
: b64s[j+0] % 4 * 64 + (b64s[j+1] / 1 | 0)); | ||
@@ -52,0 +52,0 @@ } |
const merge = a => b => { | ||
let c = {}; | ||
for (let key in a) | ||
c[key] = a[key]; | ||
c[key] = a[key]; | ||
for (let key in b) | ||
c[key] = b[key]; | ||
c[key] = b[key]; | ||
return c; | ||
@@ -8,0 +8,0 @@ } |
@@ -13,3 +13,3 @@ // The RLP format | ||
const padEven = str => | ||
str.length % 2 === 0 ? str : "0" + str; | ||
str.length % 2 === 0 ? str : "0" + str; | ||
@@ -25,3 +25,3 @@ const uint = num => | ||
const hex = tree.slice(2); | ||
const pre = hex.length != 2 || hex >= "80" ? length(hex.length / 2, 128) : ""; | ||
const pre = hex.length != 2 || hex >= "80" ? length(hex.length / 2, 128) : ""; | ||
return pre + hex; | ||
@@ -28,0 +28,0 @@ } else { |
@@ -8,3 +8,3 @@ const F = require("forall"); | ||
form: "a JavaScript String starting with a `0x`, followed by an even number of low-case hex chars (i.e., `0123456789abcdef`)", | ||
rand: () => "0x" + A.generate((Math.random() * 16 | 0) * 2, () => (Math.random() * 16 | 0).toString(16)).join(""), | ||
rand: () => "0x" + A.generate((Math.random() * 16 | 0) * 2, () => (Math.random() * 16 | 0).toString(16)).join(""), | ||
test: value => typeof value === "string" && /^0x([0-9a-f][0-9a-f])*$/.test(value), | ||
@@ -19,3 +19,3 @@ }).__name("Bytes").__desc("any arbitrary data"); | ||
.__name("NBytes(" + bytes + ")") | ||
.__desc("any arbitrary data of exactly " + bytes + "-byte" + (bytes > 1 ? "s" : "")); | ||
.__desc("any arbitrary data of exactly " + bytes + "-byte" + (bytes > 1 ? "s" : "")); | ||
@@ -22,0 +22,0 @@ F.Nat = F(F.Type, { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44922
20
1220