File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -67,7 +67,11 @@ pub const EIP5564 = struct {
6767 Keccak256 .hash (& s .toCompressedSec1 (), & s_hashed , .{});
6868
6969 const fe_spending_key = try Secp256k1 .scalar .Scalar .fromBytes (spending_key , Endian .Big );
70- const fe_s_hashed = try Secp256k1 .scalar .Scalar .fromBytes (s_hashed , Endian .Big );
70+ // A direct .fromBytes(...) errors on non-canonical representations, so we pad it to use
71+ // .fromBytes48(...) which does the (potentially needed) wrapping.
72+ var padded_s_hashed : [48 ]u8 = [_ ]u8 {0 } ** 48 ;
73+ @memcpy (padded_s_hashed [padded_s_hashed .len - 32 .. ], & s_hashed );
74+ const fe_s_hashed = Secp256k1 .scalar .Scalar .fromBytes48 (padded_s_hashed , Endian .Big );
7175
7276 return Secp256k1 .scalar .Scalar .add (fe_spending_key , fe_s_hashed ).toBytes (Endian .Big );
7377 }
You can’t perform that action at this time.
0 commit comments