spacemeshos / svm

SVM - Spacemesh Virtual Machine
https://spacemesh.io
MIT License
85 stars 14 forks source link

Implement Simple-Coin with 2-3 MultiSig Template #450

Open YaronWittenstein opened 2 years ago

YaronWittenstein commented 2 years ago

Depends on #449

See also: SVM Transactions Signatures

Writing this Template should be very similar to the one at #449. The Template Storage will consist of 3 Public Keys that will be given upon the ctor.

As a reminder on this stage, the Immutable Storage has not been implemented yet (should be part of Simple Coin Integration #4).

The verify method will expect the parties involved in the Signatures as parameters.

It should look in high-level like this:

#[verify]
fn verify(a: u8, b: u8) -> bool {
    if a == b {
      return false;
   }

   verify_sig(a, read_sig(0)) && verify_sig(b, read_sig(1))
}

fn verify_sig(id: u8, sig: Blob64) -> bool {
  let pub_key = Storage::get_pub_key(id);
  Host::tx_verify(sig, pub_key)
}

fn read_sig(index: u8) -> Blob64 {
    let sigdata = Host::SigData();

    // decode the `index` signature
    // the exact decoding depends on the ABI of `sigdata`
}