Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ __Note: The [file](utils/populate.ts) being used to populate the inputs is also
yarn
```

* Make sure you are using the nargo version `0.7.1`. The libraries being used are only compatible with this version. You can check your nargo version using the below command
* Make sure you are using the nargo version matches the libraries (`ecrecover`) being used are only compatible with this version. You can check your nargo version using the below command

```bash
nargo --version
Expand All @@ -85,7 +85,7 @@ noirup -v 0.7.1
```
git checkout -b solution
```

- Make changes to the `circuits/src/main.nr` file.

- Run Tests
Expand Down
5 changes: 3 additions & 2 deletions circuits/Nargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[package]
name = "stealthdrop"
authors = [""]
compiler_version = "0.7.1"
compiler_version = "0.9.0"

[dependencies]
ecrecover = { tag = "v0.8.0", git = "https://github.com/colinnielsen/ecrecover-noir" }
ecrecover = { tag = "v0.9.0", git = "https://github.com/colinnielsen/ecrecover-noir" }
31 changes: 29 additions & 2 deletions circuits/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,38 @@ fn main(
polynomial_commitment: Field,
nullifier: pub [u8; 32],
) {
// Write your main logic here

let nullifier_hash = std::hash::blake2s(signature);
assert(nullifier_hash == nullifier);
std::println("checking nullifier passed");

let mut pub_key_x = [0; 32];
let mut pub_key_y = [0; 32];
for i in 0..32 {
pub_key_x[i] = pub_key[i];
pub_key_y[i] = pub_key[i + 32];
}
let signer = ecrecover::ecrecover(pub_key_x, pub_key_y, signature, hashed_message);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could have used this too - let key = ecrecover::secp256k1::PubKey::from_unified(pub_key); for conversion

std::println("signer address recovered");

let polynomial_hash = std::hash::pedersen(polynomial);
assert(polynomial_hash[0] == polynomial_commitment);
std::println("checking polynomial commitment passed");

let value = evaluate_polynomial(polynomial, signer);
assert(value == 0);
std::println("evaluation of address passed");
}

fn evaluate_polynomial(polynomial: [Field; CANDIDATES + 1], x: Field) -> Field {
// Write logic to evaluate polynomial here
let mut mult = 1;
let mut evaluation = 0;

for i in 0..CANDIDATES + 1 {
evaluation = mult * polynomial[i] + evaluation;
mult = mult * x;
}
evaluation
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
"node_modules",
"**/node_modules/**"
]
}
}