Skip to content
This repository has been archived by the owner on Aug 14, 2023. It is now read-only.

Exend the svm-codec to support Signatures #483

Open
YaronWittenstein opened this issue Dec 26, 2021 · 0 comments
Open

Exend the svm-codec to support Signatures #483

YaronWittenstein opened this issue Dec 26, 2021 · 0 comments
Assignees
Labels
AA Related to the Accounts Abstraction simple-coin-iteration-2 svm svm-core SVM core change

Comments

@YaronWittenstein
Copy link
Contributor

YaronWittenstein commented Dec 26, 2021

Once we have a binary Transaction, we'd like to be able to sign it.

The algorithms and Signatures Schemes would vary between different Templates.
Not only that, but the ABI used for the sigdata can also vary between Templates.
Finally, the sigdata will be appended to the binary Transaction.

Transaction Binary Format

+----------------------+
|       Envelope       |
+----------------------+
|       Message        |
+----------------------+
|      Signatures      |
+----------------------+

Implementation Proposal

pub trait Signer {
  type Params;

  fn sign(&self, tx: &[u8], params: &Self::Params) -> Vec<u8>;
}

// EdDSA is one example of an Algorithm to sign the Transaction digitally.
pub struct EdDSA {
  hasher: Hasher,
  config: Config
}

impl EdDSA { 
  pub fn new(hasher: Hasher, config: Config) -> Self {
    Self { hasher, config }
  }
}

impl SignAlgorithm for EdDSA {
  type Params = EdsaParams;

  fn sign(&self, tx: &[u8], params: &EdsaParams) -> Vec<u8> {
    // ...
  }
}

Example

let tx: &[u8] = ...

let params1 = EdsaParams::new(private_key1);
let sig1 = svm_codec::sign<EdDSA>(tx, &params1);

let params2 = EdsaParams::new(private_key2);
let sig2 = svm_codec::sign<EdDSA>(tx, &params2);

// Concatenate the given signatures to form the `sigdata`.
// Different Templates could apply different encodings for the `sigdata`.
// That said, most will end up just concatening the signatures.
let sigdata = svm_codec::concat_sigs(&[sig1, sig2]);

/// Append the `sigdata` to the transaction
/// Returning the fully formed transaction (`envelope`, `message` and `sigdata`)
let tx = svm_codec::append_sigs(&sigdata);
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
AA Related to the Accounts Abstraction simple-coin-iteration-2 svm svm-core SVM core change
Projects
None yet
Development

No branches or pull requests

2 participants