| 70 | /// bytes) and check it verifies. Returns the attested document (JSON). |
| 71 | #[wasm_bindgen(js_name = attachProof)] |
| 72 | pub fn attach_proof( |
| 73 | document: &str, |
| 74 | public_key_bytes: &[u8], |
| 75 | signature: &[u8], |
| 76 | ) -> Result<String, JsError> { |
| 77 | let pk = public_key(public_key_bytes)?; |
| 78 | let sig = Signature::from_slice(signature).map_err(|e| JsError::new(&e.to_string()))?; |
| 79 | let attested = proof::attach_proof(parse(document)?, &pk, &sig); |
| 80 | proof::verify_value(&attested, &pk).map_err(|e| JsError::new(&e.to_string()))?; |
| 81 | Ok(attested.to_string()) |
| 82 | } |
| 83 | |
| 84 | /// Check an attested document (JSON) against a public key. |
| 85 | #[wasm_bindgen(js_name = verifyAttestation)] |