Skip to content

Commit c5a5632

Browse files
committed
fix(bls): ProofOfPossession double wrapping issue
1 parent 27bc58d commit c5a5632

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

packages/wasm/rust/src/bls.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,19 @@ impl<C: BlsSignatureImpl> Bls<C>
6464
JsError::new(&format!("Failed to serialize signature to JSON: {}", e))
6565
)?;
6666

67-
let signature_bytes = signature_json.as_bytes().to_vec();
68-
Ok(Uint8Array::from(signature_bytes.as_slice()))
67+
// Parse the signature JSON to get the ProofOfPossession value
68+
let signature_json: serde_json::Value = serde_json::from_str(&signature_json)?;
69+
let proof_of_possession = signature_json
70+
.get("ProofOfPossession")
71+
.ok_or_else(|| JsError::new("Missing ProofOfPossession field"))?
72+
.as_str()
73+
.ok_or_else(|| JsError::new("ProofOfPossession is not a string"))?;
74+
75+
// Convert hex string to bytes
76+
let proof_bytes = hex::decode(proof_of_possession)
77+
.map_err(|e| JsError::new(&format!("Failed to decode hex: {}", e)))?;
78+
79+
Ok(Uint8Array::from(proof_bytes.as_slice()))
6980
}
7081

7182
pub fn verify(

0 commit comments

Comments
 (0)