Skip to content
This repository has been archived by the owner on Apr 8, 2022. It is now read-only.

Witness signature should be versioned with the signature algorithm #131

Open
TheQuantumPhysicist opened this issue Nov 18, 2021 · 1 comment

Comments

@TheQuantumPhysicist
Copy link
Contributor

Looking at this code from utxo/lib.src:

        pub fn sign(
            mut self,
            utxos: &[TransactionOutput<AccountId>],
            index: usize,
            pk: &sr25519::Public,
        ) -> Option<Self> {
            let msg = crate::sign::TransactionSigMsg::construct(
                Default::default(),
                &self,
                utxos,
                index as u64,
                u32::MAX,
            );
            self.inputs[index].witness =
                crypto::sr25519_sign(SR25519, pk, &msg.encode())?.0.to_vec();
            Some(self)
        }

And given that we may use a different signature algorithm in the future, it may be wise to use a serialization mechanism that can detect the signature algorithm. A simple way of doing this is: Instead of using Vec as type for the witness, we use an enum that has SR25519 as one arm with Vec as underlying type, and we just support adding more in the future. Scalecodec can take care of the serialization.

PS: Whether we're gonna remove the witness from inputs is a different discussion.

@iljakuklic
Copy link
Contributor

Either this or spare ourselves an extra byte by allocating a new Destination enum arm to new signature schemes. E.g. rename Destination::Pubkey to Destination::PubkeySchnorr, eventually add Destination::PubkeyBLS, etc. Signatures inside scripts already have sig type tags as proposed here (at expense of a 1-byte overhead).

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

No branches or pull requests

2 participants