How to Convert Hex Private Key To Hex Public Key In Chilkat VB6 - vb6

I have a 32 byte hex private key: 081549973bafbba825b31bcc402a3c4ed8e3185c2f3a31c75e55f423e9629aa3
And I want to convert it to 32 byte hex Public Key according to https://learnmeabitcoin.com/technical/hd-wallets
To generate an Ethereum address, I need the Public Key code.
I looked through all the Chilkat examples but couldn't find any code to convert it! But on the site https://lab.miguelmota.com/ethereum-private-key-to-public-key/example/
I was able to find that, unfortunately, it is written in Github with Json and I only know VB6: https://github.com/miguelmota/ethereum-private-key-to-public-key
Can you convert the code in GitHub to VB6 using Chilkat algorithms? And how can generate ethereum address from public key code?
thank you

Related

Is there any vb6 library that uses hkdf and sha-512

I am encrypting my data using AES-128 CBC. However it is decrypted by another software CodeIgnitor, which actually converts password into 2 elements. HMAC key and encryption_key using hkdf and SHA-512 digest.
How can i implement this thing in my code. (I am using VB 6)
Re-phrasing my question: How is password converted into 2 elements HMAC_key and encryption_key?
Let's see if I can explain further..
Encryption software used is CryptoSys while decryptionis done by CodeIgnitor..which is not working
So the difference I can see between the two is that codeignitor is expecting an HMAC authmessage when decrypting while the encryption does not prepend it the final message. So how can i do that? I am using VB6 for encryption.
So far I have come to the conclusion that there could be 2 key-derivation function a pb-kdf or a h-kdf.
The h-kdf authentication in particular works as follows:
A password is enterd by user
Based on this password and a random IV, an HMAC key is generated using HKDF and SHA-512 digest algo.
This HMAC key is saved and also expanded and then using IV/salt encrypts the plaintext message.
The IV is pre-pended to the plain-text message and base64 encoded.
The HMAC key is then pre-pended to the final message gereated in step 4.
So basically hkdf does not convert a key into 2 elements but only uses the basic key generated to generate other keys (and HMAC key is the original key used to generate other keys) now my question becomes...
Is there any vb6 library that uses hkdf and sha-512? As far as i have researched, Chilkat and CryptoSys APIs are only pbkdf based..Am I correct?

ECDH (256 bit key), Create Private Key from X component

I am trying to implement BitMessage Crypto with Windows CNG functions
I am trying to create a key pair from a single 32 byte value.
In order to encrypt the pubkey data, a double SHA-512 hash is calculated from the address version number, stream number, and ripe hash of the Bitmessage address that the pubkey corresponds to. The first 32 bytes of this hash are used to create a public and private key pair with which to encrypt and decrypt the pubkey data, using the same algorithm as message encryption (see Encryption).
Bitmessage Protocol regarding this
This can be done by using the 32 byte integer as the private key component.
But how can i do this using Windows CNG functions.
or maybe i can do the calculation manually?
Thanks for any input.
BCryptImportKeyPiar using a blank public key(X,Y), and use the random 32 byte number as the private part of the BCRYPT_ECCKEY_BLOB.
duh..

Specification defining ECDSA signature data

I want to know what specification (or standard) define the data format of the ECDSA signature and public key?
I'm testing the ECDSA signature on java card. I found out that there is a TLV format in the signature and the public key value.
* Public key (TV format)
[Tag=04] [public key value 1] [public key value 2]
04 038A3F59E813995DAB730588CFCBB985F5A1ED90C0D62960AE0B274D 2E6B12672318E0B113DECC0406B62887B6BCB9B1583B1A50779EAB5A
* Signature (TLV format)
[Tag=30] [Length=3C~3E] [Tag=02] [Length=1C~1D] [signature value 1] [Tag=02] [Length=1C~1D] [signature value 2]
303C 021C 7EEB0B2596F74344B3D7B046EA0BD17C4461FC277658CE93509F1674 021C 4F5DBFB30D994664DA80528847A767F0194876B068E5958161797991
303E 021D 0080F20B82D407AE663F010F4990F12073631D653EA1D65DC75EBD4293 021D 00880DB667EF51AEA8E7C9BB012496C7C9ECE3BC5829B82B692B9211C3
303D 021D 00F77447EF326A4A49597D0B839F68F524891F3655DA4561F1AA10EF70 021C 152F7FF18644C5E5C9118736E1F7528F0B10C5FF641C7B7CDF012129
303D 021D 00A2EBCC5C5981341D0726F2E846CC3879C74EFD64D8698589A8CEAB60 021C 6E04FF884A451D7C0737A182BC2DE7F7D3008EE182B46A009BFFC9E8
I think that the data format is defined in some specification or standard. I just want to know the document name.
The ASN.1 structure is defined in SEC 1: Elliptic Curve Cryptography (part C: ASN.1 for Elliptic Curve Cryptography), from the SECG (Standards for Efficient Cryptography Group).
It's in here:
https://www.ietf.org/rfc/rfc5480.txt
Also ANDI X9.62 might be important, but not freely available i think
For example:
ECDSA-Sig-Value ::= SEQUENCE {
r INTEGER,
s INTEGER
}
The public key value is an uncompressed point. It is defined by value 04, which is an identifier for an uncompressed point, followed by the X and Y coordinate, where the X and Y are encoded as unsigned big endian octet strings that have the same size as the key size (same as the size of the order of the curve in the parameters). Note that 04 is also the tag for an OCTET STRING in ASN.1, but that has nothing to do with the uncompressed point indicator.
The format of the domain parameters is unknown to me. It's certainly not encoded as https://www.ietf.org/rfc/rfc5480.txt as Paul suggests. I presume it is some proprietary DER format, which uses multiple ASN.1 SEQUENCE values filled with two ASN.1 INTEGER values each. These integer values (after the length) are signed, unpadded, big endian encodings, which fortunately are completely compatible with the encoding of Java's BigInteger.
Paul Bastian is correct with regards to the signature generated, it's X9.42 compatible. Plain signatures are not yet supported by Java Card.

How to decrypt a string with known key and a IV in java?

I have a string that is encrypted in c#.net which I have to decrypt in java using a key and a IV provided by the client. Used algorithm is AES.
I have tried few things. The key looks something like
key = "QWEEqweASDreefERTfdf45fefdWERfsdf34fedfdwn5=" //length 44 bytes
iv = "nkfghER24dfdfdf56YUIgH==" // lenght=24 bytes
When I use this with Cipher class with algorith AES/CBC/PKCS5Padding
passing the above key to Secretkeyspec class it says invalid key lenth 44 bytes
I am not able makeout whats wrong with the key. Tried all suggested solutions for few days nothing works. Can some one help please? Thank you.
Use java native for C# code.
First write C# code for decrypt the key.
and calling the code in java using native.
for reference
http://www.codeproject.com/Articles/378826/How-to-wrap-a-Csharp-library-for-use-in-Java

Convert a string of 0-F into a byte array in Ruby

I am attempting to decrypt a number encrypted by another program that uses the BouncyCastle library for Java.
In Java, I can set the key like this: key = Hex.decode("5F3B603AFCE22359");
I am trying to figure out how to represent that same step in Ruby.
To get Integer — just str.hex. You may get byte array in several ways:
str.scan(/../).map(&:hex)
[str].pack('H*').unpack('C*')
[str].pack('H*').bytes.to_a
See other options for pack/unpack and examples (by codeweblog).
For a string str:
"".tap {|binary| str.scan(/../) {|hn| binary << hn.to_i(16).chr}}

Resources