-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Key format description #1
Comments
The format of a EC private key is just 32 random bytes: The format of an EC public key is 33 bytes, and is produced by running a private key through Secp256K1: https://github.com/BlockchainCommons/bc-components-rust/blob/bd1a506a6cdeaea32bfb707e986e711b60316543/src/ec_key/ec_private_key.rs#L129 |
I'm still confused :( After byteWords decoding I got: This in turn returned the following after CBOR decoding: These are two 32-byte arguments which would in JWK mean "x" and "y" but according to https://github.com/BlockchainCommons/bc-components-rust/blob/bd1a506a6cdeaea32bfb707e986e711b60316543/src/tags.rs#L74 |
Continued... After CBOR encoding I get a 16-byte blob: This is not a private key. Do you SHA256 it order to get a private key? |
First of all, recall that when CBOR is UR-encoded, the outermost tag is replaced by the UR type string, So the fully-serialzed dCBOR is:
So now you see that there are two internal tags: 40022 and 40011. Those correspond to The So it is also called a "base" because it can be used to derive all sorts of other private keys including Bitcoin BIP-32 HD keys, and it has no size limitation so it can be as big as you want. 128 bits (16 bytes) is an absolute minimum. The actual key generation algorithm has to take this variable length private key base and use it to generate a key of a fixed length. The standard method of deriving each of the various private key types (ECDSA, Schnorr, x25519) varies. For example, Since you can't move back from a public key to a private key, the public key base bundles both a signing and an agreement public key. But this isn't required for a private key base as you can generate literally anything from it. |
I now understand how private keys are represented in the CLI. What I don't understand is the example from your documentation: Since you build on hard-coded crypto, you should probably write a separate document about this to aid third party developers. |
I can't find any description of the ECDSA key format used by the CLI.
It would be nice if there was a way to convert native keys to the format used by the CLI.
The text was updated successfully, but these errors were encountered: