mirror of
https://github.com/mimblewimble/grin.git
synced 2025-02-01 17:01:09 +03:00
add proofsize check in pow verify (#2805)
This commit is contained in:
parent
4ef4212f1f
commit
4ad2ed48a3
2 changed files with 10 additions and 0 deletions
|
@ -27,6 +27,7 @@ use crate::pow::common::{CuckooParams, EdgeType};
|
||||||
use crate::pow::error::{Error, ErrorKind};
|
use crate::pow::error::{Error, ErrorKind};
|
||||||
use crate::pow::siphash::siphash_block;
|
use crate::pow::siphash::siphash_block;
|
||||||
use crate::pow::{PoWContext, Proof};
|
use crate::pow::{PoWContext, Proof};
|
||||||
|
use crate::global;
|
||||||
|
|
||||||
/// Instantiate a new CuckarooContext as a PowContext. Note that this can't
|
/// Instantiate a new CuckarooContext as a PowContext. Note that this can't
|
||||||
/// be moved in the PoWContext trait as this particular trait needs to be
|
/// be moved in the PoWContext trait as this particular trait needs to be
|
||||||
|
@ -68,6 +69,10 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn verify(&self, proof: &Proof) -> Result<(), Error> {
|
fn verify(&self, proof: &Proof) -> Result<(), Error> {
|
||||||
|
if proof.proof_size() != global::proofsize() {
|
||||||
|
return Err(ErrorKind::Verification(
|
||||||
|
"wrong cycle length".to_owned(),))?;
|
||||||
|
}
|
||||||
let nonces = &proof.nonces;
|
let nonces = &proof.nonces;
|
||||||
let mut uvs = vec![0u64; 2 * proof.proof_size()];
|
let mut uvs = vec![0u64; 2 * proof.proof_size()];
|
||||||
let mut xor0: u64 = 0;
|
let mut xor0: u64 = 0;
|
||||||
|
|
|
@ -20,6 +20,7 @@ use croaring::Bitmap;
|
||||||
use crate::pow::common::{CuckooParams, EdgeType, Link};
|
use crate::pow::common::{CuckooParams, EdgeType, Link};
|
||||||
use crate::pow::error::{Error, ErrorKind};
|
use crate::pow::error::{Error, ErrorKind};
|
||||||
use crate::pow::{PoWContext, Proof};
|
use crate::pow::{PoWContext, Proof};
|
||||||
|
use crate::global;
|
||||||
use crate::util;
|
use crate::util;
|
||||||
|
|
||||||
struct Graph<T>
|
struct Graph<T>
|
||||||
|
@ -280,6 +281,10 @@ where
|
||||||
/// Verify that given edges are ascending and form a cycle in a header-generated
|
/// Verify that given edges are ascending and form a cycle in a header-generated
|
||||||
/// graph
|
/// graph
|
||||||
pub fn verify_impl(&self, proof: &Proof) -> Result<(), Error> {
|
pub fn verify_impl(&self, proof: &Proof) -> Result<(), Error> {
|
||||||
|
if proof.proof_size() != global::proofsize() {
|
||||||
|
return Err(ErrorKind::Verification(
|
||||||
|
"wrong cycle length".to_owned(),))?;
|
||||||
|
}
|
||||||
let nonces = &proof.nonces;
|
let nonces = &proof.nonces;
|
||||||
let mut uvs = vec![0u64; 2 * proof.proof_size()];
|
let mut uvs = vec![0u64; 2 * proof.proof_size()];
|
||||||
let mut xor0: u64 = (self.params.proof_size as u64 / 2) & 1;
|
let mut xor0: u64 = (self.params.proof_size as u64 / 2) & 1;
|
||||||
|
|
Loading…
Reference in a new issue