From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 87B1FC0893 for ; Wed, 23 Dec 2020 11:45:08 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 727B522E96 for ; Wed, 23 Dec 2020 11:45:08 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fA+d+U7T6Q5T for ; Wed, 23 Dec 2020 11:45:06 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) by silver.osuosl.org (Postfix) with ESMTPS id 8142E203F7 for ; Wed, 23 Dec 2020 11:45:05 +0000 (UTC) Received: by mail-lf1-f47.google.com with SMTP id a12so39437341lfl.6 for ; Wed, 23 Dec 2020 03:45:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dhmj5euR6TtGuYeOYT7iJiuF180ZnBgbnHjRYlnrhgE=; b=lT3PE0jG1h8dfldmuZ+yPynjMva2Wa9PUsiG0o0Ku6+Ols6jM/vUiwtUj7Tg5ZhF7J or1fOCSMGERu0q7jDDXRDFmSnDtiNMZ81MJ5TvffwAMP8qNb0McBZgJ3/qFwISlstBXL jnPbnaURmUKyuwB5oy6n1jPM2lIOfRqdgwT5kM8njQVxjbQYDZrULEeaEEWa2D0LSg97 G78gaO9IvWJW1HkN4LlMEVNe5JQfHZmRk2zYpcJarupGiqKFAj4zjpyIy28opRfoYFv2 P3bCdXj0qsKRtmdoBkk6pyR7ktOmlBdpe0KiP0Ewv7t+srn1CGnYXZUZ6mQnxfWuFgfL T7Xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=dhmj5euR6TtGuYeOYT7iJiuF180ZnBgbnHjRYlnrhgE=; b=sf1vlddFIT6kxxCZo+D1gUXcgwMeCtBxgCHLhGtvWc9iVgRUvEXR9f99Pq8Nct9U4Z Zn4uv0UuidBfhKMwBPXxKqj9x7N4I5ZKCk9FGii82FX+jEhtMRIAtiodpfoR0IGd7lJc nIQ0UMGBoCWi+4pSa3+xJkknrQNdxNVUZuWc4JjbeHd0YOFBJf5mO6QojE5hPra4tQbs J8qysK80kAAFj56/FeK4FPoxc/OGHKXytTADn6WWuJnND8hzjo+O7FE5ReRMhNkeB5zy IlQDyh4OJYAqt08Au4p0hLDbapNyhVdw7Q/6CLTwT0OGXSuj3OO8rtQ6kF1gCvfKEiGW jG4w== X-Gm-Message-State: AOAM533ZA3e0n//ewqQ8gCk61yVjZ+88cy4+SsQvL3jrYZIJyAkrugD+ 6kYl3i+ou+k65nrkqZLwD/dZmdGtAk/W8IOeDik= X-Google-Smtp-Source: ABdhPJyDiDgzvc9leW2NyJeQ9j7iKBAGN1SnnLPVuCOXwgPm9mEeYJuHHNrdCXLnFjZB+zKom3SNyDC1zVQY4ytHl1Q= X-Received: by 2002:a2e:9f14:: with SMTP id u20mr12064285ljk.244.1608723903388; Wed, 23 Dec 2020 03:45:03 -0800 (PST) MIME-Version: 1.0 References: <202012230215.46394.luke@dashjr.org> In-Reply-To: From: Omar Shibli Date: Wed, 23 Dec 2020 13:44:52 +0200 Message-ID: To: monokh , Bitcoin Protocol Discussion Content-Type: multipart/alternative; boundary="000000000000cda1e505b72038b7" X-Mailman-Approved-At: Wed, 23 Dec 2020 20:06:23 +0000 Subject: Re: [bitcoin-dev] BIP Proposal: Wallet Interface X-BeenThere: bitcoin-dev@lists.linuxfoundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Bitcoin Protocol Discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Dec 2020 11:45:08 -0000 --000000000000cda1e505b72038b7 Content-Type: text/plain; charset="UTF-8" That's a great idea, in traditional banking there are wide initiatives to standardize components between different actors, most widely used is Open Banking , i think regardless of the usage, it could be hardware or software, there is a big value in standrizating communications between different components. Here is more info about Open Banking: https://fin.plaid.com/articles/what-is-the-open-banking-standard/#:~:text=The%20Open%20Banking%20Standard%20relies,data%20through%20their%20bank%20accounts On Wed, Dec 23, 2020 at 10:42 AM monokh via bitcoin-dev < bitcoin-dev@lists.linuxfoundation.org> wrote: > Thanks for the input Luke. > > > 1) People should not be encouraged to write or use web browsers for > their wallet. > > Indeed. Holding keys in the browser can be very insecure, however the spec > is not limited to this. I will amend to make this clear. The same interface > can be used to communicate from a web context or even desktop application > with hardware wallets where keys are segregated safely. The prominent > hardware wallets already have such an interface. Unfortunately as there has > been no standardisation, an application must specifically provide an > implementation for each wallet to be compatible. > > > 2) You may want to look over earlier work in this area. > > Please share if you have specifics in mind. What has been considered were > mainly hardware wallet apis. The requests have been defined such that they > would be compatible. I will make references to such considerations in the > text. I welcome any feedback on what may be missing or problematic for > these providers - something I will also pursue outwith the thread. > > -monokh > > On Wed, Dec 23, 2020 at 2:15 AM Luke Dashjr wrote: > >> 1) People should not be encouraged to write or use web browsers for their >> wallet. >> 2) You may want to look over earlier work in this area. >> >> On Tuesday 22 December 2020 14:43:11 monokh via bitcoin-dev wrote: >> > Hi >> > >> > This is a first draft of a BIP we intend to submit. The main intention >> is >> > to define a simple interface that wallets and applications can agree on >> > that would cover the vast majority of use cases. This can enable writing >> > bitcoin applications (e.g. time lock, multi sig) on the web that can be >> > seamlessly used with any compatible wallets. We have implementations of >> > such examples but I don't want to turn this thread into a promotion and >> > rather focus on the spec. >> > >> > Appreciate input from the list. Please share if there are existing >> efforts, >> > relevant specs or use cases. >> > >> > ------------------------------ >> > >> > A wallet interface specification for bitcoin applications >> > >> > ## Abstract >> > >> > This BIP describes an API for Bitcoin wallets and applications as a >> > standard. >> > >> > ## Summary >> > >> > Bitcoin wallets should expose their address derivation and signing >> > functions to external applications. The interface would be expressed as >> > follows in javascript: >> > >> > ``` >> > { >> > // Wallet Metadata >> > wallet: { >> > name: 'Bitcoin Core' >> > }, >> > >> > // Request access to the wallet for the current host >> > async enable: (), >> > >> > // Request addresses and signatures from wallet >> > async request ({ method, params }) >> > } >> > ``` >> > >> > In the web context the interface could be exposed at the top level of a >> > webpage, for example under `window.bitcoin`. However this spec does not >> > intend to define any standards for how and where the interfaces should >> be >> > exposed. >> > >> > ## Motivation >> > >> > Due to the seldom available APIs exposed by wallets, applications (web >> or >> > otherwise) are limited in how they are able to interact. Generally only >> > simple sends have been available. A more robust API that introduces >> other >> > requests will promote richer Bitcoin applications. >> > >> > Additionally, wallet APIs have frequently included inconsistencies in >> their >> > interfaces and behaviour. This has required applications to build and >> > maintain a separate client for each wallet, increasing the risk of bugs >> and >> > unintended behaviour as well as being a limiting factor for the >> adoption of >> > usable bitcoin applications. >> > >> > With a standardised wallet API: >> > >> > - Wallets have a clear API to implement >> > - Applications have a clear expectation of wallet interface and >> behaviour >> > - Applications become agnostic to the wallet specifics, increasing >> choice >> > for users >> > >> > If more wallets implement the specification, applications will be >> developed >> > more confidently by benefiting from the wallet interoperability. This >> > creates a positive feedback loop. >> > >> > ## Specification >> > >> > For simplicity, the interface is defined in the context of web >> applications >> > running in the browser (JS) however, they are simple enough to be easily >> > implemented in other contexts. >> > >> > ### General Rules >> > >> > - For sensitive functions (e.g. signing), wallet software should always >> > prompt the user for confirmation >> > >> > ### Types >> > >> > **UserDeniedError** >> > An error type indicating that the application's request has been denied >> by >> > the user >> > Type: Error >> > >> > **Hex** >> > Type: String >> > Example: >> > `"0000000000000000000a24677957d1e50d70e67c513d220dbe8868c4c3aefc08"` >> > >> > **Address** >> > Address details >> > Type: Object >> > Example: >> > >> > ``` >> > { >> > "address": "bc1qn0fqlzamcfuahq6xuujrq08ex7e26agt20gexs", >> > "publicKey": >> > "02ad58c0dced71a236f4073c3b6f0ee27dde6fe96978e9a9c9500172e3f1886e5a", >> > "derivationPath": "84'/1'/0'/0/0" >> > } >> > ``` >> > >> > ### API >> > >> > The wallet must implement the following methods. >> > >> > **enable** >> > >> > The enable call prompts the user for access to the wallet. >> > >> > If successful, it resolves to an address (`**Address**` type) of the >> > wallet. Typically the first external address to be used as an identity. >> > >> > **`UserDeniedError`** will be thrown if the request is rejected. >> > >> > **request** >> > >> > The request method must take one parameter in the following format: >> > >> > ``` >> > { >> > "method": "wallet_methodName", >> > "params": ["foo", "bar", "baz"] >> > } >> > ``` >> > >> > For a list of mandatory methods see Table >> > >> > The wallet should reject request calls unless `enable` has been >> resolved. >> > >> > Sensitive requests that involve signing should always prompt the user >> for >> > confirmation >> > >> > On success the request should resolve to the response as defined in the >> > method table. >> > >> > **`UserDeniedError`** will be thrown if the request is rejected. >> > >> > **Mandatory methods** >> > >> > method: `wallet_getAddresses` params: [`index = 0, numAddresses = 1, >> change >> > = false`] >> > return: `[ Address ]` >> > error: UserDeniedError >> > >> > method: `wallet_signMessage` params: `[ message, address ]` >> > return: Signature `Hex` >> > error: UserDeniedError >> > >> > method: `wallet_signPSBT` params: `[ [psbtBase64, inputIndex, address] >> ]` >> > return: `psbtBase64` >> > error: UserDeniedError >> > >> > method: `wallet_getConnectedNetwork` params: `[]` >> > return: Network object `mainnet` | `testnet` | `regetst` >> > error: UserDeniedError >> > >> > ## Rationale >> > >> > The purpose of the API is to expose a set of commonly used wallet >> > operations. In addition, it should be flexible enough to serve for other >> > requests such as node RPC calls. >> > >> > **Why is there a singular request call instead of named methods?** >> > The transport layer for the requests cannot be assumed, therefore it is >> > much more flexible to instead define an abstract format. >> > >> > **Why are the mandatory methods so primitive? Where is getBalance, >> > getUtxos, ... ?** >> > A wallet need not worry about providing every possible scenario for >> usage. >> > The primitives of keys and signing can expose enough to applications to >> do >> > the rest. Applications should have flexibility in how they implement >> these >> > functions. It is the role of a library rather than the wallet. >> > >> > ## Security Implications >> > >> > Great care should be taken when exposing wallet functionality >> externally as >> > the security and privacy of the user is at risk. >> > >> > ### Signing >> > >> > Operations that trigger signing using private keys should be guarded >> behind >> > confirmation screens where the user is fully aware of the nature of the >> > transaction. In the example of a PSBT signature request, the outputs, >> the >> > inputs and which key is being used should be clearly marked. >> > >> > ### Privacy >> > >> > Some api methods expose metadata about the user, such as public keys. >> > Depending on how privacy focused the wallet intends to be, the wallet >> could >> > protect these behind a confirmation. Commonly the wallet just needs to >> give >> > the origin access to all of its public keys, however it could also allow >> > the option to expose only selected derivation paths. >> > >> > -monokh >> >> _______________________________________________ > bitcoin-dev mailing list > bitcoin-dev@lists.linuxfoundation.org > https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev > --000000000000cda1e505b72038b7 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
That's a great idea, in traditional banking there are = wide initiatives=C2=A0to standardize components between different actors, m= ost widely used is Open Banking , i think regardless of the usage, it could= be hardware or software, there is a big value in standrizating communicati= ons between different components.

Here is more info abou= t Open Banking:

On Wed, Dec = 23, 2020 at 10:42 AM monokh via bitcoin-dev <bitcoin-dev@lists.linuxfoundation.org>= wrote:
Thanks for the input Luke.

> 1) People should not be enc= ouraged to write or use web browsers for their wallet.

Indeed. Holdi= ng keys in the browser can be very insecure, however the spec is not limite= d to this. I will amend to make this clear. The same interface can be used = to communicate from a web context or even desktop application with hardware= wallets where keys are segregated safely. The prominent hardware wallets a= lready have such an interface. Unfortunately as there has been no standardi= sation, an application must specifically provide an implementation for each= wallet to be compatible.

> 2) You may want to look over earlier = work in this area.

Please share if you have specifics in mind. What = has been considered were mainly hardware wallet apis. The requests have bee= n defined such that they would be compatible. I will make references to suc= h considerations in the text. I welcome any feedback on what may be missing= or problematic for these providers - something I will also pursue outwith = the thread.

-monokh=C2=A0

On Wed, Dec 23, 2020 at 2:15 AM Luke Dashjr= <luke@dashjr.org> wrote:
1)= People should not be encouraged to write or use web browsers for their wallet.
2) You may want to look over earlier work in this area.

On Tuesday 22 December 2020 14:43:11 monokh via bitcoin-dev wrote:
> Hi
>
> This is a first draft of a BIP we intend to submit. The main intention= is
> to define a simple interface that wallets and applications can agree o= n
> that would cover the vast majority of use cases. This can enable writi= ng
> bitcoin applications (e.g. time lock, multi sig) on the web that can b= e
> seamlessly used with any compatible wallets. We have implementations o= f
> such examples but I don't want to turn this thread into a promotio= n and
> rather focus on the spec.
>
> Appreciate input from the list. Please share if there are existing eff= orts,
> relevant specs or use cases.
>
> ------------------------------
>
> A wallet interface specification for bitcoin applications
>
> ## Abstract
>
> This BIP describes an API for Bitcoin wallets and applications as a > standard.
>
> ## Summary
>
> Bitcoin wallets should expose their address derivation and signing
> functions to external applications. The interface would be expressed a= s
> follows in javascript:
>
> ```
> {
> // Wallet Metadata
> wallet: {
> name: 'Bitcoin Core'
> },
>
> // Request access to the wallet for the current host
> async enable: (),
>
> // Request addresses and signatures from wallet
> async request ({ method, params })
> }
> ```
>
> In the web context the interface could be exposed at the top level of = a
> webpage, for example under `window.bitcoin`. However this spec does no= t
> intend to define any standards for how and where the interfaces should= be
> exposed.
>
> ## Motivation
>
> Due to the seldom available APIs exposed by wallets, applications (web= or
> otherwise) are limited in how they are able to interact. Generally onl= y
> simple sends have been available. A more robust API that introduces ot= her
> requests will promote richer Bitcoin applications.
>
> Additionally, wallet APIs have frequently included inconsistencies in = their
> interfaces and behaviour. This has required applications to build and<= br> > maintain a separate client for each wallet, increasing the risk of bug= s and
> unintended behaviour as well as being a limiting factor for the adopti= on of
> usable bitcoin applications.
>
> With a standardised wallet API:
>
> - Wallets have a clear API to implement
> - Applications have a clear expectation of wallet interface and behavi= our
> - Applications become agnostic to the wallet specifics, increasing cho= ice
> for users
>
> If more wallets implement the specification, applications will be deve= loped
> more confidently by benefiting from the wallet interoperability. This<= br> > creates a positive feedback loop.
>
> ## Specification
>
> For simplicity, the interface is defined in the context of web applica= tions
> running in the browser (JS) however, they are simple enough to be easi= ly
> implemented in other contexts.
>
> ### General Rules
>
> - For sensitive functions (e.g. signing), wallet software should alway= s
> prompt the user for confirmation
>
> ### Types
>
> **UserDeniedError**
> An error type indicating that the application's request has been d= enied by
> the user
> Type: Error
>
> **Hex**
> Type: String
> Example:
> `"0000000000000000000a24677957d1e50d70e67c513d220dbe8868c4c3aefc0= 8"`
>
> **Address**
> Address details
> Type: Object
> Example:
>
> ```
> {
> "address": "bc1qn0fqlzamcfuahq6xuujrq08ex7e26agt20gexs&= quot;,
> "publicKey":
> "02ad58c0dced71a236f4073c3b6f0ee27dde6fe96978e9a9c9500172e3f1886e= 5a",
> "derivationPath": "84'/1'/0'/0/0"
> }
> ```
>
> ### API
>
> The wallet must implement the following methods.
>
> **enable**
>
> The enable call prompts the user for access to the wallet.
>
> If successful, it resolves to an address (`**Address**` type) of the > wallet. Typically the first external address to be used as an identity= .
>
> **`UserDeniedError`** will be thrown if the request is rejected.
>
> **request**
>
> The request method must take one parameter in the following format: >
> ```
> {
> "method": "wallet_methodName",
> "params": ["foo", "bar", "baz"= ]
> }
> ```
>
> For a list of mandatory methods see Table
>
> The wallet should reject request calls unless `enable` has been resolv= ed.
>
> Sensitive requests that involve signing should always prompt the user = for
> confirmation
>
> On success the request should resolve to the response as defined in th= e
> method table.
>
> **`UserDeniedError`** will be thrown if the request is rejected.
>
> **Mandatory methods**
>
> method: `wallet_getAddresses` params: [`index =3D 0, numAddresses =3D = 1, change
> =3D false`]
> return: `[ Address ]`
> error: UserDeniedError
>
> method: `wallet_signMessage` params: `[ message, address ]`
> return: Signature `Hex`
> error: UserDeniedError
>
> method: `wallet_signPSBT` params: `[ [psbtBase64, inputIndex, address]= ]`
> return: `psbtBase64`
> error: UserDeniedError
>
> method: `wallet_getConnectedNetwork` params: `[]`
> return: Network object `mainnet` | `testnet` | `regetst`
> error: UserDeniedError
>
> ## Rationale
>
> The purpose of the API is to expose a set of commonly used wallet
> operations. In addition, it should be flexible enough to serve for oth= er
> requests such as node RPC calls.
>
> **Why is there a singular request call instead of named methods?**
> The transport layer for the requests cannot be assumed, therefore it i= s
> much more flexible to instead define an abstract format.
>
> **Why are the mandatory methods so primitive? Where is getBalance,
> getUtxos, ... ?**
> A wallet need not worry about providing every possible scenario for us= age.
> The primitives of keys and signing can expose enough to applications t= o do
> the rest. Applications should have flexibility in how they implement t= hese
> functions. It is the role of a library rather than the wallet.
>
> ## Security Implications
>
> Great care should be taken when exposing wallet functionality external= ly as
> the security and privacy of the user is at risk.
>
> ### Signing
>
> Operations that trigger signing using private keys should be guarded b= ehind
> confirmation screens where the user is fully aware of the nature of th= e
> transaction. In the example of a PSBT signature request, the outputs, = the
> inputs and which key is being used should be clearly marked.
>
> ### Privacy
>
> Some api methods expose metadata about the user, such as public keys.<= br> > Depending on how privacy focused the wallet intends to be, the wallet = could
> protect these behind a confirmation. Commonly the wallet just needs to= give
> the origin access to all of its public keys, however it could also all= ow
> the option to expose only selected derivation paths.
>
> -monokh

_______________________________________________
bitcoin-dev mailing list
= bitcoin-dev@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mail= man/listinfo/bitcoin-dev
--000000000000cda1e505b72038b7--