| 58 | /// `public_key`, and return it with the bytes to sign. |
| 59 | #[wasm_bindgen(js_name = prepareAttestation)] |
| 60 | pub fn prepare_attestation(document: &str, public_key_bytes: &[u8]) -> Result<Prepared, JsError> { |
| 61 | let pk = public_key(public_key_bytes)?; |
| 62 | let prepared = proof::prepare_attestation(parse(document)?, &pk); |
| 63 | Ok(Prepared { |
| 64 | document: prepared.value.to_string(), |
| 65 | signing_bytes: prepared.signing_bytes, |
| 66 | }) |
| 67 | } |
| 68 | |
| 69 | /// Attach the proof for `signature` (64 bytes, over the prepared signing |
| 70 | /// bytes) and check it verifies. Returns the attested document (JSON). |