Skip to content

Commit

Permalink
Fix some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
SoraSuegami committed Dec 12, 2024
1 parent 2426492 commit 542c279
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/circuit.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use anyhow::{anyhow, Result};
use num_bigint::BigInt;
use regex::Regex;
use serde::{Deserialize, Serialize};
use serde_json::{json, Value};
use std::{cmp, collections::VecDeque};
Expand Down Expand Up @@ -176,7 +177,9 @@ fn find_selector_in_clean_content(
position_map: &[usize],
) -> Result<(String, usize)> {
let clean_string = String::from_utf8_lossy(clean_content);
if let Some(selector_index) = clean_string.find(selector) {
let re = Regex::new(selector).unwrap();
if let Some(m) = re.find(&clean_string) {
let selector_index = m.start();
// Map this cleaned index back to original
if selector_index < position_map.len() {
let original_index = position_map[selector_index];
Expand Down Expand Up @@ -647,6 +650,7 @@ pub fn compute_signal_length(max_length: usize) -> usize {

#[cfg(test)]
mod tests {

use super::*;
use std::path::PathBuf;

Expand Down
4 changes: 3 additions & 1 deletion src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,13 +480,15 @@ pub async fn bytesToFields(bytes: JsValue) -> Promise {
/// # Returns
///
/// A `Promise` that resolves with the email nullifier as a hexadecimal string, or rejects with an error message.
pub async fn emailNullifier(signautre: Vec<u8>) -> Promise {
pub async fn emailNullifier(mut signautre: Vec<u8>) -> Promise {
use js_sys::Promise;

use crate::field_to_hex;

console_error_panic_hook::set_once();

// Reverse the bytes for little-endian format
signautre.reverse();
match email_nullifier(&signautre) {
Ok(field) => Promise::resolve(&JsValue::from_str(&field_to_hex(&field))),
Err(_) => Promise::reject(&JsValue::from_str("Failed to compute email nullifier")),
Expand Down

0 comments on commit 542c279

Please sign in to comment.