diff --git a/com/raugfer/crypto/nist256p1.java b/com/raugfer/crypto/nist256p1.java index 094908b..12f52a4 100644 --- a/com/raugfer/crypto/nist256p1.java +++ b/com/raugfer/crypto/nist256p1.java @@ -133,7 +133,7 @@ public static BigInteger[] rec(BigInteger h, Object[] S) { if (!rng(h)) throw new IllegalArgumentException("Out of range"); BigInteger r = (BigInteger) S[0]; BigInteger s = (BigInteger) S[1]; - boolean odd = (boolean) S[3]; + boolean odd = (boolean) S[2]; if (!rng(r)) throw new IllegalArgumentException("Out of range"); if (!rng(s)) throw new IllegalArgumentException("Out of range"); if (s.compareTo(n.shiftRight(2)) > 0) throw new IllegalArgumentException("Out of range"); diff --git a/com/raugfer/crypto/secp256k1.java b/com/raugfer/crypto/secp256k1.java index 026194b..bcb0fba 100644 --- a/com/raugfer/crypto/secp256k1.java +++ b/com/raugfer/crypto/secp256k1.java @@ -133,7 +133,7 @@ public static BigInteger[] rec(BigInteger h, Object[] S) { if (!rng(h)) throw new IllegalArgumentException("Out of range"); BigInteger r = (BigInteger) S[0]; BigInteger s = (BigInteger) S[1]; - boolean odd = (boolean) S[3]; + boolean odd = (boolean) S[2]; if (!rng(r)) throw new IllegalArgumentException("Out of range"); if (!rng(s)) throw new IllegalArgumentException("Out of range"); if (s.compareTo(n.shiftRight(2)) > 0) throw new IllegalArgumentException("Out of range"); diff --git a/com/raugfer/crypto/service.java b/com/raugfer/crypto/service.java index 587a982..796ad88 100644 --- a/com/raugfer/crypto/service.java +++ b/com/raugfer/crypto/service.java @@ -36,7 +36,7 @@ public static BigInteger estimate_fee(Object _source_addresses, BigInteger amoun BigInteger balance = BigInteger.ZERO; BigInteger estimatefee = BigInteger.ZERO; for (int i = 1; i <= utxos.length; i++) { - int estimatesize = 4 + (1 + i * (32 + 4 + (1 + (1 + 73) + (1 + 33)) + 4)) + (1 + 2 * (8 + (1 + 25))) + 4; + int estimatesize = 4 + (1 + i * (32 + 4 + (1 + (1 + 72) + (1 + 33)) + 4)) + (1 + 2 * (8 + (1 + 25))) + 4; estimatefee = fee.multiply(BigInteger.valueOf(estimatesize)).shiftRight(10); balance = balance.add((BigInteger) utxos[i-1].get("amount")); if (balance.compareTo(amount.add(estimatefee)) >= 0) break; diff --git a/com/raugfer/crypto/transaction.java b/com/raugfer/crypto/transaction.java index d361126..bcf3d7b 100644 --- a/com/raugfer/crypto/transaction.java +++ b/com/raugfer/crypto/transaction.java @@ -728,9 +728,9 @@ public static byte[] transaction_encode(dict fields, String coin, boolean testne l[4] = nlzint(value); l[5] = data; if (signed) { - l[6] = v; - l[7] = r; - l[8] = s; + l[6] = nlzint(binint.b2n(v)); + l[7] = nlzint(binint.b2n(r)); + l[8] = nlzint(binint.b2n(s)); } return rlp(l); } @@ -1367,9 +1367,9 @@ public static dict transaction_decode(byte[] txn, String coin, boolean testnet) fields.put("value", parse_nlzint((byte[]) l[4]).l); fields.put("data", l[5]); if (l.length > 6) { - fields.put("v", l[6]); - fields.put("r", l[7]); - fields.put("s", l[8]); + fields.put("v", binint.n2b(parse_nlzint((byte[]) l[6]).l, 1)); + fields.put("r", binint.n2b(parse_nlzint((byte[]) l[7]).l, 32)); + fields.put("s", binint.n2b(parse_nlzint((byte[]) l[8]).l, 32)); } return fields; }