wbond / oscrypto

Compiler-free Python crypto library backed by the OS, supporting CPython and PyPy
MIT License
321 stars 71 forks source link

secp256r1 seed bytes? #70

Closed FrankC01 closed 1 year ago

FrankC01 commented 1 year ago

Working with a blockchain that stores the 'keystring' in a base64 string when decoded expects 65 bytes where The first 33 bytes are the public key The remaining 32 bytes are the private key

So, for a new key generation I know I do:

    from oscrypto import asymmetric
    public, private = asymmetric.generate_pair('ec', curve='secp256r1')

My question is how to get the bytes from the respective keys to b64encode to expected keystring?

Conversely, if I load keystring, decode to bytes... how to instantiate the public and private keys to assert test the round trip?

I'm a newbie but have thick skin :)

FrankC01 commented 1 year ago

Is this still an active project? Looking for answer to above.

Thanks

wbond commented 1 year ago

This project is effectively a free-time project for me, which these days is rather few and far between.

The public and private key objects returned have an .asn1 property which returns an object from asn1crypto. You should be able to effectively do this:

public.asn1.dump()
private.asn1.dump()
FrankC01 commented 1 year ago

Sleep well my friend, I eventually figured it out.

My apologies for not closing this when I did (sometime around mid-Feb).