Skip to main content

Dive into QR codes

The Keystone devices primarily use QR Codes for data transmission. The QR Code protocol, a global standard for encoding and decoding data into a two-dimensional matrix of dots, is widely adopted due to its numerous advantages. Compared to other data transmission methods like Bluetooth and USB, QR Codes enhance transparency and security. They allow users to easily decode data and clearly understand what they are signing, thereby improving security. Additionally, QR Codes offer better compatibility, as they are less susceptible to software changes such as browser or system upgrades. Lastly, QR Codes provide a superior user experience, especially on mobile devices, compared to USB, Bluetooth, and file transfers.

However, there are some limitations to using QR Codes. The most significant one is that a single QR Code can only handle a limited amount of data. To transfer large amounts of data, multiple QR Codes must be used.

Uniform Resources (UR)

To encode data into QR Codes, specific standards are required to ensure that both the sender and receiver can properly encode and decode the data. At Keystone, we utilize the Uniform Resources (UR) encoding method, which is defined by Blockchain Commons and widely adopted within the Bitcoin community.

The UR encoding method addresses the limitations of QR Codes in transmitting binary data by providing a standardized approach to partition and reassemble data. It employs deterministic CBOR (dCBOR) for structuring binary data and Bytewords for encoding it into printable characters. This method supports both single-part and multi-part messages, with the latter using a hybrid fixed-rate and rateless partitioning scheme to optimize data transmission even under lossy conditions. This ensures robust and efficient data transfer, even if some parts of the message are lost.

UR encoding is implemented in various programming languages, enhancing interoperability and adoption. It was chosen over other serialization formats, such as Protocol Buffers and JSON-LD, due to its minimal adoption barriers, self-describing nature, and broad interoperability. For more details about UR, please refer to UR Documentation.

UR Types

To ensure that the data receiver can easily understand and efficiently decode the data embedded in QR Codes, we utilize a set of UR types to specify the data type. Examples of these types include crypto-hdkey, crypto-account, and crypto-psbt. These UR types are extensively used in Keystone to support different purposes and blockchain networks. For a comprehensive list of all UR types defined by Blockchain Commons, please refer to their documentation here.

However, the original UR types were primarily designed with Bitcoin in mind, which limits their applicability to other blockchain protocols. To address this, we have extended the UR framework to include new types that support additional blockchains, ensuring broader compatibility and functionality.

For Ethereum, we have introduced the following extended UR types:

  • eth-sign-request: This type represents a request to sign an Ethereum transaction or message. It facilitates secure and efficient signing processes within Ethereum-compatible applications.
  • eth-signature: This type captures the signature that is returned to the watch-only wallet, ensuring that the signed data can be verified and used appropriately.

These new definitions are also incorporated into the Ethereum Improvement Proposal EIP-4527, which standardizes these types for widespread adoption within the Ethereum ecosystem.

For information on other blockchains, please visit the detailed page to explore the UR types specific to those blockchains.

By extending the UR types, Keystone enhances interoperability and supports a wider range of blockchain protocols, thus offering a more versatile and robust solution for secure data transmission.

The Keystone SDK

The primary purpose of the Keystone SDK is to simplify the process for developers, removing the need to manage the intricate details of UR and QR Code generation. The SDK provides a simple and intuitive way to generate and decode UR data, making it accessible even for those without extensive technical knowledge.

Developers can use the SDK for handling UR data while utilizing their own QR Code components for rendering. This flexibility allows for seamless integration with existing infrastructure, ensuring a straightforward and efficient solution for UR and QR Code management.

By leveraging the Keystone SDK, developers can focus on core application logic, confident that UR and QR Code complexities are managed efficiently and effectively.

Meanwhile, please note that due to the design of UR, if the data is too large, animated QR codes become necessary, and the SDK will continue generating UR data. This may cause memory issues if not handled properly, so it is best practice to clear the UR data after each QR code is generated.