@@ -21,6 +21,7 @@ public MessageSignatureService(Report rep) : base(rep)
2121 {
2222 calc = new EllipticCurveCalculator ( new SecP256k1 ( ) ) ;
2323 addressBuilder = new Address ( ) ;
24+ inputService = new InputService ( rep ) ;
2425 }
2526
2627
@@ -29,6 +30,7 @@ public MessageSignatureService(Report rep) : base(rep)
2930 private readonly Sha256 hash = new Sha256 ( true ) ;
3031 private readonly EllipticCurveCalculator calc ;
3132 private readonly Address addressBuilder ;
33+ private InputService inputService ;
3234
3335
3436 private bool CheckAddress ( string addr , out Address . AddressType addrType )
@@ -46,7 +48,7 @@ private bool CheckMessage(string message, out byte[] toSign)
4648 byte [ ] toHash = ByteArray . ConcatArrays (
4749 new byte [ ] { ( byte ) MessageSignConstant . Length } ,
4850 Encoding . UTF8 . GetBytes ( MessageSignConstant ) ,
49- new CompactInt ( ( ulong ) message . Length ) . ToByteArray ( ) ,
51+ new CompactInt ( ( ulong ) msgBa . Length ) . ToByteArray ( ) ,
5052 msgBa ) ;
5153
5254 toSign = hash . ComputeHash ( toHash ) ;
@@ -134,6 +136,11 @@ public bool Validate(string message, string address, string signature)
134136 {
135137 InitReport ( ) ;
136138
139+ if ( inputService . NormalizeNFKD ( message , out string norm ) )
140+ {
141+ message = norm ;
142+ AddMessage ( "Input message was normalized using Unicode Normalization Form Compatibility Decomposition." ) ;
143+ }
137144 if ( ! CheckMessage ( message , out byte [ ] toSign ) )
138145 return Fail ( "Invalid message UTF8 format." ) ;
139146 if ( ! CheckAddress ( address , out Address . AddressType addrType ) )
@@ -301,6 +308,11 @@ public async Task<bool> TryFindProblem(string message, string address, string si
301308 {
302309 InitReport ( ) ;
303310
311+ if ( inputService . NormalizeNFKD ( message , out string norm ) )
312+ {
313+ message = norm ;
314+ AddMessage ( "Input message was normalized using Unicode Normalization Form Compatibility Decomposition." ) ;
315+ }
304316 if ( ! CheckMessage ( message , out _ ) ||
305317 ! CheckAddress ( address , out Address . AddressType addrType ) ||
306318 ! CheckSignature ( signature , out byte [ ] sigBa ) )
0 commit comments