Local Ring of a Subvariety (problem 1.3.13 in Hartshorne)

I've began to study AG to prepare for grad school and I'm stuck with the following problem in Hartshorne. The problem statement is as follows (found on p. 22 in Hartshorne's AG):

Let $Y\subseteq X$ be a subvariety. Let $\mathcal{O}_{Y,X}$ be the set of equivalence classes $\langle U,f\rangle$, where $U\subseteq X$ is open, $U\cap Y\neq \emptyset$, and $f$ is a regular function on $U$. We say that $\langle U,f\rangle$ is equivalent to $\langle V,g\rangle$, if $f=g$ on $U\cap V$. Show that $\mathcal{O}_{Y,X}$ is a local ring, with residue field $K(Y)$ and dimension = $\dim X-\dim Y$.

I consulted a few solution sets for Hartshorne that can be found online, but they both handwaved the part that I'm stuck with. The solutions sets are the following:

http://www.math.northwestern.edu/~jcutrone/Work/Hartshorne%20Algebraic%20Geometry%20Solutions.pdf

http://math.berkeley.edu/~reb/courses/256A/1.3.pdf

My approach to solve the problem is as follows. Look at the following ideal:

$$\mathfrak{m}=\{\langle U,f\rangle \mid f(P)= 0 \; \forall P\in U\cap Y\}$$

It's easy to show that any element not contained in it is invertible. We then have a canonical map $\mathcal{O}_{Y,X}\to K(Y)$ given by

$$\langle U,f\rangle \mapsto \langle U\cap Y,f\rangle$$

and the kernel of this map is obviously $\mathfrak{m}$. However, I'm totally stuck with proving that this map is surjective, which is required in order to prove that the residue field is $K(Y)$. This part seems to be handwaved by both of the solutions provided above. In other words, I would need to show that if $f$ is regular on an open set $U\subset Y$, then $f$ extends to a regular function on some open $V\subset X$ s.t. $U\supset V\cap Y$.

-

You've already shown that $\mathfrak m$ is the unique maximal ideal of $\mathcal O_{Y,X}$, since any element not in $\mathfrak m$ is invertible. Now just consider $\mathcal O_{Y,X}/\mathfrak m$. This is precisely the set of all $\langle U, f \rangle$ such that $f$ is regular on $U$ and $f(P)\neq 0$ for all $P \in U \cap Y$. This is a field that is immediately identified with $K(Y)$.

If you want to do it your way and show that $\mathcal O_{X,Y}$ surjects onto $K(Y)$, note that an element of $K(Y)$ is given by a pair $\langle V, f \rangle$ such that $V\subset Y$ is open and $f$ is regular on $V$. By shrinking, we can assume that $V$ is affine. But then $V=U \cap Y$ for some affine open $U \subset X$, and the lifting that you're looking for comes from the natural surjection of the coordinate rings of $U$ onto $V$ since $V$ is an affine closed subset of $U$.

-