Example #1
0
        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);
        }
Example #2
0
 void IVerificableMessage.SetVerificationHeader(IVerificationHeader verificationHeader)
 {
     VerifyHeader = (RequestVerificationHeader)verificationHeader;
 }
Example #3
0
 void IVerificationHeader.SetOrigin(IVerificationHeader verificationHeader)
 {
     Origin = (RequestVerificationHeader)verificationHeader;
 }
Example #4
0
 void IVerificationHeader.SetOrigin(IVerificationHeader verificationHeader)
 {
     Origin = (ResponseVerificationHeader)verificationHeader;
 }