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

Add import with function renaming #360

Closed
robby-phd opened this issue Aug 3, 2016 · 3 comments
Closed

Add import with function renaming #360

robby-phd opened this issue Aug 3, 2016 · 3 comments
Labels
feature request Asking for new or improved functionality

Comments

@robby-phd
Copy link

Cryptol currently support qualified imports to avoid function name clashes.
For example, consider AES S-Box and T-Box specifications whose top-level encryption and decryption functions are named aesEncrypt and aesDecrypt, respectively.

When trying to prove equivalences of their specification, one can currently use Cryptol qualified imports as follows:

// import aesEncrypt and aesDecrypt in AES as qualified names AESSBox::aesEncrypt and AESSBox::aesDecrypt
import AES as AESSBox(aesEncrypt, aesDecrypt)

// import aesEncrypt and aesDecrypt in AESTBox as qualified names AESTBox::aesEncrypt and AESTBox::aesDecrypt
import AESTBox as AESTBox(aesEncrypt, aesDecrypt)

Another approach that would be nice to have is renaming the imported functions, as follows:

// import function aesEncrypt and aesDecrypt in AES as top-level functions sboxEncrypt and sboxDecrypt
import AES(aesEncrypt => sboxEncrypt, aesDecrypt => sboxDecrypt)

// import function aesEncrypt and aesDecrypt in AESTBox as top-level functions tboxEncrypt and tboxDecrypt
import AESTBox(aesEncrypt => tboxEncrypt, aesDecrypt => tboxDecrypt)

This way, one can use unqualified names to refer to the functions, which would be especially useful for long module names.

@yav
Copy link
Member

yav commented Aug 3, 2016

You should be able to get a very similar result like this:

import AES as SBox
import AESTBox as TBox

sboxEncrypt = SBox::aesEncrypt
sboxDecrypt = SBox::aesDecrypt
tboxEncrypt = TBox::aesEncrypt
tboxDecrypt = TBox::aesDecrypt

@robby-phd
Copy link
Author

Sure, that also works.

@brianhuffman brianhuffman added the feature request Asking for new or improved functionality label Aug 4, 2016
@brianhuffman
Copy link
Contributor

It seems like we have an acceptable workaround, so I'm closing this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Asking for new or improved functionality
Projects
None yet
Development

No branches or pull requests

3 participants