Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: MikeJ_NpC on October 05, 2022, 08:42:32 PM



Title: DB Dump translation py script
Post by: MikeJ_NpC on October 05, 2022, 08:42:32 PM
Hello.. is there a py script that someone can point me do which translates the following

 "type": "unencrypted private key",
    "OpenSSL EVP DER-encoded serialized private key": "3081d302010104205ac70fdbcb5c4949935ad3b7374035a8dcc5ba2216f8df5f81d7cf861b2e0b6 ba08185308182020101302c06072a8648ce3d0101022100ffffffffffffffffffffffffffffffff fffffffffffffffffffffffefffffc2f300604010004010704210279be667ef9dcbbac55a06295c e870b07029bfcdb2dce28d959f2815b16f81798022100fffffffffffffffffffffffffffffffeba aedce6af48a03bbfd25e8cd0364141020101a12403220003ffb02fbbeb154159373687c798edced 6e057e401984d5cd744cbfca5b0f24c58",
    "sha256 hash of compressed public key and private key": "0dd64a6fa5870c5548e0b95c9828080bc0d7d3b18efdabacbddca0266936aa13"
  }
 
and

value d63081d30201010420fdd2d32c14360c6354874320bca7c32a382a6dc8c51f10a4534f19fe5c3cb b31a08185308182020101302c06072a8648ce3d01010221
*damaged key -- 01cb91c5aef56c7678cc1c3ef402
value d63081d3020101042076c27e0b3ea7af1186fc2e1a77f51d2d6b6df37b8aeddbca35caeef72809f 574a08185308182020101302c06072a8648ce3d01010221
key 029af47e1909a5effc0738962252baeb2eae131e9d7672e5b8eea28f2bd93476
value d63081d3020101042081120e32065d2a4420de64a096eff052e4a7b40754bd52e429a72f607cfed 4bca08185308182020101302c06072a8648ce3d01010221

Thank you...
:)



Title: Re: DB Dump translation py script
Post by: odolvlobo on October 05, 2022, 11:43:23 PM
You must provide more context. Where do these come from?

Here is what the DER-encoded private key decodes to:

SEQUENCE (4 elem)
  INTEGER 1
  OCTET STRING (32 byte) 5AC70FDBCB5C4949935AD3B7374035A8DCC5BA2216F8DF5F81D7CF861B2E0B6B
  [ 0 ] (1 elem)
    SEQUENCE (6 elem)
      INTEGER 1
      SEQUENCE (2 elem)
        OBJECT IDENTIFIER 1.2.840.10045.1.1 prime-field (ANSI X9.62 field type)
        INTEGER (256 bit) 1157920892373161954235709850086879078532699846656405640394575840079088…
      SEQUENCE (2 elem)
        OCTET STRING (1 byte) 00
        OCTET STRING (1 byte) 07
      OCTET STRING (33 byte) 0279BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798
      INTEGER (256 bit) 1157920892373161954235709850086879078528375642790749043826051631415181…
      INTEGER 1
  [ 1 ] (1 elem)
    BIT STRING (264 bit) 0000001111111111101100000010111110111011111010110001010101000001010110…


Title: Re: DB Dump translation py script
Post by: NotATether on October 06, 2022, 07:08:13 AM
Bitcoin private keys are not DER-encoded, they are encoded in WIF format and Base58...

What you have showed us is data for a different kind of (OpenSSL) private key.