Mismatch with openssl private-key/public key generation
- Dominant language
- C
- Stars
- 296
- Forks
- 70
- PR merge metrics
- No merged PRs in 30d
Description
I was trying to verify the implementation against openssl, and this library doesn't create the same public-key from a private key.
I generated reference data with the following command:
**openssl ecparam -name sect233k1 -out sect233k1.pem
openssl genpkey -paramfile sect233k1.pem -text -out prv_key.pem**
If I run tiny-ECDH with the -DECC_CURVE=NIST_K233, and I feed in the private key from below, (starting at 0x22), I get a different public key output.
**prva[0] = 0x22;
prva[1] = 0xa0;
...
assert(ecdh_generate_keys(puba, prva));**
Is there anything in the order of private key bytes that I need to do?
prv_key.pem output
-----BEGIN PRIVATE KEY-----
MH4CAQAwEAYHKoZIzj0CAQYFK4EEABoEZzBlAgEBBB4AIqCLwypv1g0HbqYx3oGu
nJ0NRy4SMico04gPkmGhQAM+AAQALdAhSNtJVEMAE1DU8P674eeCl50LY7uoC+xS
spIB3H1RSLjsLFPUo5aHjY5IdgQlNFYPNXLTsn/tYGE=
-----END PRIVATE KEY-----
Private-Key: (232 bit)
priv:
22:a0:8b:c3:2a:6f:d6:0d:07:6e:a6:31:de:81:ae:
9c:9d:0d:47:2e:12:32:27:28:d3:88:0f:92:61
pub:
04:00:2d:d0:21:48:db:49:54:43:00:13:50:d4:f0:
fe:bb:e1:e7:82:97:9d:0b:63:bb:a8:0b:ec:52:b2:
92:01:dc:7d:51:48:b8:ec:2c:53:d4:a3:96:87:8d:
8e:48:76:04:25:34:56:0f:35:72:d3:b2:7f:ed:60:
61
ASN1 OID: sect233k1
NIST CURVE: K-233
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the mismatch using OpenSSL's sect233k1 commands and the private-key bytes shown in the issue, with NIST_K233 and ecdh_generate_keys. Inspect how ecdh_generate_keys interprets private-key byte order and compare its public-key output with OpenSSL's listed value. Done means the implementation produces the same public key for this input.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- cryptography
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100