Skip to content
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
10 changes: 9 additions & 1 deletion com/raugfer/crypto/coins.java
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ public class coins {
dict attrs = new dict();
attrs.put("overloads", "ethereum");
attrs.put("transfer.gaslimit", 150000);
attrs.put("contract.address", (_testnetfun) (testnet -> testnet ? "0x5a89997f38429b5866809dc40a6d677c521ebab9" : "0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359"));
attrs.put("contract.address", (_testnetfun) (testnet -> testnet ? "0x1f1cb7a560db6e7cbdff2e6ec4544834acf2cfde" : "0x6b175474e89094c44da98b954eedeac495271d0f"));
coins.put("dai", attrs);
}

Expand Down Expand Up @@ -675,6 +675,14 @@ public class coins {
coins.put("omisego", attrs);
}

static {
dict attrs = new dict();
attrs.put("overloads", "ethereum");
attrs.put("transfer.gaslimit", 150000);
attrs.put("contract.address", (_testnetfun) (testnet -> testnet ? "0x5a89997f38429b5866809dc40a6d677c521ebab9" : "0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359"));
coins.put("sai", attrs);
}

static {
dict attrs = new dict();
attrs.put("overloads", "ethereum");
Expand Down
2 changes: 1 addition & 1 deletion com/raugfer/crypto/nist256p1.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public static boolean ver(BigInteger[] P, BigInteger h, Object[] S) {
BigInteger s = (BigInteger) S[1];
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");
if (s.compareTo(n.shiftRight(1)) > 0) throw new IllegalArgumentException("Out of range");
BigInteger w = s.modPow(n.subtract(BigInteger.valueOf(2)), n);
BigInteger u = h.multiply(w).mod(n), v = r.multiply(w).mod(n);
BigInteger[] Q = add(mul(G, u), mul(P, v));
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 @@ -120,7 +120,7 @@ public static boolean ver(BigInteger[] P, BigInteger h, Object[] S) {
BigInteger s = (BigInteger) S[1];
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");
if (s.compareTo(n.shiftRight(1)) > 0) throw new IllegalArgumentException("Out of range");
BigInteger w = s.modPow(n.subtract(BigInteger.valueOf(2)), n);
BigInteger u = h.multiply(w).mod(n), v = r.multiply(w).mod(n);
BigInteger[] Q = add(mul(G, u), mul(P, v));
Expand Down
25 changes: 6 additions & 19 deletions com/raugfer/crypto/transaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -265,19 +265,6 @@ private static pair<Object, byte[]> parse_rlp(byte[] b) {
throw new IllegalArgumentException("Unknown type");
}

private static byte[] trim_leading_zeroes(byte[] bytes) {
int offset = 0;
for (; offset < bytes.length - 1; offset++) {
if (bytes[offset] != (byte) 0) {
break;
}
}
int newLength = bytes.length - offset;
byte[] copy = new byte[newLength];
System.arraycopy(bytes, offset, copy, 0, newLength);
return copy;
}

private static final String[][] RIPPLE_FIELDS = {
{"1", "2", "TransactionType"},
{"2", "2", "Flags"},
Expand Down Expand Up @@ -741,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] = trim_leading_zeroes(r);
l[8] = trim_leading_zeroes(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 @@ -1380,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