lib/x25519/montgomery_u.rb in x25519-1.0.2 vs lib/x25519/montgomery_u.rb in x25519-1.0.3

- old
+ new

@@ -9,9 +9,14 @@ # Create an object representing a Montgomery-u coordinate from a bytestring # # @param bytes [String] 32-byte compressed Montgomery-u coordinate def initialize(bytes) X25519.validate_key_bytes(bytes) + + # The point located at a Montgomery-u coordinate of zero always returns + # the point at zero regardless of which scalar it's multiplied with + raise InvalidKeyError, "degenerate public key" if bytes == ("\0" * KEY_SIZE) + @bytes = bytes end # Return a compressed Montgomery-u coordinate serialized as a bytestring #