Skip to content

Latest commit

 

History

History
77 lines (53 loc) · 4.68 KB

0007.md

File metadata and controls

77 lines (53 loc) · 4.68 KB

BRC-7: Window Wallet Communication Substrate

Brayden Langley (brayden@projectbabbage.com)

Abstract

The Window Wallet Communication Substrate is a standardized interface that enables seamless integration between web applications and browser embedded Bitcoin wallets. It serves as a unified gateway for applications to access various wallet functionalities, including the creation of Bitcoin transactions, encryption, digital signature creation, and more. By establishing this standardized interface, applications gain the ability to support multiple wallet providers, enhancing flexibility and choice for users in managing their Bitcoin-related tasks. This interface empowers users with greater control and accessibility while maintaining compatibility across different applications and wallets.

Motivation

The motivation behind this standard is to enable web browsers to directly integrate Bitcoin wallet functionality without relying on an additional application running on the client's device.

Although BRC-5 defines a standard for local communication over HTTP, integrating wallet functionality in the browser eliminates the need for external wallet applications, reducing the overhead of inter-process communication and network requests.

This also eliminates the need for users to switch between multiple applications when approving permissions, creating transactions, etc. They can perform all wallet-related tasks within the web application they are already using, resulting in a more cohesive and convenient user experience.

Specification

We define a specification for providing access to Bitcoin wallet functionality via the global window object that is directly available in all standard browser implementations.

Once the browser has verified that the user is authenticated, an object labeled CWI should be added to the window object to provide access to the standard wallet functionality as defined by BRC-56.

Standard CWI Functions Associated with Various Message Types

For each of the message pairs (request and response) incorporated into BRC-56, we specify the existence of a corresponding message type with a specific function name:

Message Type Window Function Name Value
BRC-1 Transaction Creation window.CWI.createAction()
BRC-2 Encryption window.CWI.encrypt()
BRC-2 Decryption window.CWI.decrypt()
BRC-3 Signature Creation window.CWI.createSignature()
BRC-3 Signature Verification window.CWI.verifySignature()
BRC-53 Certificate Creation window.CWI.createCertificate()
BRC-53 Certificate Verification window.CWI.proveCertificate()
BRC-56 HMAC Creation window.CWI.createHmac()
BRC-56 HMAC Verification window.CWI.verifyHmac()
BRC-56 Public Key Derivation window.CWI.getPublicKey()
BRC-56 Certificate List window.CWI.findCertificates
BRC-56 Version Request window.CWI.getVersion()
BRC-56 Network Request window.CWI.getNetwork()
BRC-56 Authentication Request window.CWI.isAuthenticated()
BRC-56 Async Auth Request window.CWI.waitForAuthentication()

This will allow applications to call functions with the following syntax:

window.CWI.<functionName>

Parameter Format Specification

We specify that all required parameters are provided in an object to the CWI functions.

Example Identity Key Request

const identityKey = await window.CWI.getPublicKey({ 
    identityKey: true 
})

Example Encrypt Function

const ciphertext = await window.CWI.encrypt({
  plaintext: Buffer.from('Hello BRCs!'),
  protocolID: [0, 'Hello World'],
  keyID: '1'
})

Implementation

Implementors of this BRC should follow the abstract messaging layer as defined by BRC-56 to provide support for standard messaging types, and then modify the window object created to include this functionality in a CWI object.