Skip to content

fix ethereum rlp non-canonical bug (reviewed) #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion com/raugfer/crypto/nist256p1.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion com/raugfer/crypto/secp256k1.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion com/raugfer/crypto/service.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions com/raugfer/crypto/transaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
}
Expand Down