This repository was archived by the owner on Aug 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
This repository was archived by the owner on Aug 14, 2023. It is now read-only.
Exend the svm-codec to support Signatures #483
Copy link
Copy link
Open
Labels
AARelated to the Accounts AbstractionRelated to the Accounts Abstractionsimple-coin-iteration-2svmsvm-coreSVM core changeSVM core change
Description
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, ¶ms1);
let params2 = EdsaParams::new(private_key2);
let sig2 = svm_codec::sign<EdDSA>(tx, ¶ms2);
// 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);Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
AARelated to the Accounts AbstractionRelated to the Accounts Abstractionsimple-coin-iteration-2svmsvm-coreSVM core changeSVM core change