Chris Brown was so paranoid about keeping his attendance at Rihanna's birthday party a big fat secret -- he actually tried to FORCE partygoers to sign confidentiality agreements ... TMZ has learned.

Sources tell us, Chris refused to enter the private party Monday night at the famous Hearst Mansion in Beverly Hills until everyone signed an NDA -- sending his henchmen in beforehand to gather every partygoer's signature.

We're told although they didn't get EVERYONE to sign -- Chris eventually walked in ... and spent a huge chunk of the night nuzzling up against Rihanna.

According to sources, the two got real intimate -- sitting next to each other, talking, and holding hands ... all perfectly legal ever since the restraining order was lifted.

As for the rest of the party -- we're told it was jam-packed with celebs including Katy Perry, Bruno Mars, and Chris Martin (no Gwyneth).

Rihanna's cake was pretty badass too -- a giant spliff ... with a small Rihanna made out of icing, riding it like a horse.

Chris' rep tells TMZ, confidentiality agreements were distributed only to workers at the party and anyone who was caught videotaping/snapping a pic of CB.