Java Code Examples for com.btchip.BTChipDongle#BTChipPublicKey
The following examples show how to use
com.btchip.BTChipDongle#BTChipPublicKey .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BTChipHWWallet.java From green_android with GNU General Public License v3.0 | 6 votes |
public List<String> getXpubs(final GaActivity parent, final List<List<Integer>> paths) { final List<String> xpubs = new ArrayList<>(paths.size()); try { for (final List<Integer> path : paths) { final String key = Joiner.on("/").join(path); if (!mUserXPubs.containsKey(key)) { final BTChipDongle.BTChipPublicKey pubKey = mDongle.getWalletPublicKey(path); final byte[] compressed = KeyUtils.compressPublicKey(pubKey.getPublicKey()); final Object hdkey = Wally.bip32_key_init(mNetwork.getVerPublic(), 1 /*FIXME: wally bug*/, 0, pubKey.getChainCode(), compressed,null, null, null); mUserXPubs.put(key, Wally.bip32_key_to_base58(hdkey, Wally.BIP32_FLAG_KEY_PUBLIC)); Wally.bip32_key_free(hdkey); } xpubs.add(mUserXPubs.get(key)); } return xpubs; } catch (final Exception e) { throw new RuntimeException(e.getMessage()); } }
Example 2
Source File: BTChipHWWallet.java From green_android with GNU General Public License v3.0 | 5 votes |
@Override public String getBlindingKey(final GaActivity parent, final String scriptHex) { try { final BTChipDongle.BTChipPublicKey blindingKey = mDongle.getBlindingKey(Wally.hex_to_bytes(scriptHex)); final byte[] compressed = KeyUtils.compressPublicKey(blindingKey.getPublicKey()); return Wally.hex_from_bytes(compressed); } catch (final Exception e) { throw new RuntimeException(e.getMessage()); } }
Example 3
Source File: BTChipHWWallet.java From green_android with GNU General Public License v3.0 | 5 votes |
@Override public String getBlindingNonce(GaActivity parent, String pubkey, String scriptHex) { try { final byte[] fullPk = Wally.ec_public_key_decompress(Wally.hex_to_bytes(pubkey), null); final BTChipDongle.BTChipPublicKey nonce = mDongle.getBlindingNonce(fullPk, Wally.hex_to_bytes(scriptHex)); return Wally.hex_from_bytes(nonce.getPublicKey()); } catch (final Exception e) { throw new RuntimeException(e.getMessage()); } }
Example 4
Source File: BTChipHWWallet.java From GreenBits with GNU General Public License v3.0 | 5 votes |
private DeterministicKey internalGetPubKey() throws BTChipException { if (mCachedPubkey == null) { final BTChipDongle.BTChipPublicKey walletKey = mDongle.getWalletPublicKey(getPath()); final byte[] compressedPubKey = KeyUtils.compressPublicKey(walletKey.getPublicKey()); mCachedPubkey = HDKey.createMasterKey(walletKey.getChainCode(), compressedPubKey); } return mCachedPubkey; }
Example 5
Source File: TestSetup.java From ledger-javacard with GNU Affero General Public License v3.0 | 5 votes |
public void testSetupRestoreTestnet() throws BTChipException { BTChipDongle dongle = prepareDongleRestoreTestnet(false); dongle.verifyPin(DEFAULT_PIN); BTChipDongle.BTChipPublicKey publicKey = dongle.getWalletPublicKey(""); assertEquals(publicKey.getAddress(), EXPECTED_ADDRESS_1); assertTrue(Arrays.equals(publicKey.getPublicKey(), EXPECTED_PUBLIC_KEY_1)); assertTrue(Arrays.equals(publicKey.getChainCode(), EXPECTED_CHAINCODE_1)); }
Example 6
Source File: TestGetWalletPublicKey.java From ledger-javacard with GNU Affero General Public License v3.0 | 5 votes |
public void testGetWalletPublicKey() throws BTChipException { BTChipDongle dongle = prepareDongleRestoreTestnet(false); dongle.verifyPin(DEFAULT_PIN); BTChipDongle.BTChipPublicKey publicKey = dongle.getWalletPublicKey("44'/0'/0'/0/42"); assertEquals(publicKey.getAddress(), EXPECTED_ADDRESS_1); assertTrue(Arrays.equals(publicKey.getPublicKey(), EXPECTED_PUBLIC_KEY_1)); assertTrue(Arrays.equals(publicKey.getChainCode(), EXPECTED_CHAINCODE_1)); }