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

Seems the public key generated by "generate_pubkey" not match the giving source address? #1

Open
crackerli opened this issue Dec 11, 2020 · 1 comment

Comments

@crackerli
Copy link

Test platform:
Android NDK arm64v8
And
Mac 10.15.7, gcc Apple clang version 12.0.0 (clang-1200.0.32.27)

Produce steps:

  1. find the demo private key: Scalar priv_key = { 0xca14d6eed923f6e3, 0x61185a1b5e29e6b2, 0xe26d38de9c30753b, 0x3fdf0efb0a5714 }; and its address: char* source_str = "B62qiy32p8kAKnny8ZFwoMhYpBppM1DWVCqAPBYNcXnsAHhnfAAuXgg";

  2. Decode the address string with base58 decoder, and get the following byte stream:
    cb 01 01 0f 48 c6 5b d2 5f 85 f3 e4 ea 4e fe be b7 5b 79 7b d7 43 60 3b e0 4b 4e ad 84 56 98 b7 6b d3 31 00 82 7b 2d 85

remove first 3 bytes those indicate version and end five bytes of parity and checksum, then the byte stream of x coordinate of public key should be: 0f 48 c6 5b d2 5f 85 f3 e4 ea 4e fe be b7 5b 79 7b d7 43 60 3b e0 4b 4e ad 84 56 98 b7 6b d3 31.

  1. call "generate_pubkey" with param "priv_key", and get the public key data stored in Affine structure, and print any array item of Field x, for example, I do printf("{ pubkey_x: '%x',\n", (kp.pub.x)[0]); , the result is "d86d9a3b"(we can forget the data losing of convert from uint64_t to uint32_t), but I can not find any of the byte value in the byte stream I produced in step 2.

What's wrong here?

Thanks.

@crackerli
Copy link
Author

I see I should call fiat_pasta_fp_from_montgomey to convert the x coordinator data

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

1 participant