herumi / bls

288 stars 132 forks source link

Unwanted "1" at the start of blsPublicKeyGetHexStr #75

Closed khaninejad closed 2 years ago

khaninejad commented 2 years ago

Hi,

I ported the Bls to Swift but when I am trying to run blsPublicKeyGetHexStr it returns with "1 " at the beginning of the string with 386 which should be 96.

1 118b23c5d8697d5aa6aaa4289c2d3dff33b072bcb9ba9be5bc276160b17676f6aa7decf8cfc35d0a359827b15c4df83a 499f44fec119bb675474f0785b5dc1ae14c6099d6871a8e131f6ab38fcf5a9c8db821daa4728d6b320f8a9379a8f6ef 10167dc41b78dc2e0642fcd980a5d73b170b2e494ad686d660ffe2c1ab821872feab05d266c0e5b4ce583b2064f43b26 12564e74ea12f05884c427e6784ab5c8d2f3492d24d9399dd88eaf9e72355f7ac13a70a32a51227fd44669ed89f58b55

        var pub = blsPublicKey.init()
        blsGetPublicKey(&pub, &sec);

        let PUBLIC_KEY_SIZE = 96
        var publicKeyBytes = Data(count: PUBLIC_KEY_SIZE).bytes // [UInt8]
        blsPublicKeySerialize(&publicKeyBytes, PUBLIC_KEY_SIZE, &pub)
        let hex = blsPublicKeyGetHexStr(unsafePointerpub,  2048, &pub)

Any idea how to resolve this?

herumi commented 2 years ago

Could you use blsPublicKeySerialize() ?