Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SLIP0013 does not provide worked examples for HD structure #2

Closed
gary-rowe opened this issue Feb 13, 2016 · 1 comment
Closed

SLIP0013 does not provide worked examples for HD structure #2

gary-rowe opened this issue Feb 13, 2016 · 1 comment

Comments

@gary-rowe
Copy link
Contributor

The SLIP0013 reference document should provide an example of the expected values for A, B, C, D for a given set of example URIs and index values. These should include optional values (e.g. is a missing "user" field treated as empty string or null) and so on.

Adding these reference values will make supporting the feature much easier.

Here is some Java code to illustrate:

    // See https://github.com/trezor/python-trezor/blob/ca45019918bc4c54f1ace899a9acf397c8f4d92f/tests/test_msg_signidentity.py#L27 for details
    URI identityUri = URI.create("https://satoshi@bitcoin.org/login");

    List<Integer> addressN = IdentityUtils.buildAddressN(identityUri, 0);

    // m/2147483661/2637750992/2845082444/3761103859/4005495825
    assertThat(addressN.size()).isEqualTo(5);
    // Remove the hardening to see the underlying value
    assertThat(addressN.get(0) & 0x0fffffff).isEqualTo(13); // 2147483661L
    assertThat(addressN.get(1) & 0x0fffffff).isEqualTo(221831888); // 2637750992L
    assertThat(addressN.get(2) & 0x0fffffff).isEqualTo(160727884); // 2845082444L
    assertThat(addressN.get(3) & 0x0fffffff).isEqualTo(3007475); // 3761103859
    assertThat(addressN.get(4) & 0x0fffffff).isEqualTo(247399441); // 4005495825

The derivation of A,B,C,D should also be specified as little endian for the avoidance of doubt.

@gary-rowe gary-rowe changed the title SLIP0013 does not provide a worked examples for HD structure SLIP0013 does not provide worked examples for HD structure Feb 13, 2016
@prusnak
Copy link
Member

prusnak commented Feb 13, 2016

Unit test for python-trezor contains these: https://github.com/trezor/python-trezor/blob/master/tests/test_msg_signidentity.py (including the hash and A/B/C/D values). If you want, you can create a pull request to SLIP-0013 so we have it there as well.

@prusnak prusnak closed this as completed Feb 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants