Plutonomicon / cardano-transaction-lib

A Purescript library for building smart contract transactions on Cardano
https://plutonomicon.github.io/cardano-transaction-lib/
MIT License
91 stars 52 forks source link

`privatePaymentKeyToFile` and `privatePaymentKeyFromFile` do not compose to identity #1601

Open Renegatto opened 4 months ago

Renegatto commented 4 months ago

Bug report

Description

Given the example

Contract.Wallet.KeyFile.privatePaymentKeyToFile path key
key' <- Contract.Wallet.KeyFile.privatePaymentKeyFromFile path

Expected behavior

key is equal to key'.

Actual behavior

key is different from key'.

Details

privatePaymentKeyFromTextEnvelope

privatePaymentKeyFromTextEnvelope . decodeTextEnvelope gives the same result as privatePaymentKeyFromFile.

Stable state

privatePaymentKeyFromFile drops half (?) of a CBOR on the first read and does not do it any more. So in this code:

let
  f key = do
     Contract.Wallet.KeyFile.privatePaymentKeyToFile "temp" key
     Contract.Wallet.KeyFile.privatePaymentKeyFromFile "temp"
key0 <- f key
key1 <- f key0
key2 <- f key1
...

key0 /= key1 but key1 = key2 = key3 ... keyn

Revision

https://github.com/Plutonomicon/cardano-transaction-lib/commit/4e3a69c7ea43ed12c6c48dd72361c92dae670c92