Skip to content

Commit

Permalink
correct partially dummy values
Browse files Browse the repository at this point in the history
  • Loading branch information
paweljakubas committed Jul 9, 2020
1 parent 72c70d0 commit 1209bca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
18 changes: 9 additions & 9 deletions lib/shelley/src/Cardano/Wallet/Shelley/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -469,24 +469,24 @@ computeTxSize proxy witTag action cs =
where
chaff = L8.pack (show ix) <> BL.fromStrict txid

byronWits = Set.map dummyWitnessUniq $ Set.fromList (fst <$> CS.inputs cs)
byronWits = Set.map dummyWitnessUniq $ Set.fromList (CS.inputs cs)
where
dummyWitness :: BL.ByteString -> SL.BootstrapWitness TPraosStandardCrypto
dummyWitness chaff =
dummyWitness :: BL.ByteString -> Address -> SL.BootstrapWitness TPraosStandardCrypto
dummyWitness chaff addr =
SL.makeBootstrapWitness credential signingKey addrAttr
where
credential = Hash.UnsafeHash $ L8.toStrict chaff
addrAttr = Byron.mkAttributes $ Byron.AddrAttributes
(Just $ Byron.HDAddressPayload (bloatChaff keyLen))
(toHDPayloadAddress addr)
(toByronNetworkMagic mainnetMagic)
(Just xprv) = xprvFromBytes (bloatChaff sigLen)
signingKey = Crypto.SigningKey xprv
sigLen = sizeSigDSIGN $ Proxy @(DSIGN TPraosStandardCrypto)
keyLen = sizeVerKeyDSIGN $ Proxy @(DSIGN TPraosStandardCrypto)
bloatChaff n = BL.toStrict $ BL.take (fromIntegral n) $ BL.cycle chaff

dummyWitnessUniq :: TxIn -> SL.BootstrapWitness TPraosStandardCrypto
dummyWitnessUniq (TxIn (Hash txid) ix) = dummyWitness chaff
dummyWitnessUniq :: (TxIn, TxOut) -> SL.BootstrapWitness TPraosStandardCrypto
dummyWitnessUniq (TxIn (Hash txid) ix, TxOut addr _) =
dummyWitness chaff addr
where
chaff = L8.pack (show ix) <> BL.fromStrict txid

Expand Down Expand Up @@ -585,8 +585,8 @@ mkByronWitness
-> SL.BootstrapWitness TPraosStandardCrypto
mkByronWitness body protocolMagic addr (prv, pwd) =
let (SL.TxId txHash) = SL.txid body
(Just signed) = xprvFromBytes (serialize' txHash `signWith` (prv, pwd))
signingKey = Crypto.SigningKey signed
--(Just signed) = xprvFromBytes (serialize' txHash `signWith` (prv, pwd))
signingKey = Crypto.SigningKey prv
addrAttr = Byron.mkAttributes $ Byron.AddrAttributes
(toHDPayloadAddress addr)
(toByronNetworkMagic protocolMagic)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ prop_decodeSignedByronTxRoundtrip (DecodeByronSetup utxo outs slotNo magic pairs
let inps = Map.toList $ getUTxO utxo
let cs = mempty { CS.inputs = inps, CS.outputs = outs }
let unsigned = mkUnsignedTx slotNo cs mempty []
let byronWits = Set.fromList $ map (mkByronWitness unsigned magic) pairs
let byronWits =
Set.fromList $ zipWith (\((_, TxOut addr _)) pair -> mkByronWitness unsigned magic addr pair) inps pairs
let metadata = SL.SNothing
let wits = SL.WitnessSet mempty mempty byronWits
let ledgerTx = SL.Tx unsigned wits metadata
Expand Down

0 comments on commit 1209bca

Please sign in to comment.