Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SAW reports Value not in scope: integerFromBV #1824

Closed
AlwaysPS opened this issue Feb 23, 2023 · 2 comments
Closed

SAW reports Value not in scope: integerFromBV #1824

AlwaysPS opened this issue Feb 23, 2023 · 2 comments

Comments

@AlwaysPS
Copy link

AlwaysPS commented Feb 23, 2023

I am currently doing a project that aims to provide a trustworthy implementation of the SM2 algorithm. After read the CAV21 paper, I think SAW might be a good tool to provide formal safety guarantee.

As a first step, I wanted to reproduce the verification results from https://github.com/awslabs/aws-lc-verification. However, when trying to import the very first BN.saw specification, SAW immediately complains that it cannot find the definition of integerToBV.

It seems that this definition should be in some .cry files, but even after a through search in the repo I did not find the suitable file.

Here is a minimal example that will reproduce the problem:

import "../cryptol-specs/Common/utils.cry";

disable_debug_intrinsics;

m <- llvm_load_module "./bn_add_words.bc";

include "../aws-lc-verification/SAW/proof/common/helpers.saw";
include "../aws-lc-verification/SAW/proof/internal.saw";

let bn_add_words_spec n = do {
  let num_bits = eval_size {| n * 64 |};
  rp <- crucible_alloc (llvm_int num_bits);
  (a, ap) <- ptr_to_fresh_readonly "a" (llvm_int num_bits);
  (b, bp) <- ptr_to_fresh_readonly "b" (llvm_int num_bits);
  crucible_execute_func [rp, ap, bp, (crucible_term {{ `n : [64] }})];
  crucible_points_to rp (crucible_term {{ integerToBV`{num_bits} (if (integerFromBV a) + (integerFromBV b) >= 2 ^^ `num_bits then (integerFromBV a) + (integerFromBV b) - 2 ^^ `num_bits else (integerFromBV a) + (integerFromBV b)) }});
  crucible_return (crucible_term {{ if (integerFromBV a) + (integerFromBV b) >= 2 ^^ `num_bits then 1 : [64] else 0 }});
};

llvm_verify m "bn_add_words" [] false (bn_add_words_spec 2) z3;
@RyanGlScott
Copy link
Contributor

Just to be sure, have you cloned the cryptol-specs submodule in the aws-lc-verification repo? integerToBV is defined here in cryptol-specs, so it is possible that SAW wouldn't pick it up if the cryptol-specs subdirectory is empty.

@AlwaysPS
Copy link
Author

Just to be sure, have you cloned the cryptol-specs submodule in the aws-lc-verification repo? integerToBV is defined here in cryptol-specs, so it is possible that SAW wouldn't pick it up if the cryptol-specs subdirectory is empty.

Thanks for the quick reply! After a quick check I find that I was using the master branch of the repo cryptol-specs, which does not have integerToBV in utils.cry. After checking out to the commit you provide I got SAW working.

@AlwaysPS AlwaysPS closed this as completed Mar 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants