Giter Club home page Giter Club logo

research's Introduction

Blockchain Commons Research

This repository contains early-stage research of interest to the blockchain community.

Blockchain Commons Research papers (BCRs) are not standards. They are fluid specifications, typically based on our own libraries or other coding. Because of their fluidity, BCRs might change without notice. If you decide to adopt a Blockchain Commons Research paper, you are becoming a Research Partner, examining how the specification might work in the real world. We look forward to working with you!

If you are using the specifications from a BCR, please let us know. Having a BCR in usage by at least two parties other than Blockchain Commons is one of our criteria for advancing a BCR to a Blockchain Commons Proposal (BCP), increasing its stability. If you can only use a specification if it is advanced to the BCP stage, sldo let us know that, as we sometimes advance BCRs on our own if they have achieved sufficient maturity.

Generally, it's only if a BCR advances to the BCP stage that we more deeply involve community in its continued maturation and focus on it becoming an actual standard.

Status

Each BCR has a status which is indicated by a symbol.

Symbol Title Description
❌❌ Withdrawn Of historic interest only. Withdrawn either because never came into use or proved sufficiently problematic that we do not recommend its usage in any way.
Superseded Superseded by a newer BCR. We do not suggest implementing as an output format, but you may still wish to implement as an input format to maintain backward compatibility.
📙 Research Contains original research or proposes specifications that have not yet been implemented by us. Offered to the community for consideration.
⭐️ Reference Implementation At least one reference implementation has been released, usually as a library, and may include demos or other supporting tools. This specification still remains very open to change because it has not yet (to our knowledge) been implemented by additional parties.
⭐️⭐️ Multiple Implementations At least two (known) implementations exist, at least one not by the owner of the reference implementation. Has demonstrable community support. May still change due to the needs of the community, but community feedback will be sought.
⭐️⭐️⭐️ Standards Track Typically at least two implementations, and is considered stable and ready for standardization. Being proposed as a BIP, IETF Internet Draft, or some other standardization draft format. Will typically be moved to the BCP repo. Though changes may still be made to the specification, these changes will exclusively be to allow for standardization, and will be conducted with community feedback.
⭐️⭐️⭐️⭐️ Standardized A specification has been standardized as a an IETF RFC, BIP, or approved by some other standards body.
📖 Implementation Guide A developer's guide to implementating a specification that may also double as the specification itself.

❌❌ after another status symbol is read, "...but withdrawn" and ❌ is read, "...but superseded".

Contents

Number Title Owner Status
BCR-2020-001 Uniformly Translating Entropy into Cryptographic Seeds Wolf McNally 📙
BCR-2020-002 Bech32 Encoding for Cryptographic Seeds Wolf McNally ❌❌
BCR-2020-003 Encoding Binary Compatibly with URI Reserved Characters Wolf McNally 📙
BCR-2020-004 The BC32 Data Encoding Format Wolf McNally ⭐️❌❌
BCR-2020-005 Uniform Resources (UR): Encoding Structured Binary Data for Transport in URIs and QR Codes (Version 2) Wolf McNally ⭐️⭐️
BCR-2020-006 Registry of Uniform Resource (UR) Types Wolf McNally ⭐️⭐️
BCR-2020-007 UR Type Definition for Hierarchical Deterministic (HD) Keys Wolf McNally ⭐️⭐️
BCR-2020-008 UR Type Definition for Elliptic Curve (EC) Keys Wolf McNally ⭐️
BCR-2020-009 UR Type Definition for Cryptocurrency Addresses Wolf McNally ⭐️⭐️
BCR-2020-010 UR Type Definition for Bitcoin Output Descriptors (Version 1) Wolf McNally ⭐️⭐️❌
BCR-2020-011 UR Type Definition for Sharded Secret Key Reconstruction (SSKR) Wolf McNally ⭐️
BCR-2020-012 Bytewords: Encoding binary data as English words Wolf McNally ⭐️⭐️
BCR-2020-013 CRC-32 Checksums in CBOR Wolf McNally ❌❌
BCR-2020-014 URs on E-paper display Gorazd Kovacic ⭐️
BCR-2020-015 UR Type Definition for BIP44 Accounts (version 1) Craig Raw ⭐️⭐️❌
BCR-2021-001 UR Type Definitions for Transactions Between Airgapped Devices Wolf McNally ⭐️❌
BCR-2021-002 Digests for Digital Objects Wolf McNally ⭐️
BCR-2022-001 Encrypted Message Wolf McNally ⭐️
BCR-2022-002 ARID: Apparently Random Identifier Wolf McNally ⭐️
BCR-2023-001 Compressed Message Wolf McNally ⭐️
BCR-2023-002 Known Values: A Compact, Deterministic Representation for Ontological Concepts Wolf McNally ⭐️
BCR-2023-003 Gordian Envelope Extension: Known Values Wolf McNally ⭐️
BCR-2023-004 Gordian Envelope Extension: Symmetric Encryption Wolf McNally ⭐️
BCR-2023-005 Gordian Envelope Extension: Compression Wolf McNally ⭐️
BCR-2023-006 Gordian Envelope: Attachments Wolf McNally ⭐️
BCR-2023-007 Gordian Envelope: Bitcoin Output Descriptors (Version 2) Wolf McNally ⭐️❌❌
BCR-2023-008 dCBOR: Preferred Encoding of Dates Wolf McNally ⭐️
BCR-2023-009 Gordian Envelope: Cryptographic Seeds Wolf McNally ⭐️
BCR-2023-010 Bitcoin Output Descriptor (Version 3) Wolf McNally ⭐️⭐️
BCR-2023-011 UR Type Definitions for Public Key Cryptography Wolf McNally ⭐️
BCR-2023-012 Gordian Envelope Expressions Wolf McNally ⭐️
BCR-2023-013 Gordian Envelope Cryptography Wolf McNally ⭐️
BCR-2023-014 Gordian Sealed Transaction Protocol (GSTP) Wolf McNally ⭐️
BCR-2023-015 UR Type Definition for Cryptographic Nonce Wolf McNally ⭐️
BCR-2023-016 UR Type Definition for Scrypt-Hashed Password Wolf McNally ⭐️
BCR-2023-017 UR Type Definition for Random Salt Wolf McNally ⭐️
BCR-2023-018 Gordian Depository API Wolf McNally ⭐️
BCR-2023-019 UR Type Definition for BIP44 Accounts (Version 2) Craig Raw ⭐️⭐️
BCR-2024-001 Multipart UR (MUR) Implementation Guide Wolf McNally 📖⭐️⭐️
BCR-2024-002 dCBOR: A Deterministic CBOR Application Profile Wolf McNally ⭐️⭐️⭐️
BCR-2024-003 The Gordian Envelope Structured Data Format Wolf McNally ⭐️
BCR-2024-004 Gordian Transport Protocol Implementation Guide
Envelope Request & Response Implementation Guide
Shannon Appelcline 📖⭐️
BCR-2024-005 CBOR Encodings for Cryptographic Keys and Signatures Wolf McNally 📙
BCR-2024-006 Representing Graphs using Gordian Envelope Wolf McNally 📙
BCR-2024-007 Decorrelation of Gordian Envelopes Wolf McNally ⭐️

Also see our Testimony and our Blockchain Commons Proposals.

Please feel free to submit your own Drafts of BCRs for specifications that support the creation of open, interoperable, secure & compassionate digital infrastructure to this repo as PRs, as follows.

All contributions to this repo require a Signed Contributor License Agreement (which will be needed if we submit to other organizations like IETF, W3C, Linux Foundation, etc.).

BCR Number

Please number all Bitcoin Research BCRs with a four-digit number representing the current year (YYYY) followed by a three-digit sequence number for that year (SSS). For example: bcr-2020-001 is the first BCR for 2020, bcr-2020-017 is the 17th, and bcr-2021-001 is the first BCR for 2021.

Note that the sequence number reverts to 001 at the start of each year.

BCR Title

Please be sure that your title is concise, yet informative.

BCR Version

When updating BCRs, please use semantic versioning for your version number.

Most briefly: your version number should be of the form X.Y.Z, where X is the major number ("0" for a BCR Draft; "1" for something ready to become a BCR Work Product; and "2" or higher for a new version that has introduced a backward-incompatible change), Y is the minor number (for a backward-compatible new feature), and Z is the patch number (for fixing typos and making other clarifications that don't fundamentally change what the BCR means).

But please consult the semantic versioning document for more information and adjust appropriately for the fact that these are textual BCRs, not software.

BCR Owner

Please list the person primarily responsible for the BCR, and moving it forward, as the owner. If there are multiple authors, they should be listed on the BCR itself, not on this overview.

Origin, Authors, Copyright & Licenses

Unless otherwise noted (either in this /README.md or in the file's header comments) the contents of this repository are Copyright © by Blockchain Commons, LLC, and are licensed under the spdx:BSD-2-Clause Plus Patent License.

Financial Support

This research is a project of Blockchain Commons. We are proudly a "not-for-profit" social benefit corporation committed to open source & open development. Our work is funded entirely by donations and collaborative partnerships with people like you. Every contribution will be spent on building open tools, technologies, and techniques that sustain and advance blockchain and internet security infrastructure and promote an open web.

To financially support further development of this research and other projects, please consider becoming a Patron of Blockchain Commons through ongoing monthly patronage as a GitHub Sponsor. You can also support Blockchain Commons with bitcoins at our BTCPay Server.

Contributing

We encourage public contributions through issues and pull requests! Please review CONTRIBUTING.md for details on our development process. All contributions to this repository require a GPG signed Contributor License Agreement.

Discussions

The best place to talk about Blockchain Commons and its projects is in our GitHub Discussions areas.

Gordian Developer Community. For standards and open-source developers who want to talk about interoperable wallet specifications, please use the Discussions area of the Gordian Developer Community repo. This is where you talk about Gordian specifications such as Gordian Envelope, bc-shamir, Sharded Secret Key Reconstruction, and bc-ur as well as the larger Gordian Architecture, its Principles of independence, privacy, resilience, and openness, and its macro-architectural ideas such as functional partition (including airgapping, the original name of this community).

Blockchain Commons Discussions. For developers, interns, and patrons of Blockchain Commons, please use the discussions area of the Community repo to talk about general Blockchain Commons issues, the intern program, or topics other than those covered by the Gordian Developer Community or the Gordian User Community.

Other Questions & Problems

As an open-source, open-development community, Blockchain Commons does not have the resources to provide direct support of our projects. Please consider the discussions area as a locale where you might get answers to questions. Alternatively, please use this repository's issues feature. Unfortunately, we can not make any promises on response time.

If your company requires support to use our projects, please feel free to contact us directly about options. We may be able to offer you a contract for support from one of our contributors, or we might be able to point you to another entity who can offer the contractual support that you need.

Credits

The following people directly contributed to this repository. You can add your name here by getting involved. The first step is learning how to contribute from our CONTRIBUTING.md documentation.

Name Role Github Email GPG Fingerprint
Christopher Allen Principal Architect @ChristopherA <[email protected]> FDFE 14A5 4ECB 30FC 5D22 74EF F8D3 6C91 3574 05ED
Wolf McNally Contributor @WolfMcNally <[email protected]> 9436 52EE 3844 1760 C3DC  3536 4B6C 2FCF 8947 80AE

Responsible Disclosure

We want to keep all of our software safe for everyone. If you have discovered a security vulnerability, we appreciate your help in disclosing it to us in a responsible manner. We are unfortunately not able to offer bug bounties at this time.

We do ask that you offer us good faith and use best efforts not to leak information or harm any user, their data, or our developer community. Please give us a reasonable amount of time to fix the issue before you publish it. Do not defraud our users or us in the process of discovery. We promise not to bring legal action against researchers who point out a problem provided they do their best to follow the these guidelines.

Reporting a Vulnerability

Please report suspected security vulnerabilities in private via email to [email protected] (do not use this email for support). Please do NOT create publicly viewable issues for suspected security vulnerabilities.

The following keys may be used to communicate sensitive information to developers:

Name Fingerprint
Christopher Allen FDFE 14A5 4ECB 30FC 5D22 74EF F8D3 6C91 3574 05ED

You can import a key by running the following command with that individual’s fingerprint: gpg --recv-keys "<fingerprint>" Ensure that you put quotes around fingerprints that contain spaces.

research's People

Contributors

aaronisme avatar andreasgassmann avatar chaitika avatar christophera avatar craigraw avatar dspicher avatar gorazdko avatar mflaxman avatar nochiel avatar shannona avatar wolfmcnally avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

research's Issues

incorrect header for CBOR byte string in BCR-2020-005 paper

Hi,

The BCR-2020-005 paper says (about CBOR byte strings)

"If the encoded byte string has 65536..2^32-1 bytes, it is preceded by (0x60, b1, b2, b3, b4) where b(n) is the big-endian four byte length of the following byte string."

This is not correct. According to https://tools.ietf.org/html/rfc7049 the header for 65536+ byte strings is 0x5a (Indeed, the value after 0x59. 0x60 is the header of shortest UTF-8 strings)

release reference implementations into the public domain

Some specifications, such as BCR-2020-005, are specified in terms of reference implementations. Ideally, specifications should be complete without those implementations, but if its unavoidable we propose them be released into the public domain for maximal interoperability.

Our concrete issue is that the SeedHammer implementation is in the public domain and it adds friction to implement your specifications without becoming a derivative and thus having to include your license.

A new specification for bc32 or bc64 with no HRP/UIR collision?

Re: https://github.com/BlockchainCommons/Research/blob/master/papers/bcr-0003-uri-binary-compatibility.md

Should we define a new specification that is bech32 but addresses the HRP collision problem with the URI reserved character set? Maybe call it bc32?

I'm also trying to get the parameters from @sipa for a possible 64-128 byte optimized form that could also form a new specification. (see Twitter thread https://twitter.com/pwuille/status/1250663639930953729?s=20 )

I like bech32 for its ability to be read over phone and to offer both error detection and some error correction. But we have to specify it carefully, quoting @sipa in BIP-0173:

An unfortunate side effect of error correction is that it erodes error detection: correction changes invalid inputs into valid inputs, but if more than a few errors were made then the valid input may not be the correct input.…Because of this, implementations SHOULD NOT implement correction beyond potentially suggesting to the user where in the string an error might be found, without suggesting the correction to make.

This limitation also makes bech32 as an encoding format limited in another way that Base64URL format is not — it is only suitable for short lengths.

Either, or both of these new specifications I might be able to run the flag up to get standardized in IETF or W3C.

cc/ @maaku @kanzure @Fonta1n3 @ksedgwic

-- Christopher Allen

add name property to crypto-output

crypto-hdkey can have names, but crypto-output cannot. This issue proposes adding a name property to crypto-output.

This is useful to identify a particular wallet setup, in particular where the names of individual shares are not important. For SeedHammer, each steel plate represents a share, but without descriptor names a user can't easily know which plates form a wallet.

One workaround is to give every crypto-hdkey in a descriptor the same name. However, at least Sparrow enforces unique names, for good reasons. Adding numbers ("My Cold Storage #1", "My Cold Storage #2"...) is feasible, but ugly and confusing.

Consider a compact PSBT based encoding for wallet descriptors

Prompted by discussions at wizardsardine/liana#539, this is a sketch for a BIP proposal for serializing wallet descriptors. I raise it here for comments and because Blockchain Commons is a recognized standards body for Bitcoin specifications. If there's enough interest, it should be fleshed out and proposed as a BIP.

A Go implementation written from scratch is here: https://github.com/seedhammer/bip-serialized-descriptors

At the high level, this is a binary and compact serialization specification for the [wallet-policies] BIP.

  • Binary format, based on the [BIP174] PSBT format.
  • Descriptor is in text, as described in BIPs 380-386 (+389). Like the wallet-policies BIP, keys are always by indexed reference.
  • Key references uses the wallet-policies format @<key-index>.
  • Miniscript is trivially supported, except pk(NAME) expressions are replaced with key indexes.

Borrowing from BIP174, the format would be

 <desc> := <magic> <global-map> <key-map>*
 <magic> := 0x64 0x65 0x73 0x63 0xFF
 <global-map> := <keypair>* 0x00
 <key-map> := <keypair>* 0x00
 <keypair> := <key> <value>
 <key> := <keylen> <keytype> <keydata>
 <value> := <valuelen> <valuedata>

Where <global-map> contains one or more of the fields:

  • DESC_BIP38x_DESCRIPTOR: The descriptor itself, encoded in UTF-8 according to the BIP380 family, with the Miniscript extensions. Keys must be specified as @ according to the wallet-policies BIP. Inline keys are not allowed.
  • DESC_NAME: The name of the wallet in UTF-8.
  • DESC_BIRTHDATE: The wallet birthdate in blocks, encoded as a compact integer.

In future, other script formats (Simplicity?) can be added as separate field types.

The <key-map> is a list of keys, matching the indexed references from the descriptor. Each <key-map> contains one or more of the fields:

  • PSBT_GLOBAL_XPUB: An extended key, encoded just like PSBTs would.
  • DESC_KEY_NAME: The name of the key encoded in UTF-8.

FAQ

Why not use the Blockchain Commons [BCR-2020-010] format?

The format was recently deprecated, for good reasons: its binary format is compact but difficult to extend to support extensions to the descriptor format, such as Miniscript.

Why not use the Blockchain Commons Envelope format for descriptors?

  • It relies on the CBOR encoding which is a significant complexity in a specification (more on CBOR later).
  • CBOR is more compact than text, but descriptors are encoded in text and does not enjoy any of the advantages of CBOR.

The standard is being developed and as such does not have an advantage of existing use.

Why not use CBOR for encoding?

  • CBOR is significantly more general, and therefore complex, than the PSBT encoding.
  • CBOR is more complex and thus require more code space, which is scarce in embedded applications.
  • Wallet software already include PSBT decoders for transaction processing. To be fair, most wallet software also includes some CBOR capability because of the Blockchain Commons UR standard (more on UR later).
  • A specification (or BIP) should ideally be complete and self-contained, and referencing another standard (CBOR) makes implementing, debugging and ensuring interoperability harder. For an example of this complexity, CBOR is not deterministic (I believe the Blockchain Commons is working on a dCBOR proposal to fix that).
  • The PSBT format is already a BIP and widely accepted. A self-contained specification based on an already widely accepted binary format increases our chances of widespread support. In particular, I'd like to see Bitcoin Core support this format.

What about QR code representation?

A straightforward encoding would be the use the Blockchain Commons [BCR-2020-005] standard for splitting the serialized descriptor into multiple QR code frames. I believe the general purpose bytes urtype is sufficient, because the magic header decreases the likelihood of misinterpretation.

Doesn't UR support rely on a CBOR implementation anyway?

It's true that the UR specification rely on CBOR for encoding data shards, but it's my understanding that the subset of CBOR required can practically be implemented ad-hoc without a full fledged CBOR library.

Some devices, such as the camera-less Coldcards, won't implement the UR encoding because they exchange serialized descriptors through higher bandwidth mediums such as SD cards, USB, or NFC.

Why not encode the descriptor itself in binary?

The BC envelope format made the same decision of encoding the descriptor in text, for good reasons:

  • The descriptor language is complicated and expanding. Relying on existing standards for encoding saves a lot of complexity and duplicate specification efforts. In particular, any future descriptor extension BIPs such as Miniscript may be used immediately for this BIP, without deciding on a binary representation first.
  • The major source of bloat, extended keys, are binary encoded for compactness and can be re-used multiple times in a single descriptor.

[wallet-policies] https://github.com/bitcoin/bips/blob/bb98f8017a883262e03127ab718514abf4a5e5f9/bip-wallet-policies.mediawiki
[BIP174] https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki
[BCR-2020-010] https://github.com/BlockchainCommons/Research/blob/master/papers/bcr-2020-010-output-desc.md
[BCR-2020-005] https://github.com/BlockchainCommons/Research/blob/master/papers/bcr-2020-005-ur.md

Fisher-Yates Shuffle test in multipart UR paper could better showcase the method

The current test for the Fisher-Yates Shuffle returns a different list of shuffled indexes for each iteration of the map method because the same random number generator variable is reused for all calls on the shuffled() method. This does not invalidate the test, but makes it less obvious what the count argument does in the shuffled() method. When implementing myself, I was initially under the impression that the count somehow influenced the returned result, which was puzzling. Moreover, I was contrasting this implementation with the Hummingbird implementation of this method, which always returns the fully shuffled list. I was expecting the count to simply help me return a subset of the list, but since all the lists were different on each iterations in the Swift test, I got confused for a little bit until I realized that the issue was simply that the rng was being reused for each call.

Current test

func testShuffle() {
    let rng = Xoshiro256(string: "Wolf")
    let indexes = 1...10
    let values = Array(indexes)
    let result = indexes.map { count in
        shuffled(values, rng: rng, count: count)
    }
    let expectedResult = [
        [6],
        [5, 8],
        [4, 10, 5],
        [7, 10, 3, 8],
        [10, 8, 6, 5, 1],
        [1, 3, 9, 8, 4, 6],
        [4, 6, 8, 9, 3, 2, 1],
        [3, 9, 7, 4, 5, 1, 10, 8],
        [3, 10, 2, 6, 8, 5, 7, 9, 1],
        [1, 5, 3, 8, 2, 6, 7, 9, 4, 10]
    ]
    XCTAssertEqual(result, expectedResult)
}

Proposed new test

The text accompanying this Fisher-Yates Shuffle section mentions:

Its implementation affords efficiently generating only the number of fragments needed for a given part, rather than shuffling all fragment indexes and then taking a subset.

I propose the following small change which (a) makes explicit the value of the count argument in the method, and (b) showcases what the paragraph above describing the choice of algorithm mentions and brings it more in line with its test:

func testShuffle() {
    let indexes = 1...10
    let values = Array(indexes)
    let result: [[Int]] = indexes.map { count in
        let rng = Xoshiro256(string: "Wolf")
        return shuffled(values, rng: rng, count: count)
    }
    let expectedResult = [
        [6],
        [6, 4],
        [6, 4, 9],
        [6, 4, 9, 3],
        [6, 4, 9, 3, 10],
        [6, 4, 9, 3, 10, 5],
        [6, 4, 9, 3, 10, 5, 7],
        [6, 4, 9, 3, 10, 5, 7, 8],
        [6, 4, 9, 3, 10, 5, 7, 8, 1],
        [6, 4, 9, 3, 10, 5, 7, 8, 1, 2]
    ]
    XCTAssertEqual(result, expectedResult)
}

I'm happy to open the PR on the paper as well as the URKit tests if this is a welcome change.

bytewords should follow alphabetically consistently

Abstract

In bcr-2020-012-bytewords.md most of the words look to be ordered alphabetically. The exception I ran into is
the last line:

0xf8: yoga yurt zaps zest zinc zone zoom zero

The same issue is in both (c and c++) implementations of bytewords.

This causes lots of difficulties on the UI side in lethekit.

UR type crypto-psbt?

Having re-implemented/ported URKit to Java, mainly in order to assist with the transfer of PSBTs over QR, I am wondering why there is no registered type crypto-psbt. I am currently using ur:bytes/ with the CBOR encoded bytes of the serialized PSBT.

I realise PSBTs are Bitcoin-only, but it seems like such a clear use for the standardisation that URs provide given that PSBTs are becoming the standard of partial transactions when signing between different QR capable devices.

Bytewords (BCR-2020-012) checksum

The choice to use the first four bytes of a CRC32 hash of a Bytewords body is open for comment. This issue is being tracked here. Please leave your comments below.

Type for SSKR config parameters

To help with guided recovery on clients, and metadata for collaborative recovery services (BlockchainCommons/Community#149), it is useful to have a type encoding just the config parameters of a unique SSKR split, without the share values.

The following parameters from https://github.com/BlockchainCommons/Research/blob/master/papers/bcr-2020-011-sskr.md would be useful as part of this type:

  • identifier (id)
  • group-threshold (Gt)
  • group-count (g)
  • member-threshold (t) per group

bcr-2020-005-ur: sha256 digest

sha256 digest of the message is 32 bytes, when converted to bc2 it is 58 characters long.
If I understand correctly it is only used to check the integrity of all pieces.

I have two suggestions:

  • take only a part of the digest, for example 8 bytes instead of all 32, it is good enough for the checksum, and error correction is not possible with hash digests anyways
  • allow transmitting hash digest only in one QR code, not in all of them - I don't see a reason to waste QR code capacity and transmit the same data in all frames. Or make it optional for sequential QR codes as well and let the implementation decide if they want to use it or not.

crypto-address improvements.

Currently the BCR-2020-006 standard defines the crypto-address UR type but the definition is a little bit ambiguous.

On Example/Test Vector 1 the specified P2PKH address 1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2 does not include the type of the address in the encoded CBOR, making it ambiguous to differentiate between it P2SH and P2PKH as these are both 20-byte hashes.

On the CDDL comment it should also:

- ;   For addresses of type `p2wphk`, the sha256 of the script bytes (32 bytes).
+ ;   For addresses of type `p2wpkh`, the witness program (20 bytes).

It is not a script hash but the witness program and for P2WPKH it is 20 bytes, for P2WSH it is 32 bytes.

P2WSH could be also added and P2TR addresses too.

So:

  • P2PKH, P2SH and P2WPKH types of addresses use 20-bytes of data.
  • P2WSH and P2TR use 32-bytes of data.

I think to differentiate these the type field should be always included when info specifies a Bitcoin address. Also maybe the info field should have a .default specifier but I don't know if CDDL allows that for maps or if the behavior is to skip a field in a map completely when all the fields of the inner map can be ommited because of the default values.

incorrect test vectors: hdkey serialization

Abstract

Across HD keys and output descriptors the test vectors are incomplete wrt depth and child number:

EDIT: removed incorrect example and showed a new example:

Output Descriptors

  • incorrect depth. In certain cases depth must be provided despite derivation-path presence:
04 ; version 4
88b21e ; `xpub`
04 ; depth 4
78412e3a ; parent fingerprint
fffffffe ; child number
637807030d55d01f9a0cb3a7839515d796bd07706386a6eddf06cc29a65a0e29 ; chain code
02d2b36900396c9282fa14628566582f206a5dd0bcc8d5e892611806cafb0301f0 ; key data
7e652001 ; base58 checksum

    In the CBOR diagnostic notation:

403( ; public-key-hash
	303({ ; crypto-hdkey
		3: h'02d2b36900396c9282fa14628566582f206a5dd0bcc8d5e892611806cafb0301f0', ; key-data
		4: h'637807030d55d01f9a0cb3a7839515d796bd07706386a6eddf06cc29a65a0e29', ; chain-code
		6: 304({ ; origin: crypto-keypath
			1: [ ; components
				44, true, 0, true, 0, true ; 44'/0'/0'
			],
			2: 3545084735 ; origin-fingerprint
		}),

Crypto address

How to get version for the witness program? From type which is optional?

#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum Payload {
    /// P2PKH address
    PubkeyHash(PubkeyHash),
    /// P2SH address
    ScriptHash(ScriptHash),
    /// Segwit addresses
    WitnessProgram {
        /// The witness program version
        version: bech32::u5,
        /// The witness program
        program: Vec<u8>,
    },
}

MUR Implementation Guide mentions fragment chooser uses SHA-256 hash as seed but implementations don't

The Fragment Chooser section of the Multipart UR Implementation Guide states the following:

When seqNum is greater than seqLen, the big-endian serialized seqNum and checksum are concatenated and then passed through SHA-256 to generate a 256-bit seed for the PRNG.

(seqNum || checksum) -> SHA256 -> Xoshiro256

I have not found this to be the case in the URKit, Hummingbird, ur-rs, or foundation-ur-py libraries.

Instead, a 64-bit seed composed of the joined seqNum and checksum is passed to the Xoshiro256 RNG without hashing. Note that Xoshiro internally does sha-256 hash the seed when initialized, so that might be where this came from, or maybe where I'm getting confused? In any case, the seed provided to the Xoshiro constructor is not a 256-bit seed.

Replace RandomSampler for multi-part URs fountain codes

The UR encoder and decoder have to agree on the degree and selection of part indices for any given fragment, so the pseudo-random algorithm has to be followed by every implementation. However:

  • Choosing a degree depends on an almost 100 line RandomSampler just to get the complexity from O(n) or O(log n) to O(1)[*].
  • RandomSampler uses doubles for its computations; floating point computations are notoriously hard to make deterministic across platforms, and they're slow on embedded devices. RandomSampler even has a comment,
        while !S.isEmpty {
            // can only happen through numeric instability
            probs[S.removeLast()] = 1
        }

which doesn't instill confidence in the complete reproducibility of the resulting degree selection.

I suggest one or more of the following:

  • Change the UR multi-part standard to use a simpler degree selection method, preferably avoiding floating point computations. It may even be possible that a replacement exists that is backwards-compatible.
  • Change the standard to require data sizes below a certain threshold not use fountain codes.
  • Completely document the algorithm, removing references to any particular implementation.

[*]: Note that chooseDegree re-creates the RandomSampler at every use, thus defeating the O(1) advantage.

BCR-2020-007 Keypath/HD Keys: Master vs parent fingerprint

In BCR-2020-007, the specification for a derived-key includes a crypto-keypath for the key origin. However, crypto-keypath specifies a parent-fingerprint field instead of a master-fingerprint field, as would be normal for key origin information. This leads to a number of issues, and I believe the specification for a derived-key needs to be changed.

Note that the parent fingerprint is necessary in order to construct the xpub from a crypto-hdkey UR encoding. Therefore, the example in Test Vector 2 encodes the parent fingerprint into the key origin crypto-keypath, instead of the master fingerprint. This means the xpub can be reconstructed, but the master fingerprint is lost.

The issue is more serious when considering BCR-2020-010: Output descriptors. Considering Test Vector 4, we see here that the master fingerprint is encoded into the origin crypto-keypath instead of the parent fingerprint. This means that the parent fingerprint (in this case 0x78412e3a) is lost, and the xpub - and therefore the output descriptor - cannot be reconstructed.

My suggestion to resolve these issues is to add a further crypto-keypath to derived-key in BCR-2020-007 which contains the parent fingerprint, one path component with the child number, and the depth the HD key was derived at (as per BIP32). This means all the fields necessary to derive the xpub are available independently of the origin crypto-keypath.

derived-key = (
        ...
        ? parent: #6.304(crypto-keypath)
)

...
parent = 8

Further, the definition for crypto-keypath should not reference parent-fingerprint but rather master-fingerprint.

Version bits for SSKR?

In https://github.com/BlockchainCommons/Research/blob/master/papers/bcr-2020-011-sskr.md, should we have a version bit or bytes for SSKR so that we are not 100% intersecting the binary version of SLIP-39? Not that they are exposing that anywhere. Is the customization string ofshamir enough? I was always a bit uncomfortable with that trick in case we ever wanted to upgrade the checksum mechanism (say to bc32).

I know that @ksedgwic would ideally whatever we do to be small enough that when converted to mnemonics can fit on 2 of his metal doglegs. 15 characters per line, 6 lines per tag. So if a 1 byte version byte puts us over in whatever final mnemonic scheme we come up with, it could hurt. So it could maybe be a nibble somewhere?

-- Christopher Allen

Rust implementation of UR

Hi!

I'm interested in working on a Rust implementation of Uniform Resources, does anybody know if somebody has already started to do this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.