figured out the respec callback syntax, made changes based on early feedback from @__agl and rsleevi
authorDavid Dahl <ddahl@mozilla.com>
Mon, 28 Jan 2013 17:54:42 -0600
changeset 9 3083bee93329
parent 8 a919ca60eb97
child 10 def6e0e07e79
figured out the respec callback syntax, made changes based on early feedback from @__agl and rsleevi
Overview.html
highlevel-api-source.html
--- a/Overview.html	Mon Jan 28 12:02:14 2013 -0600
+++ b/Overview.html	Mon Jan 28 17:54:42 2013 -0600
@@ -171,64 +171,64 @@
 
       <section>
         <h3>Highlevel interface</h3>
-        <dl title="interface Highlevel" class="idl">
-          <dt>void getPublicKey (in DOMString aJWKID)</dt>
-          <dd>Get public key by an ID if it exists</dd>
-          <dt>[TreatNonCallableAsNull] attribute Function? onGetKeypair</dt>
-          <dd>onGetKeypair event handler</dd>
-          <dt>void createKeyPair (in DOMString aJoseAlg)</dt>
-          <dd>Generate a public keypair</dd>
-          <dt>[TreatNonCallableAsNull] attribute Function? onCreateKeypair</dt>
+
+        <dl title="callback CreateKeypairSuccess = void (in DOMString publicKey)" class="idl">
+        </dl>
+        <dl title="callback CreateKeypairError = void (in DOMString error)" class="idl">
+        </dl>
+        <dl title="callback EncryptSuccess = void (in DOMString cipherText, in DOMString keyID)" class="idl">
+        </dl>
+        <dl title="callback EncryptError = void (in DOMString error)" class="idl">
+        </dl>
+        <dl title="callback DecryptSuccess = void (in DOMString plainText)" class="idl">
+        </dl>
+        <dl title="callback DecryptError = void (in DOMString error)" class="idl">
+        </dl>
+        <dl title="callback SealSuccess = void (in DOMString cipherText, in DOMString keyID)" class="idl">
+        </dl>
+        <dl title="callback SealError = void (in DOMString error)" class="idl">
+        </dl>
+        <dl title="callback OpenSuccess = void (in DOMString plainText)" class="idl">
+        </dl>
+        <dl title="callback OpenError = void (in DOMString error)" class="idl">
+        </dl>
+
+
+        <dl title="[Constructor] interface Highlevel" class="idl">
+          <dt>void createKeyPair (optional in DOMString joseAlg)</dt>
+          <dd>Generate a keypair</dd>
+          <dt>[TreatNonCallableAsNull] attribute CreateKeypairSuccess onCreateKeypairSuccess</dt>
+          <dd>onCreateKeypair event handler</dd>
+          <dt>[TreatNonCallableAsNull] attribute CreateKeypairError onCreateKeypairError</dt>
           <dd>onCreateKeypair event handler</dd>
 
-          <dt>void encryptAndSign (in DOMSring aPlainText, in DOMString aRecipientJWK, in DOMString aJWKID)</dt>
+          <dt>void encryptAndSign (in DOMString plainText, in DOMString recipientJWK, in DOMString jwkID)</dt>
           <dd>Perform encryption, signing the encrypted data</dd>
-          <dt>[TreatNonCallableAsNull] attribute Function? onEncryptComplete</dt>
+          <dt>[TreatNonCallableAsNull] attribute EncryptSuccess onEncryptSuccess</dt>
           <dd>onEncryptComplete event handler</dd>
-          <dt>[TreatNonCallableAsNull] attribute Function? onEncryptError</dt>
+          <dt>[TreatNonCallableAsNull] attribute EncryptError onEncryptError</dt>
           <dd>onEncryptError event handler</dd>
 
-          <dt>void verifyAndDecrypt (in DOMString aReceivedJWE, in DOMString aSenderJWK, in DOMString aRecipientJWKID)</dt>
-          <dd>Verify signature and decrypttion method</dd>          
-          <dt>[TreatNonCallableAsNull] attribute Function? onDecryptComplete</dt>
+          <dt>void verifyAndDecrypt (in DOMString receivedJWE, in DOMString senderJWK, in DOMString recipientJWKID)</dt>
+          <dd>Verify signature and decryption method</dd>          
+          <dt>[TreatNonCallableAsNull] attribute DecryptSuccess onDecryptSuccess</dt>
           <dd>onDecryptComplete event handler</dd>
-          <dt>[TreatNonCallableAsNull] attribute Function? onDecryptError</dt>
+          <dt>[TreatNonCallableAsNull] attribute DecryptError onDecryptError</dt>
           <dd>onDecryptError event handler</dd>
 
-          <dt>void protect (in DOMString aPlainText, in DOMString aJOSEAlg)</dt>
+          <dt>void seal (in DOMString plainText)</dt>
           <dd>Symmetric encryption of a string (a key is generated on each use)</dd>
-          <dt>[TreatNonCallableAsNull] attribute Function? onProtectComplete</dt>
-          <dd>onProtectComplete event handler, ciphertext and keyID are passed to this function</dd>
-          <dt>[TreatNonCallableAsNull] attribute Function? onProtectError</dt>
-          <dd>onProtectError event handler</dd>
-
-          <dt>void unprotect (in DOMString aKeyID, in DOMString aPlainText)</dt>
-          <dd>Symmetric decryption of a string</dd>
-          <dt>[TreatNonCallableAsNull] attribute Function? onUnprotectComplete</dt>
-          <dd>onUnprotectComplete event handler</dd>
-          <dt>[TreatNonCallableAsNull] attribute Function? onUnprotectError</dt>
-          <dd>onUnprotectError event handler</dd>
+          <dt>[TreatNonCallableAsNull] attribute SealSuccess onSealSuccess</dt>
+          <dd>onSealSuccess event handler, ciphertext and keyID are passed to this function</dd>
+          <dt>[TreatNonCallableAsNull] attribute SealError onSealError</dt>
+          <dd>onSealError event handler</dd>
 
-          <dt>void sign(in aDOMString aClearData, in DOMString aJWKID)</dt>
-          <dd>Create a digital signature</dd>
-          <dt>[TreatNonCallableAsNull] attribute Function? onSignComplete</dt>
-          <dd>onSignComplete event handler</dd>
-          <dt>[TreatNonCallableAsNull] attribute Function? onSignError</dt>
-          <dd>onSignError event handler</dd>
-
-          <dt>void verify (in DOMString aJWS, in DOMString aDataToVerify, in DOMString aJWK)</dt>
-          <dd>Verify a digital signature</dd>
-          <dt>[TreatNonCallableAsNull] attribute Function? onVerifyComplete</dt>
-          <dd>onVerifyComplete event handler</dd>
-          <dt>[TreatNonCallableAsNull] attribute Function? onVerifyError</dt>
-          <dd>onVerifyError event handler</dd>
-
-          <dt>void hash(in DOMString aJOSEAlg, in DOMString aData)</dt>
-          <dd>Create a cryptographic hash</dd>
-          <dt>[TreatNonCallableAsNull] attribute Function? onHashComplete</dt>
-          <dd>onHashComplete event handler</dd>
-          <dt>[TreatNonCallableAsNull] attribute Function? onHashError</dt>
-          <dd>onHashError event handler</dd>
+          <dt>void open (in DOMString keyID, in DOMString cipherText)</dt>
+          <dd>Symmetric decryption of a string</dd>
+          <dt>[TreatNonCallableAsNull] attribute OpenSuccess onOpenSuccess</dt>
+          <dd>onOpenComplete event handler</dd>
+          <dt>[TreatNonCallableAsNull] attribute OpenError onOpenError</dt>
+          <dd>onOpenError event handler</dd>
         </dl>
       </section>
       
@@ -244,130 +244,100 @@
     
     <section>
       <h2>Examples</h2>
-      <h3>Keypair handling, generation</h3>
+      <h3>Keypair generation</h3>
       <pre class="example sh_html sh_sourceCode">
-var myCurrentKeyPair = null;
+var cryptoAPI = new window.crypto.highlevel();
 
-function onGetKeypair(aKeypair)
+function onCreateKeypairSuccess(aKeypair)
 {
   localStorage.setItem(aKeypair.id, aKeypair.publicKey);
 }
 
-var cryptoAPI = new window.crypto.highlevel();
-cryptoAPI.onGetKeypair = onGetKeypair;
-
-function onCreateKeypair(aKeypair)
-{
-  localStorage.setItem(aKeypair.id, aKeypair.publicKey);
-  myCurrentKeyPair = aKeypair;
-}
-
 cryptoAPI.onCreateKeypair = onCreateKeypair;
 
-cryptoAPI.createKeypair("RSA1_5");
+function onCreateKeypairError(aError)
+{
+  console.log(aError);
+}
+
+cryptoAPI.createKeypair();
 </pre>
       <h3>Public Key Encryption</h3>
 <pre class="example sh_html sh_sourceCode">
+var cryptoAPI = new window.crypto.highlevel();
+
 var plainText = "The rain in Spain falls mainly on the plain.";
 
-function onEncryptComplete(aJWE, aPublicKey){
+function onEncryptSuccess(aJWE, aPublicKey) {
   // send cipher data to the server for storage, etc...
 }
-cryptoAPI.onEncryptComplete = onEncryptComplete;
-cryptoAPI.encryptAndSign(plainText, RECIPIENT_JWK, SENDER_JWK_ID);
+
+cryptoAPI.onEncryptSuccess = onEncryptSuccess;
+
+function onEncryptError(aError) {
+  console.log(aError);
+}
+
+cryptoAPI.onEncryptError = onEncryptError;
+
+cryptoAPI.encryptAndSign(plainText, recipientJSONWebKey, myKeyID);
 </pre>
 
 <h3>Public Key Decryption</h3>
 <pre class="example sh_html sh_sourceCode">
-function onDecryptComplete(aPlainText) {
+var cryptoAPI = new window.crypto.highlevel();
+
+function onDecryptSuccess(aPlainText) {
   // read and save plain text
 }
 
-function onDecryptError(aException) {
-  // examine exception raised, re-throw or throw a new error
+function onDecryptError(aError) {
+  console.log(aError);
 }
+
 cryptoAPI.onDecryptError = onDecryptError;
 
-// we have recvd a new cipher message...
-// set the event handler
-cryptoAPI.onDecryptComplete = onDecryptComplete;
+cryptoAPI.onDecryptSuccess = onDecryptSuccess;
+
 // verfiy and decrypt - if verification or decryption fails, onDecryptError is fired
-cryptoAPI.verifyAndDecrypt(RECEIVED_JWE, SENDER_JWK, RECIPIENT_JWK_ID);
+cryptoAPI.verifyAndDecrypt(receivedJSONWebEncryption, senderJSONWebKey, myKeyID);
 </pre>
 
 <h3>Symmetric Encryption</h3>
 <pre class="example sh_html sh_sourceCode">
-function onProtectComplete(aCipherText, aKeyID) {
+var cryptoAPI = new window.crypto.highlevel();
+
+function onSealComplete(aCipherText, aKeyID) {
   // cipher text and the key ID are provided to this event handler
 }
 
-function onProtectError(aException) {
-  // examine exception or error message
+function onSealError(aError) {
+  console.log(aError);
 }
-cryptoAPI.onProtectError = onProtectError;
+cryptoAPI.onSealError = onSealError;
 
-cryptoAPI.onProtectComplete = onProtectComplete;
-// 
-cryptoAPI.protect("s3kr3t m355ag3", "A256GCM");
+cryptoAPI.onSealComplete = onSealComplete;
+
+cryptoAPI.seal("s3kr3t m355ag3");
 </pre>
 
 <h3>Symmetric Decryption</h3>
 <pre class="example sh_html sh_sourceCode">
-function onUnprotectComplete(aPlainText) {
-  savePlainTextToLocalStorage(aPlainText);
+var cryptoAPI = new window.crypto.highlevel();
+
+function onOpenSuccess(aPlainText) {
+  savePlainTextToLocalStorageOrWhatever(aPlainText);
 }
 
-function onUnprotectError(aException) {
-  // examine exception or error message
+function onOpenError(aError) {
+  console.log(aError);
 }
-cryptoAPI.onUnprotectError = onUnprotectError;
-
-cryptoAPI.onUnprotectComplete = onUnprotectComplete;
-
-cryptoAPI.unprotect(keyID, cipherString);
-</pre>
-
-<h3>Signature creation</h3>
-<pre class="example sh_html sh_sourceCode">
-var dataToSign = "This is some data to sign";
-
-cryptoAPI.onSignComplete = function (aJWS) {
-  // send the signature to the server, etc.
-};
-
-cryptoAPI.onSignError = function (aError) {
-  // console.log(), etc.
-};
-
-cryptoAPI.sign(dataToSign, JWK_ID);
-</pre>
 
-<h3>Signature Verification</h3>
-<pre class="example sh_html sh_sourceCode">
-cryptoAPI.onVerifyComplete = function (aVerified) {
-  // aVerified is a boolean
-};
-
-cryptoAPI.onVerifyError = function (aError) {
-  // console.log(), etc.
-};
-
-cryptoAPI.verify(RECEIVED_JWS, SIGNER_JWK);        
-</pre>
+cryptoAPI.onOpenError = onOpenError;
 
-<h3>Hash creation</h3>
-<pre class="example sh_html sh_sourceCode">
-var stringToHash = "Please hash me";
+cryptoAPI.onOpenSuccess = onOpenSuccess;
 
-cryptoAPI.onHashComplete = function (aHashString) {
-  // save this hash, compare to another, etc
-};
-
-cryptoAPI.onHashError = function (aError) {
-  // console.log(aError), etc.
-};
-
-cryptoAPI.hash("SHA512", stringToHash);
+cryptoAPI.open(cipherString, keyID);
 </pre>
         
       </section> 
--- a/highlevel-api-source.html	Mon Jan 28 12:02:14 2013 -0600
+++ b/highlevel-api-source.html	Mon Jan 28 17:54:42 2013 -0600
@@ -171,64 +171,64 @@
 
       <section>
         <h3>Highlevel interface</h3>
-        <dl title="interface Highlevel" class="idl">
-          <dt>void getPublicKey (in DOMString aJWKID)</dt>
-          <dd>Get public key by an ID if it exists</dd>
-          <dt>[TreatNonCallableAsNull] attribute Function? onGetKeypair</dt>
-          <dd>onGetKeypair event handler</dd>
-          <dt>void createKeyPair (in DOMString aJoseAlg)</dt>
-          <dd>Generate a public keypair</dd>
-          <dt>[TreatNonCallableAsNull] attribute Function? onCreateKeypair</dt>
+
+        <dl title="callback CreateKeypairSuccess = void (in DOMString publicKey)" class="idl">
+        </dl>
+        <dl title="callback CreateKeypairError = void (in DOMString error)" class="idl">
+        </dl>
+        <dl title="callback EncryptSuccess = void (in DOMString cipherText, in DOMString keyID)" class="idl">
+        </dl>
+        <dl title="callback EncryptError = void (in DOMString error)" class="idl">
+        </dl>
+        <dl title="callback DecryptSuccess = void (in DOMString plainText)" class="idl">
+        </dl>
+        <dl title="callback DecryptError = void (in DOMString error)" class="idl">
+        </dl>
+        <dl title="callback SealSuccess = void (in DOMString cipherText, in DOMString keyID)" class="idl">
+        </dl>
+        <dl title="callback SealError = void (in DOMString error)" class="idl">
+        </dl>
+        <dl title="callback OpenSuccess = void (in DOMString plainText)" class="idl">
+        </dl>
+        <dl title="callback OpenError = void (in DOMString error)" class="idl">
+        </dl>
+
+
+        <dl title="[Constructor] interface Highlevel" class="idl">
+          <dt>void createKeyPair (optional in DOMString joseAlg)</dt>
+          <dd>Generate a keypair</dd>
+          <dt>[TreatNonCallableAsNull] attribute CreateKeypairSuccess onCreateKeypairSuccess</dt>
+          <dd>onCreateKeypair event handler</dd>
+          <dt>[TreatNonCallableAsNull] attribute CreateKeypairError onCreateKeypairError</dt>
           <dd>onCreateKeypair event handler</dd>
 
-          <dt>void encryptAndSign (in DOMSring aPlainText, in DOMString aRecipientJWK, in DOMString aJWKID)</dt>
+          <dt>void encryptAndSign (in DOMString plainText, in DOMString recipientJWK, in DOMString jwkID)</dt>
           <dd>Perform encryption, signing the encrypted data</dd>
-          <dt>[TreatNonCallableAsNull] attribute Function? onEncryptComplete</dt>
+          <dt>[TreatNonCallableAsNull] attribute EncryptSuccess onEncryptSuccess</dt>
           <dd>onEncryptComplete event handler</dd>
-          <dt>[TreatNonCallableAsNull] attribute Function? onEncryptError</dt>
+          <dt>[TreatNonCallableAsNull] attribute EncryptError onEncryptError</dt>
           <dd>onEncryptError event handler</dd>
 
-          <dt>void verifyAndDecrypt (in DOMString aReceivedJWE, in DOMString aSenderJWK, in DOMString aRecipientJWKID)</dt>
-          <dd>Verify signature and decrypttion method</dd>          
-          <dt>[TreatNonCallableAsNull] attribute Function? onDecryptComplete</dt>
+          <dt>void verifyAndDecrypt (in DOMString receivedJWE, in DOMString senderJWK, in DOMString recipientJWKID)</dt>
+          <dd>Verify signature and decryption method</dd>          
+          <dt>[TreatNonCallableAsNull] attribute DecryptSuccess onDecryptSuccess</dt>
           <dd>onDecryptComplete event handler</dd>
-          <dt>[TreatNonCallableAsNull] attribute Function? onDecryptError</dt>
+          <dt>[TreatNonCallableAsNull] attribute DecryptError onDecryptError</dt>
           <dd>onDecryptError event handler</dd>
 
-          <dt>void protect (in DOMString aPlainText, in DOMString aJOSEAlg)</dt>
+          <dt>void seal (in DOMString plainText)</dt>
           <dd>Symmetric encryption of a string (a key is generated on each use)</dd>
-          <dt>[TreatNonCallableAsNull] attribute Function? onProtectComplete</dt>
-          <dd>onProtectComplete event handler, ciphertext and keyID are passed to this function</dd>
-          <dt>[TreatNonCallableAsNull] attribute Function? onProtectError</dt>
-          <dd>onProtectError event handler</dd>
-
-          <dt>void unprotect (in DOMString aKeyID, in DOMString aPlainText)</dt>
-          <dd>Symmetric decryption of a string</dd>
-          <dt>[TreatNonCallableAsNull] attribute Function? onUnprotectComplete</dt>
-          <dd>onUnprotectComplete event handler</dd>
-          <dt>[TreatNonCallableAsNull] attribute Function? onUnprotectError</dt>
-          <dd>onUnprotectError event handler</dd>
+          <dt>[TreatNonCallableAsNull] attribute SealSuccess onSealSuccess</dt>
+          <dd>onSealSuccess event handler, ciphertext and keyID are passed to this function</dd>
+          <dt>[TreatNonCallableAsNull] attribute SealError onSealError</dt>
+          <dd>onSealError event handler</dd>
 
-          <dt>void sign(in aDOMString aClearData, in DOMString aJWKID)</dt>
-          <dd>Create a digital signature</dd>
-          <dt>[TreatNonCallableAsNull] attribute Function? onSignComplete</dt>
-          <dd>onSignComplete event handler</dd>
-          <dt>[TreatNonCallableAsNull] attribute Function? onSignError</dt>
-          <dd>onSignError event handler</dd>
-
-          <dt>void verify (in DOMString aJWS, in DOMString aDataToVerify, in DOMString aJWK)</dt>
-          <dd>Verify a digital signature</dd>
-          <dt>[TreatNonCallableAsNull] attribute Function? onVerifyComplete</dt>
-          <dd>onVerifyComplete event handler</dd>
-          <dt>[TreatNonCallableAsNull] attribute Function? onVerifyError</dt>
-          <dd>onVerifyError event handler</dd>
-
-          <dt>void hash(in DOMString aJOSEAlg, in DOMString aData)</dt>
-          <dd>Create a cryptographic hash</dd>
-          <dt>[TreatNonCallableAsNull] attribute Function? onHashComplete</dt>
-          <dd>onHashComplete event handler</dd>
-          <dt>[TreatNonCallableAsNull] attribute Function? onHashError</dt>
-          <dd>onHashError event handler</dd>
+          <dt>void open (in DOMString keyID, in DOMString cipherText)</dt>
+          <dd>Symmetric decryption of a string</dd>
+          <dt>[TreatNonCallableAsNull] attribute OpenSuccess onOpenSuccess</dt>
+          <dd>onOpenComplete event handler</dd>
+          <dt>[TreatNonCallableAsNull] attribute OpenError onOpenError</dt>
+          <dd>onOpenError event handler</dd>
         </dl>
       </section>
       
@@ -244,130 +244,100 @@
     
     <section>
       <h2>Examples</h2>
-      <h3>Keypair handling, generation</h3>
+      <h3>Keypair generation</h3>
       <pre class="example sh_html sh_sourceCode">
-var myCurrentKeyPair = null;
+var cryptoAPI = new window.crypto.highlevel();
 
-function onGetKeypair(aKeypair)
+function onCreateKeypairSuccess(aKeypair)
 {
   localStorage.setItem(aKeypair.id, aKeypair.publicKey);
 }
 
-var cryptoAPI = new window.crypto.highlevel();
-cryptoAPI.onGetKeypair = onGetKeypair;
-
-function onCreateKeypair(aKeypair)
-{
-  localStorage.setItem(aKeypair.id, aKeypair.publicKey);
-  myCurrentKeyPair = aKeypair;
-}
-
 cryptoAPI.onCreateKeypair = onCreateKeypair;
 
-cryptoAPI.createKeypair("RSA1_5");
+function onCreateKeypairError(aError)
+{
+  console.log(aError);
+}
+
+cryptoAPI.createKeypair();
 </pre>
       <h3>Public Key Encryption</h3>
 <pre class="example sh_html sh_sourceCode">
+var cryptoAPI = new window.crypto.highlevel();
+
 var plainText = "The rain in Spain falls mainly on the plain.";
 
-function onEncryptComplete(aJWE, aPublicKey){
+function onEncryptSuccess(aJWE, aPublicKey) {
   // send cipher data to the server for storage, etc...
 }
-cryptoAPI.onEncryptComplete = onEncryptComplete;
-cryptoAPI.encryptAndSign(plainText, RECIPIENT_JWK, SENDER_JWK_ID);
+
+cryptoAPI.onEncryptSuccess = onEncryptSuccess;
+
+function onEncryptError(aError) {
+  console.log(aError);
+}
+
+cryptoAPI.onEncryptError = onEncryptError;
+
+cryptoAPI.encryptAndSign(plainText, recipientJSONWebKey, myKeyID);
 </pre>
 
 <h3>Public Key Decryption</h3>
 <pre class="example sh_html sh_sourceCode">
-function onDecryptComplete(aPlainText) {
+var cryptoAPI = new window.crypto.highlevel();
+
+function onDecryptSuccess(aPlainText) {
   // read and save plain text
 }
 
-function onDecryptError(aException) {
-  // examine exception raised, re-throw or throw a new error
+function onDecryptError(aError) {
+  console.log(aError);
 }
+
 cryptoAPI.onDecryptError = onDecryptError;
 
-// we have recvd a new cipher message...
-// set the event handler
-cryptoAPI.onDecryptComplete = onDecryptComplete;
+cryptoAPI.onDecryptSuccess = onDecryptSuccess;
+
 // verfiy and decrypt - if verification or decryption fails, onDecryptError is fired
-cryptoAPI.verifyAndDecrypt(RECEIVED_JWE, SENDER_JWK, RECIPIENT_JWK_ID);
+cryptoAPI.verifyAndDecrypt(receivedJSONWebEncryption, senderJSONWebKey, myKeyID);
 </pre>
 
 <h3>Symmetric Encryption</h3>
 <pre class="example sh_html sh_sourceCode">
-function onProtectComplete(aCipherText, aKeyID) {
+var cryptoAPI = new window.crypto.highlevel();
+
+function onSealComplete(aCipherText, aKeyID) {
   // cipher text and the key ID are provided to this event handler
 }
 
-function onProtectError(aException) {
-  // examine exception or error message
+function onSealError(aError) {
+  console.log(aError);
 }
-cryptoAPI.onProtectError = onProtectError;
+cryptoAPI.onSealError = onSealError;
 
-cryptoAPI.onProtectComplete = onProtectComplete;
-// 
-cryptoAPI.protect("s3kr3t m355ag3", "A256GCM");
+cryptoAPI.onSealComplete = onSealComplete;
+
+cryptoAPI.seal("s3kr3t m355ag3");
 </pre>
 
 <h3>Symmetric Decryption</h3>
 <pre class="example sh_html sh_sourceCode">
-function onUnprotectComplete(aPlainText) {
-  savePlainTextToLocalStorage(aPlainText);
+var cryptoAPI = new window.crypto.highlevel();
+
+function onOpenSuccess(aPlainText) {
+  savePlainTextToLocalStorageOrWhatever(aPlainText);
 }
 
-function onUnprotectError(aException) {
-  // examine exception or error message
+function onOpenError(aError) {
+  console.log(aError);
 }
-cryptoAPI.onUnprotectError = onUnprotectError;
-
-cryptoAPI.onUnprotectComplete = onUnprotectComplete;
-
-cryptoAPI.unprotect(keyID, cipherString);
-</pre>
-
-<h3>Signature creation</h3>
-<pre class="example sh_html sh_sourceCode">
-var dataToSign = "This is some data to sign";
-
-cryptoAPI.onSignComplete = function (aJWS) {
-  // send the signature to the server, etc.
-};
-
-cryptoAPI.onSignError = function (aError) {
-  // console.log(), etc.
-};
-
-cryptoAPI.sign(dataToSign, JWK_ID);
-</pre>
 
-<h3>Signature Verification</h3>
-<pre class="example sh_html sh_sourceCode">
-cryptoAPI.onVerifyComplete = function (aVerified) {
-  // aVerified is a boolean
-};
-
-cryptoAPI.onVerifyError = function (aError) {
-  // console.log(), etc.
-};
-
-cryptoAPI.verify(RECEIVED_JWS, SIGNER_JWK);        
-</pre>
+cryptoAPI.onOpenError = onOpenError;
 
-<h3>Hash creation</h3>
-<pre class="example sh_html sh_sourceCode">
-var stringToHash = "Please hash me";
+cryptoAPI.onOpenSuccess = onOpenSuccess;
 
-cryptoAPI.onHashComplete = function (aHashString) {
-  // save this hash, compare to another, etc
-};
-
-cryptoAPI.onHashError = function (aError) {
-  // console.log(aError), etc.
-};
-
-cryptoAPI.hash("SHA512", stringToHash);
+cryptoAPI.open(cipherString, keyID);
 </pre>
         
       </section>