1

I'm using cardanocli-js to create both VRF files for running a stake pool: vrf.vkey and vrf.skey:

const vrfKeyAccount = cardanocliJs.nodeKeyGenVRF("Totem");

Then I want to read the vrf.vkey file and convert the cborHex value to VRFKeyHash format, from the Cardano Serialization Lib. For that, I do:

CardanoWasm.VRFKeyHash.from_hex(JSON.parse(vrfKeyFile).cborHex);

But I'm getting the following error:

/cardano-multiplatform-lib/rust/pkg/package/cardano_multiplatform_lib.js:16780
    throw takeObject(arg0);
    ^
JsValue("Deserialization failed in VRFKeyHash because: Invalid cbor: expected tuple 'hash length' of length 32 but got length Len(34).")
(Use `node --trace-uncaught ...` to show where the exception was thrown)

2 Answers 2

0

Maybe this could help,

as cborHex is in hex, and you can pass a Uint8Array (bytes) to initialize a VRFKeyHash like in many cardano-serialization-lib objects, in theory you can use Buffer.from(hexValue,"hex"), like this:

CardanoWasm.VRFKeyHash.from_bytes(Buffer.from((JSON.parse(vrfKeyFile).cborHex,"hex")));

not tested!

0

I have checked that every cborHex on vrf.vkey files starts with the prefix "5820" and every cborHex on vrf.skey files starts with the prefix "5840". If I remove those prefixes from the conversion, then it works:

CardanoWasm.VRFKeyHash.from_hex(JSON.parse(vrfKeyFile).cborHex.substring(4)));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.