/* GABA:
   (expr
     (name make_writekey)
     (globals
       (open IO_WRITE_FILE)
       (stdin IO_READ_STDIN)
       (read READ_SEXP))
     (params
       (private object io_write_file_info)
       (public object io_write_file_info))
     (expr
       (lambda (backend)
         (let ((key (read (stdin backend))))
           (prog1 (transport (open backend public) (private2public key))
	          ; FIXME: Add encryption here
	          (canonical (open backend private) key))))))
*/

static struct lsh_object *
make_writekey(struct io_write_file_info *private,
              struct io_write_file_info *public)
{
  /* (S (S (B S (C (B* (B* prog1) transport (C open public))
                   private2public))
           (B canonical (C open private)))
        (B read stdin)) */
  return MAKE_TRACE("make_writekey", 
    S2(S2(B2(S, C2(Bp3(Bp1(PROG1), TRANSPORT,
		       C2(IO_WRITE_FILE, ((struct lsh_object *) public))),
		   PRIVATE2PUBLIC)),
	  B2(CANONICAL, C2(IO_WRITE_FILE,
			   ((struct lsh_object *) private)))),
       B2(READ_SEXP, IO_READ_STDIN)) );
}