Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nami Wallet returns witness seen as invalid by Cardano CLI (InvalidWitnessesUTXOW) #147

Closed
ZDust172 opened this issue Dec 18, 2021 · 1 comment

Comments

@ZDust172
Copy link

ZDust172 commented Dec 18, 2021

I am attempting to sign and submit a simple "always succeeds" transaction body built by the CLI and signed with nami wallet.

cardano-cli transaction build-raw \ --alonzo-era \ --fee 200000 \ --tx-in {NAMI_ADDRESS_UTXO} \ --tx-out {SCRIPT_ADDRESS}+1800000 \ --tx-out {NAMI_ADDRESS}+998000000 \ --invalid-hereafter 50000000 \ --protocol-params-file protocol.json \ --out-file tx-script.draft

Signing this file with an initial key in the CLI, I then sign it with nami using
const witnessSet = await window.cardano.signTx(transaction, true);

Generating the following hex CBOR:
a10081825820863d383db3cc7494604d02d3bf214706a18a178ce50eb1f04ad3ef45f50815735840da3ef50001e801bb9580ea361cff86fedef6aab41ebf835dbd246afae02a8b380cbfef0bb1c1ad299b57837dcc04d22a8fc81d713989160513fb14020b7ca203

This hex is sent to the back-end where I do some transformations to get the set in the form of [0, [vkey witnesses]] as shown in #85.

let bufferWitness = Buffer.from(witnessSet, "hex");
let witnessDecoded = await cbor.decodeFirst(bufferWitness);

const newWitness = [0]; // Array format accepted by the CLI
newWitness.push(witnessDecoded.get(0)[0]); // vkey witness generated by Nami
console.log('Result:', cbor.encode(newWitness).toString("hex"));

This generates the following hex CBOR:
8200825820863d383db3cc7494604d02d3bf214706a18a178ce50eb1f04ad3ef45f50815735840da3ef50001e801bb9580ea361cff86fedef6aab41ebf835dbd246afae02a8b380cbfef0bb1c1ad299b57837dcc04d22a8fc81d713989160513fb14020b7ca203

Decoded as:
[0, [h'863D383DB3CC7494604D02D3BF214706A18A178CE50EB1F04AD3EF45F5081573', h'DA3EF50001E801BB9580EA361CFF86FEDEF6AAB41EBF835DBD246AFAE02A8B380CBFEF0BB1C1AD299B57837DCC04D22A8FC81D713989160513FB14020B7CA203']]

When I use cardano-cli assemble to generate the final transaction and submit, I get this error:

ShelleyTxValidationError ShelleyBasedEraAlonzo (ApplyTxError [UtxowFailure (WrappedShelleyEraFailure (InvalidWitnessesUTXOW [VKey (VerKeyEd25519DSIGN "863d383db3cc7494604d02d3bf214706a18a178ce50eb1f04ad3ef45f5081573")]))])

Which I do not understand as the tx body is not altered by the time it is sent to Nami, only signed with a dummy key but I'm assuming that should not affect the witness generated?

Any help would be appreciated, thanks.

*EDIT: I have also attempted loading the transaction through the serialization lib as well and get exactly the same error so it seems like Nami Wallet/serlization lib make different signatures to the CLI, how can this be?

@ZDust172 ZDust172 changed the title Nami Wallet returns overriden witnesses which are seen as invalid by Cardano CLI Nami Wallet returns witness seen as invalid by Cardano CLI (InvalidWitnessesUTXOW) Dec 18, 2021
@ZDust172
Copy link
Author

ZDust172 commented Dec 20, 2021

Closing as this actually concerns the Serialization lib and is not directly caused by Nami. I'll open an issue there instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant