SIMD-0334
Fix alt_bn128_pairing syscall length check
Feature Gate Status
bnYzodLwmybj7e1HAe98yZrdJTd7we69eMMLgCXqKZm
TL;DR
The `alt_bn128_pairing` syscall takes a byte slice as input, interprets the bytes as an array of pairs of g1 and g2 points on bn128 elliptic curve, and applies a pairing operation. If the byte slice input has an improper length, the function should terminate early. Specifically, if the byte slice length is not a multiple of 192 (the sum of the lengths of g1 and g2 points), the function should terminate early with an error. However, the current code does not perform this check correctly. This document proposes to fix this length check by checking for the correct length.
Summary
The `alt_bn128_pairing` syscall takes a byte slice as input, interprets the bytes as an array of pairs of g1 and g2 points on bn128 elliptic curve, and applies a pairing operation. If the byte slice input has an improper length, the function should terminate early. Specifically, if the byte slice length is not a multiple of 192 (the sum of the lengths of g1 and g2 points), the function should terminate early with an error. However, the current code does not perform this check correctly. This document proposes to fix this length check by checking for the correct length.
Motivation
The `alt_bn128_pairing` function still works with the incorrect length check because it only processes multiples of 192 bytes and discards the rest. However, there could be successful inputs that are not multiples of 192. This could make the application logic harder to debug.
Impact
This fix will prevent accidental misuse of the `alt_bn128_pairing` syscall function and make programs easier to debug.
Security Considerations
This does update the behavior of the syscall function and therefore should be properly feature-gated.