Skip to content

Bound input length in split_to_two_frs#966

Closed
jonas-lj wants to merge 1 commit into
mainfrom
jonas/fix-split-to-two-frs-length-check
Closed

Bound input length in split_to_two_frs#966
jonas-lj wants to merge 1 commit into
mainfrom
jonas/fix-split-to-two-frs-length-check

Conversation

@jonas-lj

@jonas-lj jonas-lj commented May 22, 2026

Copy link
Copy Markdown
Contributor

Reject inputs outside [33, 47] bytes in split_to_two_frs: shorter inputs would underflow len() - 16, and ≥ 48 byte inputs let the first half exceed the BN254 modulus and silently reduce (enabling collisions).

Also adds a note in get_nonce about a related latent underflow that is unreachable in practice.

This has no impact on Sui which always builds extended_pk_bytes = flag (1 byte) || public_key_bytes, producing 33 bytes for ed25519 and 34 bytes for compressed secp256k1 / secp256r1 both of which are inside the new bounds. The verify_zk_login path in sui-types::zk_login_authenticator and the CLI keytool nonce-generation path are both unaffected.

Reject inputs outside [33, 47] bytes. Previously a `len() - 16` could
underflow on too-short input, and inputs ≥ 48 bytes could trigger silent
modular reduction in the first half (enabling collisions). Also add a
note in get_nonce about a related latent underflow that is unreachable
in practice.
@jonas-lj jonas-lj requested review from benr-ml and joyqvq and removed request for benr-ml May 22, 2026 08:00
@jonas-lj

Copy link
Copy Markdown
Contributor Author

Covered in #939. Closing

@jonas-lj jonas-lj closed this May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant