Updated on 2026-08-14

This commit is contained in:
Tangem 2018-09-07 11:28:10 +03:00
parent 5c6ea5ca04
commit ff6679eaad
11 changed files with 15 additions and 391 deletions

View file

@ -197,11 +197,11 @@ public class Cryptonit_OtherAPI {
String signature = calcSignature();
Log.e("CRYPTONIT", "user: " + userId);
Log.e("CRYPTONIT", "key: " + key);
Log.e("CRYPTONIT", "secret: " + secret);
Log.e("CRYPTONIT", "nonce: " + nonce);
Log.e("CRYPTONIT", "signature: " + signature);
// Log.e("CRYPTONIT", "user: " + userId);
// Log.e("CRYPTONIT", "key: " + key);
// Log.e("CRYPTONIT", "secret: " + secret);
// Log.e("CRYPTONIT", "nonce: " + nonce);
// Log.e("CRYPTONIT", "signature: " + signature);
api.getBalance(cryptoCurrency, fiatCurrency,
RequestBody.create(MediaType.parse("text/plain"), key),
@ -222,12 +222,12 @@ public class Cryptonit_OtherAPI {
String signature = calcSignature();
Log.e("CRYPTONIT", "user: " + userId);
Log.e("CRYPTONIT", "key: " + key);
Log.e("CRYPTONIT", "secret: " + secret);
Log.e("CRYPTONIT", "nonce: " + nonce);
Log.e("CRYPTONIT", "signature: " + signature);
// Log.e("CRYPTONIT", "user: " + userId);
// Log.e("CRYPTONIT", "key: " + key);
// Log.e("CRYPTONIT", "secret: " + secret);
// Log.e("CRYPTONIT", "nonce: " + nonce);
// Log.e("CRYPTONIT", "signature: " + signature);
//
api.cryptoWithdrawal(
RequestBody.create(MediaType.parse("text/plain"), currency),
RequestBody.create(MediaType.parse("text/plain"), amount),

View file

@ -233,9 +233,9 @@ public class Kraken {
initApi();
Log.e("kraken", "key: " + key);
Log.e("kraken", "secret: " + secret);
Log.e("kraken", "nonce: " + nonce);
// Log.e("kraken", "key: " + key);
// Log.e("kraken", "secret: " + secret);
// Log.e("kraken", "nonce: " + nonce);
api.getBalance(nonce.toString())
.subscribeOn(Schedulers.io())

View file

@ -411,6 +411,7 @@ public class ServerApiHelper {
Log.e(TAG, "LastVersion onFailure " + t.getMessage());
}
});
}
}

View file

@ -63,73 +63,6 @@ public class CardCrypto {
}
// public static boolean isCanonical(BigInteger s) {
//
// ECNamedCurveParameterSpec spec = ECNamedCurveTable.getParameterSpec("secp256k1");
//
// BigInteger HALF_CURVE_ORDER = spec.getN().shiftRight(1);
// return s.compareTo(HALF_CURVE_ORDER) <= 0;
// }
//
// public static BigInteger toCanonicalised(BigInteger s) {
//
// // The order of the curve is the number of valid points that exist on that curve. If S is in the upper
// // half of the number of valid points, then bring it back to the lower half. Otherwise, imagine that
// // N = 10
// // s = 8, so (-8 % 10 == 2) thus both (r, 8) and (r, 2) are valid solutions.
// // 10 - 8 == 2, giving us always the latter solution, which is canonical.
// ECNamedCurveParameterSpec spec = ECNamedCurveTable.getParameterSpec("secp256k1");
// if(!isCanonical(s)) {
// BigInteger canon = spec.getN().subtract(s);
// //Log.e("TX_SIGN", "non Canonical S");
// return canon;
// }
//
// return s;
//
// }
//
// public static BigInteger[] calcSign2(byte[] priv, byte[] hash)
// {
// ECDSASigner signer = new ECDSASigner();
// BigInteger d = new BigInteger(priv);
//
// ECNamedCurveParameterSpec CURVE_PARAMS = ECNamedCurveTable.getParameterSpec("secp256k1");
// ECDomainParameters CURVE = new ECDomainParameters(CURVE_PARAMS.getCurve(), CURVE_PARAMS.getG(), CURVE_PARAMS.getN(),
// CURVE_PARAMS.getH());
// ECPrivateKeyParameters params = new ECPrivateKeyParameters(d, CURVE);
// //ECPublicKeyParameters params = new ECPublicKeyParameters(CURVE.getCurve().decodePoint(pub), CURVE);
// signer.init(true, params);
// BigInteger[] rs = signer.generateSignature(hash);
// return rs;
//
// }
//
// public static byte[] Signature3(byte[] privateKeyArray, byte[] data) throws Exception
// {
// byte[] hash=Util.calculateSHA256(data);
// BigInteger[] signBI=calcSign2(privateKeyArray, hash);
// //signBI[0]=toCanonicalised(signBI[0]);
// signBI[1]=toCanonicalised(signBI[1]);
// byte[] r = signBI[0].toByteArray();
// byte[] s = signBI[1].toByteArray();
//
// byte[] res = new byte[64];
// if( r.length==32 ) {
// System.arraycopy(r, 0, res, 0, r.length);
// }else if( r.length==33 && r[0]==0 ){
// System.arraycopy(r, 1, res, 0, r.length-1);
// }else {
// throw new Exception("unsupported r-length");
// }
// if( s.length==32 ) {
// System.arraycopy(s, 0, res, 32, 32);
// }else{
// throw new Exception("unsupported s-length");
// }
// return res;
// }
public static byte[] Signature(byte[] privateKeyArray, byte[] data) throws Exception {
ECNamedCurveParameterSpec spec = ECNamedCurveTable.getParameterSpec("secp256k1");
KeyFactory factory = KeyFactory.getInstance("EC", "SC");

View file

@ -283,64 +283,6 @@ public class CardProtocol {
}
}
// send command APDU, get response APDU, and display HEX data to user
// private ResponseApdu SendAndReceive(CommandApdu cmdApdu, boolean breakOnNeedPause) throws Exception {
// if (mCard.encryptionMode != TangemCard.EncryptionMode.None) {
// if (sessionKey == null) {
// run_OpenSession(mCard.encryptionMode);
// }
// cmdApdu.Crypt(sessionKey);
// }
// cmdApdu.setP1(mCard.encryptionMode.getP());
// byte[] cmdBytes = cmdApdu.toBytes();
// String cmdStr = CommandApdu.toString(cmdBytes, cmdApdu.getLc());
// Log.v("NFC", String.format("<< [%s]: %s", cmdApdu.getCommandName(), cmdStr));
// byte[] rsp;
// ResponseApdu rspApdu;
// try {
// do {
// try {
// mNotifications.onReadBeforeRequest(mIsoDep.getTimeout());
// try {
// rsp = mIsoDep.transceive(cmdBytes);
// } finally {
// mNotifications.onReadAfterRequest();
// }
// } catch (IOException e) {
// if (e.getMessage().contains("length exceeds supported maximum") && mIsoDep.isExtendedLengthApduSupported()) {
// throw new TangemException_ExtendedLengthNotSupported(e.getMessage());
// }
// throw e;
// }
// if (mCard.encryptionMode != TangemCard.EncryptionMode.None) {
// rspApdu = ResponseApdu.Decrypt(rsp, sessionKey);
// } else {
// rspApdu = new ResponseApdu(rsp);
// }
//
// if (rspApdu.isParsedWithError()) {
// Log.v("NFC", String.format(">> [%s]: %s", cmdApdu.getCommandName(), Util.bytesToHex(rsp)));
// throw new TangemException(rspApdu.getParseErroMessage());
// } else if (rspApdu.getSW1SW2() == SW.NEED_PAUSE && mNotifications != null) {
// int remainingPause = rspApdu.getTLVs().getTagAsInt(TLV.Tag.TAG_Pause) * 10;
// Log.v("NFC", String.format(">> Security delay, remaining %f s", remainingPause / 1000.0));
// if (breakOnNeedPause) {
// break;
// } else {
// mNotifications.onReadWait(remainingPause);
// }
// } else {
// Log.v("NFC", String.format(">> [%s]: %s", cmdApdu.getCommandName(), Util.bytesToHex(rsp)));
// }
// } while (rspApdu.getSW1SW2() == SW.NEED_PAUSE);
// } finally {
// mNotifications.onReadWait(0);
// }
//
// return rspApdu;
// }
private ResponseApdu SendAndReceive(CommandApdu cmdApdu, boolean breakOnNeedPause) throws Exception {
if (mCard.encryptionMode != TangemCard.EncryptionMode.None) {
if (sessionKey == null) {

View file

@ -1,88 +0,0 @@
package com.tangem.domain.cardReader;
import android.content.Context;
import android.nfc.TagLostException;
import android.nfc.tech.IsoDep;
import com.tangem.util.Util;
import java.io.IOException;
public class CustomCardReader implements Runnable {
protected NfcManager mNfcManager;
public interface UiCallbacks {
// display console messages
void onMessageSend(String raw, String name);
void onMessageRcv(String raw, String name);
void onOkay(String message);
void onError(String message);
void onStart(String message);
void onAction(String message, String name);
void onSeparator();
// clear console messages
void clearMessages();
// ui listeners
void setUserSelectListener(UiListener callback);
// cleanup, if needed
void onFinish(boolean err);
}
public interface UiListener {
void onUserSelect(String aid);
}
public static final int SW_NO_ERROR = 0x9000;
public static final int SW_GET_RESPONSE = 0x6700;
protected IsoDep mIsoDep;
protected UiCallbacks mUiCallbacks;
protected String mAid;
protected byte[] mAidBytes;
protected Context mContext;
public CustomCardReader(Context context, NfcManager manager, IsoDep isoDep, String aid, UiCallbacks uiCallbacks) {
this.mIsoDep = isoDep;
this.mAid = aid;
this.mAidBytes = Util.hexToBytes(aid);
this.mUiCallbacks = uiCallbacks;
this.mNfcManager = manager;
this.mContext = context;
}
// send command APDU, get response APDU, and display HEX data to user
protected ResponseApdu sendAndRcv(CommandApdu cmdApdu)
throws TagLostException, IOException {
byte[] cmdBytes = cmdApdu.toBytes();
String cmdStr = CommandApdu.toString(cmdBytes, cmdApdu.getLc());
//mUiCallbacks.onMessageSend(cmdStr, cmdApdu.getCommandName());
byte[] rsp = mIsoDep.transceive(cmdBytes);
ResponseApdu rspApdu = new ResponseApdu(rsp);
byte[] data = rspApdu.getData();
//mUiCallbacks.onMessageRcv(Util.bytesToHex(rsp), cmdApdu.getCommandName());
if (rspApdu.isParsedWithError()) {
mUiCallbacks.onError(rspApdu.getParseErroMessage());
}
/*
Log.d(TAG, "response APDU: " + Util.bytesToHex(rsp));
if (data.length > 0) {
Log.d(TAG, TLVUtil.prettyPrintAPDUResponse(data));
}
*/
return rspApdu;
}
@Override
public void run() {
}
}

View file

@ -5,9 +5,6 @@ package com.tangem.domain.cardReader;
*/
public enum INS {
Unknown(0x00),
BootROM_SOS(0x40),
BootROM_Tangem(0xF0),
Personalize(0xF1),
Read(0xF2),
VerifyCard(0xF3),
ValidateCard(0xF4),

View file

@ -27,7 +27,6 @@ public class TLV {
TAG_SettingsMask(0x0A),
TAG_CardData(0x0C),
TAG_NDEFData(0x0D),
TAG_CreateWalletAtPersonalize(0x0E),
TAG_Health(0x0F),
TAG_PIN(0x10),
@ -72,11 +71,6 @@ public class TLV {
TAG_RemainingSignatures(0x62),
TAG_SignedHashes(0x63),
TAG_Wallet_PrivateKey(0x70),
TAG_Card_PrivateKey(0x71),
TAG_Block_Reason(0x72),
TAG_Firmware(0x80),
TAG_Batch(0x81),
TAG_ManufactureDateTime(0x82),

View file

@ -67,9 +67,6 @@ public class Issuer {
public static void Init(Context context) {
try {
// JsonArray jaIssuers=loadIssuersFile();
//
Issuer unknown = new Issuer();
unknown.id = "UNKNOWN";
unknown.officialName = "UNKNOWN";
@ -82,56 +79,11 @@ public class Issuer {
}
}
instances.add(0, unknown);
// for (JsonElement jeIssuer : jaIssuers) {
// Issuer instance = new Gson().fromJson(jeIssuer, Issuer.class);
// instances.add(instance);
// }
} catch (Exception e) {
e.printStackTrace();
}
}
// private static JsonArray loadIssuersFile() throws IOException {
// String result;
// JsonParser jsonParser = new JsonParser();
// try (BufferedReader reader = Files.newReader(new File("Issuers.json"), StandardCharsets.UTF_8)) {
// String str;
// StringBuilder buf = new StringBuilder();
// while ((str = reader.readLine()) != null) {
// buf.append(str);
// buf.append("\n");
// }
// result = buf.toString();
// }
// return jsonParser.parse(result).getAsJsonArray();
// }
//
// static String ReadJSONResource(Context mContext, int id) {
// Resources resources = mContext.getResources();
// InputStream resourceReader = resources.openRawResource(id);
// Writer writer = new StringWriter();
// try {
// try (BufferedReader reader = new BufferedReader(new InputStreamReader(resourceReader, "UTF-8"))) {
// String line = reader.readLine();
// while (line != null) {
// writer.write(line);
// line = reader.readLine();
// }
// }
// } catch (Exception e) {
// Log.e("ReadJSONResource", "Unhandled exception while using JSONResourceReader", e);
// } finally {
// try {
// resourceReader.close();
// } catch (Exception e) {
// Log.e("ReadJSONResource", "Unhandled exception while using JSONResourceReader", e);
// }
// }
//
// return writer.toString();
// }
public byte[] getPublicDataKey() throws Exception {
if (dataKey == null)
throw new Exception("Data key not specified!");

View file

@ -5,29 +5,6 @@ package com.tangem.domain.wallet;
*/
public enum Manufacturer {
// Unknown("", "Unknown", new byte[]{}),
// SMARTCASH_AG("SMART CASH AG","SMART CASH AG",
// new byte[]{0x04,
// (byte) 0x4F, (byte) 0x53, (byte) 0x90, (byte) 0x2D, (byte) 0x50, (byte) 0xE2, (byte) 0xBB, (byte) 0x16,
// (byte) 0xD3, (byte) 0xDD, (byte) 0xC7, (byte) 0xA2, (byte) 0x03, (byte) 0x97, (byte) 0x28, (byte) 0x5E,
// (byte) 0x94, (byte) 0x21, (byte) 0x53, (byte) 0x69, (byte) 0x59, (byte) 0x8C, (byte) 0xE4, (byte) 0xDD,
// (byte) 0x62, (byte) 0x42, (byte) 0xDD, (byte) 0xB4, (byte) 0x5B, (byte) 0x96, (byte) 0xA1, (byte) 0x03,
// (byte) 0x1A, (byte) 0xF5, (byte) 0xC9, (byte) 0x73, (byte) 0x94, (byte) 0xC6, (byte) 0xF9, (byte) 0xC8,
// (byte) 0xD7, (byte) 0x6F, (byte) 0x38, (byte) 0xF9, (byte) 0x65, (byte) 0xCB, (byte) 0xA8, (byte) 0xAE,
// (byte) 0x85, (byte) 0xAF, (byte) 0xF7, (byte) 0x68, (byte) 0x55, (byte) 0xDC, (byte) 0xAA, (byte) 0x08,
// (byte) 0xF3, (byte) 0xCD, (byte) 0x15, (byte) 0x43, (byte) 0x04, (byte) 0x19, (byte) 0xF4, (byte) 0x49}),
// DEVELOPERS_SMARTCASH_AG("DEVELOP CASH AG","SMART CASH AG (DEVELOPERS)",
// new byte[]{0x04,
// (byte) 0xBA, (byte) 0xB8, (byte) 0x6D, (byte) 0x56, (byte) 0x29, (byte) 0x8C, (byte) 0x99, (byte) 0x6F,
// (byte) 0x56, (byte) 0x4A, (byte) 0x84, (byte) 0xFC, (byte) 0x88, (byte) 0xE2, (byte) 0x8A, (byte) 0xED,
// (byte) 0x38, (byte) 0x18, (byte) 0x4B, (byte) 0x12, (byte) 0xF0, (byte) 0x7E, (byte) 0x51, (byte) 0x91,
// (byte) 0x13, (byte) 0xBE, (byte) 0xF4, (byte) 0x8C, (byte) 0x76, (byte) 0xF3, (byte) 0xDF, (byte) 0x3A,
//
// (byte) 0xDC, (byte) 0x30, (byte) 0x35, (byte) 0x99, (byte) 0xB0, (byte) 0x8A, (byte) 0xC0, (byte) 0x5B,
// (byte) 0x55, (byte) 0xEC, (byte) 0x3D, (byte) 0xF9, (byte) 0x8D, (byte) 0x93, (byte) 0x38, (byte) 0x57,
// (byte) 0x3A, (byte) 0x62, (byte) 0x42, (byte) 0xF7, (byte) 0x6F, (byte) 0x5D, (byte) 0x28, (byte) 0xF4,
// (byte) 0xF0, (byte) 0xF3, (byte) 0x64, (byte) 0xE8, (byte) 0x7E, (byte) 0x8F, (byte) 0xCA, (byte) 0x2F});
Unknown("", "Unknown"),
SMARTCASH_AG("SMART CASH AG", "SMART CASH AG"),
@ -36,69 +13,16 @@ public enum Manufacturer {
private String ID;
private String officialName;
// private byte[] publicKey;
// Manufacturer(String id, String officialName, byte[] publicKey) {
Manufacturer(String id, String officialName) {
this.ID = id;
this.officialName = officialName;
// this.publicKey = publicKey;
}
public String getOfficialName() {
return officialName;
}
// public boolean VerifySignature(byte[] Challenge, byte[] Salt, byte[] Signature) {
//
// if (publicKey == null || Challenge == null || Salt == null || Signature == null) {
// Log.e(getOfficialName(), "Not all data read, can't check signature!");
// return false;
// }
// try {
// java.security.Signature signature = java.security.Signature.getInstance("SHA256withECDSA");
// ECNamedCurveParameterSpec spec = ECNamedCurveTable.getParameterSpec("secp256k1");
// KeyFactory factory = KeyFactory.getInstance("EC", "SC");
//
// ECPoint p1 = spec.getCurve().decodePoint(publicKey);
//
// ECPublicKeySpec keySpec = new ECPublicKeySpec(p1, spec);
//
// PublicKey publicKey = factory.generatePublic(keySpec);
// signature.initVerify(publicKey);
// signature.update(Challenge);
// signature.update(Salt);
//
// ASN1EncodableVector v = new ASN1EncodableVector();
// int size = Signature.length / 2;
// v.add(/*r*/new ASN1Integer(new BigInteger(1, Arrays.copyOfRange(Signature, 0, size))));
// v.add(/*s*/new ASN1Integer(new BigInteger(1, Arrays.copyOfRange(Signature, size, size * 2))));
// byte[] sigDer = new DERSequence(v).getEncoded();
//
// if (signature.verify(sigDer)) {
// Log.i(getOfficialName(), "Signature verification OK");
// return true;
// } else {
// Log.e(getOfficialName(), "Signature verification failed");
// }
// }
// catch (Exception e)
// {
// e.printStackTrace();
// }
// return false;
// }
//
// public static Manufacturer FindManufacturer(String ID, byte[] Challenge, byte[] Salt, byte[] Signature) {
// Manufacturer[] manufacturers = Manufacturer.values();
// for (int i = 1; i < manufacturers.length; i++) {
// if ( manufacturers[i].ID.equals(ID) && manufacturers[i].VerifySignature(Challenge, Salt, Signature)) {
// return manufacturers[i];
// }
// }
// return Manufacturer.Unknown;
// }
public static Manufacturer FindManufacturer(String ID) {
Manufacturer[] manufacturers = Manufacturer.values();
for (int i = 1; i < manufacturers.length; i++) {

View file

@ -47,18 +47,6 @@ public class TangemCard {
private float rate = 0;
private float rateAlter = 0;
// public static final int SettingsMask_AllowSwapPIN = 0x0010;
// public static final int SettingsMask_IsReusable = 0x0001;
// public static final int SettingsMask_UseRecovery = 0x0002;
// public static final int SettingsMask_UseBlock = 0x0004;
//
// public static final int SettingsMask_AllowSwapPIN2 = 0x0020;
// public static final int SettingsMask_UseCVC = 0x0040;
//
// public static final int SettingsMask_UseOneCommandAtTime = 0x100;
// public static final int SettingsMask_UseNDEF = 0x200;
// public static final int SettingsMask_UseDynamicNDEF = 0x400;
private BigInteger countConfirmTX = null;
public BigInteger GetConfirmTXCount() {
@ -93,8 +81,6 @@ public class TangemCard {
}
public Blockchain getBlockchain() {
//TODO: hard fork only for test
//return Blockchain.Ethereum;
return Blockchain.fromId(blockchainID);
}
@ -126,21 +112,6 @@ public class TangemCard {
public void setBlockchainIDFromCard(String blockchainID) {
//TODO: ONLY FOR TEST
// if(Blockchain.fromId(blockchainID) == Blockchain.Bitcoin)
// {
// this.blockchainID = "BCH";
// return;
// }
//
// if(Blockchain.fromId(blockchainID) == Blockchain.BitcoinTestNet)
// {
// this.blockchainID = "BCH/test";
// return;
// }
if (Blockchain.fromId(blockchainID) != Blockchain.Ethereum && Blockchain.fromId(blockchainID) != Blockchain.EthereumTestNet)
this.blockchainID = blockchainID;
@ -150,8 +121,6 @@ public class TangemCard {
} else {
this.blockchainID = blockchainID;
}
}
public void setWalletPublicKey(byte[] publicKey) {