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

Support property annotation #124

Open
weaversa opened this issue Nov 22, 2020 · 0 comments
Open

Support property annotation #124

weaversa opened this issue Nov 22, 2020 · 0 comments
Labels

Comments

@weaversa
Copy link

It would be nice to know what functions in a Cryptol spec have the property annotation applied. Otherwise, we have to do something like below, and there no way to differentiate between properties and functions that return a bit.

from argo.connection import RemoteSocketProcess
from cryptol import connect, CryptolContext, CryptolFunctionHandle

from cihelper import check

c = connect(
    RemoteSocketProcess( 'localhost', 35553 ),
)

command = c.load_module('Primitive::Symmetric::Cipher::Stream::Salsa20')

ctx = CryptolContext(c)
fhs = [
    fh
    for attr in dir(ctx)
    if isinstance((fh := getattr(ctx, attr)), CryptolFunctionHandle)
]
bit_names = [
    name
    for fh in fhs
    if (
        fh.ty == 'Bit'
        and (name := fh.name) not in 'False True'
    )
]
ubf_names = [
    name
    for fh in fhs
    if (
        fh.ty.endswith('-> Bit')
        and fh.ty.find('->') == (len(fh.ty) - len('-> Bit'))
        and (name := fh.name) not in 'and or'
    )
]

for name in bit_names:
    check(c, name)
>>> ubf_names
['columnround_is_transpose_of_rowround', 'columnround_opt_is_columnround', 'littleendian_is_invertable', 'rowround_opt_is_rowround']
>>> bit_names
['Salsa20_passes_tests', 'columnround_passes_tests', 'doubleround_passes_tests', 'littleendian_passes_tests', 'quarterround_passes_tests', 'rowround_passes_tests']
@atomb atomb self-assigned this May 20, 2021
@atomb atomb added the Priority label May 20, 2021
@atomb atomb removed their assignment Oct 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants