1. The Law of One Who Obligates Himself to His Friend, 2 Seifim: If one unconditionally obligated himself monetarily to another, he is required to pay, even if he was not otherwise obligated. How so? If one tells witnesses “you are witnesses that I owe so and so a maneh,”; if there are no witnesses but he writes in a document “I owe you a maneh”; or if he does not say “you are witnesses” but says in front of witnesses “I owe you a maneh via a document”- since he said the term “document” it is as if he said you should be witnesses for me- in all such cases he is required to pay even if both parties admit, and the witnesses are aware, that he did not in fact owe the other anything, because he has obligated himself in the same fashion a co-signer can obligate himself. All the more so in a case where one writes “I accepted such and such sum of money from you with respect to the debt you owed me” would he waive his right to the loan even though we know he did not in fact accept any money. (Beis Yosef, Seif 73, in the name of the Ritvah)
2. If a borrower writes a document in his own handwriting with witnesses testifying on it and he hands it over to the lender, the document has the status of a formal, valid document. Similarly, if the borrower wrote the document without witnesses, but handed it over to the lender in front of witnesses, the loan is considered a documented loan so long as his handwriting is not forgeable and the witnesses who witnessed the handing over of the document read the document. There are those of the Geonim who rule that the borrower must tell the witnesses who witnessed the handing over to sign and testify that it was handed over in front of you.