diff --git a/Scarb.lock b/Scarb.lock index dd768b96..b048f148 100644 --- a/Scarb.lock +++ b/Scarb.lock @@ -53,15 +53,9 @@ dependencies = [ "alexandria_data_structures", ] -[[package]] -name = "cairo_lib" -version = "0.2.0" -source = "git+https://github.com/HerodotusDev/cairo-lib.git#a0c0ee4feeb4edb61e7a35d29595ad8647c3d469" - [[package]] name = "raito" version = "0.1.0" dependencies = [ "alexandria_math", - "cairo_lib", ] diff --git a/Scarb.toml b/Scarb.toml index 1a266abe..fad892e4 100644 --- a/Scarb.toml +++ b/Scarb.toml @@ -8,7 +8,6 @@ gen_data_test= "chmod -x ./scripts/data/launch.sh && bash ./scripts/data/launch. [dependencies] alexandria_math = { git = "https://github.com/keep-starknet-strange/alexandria.git" } -cairo_lib = { git = "https://github.com/HerodotusDev/cairo-lib.git" } [dev-dependencies] cairo_test = "2.7.0" \ No newline at end of file diff --git a/src/validation.cairo b/src/validation.cairo index 315079e8..3401567f 100644 --- a/src/validation.cairo +++ b/src/validation.cairo @@ -76,7 +76,6 @@ fn convert_u32_to_u256(val: u32) -> u256 { val_u256.low = low; val_u256.high = high; val_u256 - } fn compute_bitwise_not_for_u256(val: u256) -> u256 { @@ -86,6 +85,11 @@ fn compute_bitwise_not_for_u256(val: u256) -> u256 { not_val } + +// Need to compute 2**256 / (target+1), but we can't represent 2**256 +// as it's too large for an u256. However, as 2**256 is at least as large +// as target+1, it is equal to ((2**256 - target - 1) / (target+1)) + 1, +// or ~target / (target+1) + 1. fn compute_work_from_target(target: u256) -> u256 { let one_i257: i257 = I257Impl::new(ONE_256, false); let target_i257: i257 = target.into();