public static void Sign(this ECDsa key, IVerificableMessage message) { var meta = message.GetMetaHeader(); IVerificationHeader verify = message is IRequest ? new RequestVerificationHeader() : message is IResponse ? new ResponseVerificationHeader() : throw new InvalidOperationException("unsupport message type"); var verifyOrigin = message.GetVerificationHeader(); if (verifyOrigin is null) { verify.BodySignature = key.SignMessagePart(message.GetBody()); } verify.MetaSignature = key.SignMessagePart(meta); verify.OriginSignature = key.SignMessagePart(verifyOrigin); verify.SetOrigin(verifyOrigin); message.SetVerificationHeader(verify); }
void IVerificableMessage.SetVerificationHeader(IVerificationHeader verificationHeader) { VerifyHeader = (RequestVerificationHeader)verificationHeader; }
void IVerificationHeader.SetOrigin(IVerificationHeader verificationHeader) { Origin = (RequestVerificationHeader)verificationHeader; }
void IVerificationHeader.SetOrigin(IVerificationHeader verificationHeader) { Origin = (ResponseVerificationHeader)verificationHeader; }