Skip to content

Commit

Permalink
Address comments part 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Rigidity committed Aug 15, 2024
1 parent ed78752 commit 3e983e9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions c-bindings/wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
#include "verifier.hpp"

extern "C" {
bool validate_proof(const uint8_t* seed, uint8_t k, const uint8_t* challenge, const uint8_t* proof, uint16_t proof_len, uint8_t* quality_buf) {
bool validate_proof(const uint8_t* plot_id, uint8_t k, const uint8_t* challenge, const uint8_t* proof, uint16_t proof_len, uint8_t* quality_buf) {
Verifier v;
auto quality = v.ValidateProof(seed, k, challenge, proof, proof_len);
if (quality.GetSize() == 0) {
auto quality = v.ValidateProof(plot_id, k, challenge, proof, proof_len);
if (quality.GetSize() != 256) {
return false;
}
quality.ToBytes(quality_buf);
Expand Down
2 changes: 1 addition & 1 deletion c-bindings/wrapper.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "picosha2.hpp"

extern "C" {
bool validate_proof(const uint8_t* seed, uint8_t k, const uint8_t* challenge, const uint8_t* proof, uint16_t proof_len, uint8_t* quality_buf);
bool validate_proof(const uint8_t* plot_id, uint8_t k, const uint8_t* challenge, const uint8_t* proof, uint16_t proof_len, uint8_t* quality_buf);
}
20 changes: 10 additions & 10 deletions rust-bindings/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ mod bindings {
}

pub fn validate_proof(
seed: &[u8; 32],
plot_id: &[u8; 32],
k: u8,
challenge: &[u8; 32],
proof: &[u8],
Expand All @@ -22,7 +22,7 @@ pub fn validate_proof(

unsafe {
bindings::validate_proof(
seed.as_ptr(),
plot_id.as_ptr(),
k,
challenge.as_ptr(),
proof.as_ptr(),
Expand All @@ -48,7 +48,7 @@ mod tests {

for line in proofs.lines() {
let mut parts = line.split(", ");
let seed = hex::decode(parts.next().unwrap())
let plot_id = hex::decode(parts.next().unwrap())
.unwrap()
.try_into()
.unwrap();
Expand All @@ -63,7 +63,7 @@ mod tests {
// The test should pass with the initial data.
let mut actual_quality = [0; 32];
assert!(validate_proof(
&seed,
&plot_id,
k,
&challenge,
&proof,
Expand All @@ -73,10 +73,10 @@ mod tests {

// If you change the seed, the test should fail.
let mut actual_quality = [0; 32];
let mut new_seed = seed;
new_seed[0] = new_seed[0].wrapping_add(1);
let mut new_plot_id = plot_id;
new_plot_id[0] = new_plot_id[0].wrapping_add(1);
assert!(!validate_proof(
&new_seed,
&new_plot_id,
k,
&challenge,
&proof,
Expand All @@ -88,7 +88,7 @@ mod tests {
let mut actual_quality = [0; 32];
let new_k = k.wrapping_add(1);
assert!(!validate_proof(
&seed,
&plot_id,
new_k,
&challenge,
&proof,
Expand All @@ -100,7 +100,7 @@ mod tests {
let mut new_challenge = challenge;
new_challenge[0] = new_challenge[0].wrapping_add(1);
assert!(!validate_proof(
&seed,
&plot_id,
k,
&new_challenge,
&proof,
Expand All @@ -113,7 +113,7 @@ mod tests {
let mut new_proof = proof;
new_proof[0] = new_proof[0].wrapping_add(1);
assert!(!validate_proof(
&seed,
&plot_id,
k,
&challenge,
&new_proof,
Expand Down

0 comments on commit 3e983e9

Please sign in to comment.