Signing a portion of a message

21 views
Skip to first unread message

John Midgley

unread,
Apr 25, 2023, 11:34:19 PM4/25/23
to capn...@googlegroups.com
Hi there. I'm trying to figure out the best way to include a signature in a struct. For example, if I have a struct like:

struct SignedTransaction {
  transaction @0 :Transaction;
  signature @1 :Signature;
}

I'd like to be able to sign the transaction bytes (i.e. the packed Transaction on its own). Clearly I can just replace the transaction field with the message bytes of building the Transaction separately, but I expect packing would be less efficient, plus it creates a level of indirection to access the transaction. Basically, I'd like to:

1. Build the transaction Struct separately
2. Pack it to bytes and get the signature
3. Create a SignedTransaction, using the already constructed Transaction.
4. When deserializing, I'd need to be able to pull out the packed Transaction to verify the signature. 

Is there any simple way to do this? Other ideas?

Thanks,

John


Reply all
Reply to author
Forward
0 new messages