Quantcast
Jump to content


“Where’s My Crypto Coin?” Featuring Samsung Blockchain Keystore SDK


Recommended Posts

Distributed ledger-based technologies are becoming more popular and easy to use. Anyone can now build a new cryptocurrency or token in the Blockchain world. This rise in popularity and value makes crypto assets a big target for hackers. If you want to keep your valuable crypto assets safe, using a hardware cold wallet such as Trezor or Ledger Nano S has become a necessity. Unfortunately, that adds up to one more item in your pocket that you always have to carry around.

Thankfully, gone are the days of carrying clunky, old wallets. Recent Galaxy phones, such as the S10e, S10, S10+, and Fold, can now securely store your cryptocurrency wallet using the Samsung Blockchain Keystore (SBK). Along with storing your cryptocurrency wallet, the SBK SDK allows you to get your Blockchain address and sign cryptocurrency transactions.

In this article, we explore one of the key features offered by the Keystore SDK–how to get your Blockchain address from the SBK SDK and three ways to share it:

  • Display as QR code
  • Copy to clipboard
  • Share through Android’s share intent

Setting up the Project and Handling SBK Data

To set up your Android project with the SBK SDK, follow these instructions.

To use functionalities offered by the SDK, first fetch an instance of the service.

private ScwService mScwService = ScwService.getInstance();

After you have fetched the ScwService instance, you can check whether your device is Keystore-supported.

if (mScwService == null) {
    Log.e("KeystoreApp", "Keystore is not supported on this device.");
}

If the device is Keystore-supported, you can fetch the address list with getAddressList():

mScwService.getAddressList(addressListCallback, hdPathList);

The first parameter to getAddressList() is a ScwGetAddressListCallback, which is executed after getting a response from Keystore. ScwGetAddressListCallback() has two functions:

  • onSuccess(): This function is called when the address list has been fetched successfully from Keystore.
  • onFailure(): This function is called if any errors occur while fetching the address list from Keystore.
ScwService.ScwGetAddressListCallback addressListCallback = new ScwService.ScwGetAddressListCallback() {
    @Override
    public void onSuccess(List addressList) {
        //You can share your address from the address list here
    }

    @Override
    public void onFailure(int failureCode) {
        //Based on the failure code you can show appropriate alerts here
    }
};

The second parameter is an ArrayList of Hierarchical Deterministic (HD) Path(s) whose addresses you want to fetch. If you want to learn more about HD paths, please refer to BIP-44. For example, if you want to find the public address of your first five accounts, pass the following list as a parameter:

ArrayList hdPathList = new ArrayList<>();
hdPathList.add("m/44'/60'/0'/0/0");
hdPathList.add("m/44'/60'/0'/0/1");
hdPathList.add("m/44'/60'/0'/0/2");
hdPathList.add("m/44'/60'/0'/0/3");
hdPathList.add("m/44'/60'/0'/0/4");

A Sample App with the SBK SDK

Now that we are familiar with getAddressList(), let’s dive into our sample application. Features of our Public Address with SBK app are:

  • Fetch your public address from the Keystore
  • Switch between multiple public addresses
  • Display QR code of the selected account
  • Copy selected address into the clipboard
  • Send the selected address with supported applications with Android’s share intent

Initially, only the address of the first account is loaded. When you press the Add button, the HD path of a new account is added to hdPathList, and public addresses are fetched.

public void addAccount(View view) {
    //Account Index is incremented by 1 to get the new account
    accountIndex++;
    //HDPath of new account is added to hdPathList
    hdPathList.add("m/44'/60'/0'/0/" + accountIndex);
    showToast("HDPath Added to list");
    //Public Address of new account is fetched
    getPublicAddress();
}

Public addresses are fetched using the getPublicAddress() function depicted below.

If the address list is fetched successfully, onSuccess() is called, and:

  • The spinner’s previous data is cleared.
  • The newly fetched list is added to the spinner.
  • The UI is updated.

If an error occurs, it is logged and available from logcat. Common errors such as ERROR_INVALID_SCW_APP_ID can be fixed very easily by enabling Developer Mode from the Keystore application. You can find instructions on how to enable Developer Mode here.

private void getPublicAddress() {
    ScwService.ScwGetAddressListCallback addressListCallback = new ScwService.ScwGetAddressListCallback() {
        @Override
        public void onSuccess(final List publicAddressList) {
            //After Address List has been fetched Spinner is updated with new list
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    //Clear existing list
                    spinnerAdapter.clear();
                    //New list is added
                    spinnerAdapter.addAll(publicAddressList);
                    spinnerAdapter.notifyDataSetChanged();
                    if (publicAddressList.size() == 1) {
                        showToast(publicAddressList.size() + " address fetched.");
                    } else {
                        showToast(publicAddressList.size() + " addresses fetched.");
                    }
                }
            });
        }

        @Override
        public void onFailure(int errorCode) {
            switch (errorCode) {
                case ScwErrorCode.ERROR_INVALID_SCW_APP_ID:
                    Log.e(LOG_TAG,"Developer option not enabled.");
                    break;
                case ScwErrorCode.ERROR_CHECK_APP_VERSION_FAILED:
                    Log.e(LOG_TAG,"Check internet connection.");
                    break;
                case ScwErrorCode.ERROR_OP_FAIL:
                    Log.e(LOG_TAG,"Operation Failed");
                    break;
                default:
                    Log.e(LOG_TAG,"Error with Error Code: "+errorCode);
                    break;
            }
        }
    };
    if (mScwService == null) {
        Log.e(LOG_TAG, "Keystore is not supported in this device.");
    } else {
        //If Keystore is supported on device address list is requested
        mScwService.getAddressList(addressListCallback, hdPathList);
    }
}

After loading all addresses into the spinner, we can now select any address from it. Once an address is selected, its QR Code is generated and displayed.

publicAddressSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
    @Override
    public void onItemSelected(AdapterView<?> adapterView, View view, int position, long l) {
        //Get Selected Address from spinner
        selectedAddress = adapterView.getItemAtPosition(position).toString();
        selectedAddressTextView.setText(selectedAddress);
        qrCodeImageView.setImageBitmap(generateQRCode(selectedAddress));
    }

In this application, we used “ZXing” to generate the QR bitmap of the selected public address.

private Bitmap generateQRCode(String text) {
    MultiFormatWriter multiFormatWriter = new MultiFormatWriter();
    Bitmap bitmap = Bitmap.createBitmap(10, 10, Bitmap.Config.RGB_565);
    try {
        //Text encoded to QR BitMatrix
        BitMatrix bitMatrix = multiFormatWriter.encode(text, BarcodeFormat.QR_CODE, 1000, 1000);
        BarcodeEncoder barcodeEncoder = new BarcodeEncoder();
        //QR Bitmatrix encoded to Bitmap
        bitmap = barcodeEncoder.createBitmap(bitMatrix);
    } catch (WriterException e) {
        e.printStackTrace();
    } finally {
        return bitmap;
    }
}

When you press the copy button, the address is copied to the clipboard.

public void copyAddress(View view) {
    ClipboardManager clipboardManager = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData clipData = ClipData.newPlainText("Public Address", selectedAddress);
    clipboardManager.setPrimaryClip(clipData);
    Toast.makeText(this, "Address Copied", Toast.LENGTH_SHORT).show();
}

We can also share the selected public address using the Android ACTION_SEND intent.

public void shareAddress(View view) {
    Intent sendIntent = new Intent();
    sendIntent.setAction(Intent.ACTION_SEND);
    sendIntent.putExtra(Intent.EXTRA_TEXT, selectedAddress);
    sendIntent.setType("text/plain");
    startActivity(sendIntent);
}

Conclusion

Now that you know more about the Samsung Blockchain Keystore SDK, you can use it to enrich your Blockchain application. For more resources on Keystore SDK, visit https://developer.samsung.com/blockchain/keystore/sdk.

View the full blog at its source

Link to comment
Share on other sites



  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Similar Topics

    • By Samsung Newsroom
      Samsung Electronics, the world’s leading TV manufacturer for the 18th consecutive year, commenced its 2024 Southeast Asia Tech Seminar in Bangkok, Thailand. From April 23 to 24, Samsung will showcase its 2024 lineup, featuring AI-powered technologies that offer enhanced picture, sound, and customization.
       
      Since 2012, Samsung’s global Tech Seminar sessions have served as a platform for sharing detailed information and exclusive product experiences. As part of its ‘Screens Everywhere, Screens for All’ vision, Samsung plans to present innovations that deliver industry-leading viewing experiences and user-friendly features.
       
      ▲ Haylie Jung (right), Picture Quality Solution Lab at Samsung Electronics, explains that the 2024 Neo QLED 8K incorporates the new and powerful NQ8 AI Gen3 Processor to support AI-backed features such as 8K AI Upscaling Pro and AI Motion Enhancer Pro
       
      The 2024 Southeast Asia Tech Seminar in Bangkok follows a successful series kickoff in Frankfurt, Germany this February. At this event and upcoming seminars in regions such as Latin America, Samsung will present new TV and monitor technologies, as well as lifestyle products:
       
      Samsung’s 2024 Neo QLED 8K includes the latest NQ8 AI Gen3 Processor, which enables a vivid and more precise picture through its 512 neural networks—eight times as many as its predecessor. It supports features like 8K AI Upscaling Pro and AI Motion Enhancer Pro for the best Neo QLED 8K visuals to date. The 2024 Samsung OLED TV upscales content to 4K resolution thanks to the NQ4 AI Gen2 Processor, and features OLED Glare Free technology. Certified by Underwriters Laboratories Inc. (UL), the technology reduces light reflection on the screen to provide a more immersive viewing experience with fewer distractions. Music Frame is a new lifestyle product that functions as a frame-shaped speaker. It can be used as a frame on the wall by inserting images or photos into its replaceable photo frame. Samsung Knox, applied to Samsung TV, achieved a ‘Common Criteria’ certification, recognized by 31 countries this February as strengthening TV security measures in terms of software and hardware.  
      ▲ Kevin Cha (left), Picture Quality Solution Lab at Samsung Electronics, explains that AI-backed features such as 8K AI upscaling pro are powered by a new and powerful NQ8 AI Gen3 processor to the 2024 Neo QLED 8K
       
      “We are extremely excited to share Samsung’s key AI TV technologies at the Tech Seminar,” said Yongjae Kim, Executive Vice President of Visual Display Business at Samsung Electronics. “We are not only showcasing the latest technologies that make our TVs stand out, but also our real efforts to better serve customers and our focus on protecting their information.”
       
      For more information on Samsung’s 2024 TV and monitor lineup, visit www.samsung.com/.
       
      ▲ Samsung Electronics has received a CC certification for 10 consecutive years since first applying Samsung Knox, the industry’s best security solution, to its TV products in 2015
       
      ▲ Andrew Sohn (left), Picture Quality Solution Lab at Samsung Electronics, shows off Samsung’s AI engine that can instantly optimize picture and sound quality based on the game or genre being played
       
      ▲ According to Kevin Cha (right), Picture Quality Solution Lab at Samsung Electronics, the 2024 Samsung OLED features Glare free technology to deliver a comfortable viewing experience
      View the full article
    • By Samsung Newsroom
      For the ninth year, Samsung Electronics is highlighting some of its industry-leading technical capabilities that are redefining the meaning of “user convenience” at the Samsung Developer Conference 2023 (SDC23) in San Francisco, CA. On October 5 at the Moscone Center, SDC23 brought together some of Samsung’s top executives and developers to highlight the innovative platforms and services offering safer, healthier, more sustainable and fun experiences.
       

       
      Read on to learn about some of the main innovations covered at SDC23 that are enhancing users’ lives.
       
       
      Enriching Customer Experiences: Innovating Platforms and Enhancing Ecosystems
      Jong-Hee (JH) Han, Vice Chairman, CEO and Head of Device eXperience (DX) Division at Samsung Electronics, kicked off the event by highlighting how the growing number of Samsung devices around the world drives innovation within the company.
       
      “Over 500 million Samsung products are sold every year, and the number of people using Samsung accounts exceeds 600 million. To us, this is both a huge asset and a profound responsibility,” he stated. “Samsung’s innovations connect countless people, products and services. I believe that if you join this journey of innovation, we can create greater opportunities and a brighter future together.”
       

       
      Touching on the main advancements to Samsung’s suite of devices and applications — including the SmartThings ecosystem, Bixby virtual assistant, Samsung Knox security platform and more — Han expressed how collaboration has helped bring many of the company’s products to life.
       
      “The possibilities we can realize together are endless because as developers, we share the engines of innovation and collaboration,” he said.
       
       
      Building Meaningful Home Experiences Through Enhanced Partnerships
      Jaeyeon Jung, Executive Vice President and Head of SmartThings, Device Platform Center at Samsung Electronics, discussed Samsung’s ongoing commitment to increasing interoperability between devices and expanding the SmartThings home ecosystem — focusing on the company’s support for open home standards such as Matter and the Home Connectivity Alliance.
       
      “We are building experiences that promote the whole family’s well-being by keeping us all connected during the busyness of everyday life,” she said.
       

       
      Through Multi Hub Network and SmartThings Home API, Jung showcased the newest additions to the SmartThings platform that provide access to a growing list of devices, apps and services. By utilizing its wide network of partnerships and tapping other industry leaders, Samsung aims to enable users to live more digitally integrated lives – both inside and outside their homes.
       
       
      Bixby: Setting a New Standard for the Samsung Ecosystem
      Enhancing at-home experiences means using the most advanced technologies to tailor them to each user’s needs and tastes. Anil Yadav, Head of Bixby Lab at Samsung Research1 America, underlined Samsung’s future vision for Bixby and how the company is working to create more intelligent and comfortable spaces for the future.
       

       
      Thanks to deeper home integration, Bixby will intuitively respond to users’ commands based on their unique preferences — making smart homes that much smarter for individuals and their families. Additionally, Bixby will seamlessly route user commands to the appropriate device, creating a harmonious multi-device home ecosystem.
       
      “This combination of personalization and adaptation ensures that every interaction with Bixby will be optimized, easy and convenient,” he said.
       
       
      Providing a Safe, Secure and Convenient Cross-Device Environment
      Since multi-device networks can be prone to hacks and breaches, forward-thinking security solutions are more necessary than ever. With this in mind, Samsung has been reinforcing its security solutions to anticipate evolving digital threats.
       
      Shin Baik, Engineer of Security Team, Mobile eXperience (MX) Business at Samsung Electronics, emphasized the need for comprehensive security solutions in an expansive and highly connected device network.
       
      “It’s time to look beyond today’s solutions and start building a better-protected future,” he said.
       

       
      Baik spotlighted the company’s proprietary security innovations containing the latest features. These include:
       
      Samsung Knox Matrix — which comes with updates to Credential Sync — enabling end-to-end encryption to backup or restore data on the Samsung Cloud. If a server is compromised or account details are stolen, user data is protected as data can only be encrypted or decrypted through the user’s device.
       
      Mobile devices with One UI 6 will have access to passkeys — a digital credential technology that uses biometric recognition as authentication on websites and applications — marking a significant step towards a password-less future.
       
      Beyond flagship mobile devices, Samsung Knox Vault is being expanded to Samsung Neo QLED 8K TVs in 2023, and Galaxy A series smartphones that launch with One UI 6 or later2 in 2024 — protecting more customers and their devices.
       
       
      Tizen Reboot: Paving the Path for the Decade Ahead
      Hobum Kwon, Vice President of Platform Team at Samsung Research, unveiled advancements to Tizen, Samsung’s Linux-based open-source operating system, and how the company is rebooting it for a new generation of devices.
       
      “We’re always thinking of how to expand the Tizen Ecosystem — and as a result, the platform has a reliable and adaptable architecture built on our commitment to open innovation,” he said.
       

       
      Recently, Samsung expanded Tizen to operate on new home appliances with larger displays, such as washing machines and ovens, to enrich the user experience by providing graphic information, convenient UI and useful video content. Alongside the expansion of applicable product lines, Samsung will boost developer support through a unified Tizen Software Development Kit (SDK) that includes a 2D and 3D combined graphics engine and a new Samsung Experience Services feature.
       
       
      Tizen Screen: Your Window to a World of Possibilities
      Bongjun Ko, Executive Vice President of Application Software R&D Group, Visual Display (VD) Business, revealed how Samsung is elevating the Tizen TV experience for users in their day-to-day lives.
       
      “Whether it’s through a TV or smartphone while you wait for your train, these screens are part of our daily lives,” he said. “This is why we, at Samsung, are always innovating to deliver best-in-class experiences with Tizen, starting with the biggest screens in your home.”
       

       
      Ko shared that Samsung Gaming Hub is now available on a variety of Tizen-supported screens such as The Freestyle 2nd Gen and Odyssey Neo G9 as well as 2022 and 2023 Samsung Smart TVs. Taking social interaction to new heights, Chat Together connects users with friends in chat rooms while they are watching their favorite shows, movies and sports. What’s more, the platform is adding Relumino Mode to Samsung TVs to create a more accessible and immersive viewing experience for those with low vision.
       
      Tizen is opening its doors to a broader ecosystem of partners and developers, offering robust support and a dynamic environment to revolutionize how people connect, play and interact via screens.
       
       
      Expanding the Galaxy Experience With One UI 6
      One of the main highlights was the reveal of One UI 6, a transformative user experience designed for Galaxy devices. Sally Hyesoon Jeong, Vice President of Framework R&D Group, Mobile eXperience (MX) Business, introduced this innovative upgrade, focusing on enhanced usability and intelligent photo and video editing. One UI 6 includes a fresh, intuitive look and feel with a revamped Quick panel, redesigned app interfaces and a stylish, exclusive typeface: One UI Sans.
       
      Additionally, One UI 6 will analyze photos in the Gallery using AI features — such as Photo Remaster and Object Eraser — to suggest the most relevant editing options, helping users enhance their photos quickly and more precisely. Likewise, with Samsung Studio and its multi-layer video editing features, users have greater control when editing their content to freely add effects such as text, stickers and music with the video editing timeline.
       

       
      Jeong also announced the highly anticipated Galaxy SmartTag2. With a compact design, improved battery life and IP67 rating for dust and water resistance, the SmartTag2 is set to redefine how users keep track of their belongings — giving more people greater peace of mind.
       
       
      Building a Digital Health Ecosystem Through Connected Care at Home
      Hon Pak, Vice President of Digital Health Team, Mobile eXperience (MX) Business, highlighted the importance of fostering strong connections among devices, data, consumers and services for more optimized digital health experiences.
       
      “Our vision for Samsung Health is to build a healthier future for everyone,” he said. “It starts from the same place where many of you started your day today — at home.”
       

       
      Samsung’s vision is recognized through strategic partnerships aimed at strengthening the digital health ecosystem. Samsung Privileged Health SDK provides access to the Samsung BioActive Sensor, giving partners increased flexibility to develop powerful, health-sensing capabilities in their applications. Samsung Research launched Samsung Health Stack 1.0 to support researchers with critical tools to advance their studies. The App SDK included in Samsung Health Stack 1.0 provides developers with the building blocks to streamline participant data collection, and Web portal provides researchers with a dashboard to monitor and manage research progress in an organized and easily readable way.
       
      Additionally, Samsung partnered with the MIT Media Lab to focus on cutting-edge research in sleep and mental health monitoring. Together, they will develop novel, scientifically validated and accessible solutions that help people sleep better and improve their health, well-being and daytime performance. The collaboration highlights Samsung’s commitment to bolstering the wellness industry and enhancing the lives of users.
       
       
      Savoring the Future of Cooking With Food AI
      Nick Holzherr, CEO of Whisk, Head of Samsung Food Platform, expressed how new AI-enabled customer experiences will help people not only eat better but also make “Food Your Way.”
       
      Samsung Food makes it easier for users to share their favorite dishes with the community and follow their favorite food content creators. With the app, users can explore new levels of customization and convenience in the kitchen, from grocery shopping and personalized recipe recommendations to automated cooking settings.
       

       
      “Over the coming year, we’ll continue to grow our device connectivity across Samsung’s appliances, watches and phones,” he said. “I’m super excited about how we can bring software and hardware together to create value for our Samsung customers!”
       
       
      Smarter Living, Every Day
      To close out the presentation, JH Han returned to the stage to offer a final word on the company’s vision for the future of hyper-connected living. Leveraging its industry partnerships, Samsung is committed to redefining how individuals interact with technology — striving to make daily life more connected and convenient for users everywhere.
       

       
      “Samsung’s new products and technologies need to be anchored by a solid ecosystem,” he said. “We are committed to fostering mutual growth with all the developers and partners here.”
       
       
      Watch the video below to see the complete recording of the SDC23 keynote.
       
        
       
      1 Serving as Samsung Electronics’ advanced R&D hub, Samsung Research leads the development of future technologies for the company’s Device eXperience (DX) Division.
      2 Samsung Knox Vault availability may vary by model.
      View the full article





×
×
  • Create New...