+ /**
+ * Encode the given string as a signed MagicEnvelope XML document,
+ * using the keypair for the given local user profile.
+ *
+ * Side effects: will create and store a keypair on-demand if one
+ * hasn't already been generated for this user. This can be very slow
+ * on some systems.
+ *
+ * @param string $text XML fragment to sign, assumed to be Atom
+ * @param Profile $actor Profile of a local user to use as signer
+ * @return string XML string representation of magic envelope
+ *
+ * @throws Exception on bad profile input or key generation problems
+ * @fixme if signing fails, this seems to return the original text without warning. Is there a reason for this?
+ */