import normalizeSafeSignature from "./normalizeSafeSignature" describe("normalizeSafeSignature", () => { const signatureLength = "81" const vForUtf8Validation = "a7" const vForRawBytes = "27" // signature with v set to execute utf8 validation path and moved to the end const convertedSignatureWithoutV = "99a1c1d934dc4b57d031c016f43b65f7910d348a1254a0f9fcec0e997e46d0105b35e115b9155288e15153d8ad3ba6eed5d2823e9b8c50826eabd580f6f960f6" // uncompressed public key with 04 prefix dropped const uncompressedPublicKey = "d6297218553acc1b236a0a4d6a9b50b6956ca100fd27f5b64fc328f503dbf32b26ee6ccf22e0ac278e3edb684879359ef3a81e5ecc06c8a779cd978af637f450" it("should normalize a signature", async () => { const publicKey = "02d6297218553acc1b236a0a4d6a9b50b6956ca100fd27f5b64fc328f503dbf32b" const signature = "0x2799a1c1d934dc4b57d031c016f43b65f7910d348a1254a0f9fcec0e997e46d0105b35e115b9155288e15153d8ad3ba6eed5d2823e9b8c50826eabd580f6f960f6" const result = await normalizeSafeSignature(signature, publicKey) const expectedSignature = signatureLength + convertedSignatureWithoutV + vForUtf8Validation + uncompressedPublicKey expect(result).toBe(expectedSignature) }) it("should not set the highest bit on v if UTF-8 conversion flag is set to false", async () => { const publicKey = "02d6297218553acc1b236a0a4d6a9b50b6956ca100fd27f5b64fc328f503dbf32b" const signature = "0x2799a1c1d934dc4b57d031c016f43b65f7910d348a1254a0f9fcec0e997e46d0105b35e115b9155288e15153d8ad3ba6eed5d2823e9b8c50826eabd580f6f960f6" const result = await normalizeSafeSignature(signature, publicKey, false) const expectedSignature = signatureLength + convertedSignatureWithoutV + vForRawBytes + uncompressedPublicKey expect(result).toBe(expectedSignature) }) })